+
+ 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);
+
+
+ /* Set the default visibilities */
+ {
+ GValue value = { 0 };
+ guint flags;
+ gint i;
+ g_value_init (&value, button_flags->value_type);
+ g_param_value_set_default(button_flags, &value);
+
+
+ flags = g_value_get_flags (&value);
+
+ for (i = 0 ; i < n_PsppireButtonBoxButtons ; ++i )
+ g_object_set (bb->button[i], "visible", 0x01 & (flags >> i) , NULL);
+
+ g_value_unset (&value);
+ }
+
+
+ g_signal_connect (bb, "realize", G_CALLBACK (on_realize), NULL);
+}
+
+
+/* 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,
+ int *nvis_secondaries,
+ int *width,
+ int *height)
+{
+ GtkButtonBox *bbox;
+ GList *children;
+ gint nchildren;
+ gint nsecondaries;
+ gint needed_width;
+ gint needed_height;
+ GtkRequisition child_requisition;
+ gint ipad_w;
+ gint ipad_h;
+ gint width_default;
+ gint height_default;
+ gint ipad_x_default;
+ gint ipad_y_default;
+
+ gint child_min_width;
+ gint child_min_height;
+ gint ipad_x;
+ gint ipad_y;
+
+ g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
+
+ bbox = GTK_BUTTON_BOX (widget);
+
+ gtk_widget_style_get (widget,
+ "child-min-width", &width_default,
+ "child-min-height", &height_default,
+ "child-internal-pad-x", &ipad_x_default,
+ "child-internal-pad-y", &ipad_y_default,
+ NULL);
+
+ child_min_width = bbox->child_min_width != GTK_BUTTONBOX_DEFAULT
+ ? bbox->child_min_width : width_default;
+ child_min_height = bbox->child_min_height !=GTK_BUTTONBOX_DEFAULT
+ ? bbox->child_min_height : height_default;
+ ipad_x = bbox->child_ipad_x != GTK_BUTTONBOX_DEFAULT
+ ? bbox->child_ipad_x : ipad_x_default;
+ ipad_y = bbox->child_ipad_y != GTK_BUTTONBOX_DEFAULT
+ ? bbox->child_ipad_y : ipad_y_default;
+
+ nchildren = 0;
+ nsecondaries = 0;
+
+ 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)
+ {
+ GtkWidget *child = children->data;
+ children = children->next;
+
+ if (gtk_widget_get_visible (child))
+ {
+ gboolean is_secondary = FALSE;
+ nchildren += 1;
+ 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;
+
+ gtk_container_child_get (GTK_CONTAINER (bbox), child, "secondary", &is_secondary, NULL);
+
+ if (is_secondary)
+ nsecondaries++;
+ }
+ }
+
+ if (nvis_children)
+ *nvis_children = nchildren;
+ if (nvis_secondaries)
+ *nvis_secondaries = nsecondaries;
+ if (width)
+ *width = needed_width;
+ if (height)
+ *height = needed_height;
+}
+
+
+GType
+psppire_button_flags_get_type (void)
+{
+ static GType ftype = 0;
+ if (ftype == 0)
+ {
+ static const GFlagsValue values[] =
+ {
+ { 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);
+
+ }
+ return ftype;