From: Thaddaeus Tintenfisch Date: Sat, 5 Apr 2014 15:00:58 +0200 Subject: Add or change various menu icons: - Open With DEFAULT Application - Open in New Tab/Window - New Tab/Window - Create Folder... --- thunar/thunar-launcher.c | 12 +++++++++--- thunar/thunar-location-buttons.c | 6 +++--- thunar/thunar-shortcuts-view.c | 10 +++++++++- thunar/thunar-standard-view.c | 2 +- thunar/thunar-tree-view.c | 17 ++++++++++++++++- thunar/thunar-window.c | 4 ++-- 6 files changed, 40 insertions(+), 11 deletions(-) --- a/thunar/thunar-launcher.c +++ b/thunar/thunar-launcher.c @@ -175,8 +175,8 @@ struct _ThunarLauncherPokeData static const GtkActionEntry action_entries[] = { { "open", GTK_STOCK_OPEN, N_ ("_Open"), "O", NULL, G_CALLBACK (thunar_launcher_action_open), }, - { "open-in-new-tab", NULL, N_ ("Open in New _Tab"), "P", NULL, G_CALLBACK (thunar_launcher_action_open_in_new_tab), }, - { "open-in-new-window", NULL, N_ ("Open in New _Window"), "O", NULL, G_CALLBACK (thunar_launcher_action_open_in_new_window), }, + { "open-in-new-tab", GTK_STOCK_NEW, N_ ("Open in New _Tab"), "P", NULL, G_CALLBACK (thunar_launcher_action_open_in_new_tab), }, + { "open-in-new-window", GTK_STOCK_NEW, N_ ("Open in New _Window"), "O", NULL, G_CALLBACK (thunar_launcher_action_open_in_new_window), }, { "open-with-other", NULL, N_ ("Open With Other _Application..."), NULL, N_ ("Choose another application with which to open the selected file"), G_CALLBACK (thunar_launcher_action_open_with_other), }, { "open-with-menu", NULL, N_ ("Open With"), NULL, NULL, NULL, }, { "open-with-other-in-menu", NULL, N_ ("Open With Other _Application..."), NULL, N_ ("Choose another application with which to open the selected file"), G_CALLBACK (thunar_launcher_action_open_with_other), }, @@ -815,8 +815,9 @@ thunar_launcher_update_idle (gpointer data) ** - "Open", "Open in n New Windows" and "Open in n New Tabs" actions **/ - /* Prepare "Open" label */ + /* Prepare "Open" label and icon */ gtk_action_set_label (launcher->action_open, _("_Open")); + gtk_action_set_stock_id (launcher->action_open, GTK_STOCK_OPEN); if (n_selected_files == n_directories && n_directories >= 1) { @@ -928,6 +929,7 @@ thunar_launcher_update_idle (gpointer data) /* turn the "Open" action into "Execute" */ g_object_set (G_OBJECT (launcher->action_open), "label", _("_Execute"), + "stock-id", GTK_STOCK_EXECUTE, "tooltip", ngettext ("Execute the selected file", "Execute the selected files", n_selected_files), NULL); } @@ -945,6 +947,10 @@ thunar_launcher_update_idle (gpointer data) g_free (tooltip); g_free (label); + /* load default application icon */ + gtk_action_set_stock_id (launcher->action_open, NULL); + gtk_action_set_gicon (launcher->action_open, g_app_info_get_icon (applications->data)); + /* remember the default application for the "Open" action */ g_object_set_qdata_full (G_OBJECT (launcher->action_open), thunar_launcher_handler_quark, applications->data, g_object_unref); --- a/thunar/thunar-location-buttons.c +++ b/thunar/thunar-location-buttons.c @@ -173,9 +173,9 @@ static const GtkActionEntry action_entries[] = { "location-buttons-down-folder", NULL, "Down Folder", "Down", NULL, G_CALLBACK (thunar_location_buttons_action_down_folder), }, { "location-buttons-context-menu", NULL, "Context Menu", NULL, "", NULL, }, { "location-buttons-open", GTK_STOCK_OPEN, N_("_Open"), "", NULL, G_CALLBACK (thunar_location_buttons_action_open), }, - { "location-buttons-open-in-new-tab", NULL, N_("Open in New Tab"), "", NULL, G_CALLBACK (thunar_location_buttons_action_open_in_new_tab), }, - { "location-buttons-open-in-new-window", NULL, N_("Open in New Window"), "", NULL, G_CALLBACK (thunar_location_buttons_action_open_in_new_window), }, - { "location-buttons-create-folder", NULL, N_("Create _Folder..."), "", NULL, G_CALLBACK (thunar_location_buttons_action_create_folder), }, + { "location-buttons-open-in-new-tab", GTK_STOCK_NEW, N_("Open in New Tab"), "", NULL, G_CALLBACK (thunar_location_buttons_action_open_in_new_tab), }, + { "location-buttons-open-in-new-window", GTK_STOCK_NEW, N_("Open in New Window"), "", NULL, G_CALLBACK (thunar_location_buttons_action_open_in_new_window), }, + { "location-buttons-create-folder", "folder-new", N_("Create _Folder..."), "", NULL, G_CALLBACK (thunar_location_buttons_action_create_folder), }, { "location-buttons-empty-trash", NULL, N_("_Empty Trash"), "", N_("Delete all files and folders in the Trash"), G_CALLBACK (thunar_location_buttons_action_empty_trash), }, { "location-buttons-paste-into-folder", GTK_STOCK_PASTE, N_("Paste Into Folder"), "", NULL, G_CALLBACK (thunar_location_buttons_action_paste_into_folder), }, { "location-buttons-properties", GTK_STOCK_PROPERTIES, N_("_Properties..."), "", NULL, G_CALLBACK (thunar_location_buttons_action_properties), }, --- a/thunar/thunar-shortcuts-view.c +++ b/thunar/thunar-shortcuts-view.c @@ -1092,19 +1092,27 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view, /* set the stock icon */ image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - + /* append the "Open in New Tab" menu action */ item = gtk_image_menu_item_new_with_mnemonic (_("Open in New Tab")); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_open_in_new_tab_clicked), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); + /* set the stock icon */ + image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + /* append the "Open in New Window" menu action */ item = gtk_image_menu_item_new_with_mnemonic (_("Open in New Window")); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_open_in_new_window_clicked), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); + /* set the stock icon */ + image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + switch (group) { case THUNAR_SHORTCUT_GROUP_DEVICES_VOLUMES: --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -393,7 +393,7 @@ static const GtkActionEntry action_entries[] = { { "file-context-menu", NULL, N_ ("File Context Menu"), NULL, NULL, NULL, }, { "folder-context-menu", NULL, N_ ("Folder Context Menu"), NULL, NULL, NULL, }, - { "create-folder", NULL, N_ ("Create _Folder..."), "N", N_ ("Create an empty folder within the current folder"), G_CALLBACK (thunar_standard_view_action_create_folder), }, + { "create-folder", "folder-new", N_ ("Create _Folder..."), "N", N_ ("Create an empty folder within the current folder"), G_CALLBACK (thunar_standard_view_action_create_folder), }, { "properties", GTK_STOCK_PROPERTIES, N_ ("_Properties..."), "Return", N_ ("View the properties of the selected file"), G_CALLBACK (thunar_standard_view_action_properties), }, { "cut", GTK_STOCK_CUT, N_ ("Cu_t"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_cut), }, { "copy", GTK_STOCK_COPY, N_ ("_Copy"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_copy), }, --- a/thunar/thunar-tree-view.c +++ b/thunar/thunar-tree-view.c @@ -1093,6 +1093,7 @@ thunar_tree_view_context_menu (ThunarTreeView *view, GtkWidget *menu; GtkWidget *item; GtkWidget *window; + GIcon *icon; GList *providers, *lp; GList *actions = NULL, *tmp; @@ -1119,13 +1120,17 @@ thunar_tree_view_context_menu (ThunarTreeView *view, /* set the stock icon */ image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - + /* append the "Open in New Tab" menu action */ item = gtk_image_menu_item_new_with_mnemonic (_("Open in New _Tab")); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_open_in_new_tab), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_set_sensitive (item, (file != NULL || device != NULL)); gtk_widget_show (item); + + /* set the stock icon */ + image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); /* append the "Open in New Window" menu action */ item = gtk_image_menu_item_new_with_mnemonic (_("Open in New _Window")); @@ -1134,6 +1139,10 @@ thunar_tree_view_context_menu (ThunarTreeView *view, gtk_widget_set_sensitive (item, (file != NULL || device != NULL)); gtk_widget_show (item); + /* set the stock icon */ + image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + /* append a separator item */ item = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); @@ -1201,6 +1210,12 @@ thunar_tree_view_context_menu (ThunarTreeView *view, g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_create_folder), view); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); + + /* set the stock icon */ + icon = g_themed_icon_new ("folder-new"); + image = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + g_object_unref (icon); /* append a separator item */ item = gtk_separator_menu_item_new (); --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -345,8 +345,8 @@ struct _ThunarWindow static GtkActionEntry action_entries[] = { { "file-menu", NULL, N_ ("_File"), NULL, }, - { "new-tab", NULL, N_ ("New _Tab"), "T", N_ ("Open a new tab for the displayed location"), G_CALLBACK (thunar_window_action_open_new_tab), }, - { "new-window", NULL, N_ ("New _Window"), "N", N_ ("Open a new Thunar window for the displayed location"), G_CALLBACK (thunar_window_action_open_new_window), }, + { "new-tab", "tab-new", N_ ("New _Tab"), "T", N_ ("Open a new tab for the displayed location"), G_CALLBACK (thunar_window_action_open_new_tab), }, + { "new-window", "window-new", N_ ("New _Window"), "N", N_ ("Open a new Thunar window for the displayed location"), G_CALLBACK (thunar_window_action_open_new_window), }, { "sendto-menu", NULL, N_ ("_Send To"), NULL, }, { "empty-trash", NULL, N_ ("_Empty Trash"), NULL, N_ ("Delete all files and folders in the Trash"), G_CALLBACK (thunar_window_action_empty_trash), }, { "detach-tab", NULL, N_ ("Detac_h Tab"), NULL, N_ ("Open current folder in a new window"), G_CALLBACK (thunar_window_action_detach_tab), },