One sample Kalmogorov-Smirnov Dialog: convert from old style to PsppireDialogAction
[pspp] / src / ui / gui / psppire-buttonbox.c
index ac40058dba77a0c219185c1bd89c78497647b8b2..a9480a331198e450fa5a5056531d76edbba79040 100644 (file)
@@ -215,6 +215,14 @@ close_and_respond (GtkWidget *w, gint response)
   psppire_dialog_close (dialog);
 }
 
+static gboolean
+is_acceptable (GtkWidget *w)
+{
+  GtkWidget *toplevel = gtk_widget_get_toplevel (w);
+
+  return (PSPPIRE_IS_DIALOG (toplevel)
+          && psppire_dialog_is_acceptable (PSPPIRE_DIALOG (toplevel)));
+}
 
 static void
 close_dialog (GtkWidget *w, gpointer data)
@@ -225,27 +233,31 @@ close_dialog (GtkWidget *w, gpointer data)
 static void
 continue_button_clicked (GtkWidget *w, gpointer data)
 {
-  close_and_respond (w, PSPPIRE_RESPONSE_CONTINUE);
+  if (is_acceptable (w))
+    close_and_respond (w, PSPPIRE_RESPONSE_CONTINUE);
 }
 
 
 static void
 ok_button_clicked (GtkWidget *w, gpointer data)
 {
-  close_and_respond (w, GTK_RESPONSE_OK);
+  if (is_acceptable (w))
+    close_and_respond (w, GTK_RESPONSE_OK);
 }
 
 
 static void
 paste_button_clicked (GtkWidget *w, gpointer data)
 {
-  close_and_respond (w, PSPPIRE_RESPONSE_PASTE);
+  if (is_acceptable (w))
+    close_and_respond (w, PSPPIRE_RESPONSE_PASTE);
 }
 
 static void
 goto_button_clicked (GtkWidget *w, gpointer data)
 {
-  close_and_respond (w, PSPPIRE_RESPONSE_GOTO);
+  if (is_acceptable (w))
+    close_and_respond (w, PSPPIRE_RESPONSE_GOTO);
 }
 
 
@@ -394,8 +406,9 @@ psppire_button_box_init (PsppireButtonBox *bb)
 }
 
 
-/* This function is lifted verbatim from the Gtk2.10.6 library */
-
+/* This function was lifted verbatim from the Gtk2.10.6 library.
+   But later modified to fit Gtk2.24
+ */
 void
 _psppire_button_box_child_requisition (GtkWidget *widget,
                                       int       *nvis_children,
@@ -404,7 +417,6 @@ _psppire_button_box_child_requisition (GtkWidget *widget,
                                       int       *height)
 {
   GtkButtonBox *bbox;
-  GtkBoxChild *child;
   GList *children;
   gint nchildren;
   gint nsecondaries;
@@ -445,27 +457,32 @@ _psppire_button_box_child_requisition (GtkWidget *widget,
 
   nchildren = 0;
   nsecondaries = 0;
-  children = GTK_BOX(bbox)->children;
+
   needed_width = child_min_width;
   needed_height = child_min_height;
   ipad_w = ipad_x * 2;
   ipad_h = ipad_y * 2;
 
+  children = gtk_container_get_children (GTK_CONTAINER (bbox));
   while (children)
     {
-      child = children->data;
+      GtkWidget *child = children->data;
       children = children->next;
 
-      if (gtk_widget_get_visible (child->widget))
+      if (gtk_widget_get_visible (child))
        {
+          gboolean is_secondary = FALSE;
          nchildren += 1;
-         gtk_widget_size_request (child->widget, &child_requisition);
+         gtk_widget_size_request (child, &child_requisition);
 
          if (child_requisition.width + ipad_w > needed_width)
            needed_width = child_requisition.width + ipad_w;
          if (child_requisition.height + ipad_h > needed_height)
            needed_height = child_requisition.height + ipad_h;
-         if (child->is_secondary)
+
+          gtk_container_child_get (GTK_CONTAINER (bbox), child, "secondary", &is_secondary, NULL);
+
+          if (is_secondary)
            nsecondaries++;
        }
     }