diff options
author | Tim Janik <timj@src.gnome.org> | 1998-06-16 05:20:05 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-06-16 05:20:05 +0000 |
commit | 742d01908f754f9473e6a7993276c3aee060d1ec (patch) | |
tree | bfeef446f36bd92a51a6fa3ccd671ec706b0b9c4 /gtk/gtkbutton.c | |
parent | d36df18dee814c690fd5736729ea54175b3be628 (diff) | |
download | gtk+-742d01908f754f9473e6a7993276c3aee060d1ec.tar.gz |
boy! did i really modify that many files?
anyways, here go the child args and a lot of cleanups ;)
you wouldn't want me to put the ChangeLog entry in here, would you?
Diffstat (limited to 'gtk/gtkbutton.c')
-rw-r--r-- | gtk/gtkbutton.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 9c4afe0b30..198ea17b2f 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -49,6 +49,9 @@ static void gtk_button_init (GtkButton *button); static void gtk_button_set_arg (GtkButton *button, GtkArg *arg, guint arg_id); +static void gtk_button_get_arg (GtkButton *button, + GtkArg *arg, + guint arg_id); static void gtk_button_map (GtkWidget *widget); static void gtk_button_unmap (GtkWidget *widget); static void gtk_button_realize (GtkWidget *widget); @@ -87,6 +90,7 @@ static void gtk_real_button_pressed (GtkButton *button); static void gtk_real_button_released (GtkButton *button); static void gtk_real_button_enter (GtkButton *button); static void gtk_real_button_leave (GtkButton *button); +static GtkType gtk_button_child_type (GtkContainer *container); static GtkContainerClass *parent_class; @@ -108,7 +112,7 @@ gtk_button_get_type (void) (GtkClassInitFunc) gtk_button_class_init, (GtkObjectInitFunc) gtk_button_init, (GtkArgSetFunc) gtk_button_set_arg, - (GtkArgGetFunc) NULL, + (GtkArgGetFunc) gtk_button_get_arg, }; button_type = gtk_type_unique (gtk_container_get_type (), &button_info); @@ -131,7 +135,7 @@ gtk_button_class_init (GtkButtonClass *klass) parent_class = gtk_type_class (gtk_container_get_type ()); - gtk_object_add_arg_type ("GtkButton::label", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_LABEL); + gtk_object_add_arg_type ("GtkButton::label", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_LABEL); button_signals[PRESSED] = gtk_signal_new ("pressed", @@ -191,6 +195,7 @@ gtk_button_class_init (GtkButtonClass *klass) container_class->add = gtk_button_add; container_class->remove = gtk_button_remove; container_class->foreach = gtk_button_foreach; + container_class->child_type = gtk_button_child_type; klass->pressed = gtk_real_button_pressed; klass->released = gtk_real_button_released; @@ -210,6 +215,15 @@ gtk_button_init (GtkButton *button) button->relief = GTK_RELIEF_NORMAL; } +static GtkType +gtk_button_child_type (GtkContainer *container) +{ + if (!GTK_BUTTON (container)->child) + return GTK_TYPE_WIDGET; + else + return GTK_TYPE_NONE; +} + static void gtk_button_set_arg (GtkButton *button, GtkArg *arg, @@ -228,13 +242,31 @@ gtk_button_set_arg (GtkButton *button, button->child = NULL; } - label = gtk_label_new (GTK_VALUE_STRING(*arg)); + label = gtk_label_new (GTK_VALUE_STRING(*arg) ? GTK_VALUE_STRING(*arg) : ""); gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (button), label); gtk_container_enable_resize (GTK_CONTAINER (button)); break; default: + break; + } +} + +static void +gtk_button_get_arg (GtkButton *button, + GtkArg *arg, + guint arg_id) +{ + switch (arg_id) + { + case ARG_LABEL: + if (button->child && GTK_IS_LABEL (button->child)) + GTK_VALUE_STRING (*arg) = g_strdup (GTK_LABEL (button->child)->label); + else + GTK_VALUE_STRING (*arg) = NULL; + break; + default: arg->type = GTK_TYPE_INVALID; break; } |