static char * get_uri_for_gicon (GIcon *icon) { char *uri; uri = NULL; if (G_IS_EMBLEMED_ICON (icon) != FALSE) { GIcon *new_icon; new_icon = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon)); g_object_unref (icon); icon = g_object_ref (new_icon); } if (G_IS_FILE_ICON (icon) != FALSE) { GFile *file; file = g_file_icon_get_file (G_FILE_ICON (icon)); uri = g_file_get_uri (file); g_object_unref (file); return uri; } /* We leave the themed icons up to the applications to set */ return uri; }
static char * gicon_to_string (GIcon *icon) { GFile *file; const char *const *names; if (G_IS_FILE_ICON (icon)) { file = g_file_icon_get_file (G_FILE_ICON (icon)); if (file) return g_file_get_path (file); } else if (G_IS_THEMED_ICON (icon)) { names = g_themed_icon_get_names (G_THEMED_ICON (icon)); if (names) return g_strdup (names[0]); } else if (G_IS_EMBLEMED_ICON (icon)) { GIcon *base; base = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon)); return gicon_to_string (base); } return NULL; }
GdkPixbuf* getPixBuf(char* name) { GFile* file=g_file_new_for_path(name); GFileInfo* file_info=g_file_query_info(file,"standard::*",G_FILE_QUERY_INFO_NONE,NULL,NULL); GIcon* icon=g_file_info_get_icon(file_info); GdkPixbuf* pix=NULL; gchar* path; gchar const* const* names; GFile* icon_file; char* newname; if(G_IS_THEMED_ICON(icon)) { names=g_themed_icon_get_names(G_THEMED_ICON(icon)); pix=gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),*names,16,(GtkIconLookupFlags)(GTK_ICON_LOOKUP_USE_BUILTIN|GTK_ICON_LOOKUP_FORCE_SVG|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SIZE),NULL); if(pix==NULL) { asprintf(&newname,"gnome-mime-%s",*names); pix=gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),(const gchar*)newname,16,(GtkIconLookupFlags)(GTK_ICON_LOOKUP_USE_BUILTIN|GTK_ICON_LOOKUP_FORCE_SVG|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SIZE),NULL); debugFree(&newname); } } else if(G_IS_FILE_ICON(icon)) { icon_file=g_file_icon_get_file(G_FILE_ICON(icon)); path=g_file_get_path(icon_file); pix=gdk_pixbuf_new_from_file_at_size(path,16,16,NULL); debugFree(&path); g_object_unref(G_OBJECT(icon_file)); } g_object_unref(G_OBJECT(file)); g_object_unref(G_OBJECT(file_info)); return(pix); }
static const char * _icon_cache_get_icon_key (GIcon * icon) { const char * key = NULL; if (G_IS_THEMED_ICON (icon)) { char ** icon_names; char * name; g_object_get (icon, "names", &icon_names, NULL); name = g_strjoinv (",", icon_names); key = get_static_string (name); g_free (name); g_strfreev (icon_names); } else if (G_IS_FILE_ICON (icon)) { GFile * file; char * filename; file = g_file_icon_get_file (G_FILE_ICON (icon)); filename = g_file_get_path (file); key = get_static_string (filename); g_free (filename); g_object_unref (file); } return key; }
static GdkPixbuf* get_icon_pixbuf_for_content_type (const char *ctype, size_t size) { GIcon *icon; GdkPixbuf *pixbuf; icon = g_content_type_get_icon (ctype); pixbuf = NULL; /* based on a snippet from http://www.gtkforums.com/about4721.html */ if (G_IS_THEMED_ICON(icon)) { gchar const * const *names; names = g_themed_icon_get_names (G_THEMED_ICON(icon)); pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(), *names, size, 0, NULL); } else if (G_IS_FILE_ICON(icon)) { GFile *icon_file; gchar *path; icon_file = g_file_icon_get_file (G_FILE_ICON(icon)); path = g_file_get_path (icon_file); pixbuf = gdk_pixbuf_new_from_file_at_size (path, size, size, NULL); g_free (path); g_object_unref(icon_file); } g_object_unref(icon); return pixbuf; }
static GdkPixbuf * get_file_icon_pixbuf (GFileIcon * icon, int size) { GFile * file; char * filename; GdkPixbuf * pixbuf; file = g_file_icon_get_file (icon); filename = g_file_get_path (file); pixbuf = gdk_pixbuf_new_from_file_at_size (filename, size, -1, NULL); g_free (filename); g_object_unref (file); return pixbuf; }
static GdkPixbuf * render_icon (GIcon *icon, gint icon_size) { GdkPixbuf *pixbuf; GtkIconInfo *info; pixbuf = NULL; if (G_IS_THEMED_ICON (icon)) { gchar const * const *names; info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), icon, icon_size, 0); if (info) { pixbuf = gtk_icon_info_load_icon (info, NULL); gtk_icon_info_free (info); } if (pixbuf == NULL) { names = g_themed_icon_get_names (G_THEMED_ICON (icon)); pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), *names, icon_size, 0, NULL); } } else if (G_IS_FILE_ICON (icon)) { GFile *icon_file; gchar *path; icon_file = g_file_icon_get_file (G_FILE_ICON (icon)); path = g_file_get_path (icon_file); pixbuf = gdk_pixbuf_new_from_file_at_size (path, icon_size, icon_size, NULL); g_free (path); g_object_unref (G_OBJECT (icon_file)); } return pixbuf; }
static gchar *_cd_get_icon_path (GIcon *pIcon) { gchar *cIconPath = NULL; if (G_IS_THEMED_ICON (pIcon)) { const gchar * const *cFileNames = g_themed_icon_get_names (G_THEMED_ICON (pIcon)); //cd_message ("icones possibles : %s\n", g_strjoinv (":", (gchar **) cFileNames)); int i; for (i = 0; cFileNames[i] != NULL && cIconPath == NULL; i ++) { //cd_message (" une icone possible est : %s\n", cFileNames[i]); cIconPath = cairo_dock_search_icon_s_path (cFileNames[i]); //cd_message (" chemin trouve : %s\n", cIconPath); } } else if (G_IS_FILE_ICON (pIcon)) { GFile *pFile = g_file_icon_get_file (G_FILE_ICON (pIcon)); cIconPath = g_file_get_basename (pFile); //cd_message (" file_icon => %s\n", cIconPath); } return cIconPath; }
void ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info) { GAppInfo *app_info; const char *wm_class; GIcon *icon; g_assert (G_IS_DESKTOP_APP_INFO (desktop_info)); app_info = G_APP_INFO (desktop_info); g_set_prgname (g_app_info_get_name (app_info)); g_set_application_name (g_app_info_get_display_name (app_info)); icon = g_app_info_get_icon (app_info); if (G_IS_FILE_ICON (icon)) { GFile *file = g_file_icon_get_file (G_FILE_ICON (icon)); char *path = file ? g_file_get_path (file) : NULL; if (path) { gtk_window_set_default_icon_from_file (path, NULL); g_free (path); } g_clear_object (&file); } else if (G_IS_THEMED_ICON (icon)) { const char * const *names = g_themed_icon_get_names (G_THEMED_ICON (icon)); if (names) gtk_window_set_default_icon_name (names[0]); } g_clear_object (&icon); /* We need to re-set this because we have already parsed the * options, which inits GTK+ and sets this as a side effect. */ wm_class = g_desktop_app_info_get_startup_wm_class (desktop_info); if (wm_class) gdk_set_program_class (wm_class); }
gchar* plank_drawing_drawing_service_get_icon_from_gicon (GIcon* icon) { gchar* result = NULL; GIcon* _tmp0_ = NULL; GIcon* _tmp7_ = NULL; _tmp0_ = icon; if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, g_themed_icon_get_type ())) { gchar* icons = NULL; GIcon* _tmp1_ = NULL; gchar** _tmp2_ = NULL; gchar** _tmp3_ = NULL; gchar* _tmp4_ = NULL; const gchar* _tmp5_ = NULL; gchar* _tmp6_ = NULL; _tmp1_ = icon; _tmp3_ = _tmp2_ = g_themed_icon_get_names (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, g_themed_icon_get_type (), GThemedIcon)); _tmp4_ = _vala_g_strjoinv (";;", _tmp3_, _vala_array_length (_tmp2_)); icons = _tmp4_; _tmp5_ = icons; _tmp6_ = string_replace (_tmp5_, "(null);;", ""); result = _tmp6_; _g_free0 (icons); return result; } _tmp7_ = icon; if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, g_file_icon_get_type ())) { GIcon* _tmp8_ = NULL; GFile* _tmp9_ = NULL; gchar* _tmp10_ = NULL; _tmp8_ = icon; _tmp9_ = g_file_icon_get_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, g_file_icon_get_type (), GFileIcon)); _tmp10_ = g_file_get_path (_tmp9_); result = _tmp10_; return result; } result = NULL; return result; }
void thunar_notify_unmount (GMount *mount) { const gchar * const *icon_names; NotifyNotification *notification = NULL; const gchar *summary; GFileInfo *info; gboolean read_only = FALSE; GFile *icon_file; GFile *mount_point; GIcon *icon; gchar *icon_name = NULL; gchar *message; gchar *name; g_return_if_fail (G_IS_MOUNT (mount)); if (!thunar_notify_init ()) return; mount_point = g_mount_get_root (mount); info = g_file_query_info (mount_point, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (info != NULL) { read_only = !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE); g_object_unref (info); } g_object_unref (mount_point); name = g_mount_get_name (mount); icon = g_mount_get_icon (mount); if (G_IS_THEMED_ICON (icon)) { icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon)); if (icon_names != NULL) icon_name = g_strdup (icon_names[0]); } else if (G_IS_FILE_ICON (icon)) { icon_file = g_file_icon_get_file (G_FILE_ICON (icon)); if (icon_file != NULL) { icon_name = g_file_get_path (icon_file); g_object_unref (icon_file); } } g_object_unref (icon); if (icon_name == NULL) icon_name = g_strdup ("drive-removable-media"); if (read_only) { summary = _("Unmounting device"); message = g_strdup_printf (_("The device \"%s\" is being unmounted by the system. " "Please do not remove the media or disconnect the " "drive"), name); } else { summary = _("Writing data to device"); message = g_strdup_printf (_("There is data that needs to be written to the " "device \"%s\" before it can be removed. Please " "do not remove the media or disconnect the drive"), name); } #ifdef NOTIFY_CHECK_VERSION #if NOTIFY_CHECK_VERSION (0, 7, 0) notification = notify_notification_new (summary, message, icon_name); #else notification = notify_notification_new (summary, message, icon_name, NULL); #endif #else notification = notify_notification_new (summary, message, icon_name, NULL); #endif notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL); notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER); notify_notification_show (notification, NULL); g_object_set_data_full (G_OBJECT (mount), "thunar-notification", notification, g_object_unref); g_free (message); g_free (icon_name); g_free (name); }
static VALUE fileicon_file(VALUE self) { return GOBJ2RVAL(g_file_icon_get_file(_SELF(self))); }