I guess that you need to access the thumbnail programatically. You want to use the Gio library.
I haven't been able to find a way to check for the thumbnail and, if it doesn't exist, go for the application icon, so you need to do it in two steps. Here you have a sample (sorry, Python. I'm not fluent in C):
import gio
import gtk
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.show()
hbox = gtk.HBox()
hbox.show()
window.add(hbox)
f = gio.File(path='/home/whatever/you/want.jpg')
info = f.query_info('*')
# We check if there's a thumbnail for our file
preview = info.get_attribute_byte_string ("thumbnail::path")
image = None
if preview:
image = gtk.image_new_from_file (preview)
else:
# If there's no thumbnail, we check get_icon, who checks the
# file's mimetype, and returns the correct stock icon.
icon = info.get_icon()
image = gtk.image_new_from_gicon (icon, gtk.ICON_SIZE_MENU)
hbox.add (image)
window.show_all()
gtk.main()