From f9e666244fb25940b113cd35dbed18d0f75c4f44 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 27 Aug 2001 01:05:07 +0000 Subject: Add properties for labels, mnemonics and stock items. Added C accessor 2001-08-26 Alexander Larsson * gtk/gtkbutton.[ch]: Add properties for labels, mnemonics and stock items. Added C accessor functions for the properties. Removed deprecated button->child. * gtk/gtkradiobutton.c: * gtk/gtktogglebutton.c: Update to use the functions in GtkButton. * gtk/gtkcheckbutton.c: Update to use the functions in GtkButton. Changed size allocation of child. Now only gets as much space as it requests. * gtk/gtkclist.c: Don't use GtkButton->child * gtk/gtklabel.c: Fixed typo in docs --- gtk/gtkcheckbutton.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'gtk/gtkcheckbutton.c') diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 67f3e4a15..b9671e0d6 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -126,17 +126,7 @@ gtk_check_button_new (void) GtkWidget* gtk_check_button_new_with_label (const gchar *label) { - GtkWidget *check_button; - GtkWidget *label_widget; - - check_button = gtk_check_button_new (); - label_widget = gtk_label_new (label); - gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); - - gtk_container_add (GTK_CONTAINER (check_button), label_widget); - gtk_widget_show (label_widget); - - return check_button; + return g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, NULL); } /** @@ -152,17 +142,7 @@ gtk_check_button_new_with_label (const gchar *label) GtkWidget* gtk_check_button_new_with_mnemonic (const gchar *label) { - GtkWidget *check_button; - GtkWidget *label_widget; - - check_button = gtk_check_button_new (); - label_widget = gtk_label_new_with_mnemonic (label); - gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); - - gtk_container_add (GTK_CONTAINER (check_button), label_widget); - gtk_widget_show (label_widget); - - return check_button; + return g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, "use_underline", TRUE, NULL); } @@ -306,10 +286,11 @@ gtk_check_button_size_allocate (GtkWidget *widget, child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + 1 + widget->allocation.x); child_allocation.y = border_width + 1 + widget->allocation.y; - child_allocation.width = MAX (1, allocation->width - - (border_width + indicator_size + indicator_spacing * 3 + 1) - - border_width - 1); - child_allocation.height = MAX (1, allocation->height - (border_width + 1) * 2); + child_allocation.width = MIN (GTK_BIN (button)->child->requisition.width, + allocation->width - + ((border_width + 1) * 2 + indicator_size + indicator_spacing * 3)); + child_allocation.height = MIN (GTK_BIN (button)->child->requisition.height, + allocation->height - (border_width + 1) * 2); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) child_allocation.x = allocation->x + allocation->width -- cgit v1.2.1