diff options
author | Matthias Clasen <maclas@gmx.de> | 2003-06-09 22:04:34 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2003-06-09 22:04:34 +0000 |
commit | 4363aee1b117240df115943ff39306db4a543ba5 (patch) | |
tree | 24b4b0aee061ecd919c03c228d98f91c7f31095c | |
parent | cf566674949b5448f90178431f142bcf6c11246f (diff) | |
download | gdk-pixbuf-4363aee1b117240df115943ff39306db4a543ba5.tar.gz |
Install boolean child properties "resize" and "shrink".
2003-06-09 Matthias Clasen <maclas@gmx.de>
* gtk/gtkpaned.c (gtk_paned_class_init): Install boolean child
properties "resize" and "shrink".
(gtk_paned_[gs]et_child_property): Implementations of
GtkContainer::[gs]et_child_property.
* tests/testgtk.c (toggle_resize, toggle_shrink): Use the new
paned child properties instead of remove/add hacks. (#114667,
Soeren Sandmann)
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 10 | ||||
-rw-r--r-- | gtk/gtkpaned.c | 112 | ||||
-rw-r--r-- | tests/testgtk.c | 40 |
7 files changed, 174 insertions, 28 deletions
@@ -1,3 +1,13 @@ +2003-06-09 Matthias Clasen <maclas@gmx.de> + + * gtk/gtkpaned.c (gtk_paned_class_init): Install boolean child + properties "resize" and "shrink". + (gtk_paned_[gs]et_child_property): Implementations of + GtkContainer::[gs]et_child_property. + * tests/testgtk.c (toggle_resize, toggle_shrink): Use the new + paned child properties instead of remove/add hacks. (#114667, + Soeren Sandmann) + Mon Jun 9 16:18:11 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_button_press): Back diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f07187b76..e16f078e5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +2003-06-09 Matthias Clasen <maclas@gmx.de> + + * gtk/gtkpaned.c (gtk_paned_class_init): Install boolean child + properties "resize" and "shrink". + (gtk_paned_[gs]et_child_property): Implementations of + GtkContainer::[gs]et_child_property. + * tests/testgtk.c (toggle_resize, toggle_shrink): Use the new + paned child properties instead of remove/add hacks. (#114667, + Soeren Sandmann) + Mon Jun 9 16:18:11 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_button_press): Back diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f07187b76..e16f078e5 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +2003-06-09 Matthias Clasen <maclas@gmx.de> + + * gtk/gtkpaned.c (gtk_paned_class_init): Install boolean child + properties "resize" and "shrink". + (gtk_paned_[gs]et_child_property): Implementations of + GtkContainer::[gs]et_child_property. + * tests/testgtk.c (toggle_resize, toggle_shrink): Use the new + paned child properties instead of remove/add hacks. (#114667, + Soeren Sandmann) + Mon Jun 9 16:18:11 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_button_press): Back diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f07187b76..e16f078e5 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +2003-06-09 Matthias Clasen <maclas@gmx.de> + + * gtk/gtkpaned.c (gtk_paned_class_init): Install boolean child + properties "resize" and "shrink". + (gtk_paned_[gs]et_child_property): Implementations of + GtkContainer::[gs]et_child_property. + * tests/testgtk.c (toggle_resize, toggle_shrink): Use the new + paned child properties instead of remove/add hacks. (#114667, + Soeren Sandmann) + Mon Jun 9 16:18:11 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_button_press): Back diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f07187b76..e16f078e5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +2003-06-09 Matthias Clasen <maclas@gmx.de> + + * gtk/gtkpaned.c (gtk_paned_class_init): Install boolean child + properties "resize" and "shrink". + (gtk_paned_[gs]et_child_property): Implementations of + GtkContainer::[gs]et_child_property. + * tests/testgtk.c (toggle_resize, toggle_shrink): Use the new + paned child properties instead of remove/add hacks. (#114667, + Soeren Sandmann) + Mon Jun 9 16:18:11 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_button_press): Back diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 84eacf4ca..4f369b75a 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -40,6 +40,12 @@ enum { }; enum { + CHILD_PROP_0, + CHILD_PROP_RESIZE, + CHILD_PROP_SHRINK +}; + +enum { CYCLE_CHILD_FOCUS, TOGGLE_HANDLE_FOCUS, MOVE_HANDLE, @@ -59,6 +65,16 @@ static void gtk_paned_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gtk_paned_set_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_paned_get_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + GValue *value, + GParamSpec *pspec); static void gtk_paned_finalize (GObject *object); static void gtk_paned_realize (GtkWidget *widget); static void gtk_paned_unrealize (GtkWidget *widget); @@ -204,6 +220,8 @@ gtk_paned_class_init (GtkPanedClass *class) container_class->forall = gtk_paned_forall; container_class->child_type = gtk_paned_child_type; container_class->set_focus_child = gtk_paned_set_focus_child; + container_class->set_child_property = gtk_paned_set_child_property; + container_class->get_child_property = gtk_paned_get_child_property; paned_class->cycle_child_focus = gtk_paned_cycle_child_focus; paned_class->toggle_handle_focus = gtk_paned_toggle_handle_focus; @@ -238,6 +256,22 @@ gtk_paned_class_init (GtkPanedClass *class) 5, G_PARAM_READABLE)); + gtk_container_class_install_child_property (container_class, + CHILD_PROP_RESIZE, + g_param_spec_boolean ("resize", + _("Resize"), + _("If TRUE, the child expands and shrinks along with the paned widget"), + TRUE, + G_PARAM_READWRITE)); + + gtk_container_class_install_child_property (container_class, + CHILD_PROP_SHRINK, + g_param_spec_boolean ("shrink", + _("Shrink"), + _("If TRUE, the child can be made smaller than its requisition"), + TRUE, + G_PARAM_READWRITE)); + signals [CYCLE_HANDLE_FOCUS] = g_signal_new ("cycle_child_focus", G_TYPE_FROM_CLASS (object_class), @@ -457,6 +491,84 @@ gtk_paned_get_property (GObject *object, } static void +gtk_paned_set_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkPaned *paned = GTK_PANED (container); + gboolean old_value, new_value; + + g_assert (child == paned->child1 || child == paned->child2); + + new_value = g_value_get_boolean (value); + switch (property_id) + { + case CHILD_PROP_RESIZE: + if (child == paned->child1) + { + old_value = paned->child1_resize; + paned->child1_resize = new_value; + } + else + { + old_value = paned->child2_resize; + paned->child2_resize = new_value; + } + break; + case CHILD_PROP_SHRINK: + if (child == paned->child1) + { + old_value = paned->child1_shrink; + paned->child1_shrink = new_value; + } + else + { + old_value = paned->child2_shrink; + paned->child2_shrink = new_value; + } + break; + default: + GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); + break; + } + if (old_value != new_value) + gtk_widget_queue_resize (container); +} + +static void +gtk_paned_get_child_property (GtkContainer *container, + GtkWidget *child, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GtkPaned *paned = GTK_PANED (container); + + g_assert (child == paned->child1 || child == paned->child2); + + switch (property_id) + { + case CHILD_PROP_RESIZE: + if (child == paned->child1) + g_value_set_boolean (value, paned->child1_resize); + else + g_value_set_boolean (value, paned->child2_resize); + break; + case CHILD_PROP_SHRINK: + if (child == paned->child1) + g_value_set_boolean (value, paned->child1_shrink); + else + g_value_set_boolean (value, paned->child2_shrink); + break; + default: + GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); + break; + } +} + +static void gtk_paned_finalize (GObject *object) { GtkPaned *paned = GTK_PANED (object); diff --git a/tests/testgtk.c b/tests/testgtk.c index 11ad77267..53b116c3c 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -8559,39 +8559,23 @@ create_notebook (GtkWidget *widget) void toggle_resize (GtkWidget *widget, GtkWidget *child) { - GtkPaned *paned = GTK_PANED (child->parent); - gboolean is_child1 = (child == paned->child1); - gboolean resize, shrink; - - resize = is_child1 ? paned->child1_resize : paned->child2_resize; - shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink; - - gtk_widget_ref (child); - gtk_container_remove (GTK_CONTAINER (child->parent), child); - if (is_child1) - gtk_paned_pack1 (paned, child, !resize, shrink); - else - gtk_paned_pack2 (paned, child, !resize, shrink); - gtk_widget_unref (child); + GValue value = { 0, }; + g_value_init (&value, G_TYPE_BOOLEAN); + GtkContainer *container = GTK_CONTAINER (gtk_widget_get_parent (child)); + gtk_container_child_get_property (container, child, "resize", &value); + g_value_set_boolean (&value, !g_value_get_boolean (&value)); + gtk_container_child_set_property (container, child, "resize", &value); } void toggle_shrink (GtkWidget *widget, GtkWidget *child) { - GtkPaned *paned = GTK_PANED (child->parent); - gboolean is_child1 = (child == paned->child1); - gboolean resize, shrink; - - resize = is_child1 ? paned->child1_resize : paned->child2_resize; - shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink; - - gtk_widget_ref (child); - gtk_container_remove (GTK_CONTAINER (child->parent), child); - if (is_child1) - gtk_paned_pack1 (paned, child, resize, !shrink); - else - gtk_paned_pack2 (paned, child, resize, !shrink); - gtk_widget_unref (child); + GValue value = { 0, }; + g_value_init (&value, G_TYPE_BOOLEAN); + GtkContainer *container = GTK_CONTAINER (gtk_widget_get_parent (child)); + gtk_container_child_get_property (container, child, "shrink", &value); + g_value_set_boolean (&value, !g_value_get_boolean (&value)); + gtk_container_child_set_property (container, child, "shrink", &value); } static void |