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)
This commit is contained in:
Matthias Clasen 2003-06-09 22:04:34 +00:00 committed by Matthias Clasen
parent cf56667494
commit 4363aee1b1
7 changed files with 174 additions and 28 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -39,6 +39,12 @@ enum {
PROP_POSITION_SET
};
enum {
CHILD_PROP_0,
CHILD_PROP_RESIZE,
CHILD_PROP_SHRINK
};
enum {
CYCLE_CHILD_FOCUS,
TOGGLE_HANDLE_FOCUS,
@ -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),
@ -456,6 +490,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)
{

View File

@ -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