GtkAction * nautilus_toolbar_action_from_menu_item (NautilusMenuItem *item) { char *name, *label, *tip, *icon_name; gboolean sensitive, priority; GtkAction *action; GdkPixbuf *pixbuf; NautilusIconInfo *info; int icon_size; g_object_get (G_OBJECT (item), "name", &name, "label", &label, "tip", &tip, "icon", &icon_name, "sensitive", &sensitive, "priority", &priority, NULL); action = gtk_action_new (name, label, tip, icon_name); if (icon_name != NULL) { icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_LARGE_TOOLBAR); info = nautilus_icon_info_lookup_from_name (icon_name, icon_size); pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, icon_size); if (pixbuf != NULL) { g_object_set_data_full (G_OBJECT (action), "toolbar-icon", pixbuf, g_object_unref); } g_object_unref (info); } gtk_action_set_sensitive (action, sensitive); g_object_set (action, "is-important", priority, NULL); g_signal_connect_data (action, "activate", G_CALLBACK (extension_action_callback), g_object_ref (item), (GClosureNotify)g_object_unref, 0); g_signal_connect_object (item, "notify::sensitive", G_CALLBACK (extension_action_sensitive_callback), action, 0); g_free (name); g_free (label); g_free (tip); g_free (icon_name); return action; }
GdkPixbuf * nautilus_ui_get_menu_icon (const char *icon_name) { NautilusIconInfo *info; GdkPixbuf *pixbuf; int size; size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); if (g_path_is_absolute (icon_name)) { info = nautilus_icon_info_lookup_from_path (icon_name, size); } else { info = nautilus_icon_info_lookup_from_name (icon_name, size); } pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size); g_object_unref (info); return pixbuf; }
static void nautilus_file_management_properties_dialog_setup_media_page (GladeXML *xml_dialog) { unsigned int n; GList *l; GList *content_types; GtkWidget *other_type_combo_box; GtkListStore *other_type_list_store; GtkCellRenderer *renderer; GtkTreeIter iter; const char *s[] = {"media_audio_cdda_combobox", "x-content/audio-cdda", "media_video_dvd_combobox", "x-content/video-dvd", "media_music_player_combobox", "x-content/audio-player", "media_dcf_combobox", "x-content/image-dcf", "media_software_combobox", "x-content/software", NULL}; for (n = 0; s[n*2] != NULL; n++) { nautilus_autorun_prepare_combo_box (glade_xml_get_widget (xml_dialog, s[n*2]), s[n*2 + 1], TRUE, TRUE, NULL, NULL); } other_type_combo_box = glade_xml_get_widget (xml_dialog, "media_other_type_combobox"); other_type_list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (other_type_list_store), 1, GTK_SORT_ASCENDING); content_types = g_content_types_get_registered (); for (l = content_types; l != NULL; l = l->next) { char *content_type = l->data; char *description; GIcon *icon; NautilusIconInfo *icon_info; GdkPixbuf *pixbuf; int icon_size; if (!g_str_has_prefix (content_type, "x-content/")) continue; for (n = 0; s[n*2] != NULL; n++) { if (strcmp (content_type, s[n*2 + 1]) == 0) { goto skip; } } icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); description = g_content_type_get_description (content_type); gtk_list_store_append (other_type_list_store, &iter); icon = g_content_type_get_icon (content_type); if (icon != NULL) { icon_info = nautilus_icon_info_lookup (icon, icon_size); g_object_unref (icon); pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (icon_info, icon_size); g_object_unref (icon_info); } else { pixbuf = NULL; } gtk_list_store_set (other_type_list_store, &iter, 0, pixbuf, 1, description, 2, content_type, -1); if (pixbuf != NULL) g_object_unref (pixbuf); g_free (description); skip: ; } g_list_foreach (content_types, (GFunc) g_free, NULL); g_list_free (content_types); gtk_combo_box_set_model (GTK_COMBO_BOX (other_type_combo_box), GTK_TREE_MODEL (other_type_list_store)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (other_type_combo_box), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (other_type_combo_box), renderer, "pixbuf", 0, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (other_type_combo_box), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (other_type_combo_box), renderer, "text", 1, NULL); g_signal_connect (G_OBJECT (other_type_combo_box), "changed", G_CALLBACK (other_type_combo_box_changed), glade_xml_get_widget (xml_dialog, "media_other_action_combobox")); gtk_combo_box_set_active (GTK_COMBO_BOX (other_type_combo_box), 0); nautilus_file_management_properties_dialog_update_media_sensitivity (xml_dialog); }