X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-buttonbox.c;h=400c0c1f5410649af4c6a80d37284d9dbceefc00;hb=146997e1690f055481e2003529eaa4f8848ca4a8;hp=e5c1c561a76704c59851820541c2212aec6958d2;hpb=7eda1a159f93609f8bd68e98e1b04db2d99067f5;p=pspp-builds.git diff --git a/src/ui/gui/psppire-buttonbox.c b/src/ui/gui/psppire-buttonbox.c index e5c1c561..400c0c1f 100644 --- a/src/ui/gui/psppire-buttonbox.c +++ b/src/ui/gui/psppire-buttonbox.c @@ -32,39 +32,39 @@ #define N_(msgid) msgid -static void psppire_buttonbox_class_init (PsppireButtonBoxClass *); -static void psppire_buttonbox_init (PsppireButtonBox *); +static void psppire_button_box_class_init (PsppireButtonBoxClass *); +static void psppire_button_box_init (PsppireButtonBox *); GType psppire_button_box_get_type (void) { - static GType buttonbox_type = 0; + static GType button_box_type = 0; - if (!buttonbox_type) + if (!button_box_type) { - static const GTypeInfo buttonbox_info = + static const GTypeInfo button_box_info = { sizeof (PsppireButtonBoxClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) psppire_buttonbox_class_init, + (GClassInitFunc) psppire_button_box_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (PsppireButtonBox), 0, - (GInstanceInitFunc) psppire_buttonbox_init, + (GInstanceInitFunc) psppire_button_box_init, }; - buttonbox_type = g_type_register_static (GTK_TYPE_VBUTTON_BOX, - "PsppireButtonBox", &buttonbox_info, 0); + button_box_type = g_type_register_static (GTK_TYPE_BUTTON_BOX, + "PsppireButtonBox", &button_box_info, 0); } - return buttonbox_type; + return button_box_type; } static void -psppire_buttonbox_class_init (PsppireButtonBoxClass *class) +psppire_button_box_class_init (PsppireButtonBoxClass *class) { } @@ -118,46 +118,120 @@ refresh_clicked (GtkWidget *w, gpointer data) static void -psppire_buttonbox_init (PsppireButtonBox *buttonbox) +psppire_button_box_init (PsppireButtonBox *button_box) { GtkWidget *button ; button = gtk_button_new_from_stock (GTK_STOCK_OK); - gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button); + gtk_box_pack_start_defaults (GTK_BOX (button_box), button); g_signal_connect (button, "clicked", G_CALLBACK (ok_button_clicked), NULL); gtk_widget_show (button); button = gtk_button_new_with_mnemonic (_("_Paste")); g_signal_connect (button, "clicked", G_CALLBACK (paste_button_clicked), NULL); - gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button); + gtk_box_pack_start_defaults (GTK_BOX (button_box), button); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); g_signal_connect (button, "clicked", G_CALLBACK (close_dialog), NULL); - gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button); + gtk_box_pack_start_defaults (GTK_BOX (button_box), button); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_REFRESH); g_signal_connect (button, "clicked", G_CALLBACK (refresh_clicked), NULL); - gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button); + gtk_box_pack_start_defaults (GTK_BOX (button_box), button); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_HELP); - gtk_box_pack_start_defaults (GTK_BOX (buttonbox), button); + gtk_box_pack_start_defaults (GTK_BOX (button_box), button); gtk_widget_show (button); - gtk_widget_show (GTK_WIDGET (buttonbox)); } -GtkWidget* -psppire_buttonbox_new (void) -{ - PsppireButtonBox *buttonbox ; +/* This function is lifted verbatim from the Gtk2.10.6 library */ - buttonbox = g_object_new (psppire_button_box_get_type (), NULL); +void +_psppire_button_box_child_requisition (GtkWidget *widget, + int *nvis_children, + int *nvis_secondaries, + int *width, + int *height) +{ + GtkButtonBox *bbox; + GtkBoxChild *child; + 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; + 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; + + while (children) + { + child = children->data; + children = children->next; + + if (GTK_WIDGET_VISIBLE (child->widget)) + { + nchildren += 1; + gtk_widget_size_request (child->widget, &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) + nsecondaries++; + } + } - return GTK_WIDGET (buttonbox) ; + if (nvis_children) + *nvis_children = nchildren; + if (nvis_secondaries) + *nvis_secondaries = nsecondaries; + if (width) + *width = needed_width; + if (height) + *height = needed_height; } -