diff options
author | lukefromdc <[email protected]> | 2017-09-28 23:18:37 -0400 |
---|---|---|
committer | lukefromdc <[email protected]> | 2017-09-28 23:18:37 -0400 |
commit | c13f02a05b80d240575d6ea58362c539cd9c00c2 (patch) | |
tree | d30fe77e8282f9a667591612207881806b9b9392 | |
parent | 8a158fe4fba20e89a055e304357db68111a45422 (diff) | |
download | mate-panel-c13f02a05b80d240575d6ea58362c539cd9c00c2.tar.bz2 mate-panel-c13f02a05b80d240575d6ea58362c539cd9c00c2.tar.xz |
panel-context-menu: Add confirmation dialog to panel reset option
-rw-r--r-- | mate-panel/panel-context-menu.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/mate-panel/panel-context-menu.c b/mate-panel/panel-context-menu.c index bdec0e95..db492a03 100644 --- a/mate-panel/panel-context-menu.c +++ b/mate-panel/panel-context-menu.c @@ -177,6 +177,53 @@ panel_context_menu_setup_delete_panel_item (GtkWidget *menu, } static void +panel_reset_response (GtkWidget *dialog, + int response) +{ + if (response == GTK_RESPONSE_OK) { + panel_reset (); + } + + gtk_widget_destroy (dialog); +} + +static void +query_panel_reset (PanelToplevel *toplevel) +{ + GtkWidget *dialog; + char *text1; + char *text2; + + text1 = _("Reset this panel?"); + text2 = _("When a panel is reset,all \n" + "custom settings are lost."); + + dialog = gtk_message_dialog_new ( + GTK_WINDOW (toplevel), + GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_NONE, + "%s", text1); + + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s", text2); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Reset Panel"), GTK_RESPONSE_OK, + NULL); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); + + gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); + + g_signal_connect (dialog, "response", + G_CALLBACK (panel_reset_response), + NULL); + + gtk_widget_show_all (dialog); +} + +static void panel_context_menu_build_edition (PanelWidget *panel_widget, GtkWidget *menu) { @@ -209,8 +256,8 @@ panel_context_menu_build_edition (PanelWidget *panel_widget, gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - g_signal_connect (menuitem, "activate", - G_CALLBACK (panel_reset), NULL); + g_signal_connect_swapped (menuitem, "activate", + G_CALLBACK (query_panel_reset), panel_widget->toplevel); menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Delete This Panel")); image = gtk_image_new_from_icon_name ("edit-delete", |