Permalink
Browse files

Added a (non-functional) dialog box for the shutdown helper

  • Loading branch information...
1 parent ac83202 commit 1d1b4c944c04dbe16654a784aeba7d9212a6945f @khorben khorben committed Dec 24, 2012
Showing with 46 additions and 0 deletions.
  1. +46 −0 tools/helper.c
View
@@ -70,6 +70,7 @@ static int _helper_error(Panel * panel, char const * message, int ret);
static void _helper_about_dialog(Panel * panel);
static void _helper_position_menu(Panel * panel, GtkMenu * menu, gint * x,
gint * y, gboolean * push_in);
+static void _helper_shutdown_dialog(Panel * panel);
/* functions */
@@ -144,6 +145,7 @@ static void _helper_init(PanelAppletHelper * helper, Panel * panel,
helper->error = _helper_error;
helper->about_dialog = _helper_about_dialog;
helper->position_menu = _helper_position_menu;
+ helper->shutdown_dialog = _helper_shutdown_dialog;
}
@@ -176,10 +178,13 @@ static void _helper_about_dialog(Panel * panel)
dialog = desktop_about_dialog_new();
desktop_about_dialog_set_authors(dialog, _authors);
+ desktop_about_dialog_set_comments(dialog,
+ "Test application for the DeforaOS desktop panel");
desktop_about_dialog_set_copyright(dialog, _copyright);
desktop_about_dialog_set_logo_icon_name(dialog,
"panel-settings"); /* XXX */
desktop_about_dialog_set_license(dialog, _license);
+ desktop_about_dialog_set_name(dialog, PACKAGE);
desktop_about_dialog_set_program_name(dialog, "Panel test");
desktop_about_dialog_set_version(dialog, VERSION);
desktop_about_dialog_set_website(dialog,
@@ -211,3 +216,44 @@ static void _helper_position_menu(Panel * panel, GtkMenu * menu, gint * x,
*y += sy;
*push_in = TRUE;
}
+
+
+/* helper_shutdown_dialog */
+enum { RES_CANCEL, RES_REBOOT, RES_SHUTDOWN };
+
+static void _helper_shutdown_dialog(Panel * panel)
+{
+ GtkWidget * dialog;
+ GtkWidget * widget;
+#ifdef EMBEDDED
+ const char message[] = "This will shutdown your device,"
+ " therefore closing any application currently opened"
+ " and losing any unsaved data.\n"
+ "Do you really want to proceed?";
+#else
+ const char message[] = "This will shutdown your computer,"
+ " therefore closing any application currently opened"
+ " and losing any unsaved data.\n"
+ "Do you really want to proceed?";
+#endif
+
+ dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, "%s",
+#if GTK_CHECK_VERSION(2, 6, 0)
+ "Shutdown");
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+#endif
+ "%s", message);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, RES_CANCEL,
+ "Restart", RES_REBOOT, NULL);
+ widget = gtk_button_new_with_label("Shutdown");
+ gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name(
+ "gnome-shutdown", GTK_ICON_SIZE_BUTTON));
+ gtk_widget_show_all(widget);
+ gtk_dialog_add_action_widget(GTK_DIALOG(dialog), widget, RES_SHUTDOWN);
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
+ gtk_window_set_title(GTK_WINDOW(dialog), "Shutdown");
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+}

0 comments on commit 1d1b4c9

Please sign in to comment.