Skip to content

Commit

Permalink
Silence gtk_image_menu_item_* deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Miranda committed Jun 2, 2018
1 parent c5d6c68 commit 2e46a2f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions thunar/thunar-dnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ thunar_dnd_ask (GtkWidget *widget,
for (n = 0; n < G_N_ELEMENTS (dnd_action_items); ++n)
if (G_LIKELY ((dnd_actions & dnd_action_items[n]) != 0))
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_(dnd_action_names[n]));
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_set_data (G_OBJECT (item), I_("dnd-action"), GUINT_TO_POINTER (dnd_action_items[n]));
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (dnd_action_selected), &dnd_action);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
Expand All @@ -107,7 +109,9 @@ thunar_dnd_ask (GtkWidget *widget,
if (G_LIKELY (dnd_action_icons[n] != NULL))
{
image = gtk_image_new_from_icon_name (dnd_action_icons[n], GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS
}
}

Expand Down
4 changes: 4 additions & 0 deletions thunar/thunar-history.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
{
/* add an item for this file */
display_name = g_object_get_qdata (G_OBJECT (lp->data), thunar_history_display_name_quark);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_label (display_name);
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_set_qdata (G_OBJECT (item), thunar_history_gfile_quark, lp->data);
g_signal_connect (G_OBJECT (item), "activate", handler, history);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
Expand Down Expand Up @@ -695,7 +697,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS

image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS
}

/* release the icon factory */
Expand Down
30 changes: 30 additions & 0 deletions thunar/thunar-shortcuts-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,23 +1096,31 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
menu = gtk_menu_new ();

/* append the "Open" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Open"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_open_clicked), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* append the "Open in New Tab" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Open in New Tab"));
G_GNUC_END_IGNORE_DEPRECATIONS
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);

/* append the "Open in New Window" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Open in New Window"));
G_GNUC_END_IGNORE_DEPRECATIONS
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);
Expand All @@ -1133,19 +1141,25 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
gtk_widget_show (item);

/* append the "Mount" item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Mount"));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_visible (item, can_mount);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_mount), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

/* append the "Unmount" item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount"));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_visible (item, can_unmount);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_unmount), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

/* append the "Disconnect" (eject + safely remove drive) item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Eject"));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_visible (item, can_eject);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_eject), view);
Expand All @@ -1162,14 +1176,18 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
shortcuts_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));

/* append the "Disconnect" item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Create _Shortcut"));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_sensitive (item, mount_point != NULL && !thunar_shortcuts_model_has_bookmark (THUNAR_SHORTCUTS_MODEL (shortcuts_model), mount_point));
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_create_shortcut), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);

image = gtk_image_new_from_stock (THUNAR_STOCK_SHORTCUTS, GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

if (mount_point != NULL)
g_object_unref (mount_point);
Expand All @@ -1183,14 +1201,18 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
gtk_widget_show (item);

/* append the "Disconnect" item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Disconn_ect"));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_sensitive (item, thunar_device_can_eject (device));
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_eject), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);

image = gtk_image_new_from_stock (GTK_STOCK_DISCONNECT, GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS
break;

case THUNAR_SHORTCUT_GROUP_PLACES_TRASH:
Expand All @@ -1200,7 +1222,9 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
gtk_widget_show (item);

/* append the "Empty Trash" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Empty Trash"));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_sensitive (item, (thunar_file_get_item_count (file) > 0));
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_shortcuts_view_empty_trash), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
Expand Down Expand Up @@ -1254,7 +1278,9 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Shortcut"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_set_data_full (G_OBJECT (item), I_("thunar-shortcuts-row"),
gtk_tree_row_reference_new (model, path),
(GDestroyNotify) gtk_tree_row_reference_free);
Expand All @@ -1265,10 +1291,14 @@ thunar_shortcuts_view_context_menu (ThunarShortcutsView *view,

/* set the remove icon */
image = gtk_image_new_from_icon_name ("list-remove", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* append the rename menu item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Re_name Shortcut"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_set_data_full (G_OBJECT (item), I_("thunar-shortcuts-row"),
gtk_tree_row_reference_new (model, path),
(GDestroyNotify) gtk_tree_row_reference_free);
Expand Down
6 changes: 6 additions & 0 deletions thunar/thunar-templates-action.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ thunar_templates_action_files_ready (ThunarJob *job,
gtk_menu_set_screen (GTK_MENU (submenu), gtk_widget_get_screen (menu));

/* allocate a new menu item for the directory */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_label (thunar_file_get_display_name (file));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);

/* prepend the directory, its item and the parent menu it should
Expand All @@ -379,7 +381,9 @@ thunar_templates_action_files_ready (ThunarJob *job,
*dot = '\0';

/* allocate a new menu item */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_label (label);
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_set_data_full (G_OBJECT (item), I_("thunar-file"),
g_object_ref (file), g_object_unref);
g_signal_connect (item, "activate", G_CALLBACK (item_activated),
Expand All @@ -397,7 +401,9 @@ thunar_templates_action_files_ready (ThunarJob *job,

/* allocate an image based on the icon */
image = gtk_image_new_from_pixbuf (icon);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* release the icon reference */
g_object_unref (icon);
Expand Down
32 changes: 32 additions & 0 deletions thunar/thunar-tree-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,15 +1280,19 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
menu = gtk_menu_new ();

/* append the "Open" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Open"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_open), 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 icon */
image = gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* append the "Open in New Tab" menu action */
item = gtk_menu_item_new_with_mnemonic (_("Open in New _Tab"));
Expand Down Expand Up @@ -1366,7 +1370,9 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
if (G_LIKELY (file != NULL && !thunar_file_is_trashed (file)))
{
/* append the "Create Folder" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Create _Folder..."));
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_sensitive (item, thunar_file_is_writable (file));
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);
Expand All @@ -1375,7 +1381,9 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
/* set the icon */
icon = g_themed_icon_new ("folder-new");
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_unref (icon);

/* append a separator item */
Expand All @@ -1393,42 +1401,54 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
parent_file = thunar_file_get_parent (file, NULL);

/* append the "Cut" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Cu_t"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_cut), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, (parent_file != NULL && thunar_file_is_writable (parent_file)));
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("edit-cut", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* append the "Copy" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Copy"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_copy), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, (parent_file != NULL));
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("edit-copy", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* cleanup */
if (G_LIKELY (parent_file != NULL))
g_object_unref (G_OBJECT (parent_file));
}

/* append the "Paste Into Folder" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Paste Into Folder"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_paste_into_folder), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, (thunar_file_is_writable (file) && thunar_clipboard_manager_get_can_paste (view->clipboard)));
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("edit-paste", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS


/* "Delete" and "Rename" don't make much sense for devices */
Expand All @@ -1446,27 +1466,35 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
&& thunar_file_can_be_trashed (file))
{
/* append the "Move to Tash" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("Mo_ve to Trash"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_move_to_trash), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, (parent_file != NULL && thunar_file_is_writable (parent_file)));
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("user-trash-full", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS
}

/* append the "Delete" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("_Delete"));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_delete), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, (parent_file != NULL && thunar_file_is_writable (parent_file)));
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("edit-delete", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* cleanup */
if (G_LIKELY (parent_file != NULL))
Expand Down Expand Up @@ -1532,15 +1560,19 @@ thunar_tree_view_context_menu (ThunarTreeView *view,
}

/* append the "Properties" menu action */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
item = gtk_image_menu_item_new_with_mnemonic (_("P_roperties..."));
G_GNUC_END_IGNORE_DEPRECATIONS
g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tree_view_action_properties), view);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_set_sensitive (item, (file != NULL));
gtk_widget_show (item);

/* set the icon */
image = gtk_image_new_from_icon_name ("document-properties", GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
G_GNUC_END_IGNORE_DEPRECATIONS

/* run the menu (taking over the floating reference on the menu) */
thunar_gtk_menu_run (GTK_MENU (menu));
Expand Down

0 comments on commit 2e46a2f

Please sign in to comment.