Re: getting the icon pixbuf for a file
于 08/16/2012 07:58 PM, Andreas Rönnquist 写道: Hey I am trying to get the icon bitmap for a file and insert it into a TreeView widget - That is the pixbuf for the mime-type of a file. Is there any examples of doing this in plain C using GTK/GLib? I am satisfied with an example that work in Linux - Win32 isn't equally important to me. http://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-File-Loading.html #include gdk-pixbuf/gdk-pixbuf.h ... GdkPixbuf *pix; pix = gdk_pixbuf_new_from_file (fname, None); if (!pix) return; ... boom! cannot be easier than that! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
Hi. I am trying to get the icon bitmap for a file and insert it into a TreeView widget - That is the pixbuf for the mime-type of a file. Is there any examples of doing this in plain C using GTK/GLib? I think you'll want gtk_widget_render_icon() function [1]. This will use current theme settings to load proper icon and render it. For icon names, you can consult gtk-demo application that features icon browser. Cheers, Tadej [1] http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-render-icon -- Tadej Borovšak blog.borovsak.si tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
On Thu, 16 Aug 2012 22:41:28 +0800 Just Fill Bugs mozbug...@yahoo.com.au wrote: 于 08/16/2012 07:58 PM, Andreas Rönnquist 写道: Hey I am trying to get the icon bitmap for a file and insert it into a TreeView widget - That is the pixbuf for the mime-type of a file. Is there any examples of doing this in plain C using GTK/GLib? I am satisfied with an example that work in Linux - Win32 isn't equally important to me. http://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-File-Loading.html #include gdk-pixbuf/gdk-pixbuf.h ... GdkPixbuf *pix; pix = gdk_pixbuf_new_from_file (fname, None); if (!pix) return; boom! cannot be easier than that! Sorry, I mean loading the Pixbuf of the file-type / mime-type of a file - Not simply loading a file into a pixbuf. That is a bit more complicated getting... Sorry for not being more precise. /Andreas ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
于 08/16/2012 11:24 PM, Andreas Rönnquist 写道: Sorry, I mean loading the Pixbuf of the file-type / mime-type of a file - Not simply loading a file into a pixbuf. That is a bit more complicated getting... Maybe this: http://git.gnome.org/browse/gedit/tree/plugins/filebrowser/gedit-file-browser-utils.c GIcon *g_file_info_get_icon(GFileInfo *info); ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
On Thu, 16 Aug 2012 17:24:02 +0200 Andreas Rönnquist wrote: Sorry, I mean loading the Pixbuf of the file-type / mime-type of a file - Not simply loading a file into a pixbuf. That is a bit more complicated getting... Do you mean something like this? GtkWidget *icon; GdkPixbuf *pixbuf; pixbuf=gdk_pixbuf_new_from_file_at_scale(filename.png,500,-1,TRUE,NULL); icon=gtk_image_new_from_pixbuf(pixbuf); gtk_box_pack_start(GTK_BOX(mainmenuwidgets.action), icon, FALSE, FALSE, 30); -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
On Fri, 17 Aug 2012 00:01:08 +0800 Just Fill Bugs mozbug...@yahoo.com.au wrote: 于 08/16/2012 11:24 PM, Andreas Rönnquist 写道: Sorry, I mean loading the Pixbuf of the file-type / mime-type of a file - Not simply loading a file into a pixbuf. That is a bit more complicated getting... Maybe this: http://git.gnome.org/browse/gedit/tree/plugins/filebrowser/gedit-file-browser-utils.c GIcon *g_file_info_get_icon(GFileInfo *info); Ah! That link indeed looks quite useful! Thanks! /Andreas ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
On Fri, 17 Aug 2012 00:01:08 +0800 Just Fill Bugs mozbug...@yahoo.com.au wrote: 于 08/16/2012 11:24 PM, Andreas Rönnquist 写道: Sorry, I mean loading the Pixbuf of the file-type / mime-type of a file - Not simply loading a file into a pixbuf. That is a bit more complicated getting... Maybe this: http://git.gnome.org/browse/gedit/tree/plugins/filebrowser/gedit-file-browser-utils.c GIcon *g_file_info_get_icon(GFileInfo *info); That indeed did the trick! (See attached file for the functions I used.) Thanks guys! /Andreas ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: getting the icon pixbuf for a file
On Thu, 16 Aug 2012 19:43:26 +0200 Andreas Rönnquist mailingli...@gusnan.se wrote: On Fri, 17 Aug 2012 00:01:08 +0800 Just Fill Bugs mozbug...@yahoo.com.au wrote: 于 08/16/2012 11:24 PM, Andreas Rönnquist 写道: Sorry, I mean loading the Pixbuf of the file-type / mime-type of a file - Not simply loading a file into a pixbuf. That is a bit more complicated getting... Maybe this: http://git.gnome.org/browse/gedit/tree/plugins/filebrowser/gedit-file-browser-utils.c GIcon *g_file_info_get_icon(GFileInfo *info); That indeed did the trick! (See attached file for the functions I used.) Oh, the attachment didn't get to the list - This is how I did it: /** * */ GdkPixbuf *get_pixbuf_from_icon(GIcon *icon, GtkIconSize size) { GdkPixbuf *result=NULL; GtkIconTheme *theme; GtkIconInfo *info; gint width; if (!icon) return NULL; theme=gtk_icon_theme_get_default(); gtk_icon_size_lookup(size,width,NULL); info=gtk_icon_theme_lookup_by_gicon(theme, icon, width, GTK_ICON_LOOKUP_USE_BUILTIN); if (!info) return NULL; result=gtk_icon_info_load_icon(info,NULL); gtk_icon_info_free(info); return result; } /** * */ GdkPixbuf *get_pixbuf_from_file(GFile *file, GtkIconSize size) { GIcon *icon; GFileInfo *info; GdkPixbuf *result=NULL; info=g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_ICON, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (!info) return NULL; icon=g_file_info_get_icon(info); if (icon!=NULL) { result=get_pixbuf_from_icon(icon,size); } g_object_unref(info); return result; } Again - thanks guys! /Andreas ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list