PsppireButtonBox: Remove Close from the default set of buttons
[pspp] / src / ui / gui / psppire-buttonbox.c
index 1c692d42ba2e5af8533398c6962c95b4acf432b1..ac40058dba77a0c219185c1bd89c78497647b8b2 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2010, 2011  Free Software Foundation
+   Copyright (C) 2007, 2010, 2011, 2012  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -81,26 +81,6 @@ set_default (PsppireButtonBox *bb)
       }
 }
 
-#if !GTK_CHECK_VERSION(2,20,0)
-/**
- * gtk_widget_get_realized:
- * @widget: a #GtkWidget
- *
- * Determines whether @widget is realized.
- *
- * Return value: %TRUE if @widget is realized, %FALSE otherwise
- *
- * Since: 2.20
- **/
-static inline gboolean
-gtk_widget_get_realized (GtkWidget *widget)
-{
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-
-  return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0;
-}
-#endif  /* gtk < 2.20 */
-
 static void
 psppire_buttonbox_set_property (GObject         *object,
                                 guint            prop_id,
@@ -172,6 +152,7 @@ typedef enum
     PSPPIRE_BUTTON_GOTO_MASK   = (1 << PSPPIRE_BUTTON_GOTO),
     PSPPIRE_BUTTON_CONTINUE_MASK = (1 << PSPPIRE_BUTTON_CONTINUE),
     PSPPIRE_BUTTON_CANCEL_MASK = (1 << PSPPIRE_BUTTON_CANCEL),
+    PSPPIRE_BUTTON_CLOSE_MASK  = (1 << PSPPIRE_BUTTON_CLOSE),
     PSPPIRE_BUTTON_HELP_MASK   = (1 << PSPPIRE_BUTTON_HELP),
     PSPPIRE_BUTTON_RESET_MASK  = (1 << PSPPIRE_BUTTON_RESET),
     PSPPIRE_BUTTON_PASTE_MASK  = (1 << PSPPIRE_BUTTON_PASTE)
@@ -284,6 +265,22 @@ refresh_clicked (GtkWidget *w, gpointer data)
 
 
 
+static void
+help_clicked (GtkWidget *w, gpointer data)
+{
+  GtkWidget *toplevel = gtk_widget_get_toplevel (w);
+  PsppireDialog *dialog;
+
+  if ( ! PSPPIRE_IS_DIALOG (toplevel))
+    return;
+
+  dialog = PSPPIRE_DIALOG (toplevel);
+
+  psppire_dialog_help (dialog);
+}
+
+
+
 static void
 on_validity_change (GtkWidget *toplevel, gboolean valid, gpointer data)
 {
@@ -354,6 +351,12 @@ psppire_button_box_init (PsppireButtonBox *bb)
   psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_CANCEL]);
   g_object_set (bb->button[PSPPIRE_BUTTON_CANCEL], "no-show-all", TRUE, NULL);
 
+  bb->button[PSPPIRE_BUTTON_CLOSE] = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+  g_signal_connect (bb->button[PSPPIRE_BUTTON_CLOSE], "clicked",
+                   G_CALLBACK (close_dialog), NULL);
+  psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_CLOSE]);
+  g_object_set (bb->button[PSPPIRE_BUTTON_CLOSE], "no-show-all", TRUE, NULL);
+
 
   bb->button[PSPPIRE_BUTTON_RESET] = gtk_button_new_from_stock ("pspp-stock-reset");
   g_signal_connect (bb->button[PSPPIRE_BUTTON_RESET], "clicked",
@@ -363,6 +366,8 @@ psppire_button_box_init (PsppireButtonBox *bb)
 
 
   bb->button[PSPPIRE_BUTTON_HELP] = gtk_button_new_from_stock (GTK_STOCK_HELP);
+  g_signal_connect (bb->button[PSPPIRE_BUTTON_HELP], "clicked",
+                   G_CALLBACK (help_clicked), NULL);
   psppire_box_pack_start_defaults (GTK_BOX (bb), bb->button[PSPPIRE_BUTTON_HELP]);
   g_object_set (bb->button[PSPPIRE_BUTTON_HELP], "no-show-all", TRUE, NULL);
 
@@ -451,7 +456,7 @@ _psppire_button_box_child_requisition (GtkWidget *widget,
       child = children->data;
       children = children->next;
 
-      if (GTK_WIDGET_VISIBLE (child->widget))
+      if (gtk_widget_get_visible (child->widget))
        {
          nchildren += 1;
          gtk_widget_size_request (child->widget, &child_requisition);
@@ -484,16 +489,17 @@ psppire_button_flags_get_type (void)
     {
       static const GFlagsValue values[] =
        {
-         { PSPPIRE_BUTTON_OK_MASK,     "PSPPIRE_BUTTON_OK_MASK",     N_("OK") },
-         { PSPPIRE_BUTTON_GOTO_MASK,   "PSPPIRE_BUTTON_GOTO_MASK", N_("Go To") },
-         { PSPPIRE_BUTTON_CONTINUE_MASK,"PSPPIRE_BUTTON_CONTINUE_MASK", N_("Continue") },
-         { PSPPIRE_BUTTON_CANCEL_MASK, "PSPPIRE_BUTTON_CANCEL_MASK", N_("Cancel") },
-         { PSPPIRE_BUTTON_HELP_MASK,   "PSPPIRE_BUTTON_HELP_MASK",   N_("Help") },
-         { PSPPIRE_BUTTON_RESET_MASK,  "PSPPIRE_BUTTON_RESET_MASK",  N_("Reset") },
-         { PSPPIRE_BUTTON_PASTE_MASK,  "PSPPIRE_BUTTON_PASTE_MASK",  N_("Paste") },
+         { PSPPIRE_BUTTON_OK_MASK,      "PSPPIRE_BUTTON_OK_MASK",       "Accept dialog and run it" },
+         { PSPPIRE_BUTTON_GOTO_MASK,    "PSPPIRE_BUTTON_GOTO_MASK",     "Goto case/variable" },
+         { PSPPIRE_BUTTON_CONTINUE_MASK,"PSPPIRE_BUTTON_CONTINUE_MASK", "Accept and close the subdialog" },
+         { PSPPIRE_BUTTON_CANCEL_MASK,  "PSPPIRE_BUTTON_CANCEL_MASK",   "Close dialog and discard settings" },
+         { PSPPIRE_BUTTON_CLOSE_MASK,   "PSPPIRE_BUTTON_CLOSE_MASK",    "Close dialog" },
+         { PSPPIRE_BUTTON_HELP_MASK,    "PSPPIRE_BUTTON_HELP_MASK",     "Invoke context sensitive help" },
+         { PSPPIRE_BUTTON_RESET_MASK,   "PSPPIRE_BUTTON_RESET_MASK",    "Restore dialog to its default settings" },
+         { PSPPIRE_BUTTON_PASTE_MASK,   "PSPPIRE_BUTTON_PASTE_MASK",    "Accept dialog and paste syntax" },
          { 0, NULL, NULL }
        };
-
+      
       ftype = g_flags_register_static
        (g_intern_static_string ("PsppireButtonFlags"), values);