static void clear_tip (GtkMenuItem *item, gpointer user_data) { GList *children; GtkWidget *image; GIcon *icon, *icon2; const char *filename; /* Not a stock icon? */ filename = g_object_get_data (G_OBJECT (item), "filename"); if (filename == NULL) return; children = gtk_container_get_children (GTK_CONTAINER (item)); image = children->data; g_assert (image != NULL); g_list_free (children); gtk_image_get_gicon (GTK_IMAGE (image), &icon, NULL); if (G_IS_EMBLEMED_ICON (icon)) icon2 = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon)); else return; gtk_image_set_from_gicon (GTK_IMAGE (image), icon2, GTK_ICON_SIZE_DIALOG); g_object_unref (icon); }
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; }
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; }