Commit 6d2ce706 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Block against redundant changes.

Mon May 14 14:56:21 2001  Owen Taylor  <otaylor@redhat.com>

	* tests/prop-editor.c: Block against redundant changes.

	* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
	properties.
parent 0466a7af
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
Mon May 14 14:56:21 2001 Owen Taylor <otaylor@redhat.com>
* tests/prop-editor.c: Block against redundant changes.
* gtk/gtkpaned.c gtk/gtk[hv]paned.c: Add position, position_set
properties.
Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com> Sun May 13 18:40:04 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixmap.h: Remove creative formatting. * gdk/gdkpixmap.h: Remove creative formatting.
......
...@@ -336,12 +336,8 @@ static gboolean ...@@ -336,12 +336,8 @@ static gboolean
gtk_hpaned_button_release (GtkWidget *widget, gtk_hpaned_button_release (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
GtkPaned *paned; GtkPaned *paned = GTK_PANED (widget);
GObject *object = G_OBJECT (widget);
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
if (paned->in_drag && (event->button == 1)) if (paned->in_drag && (event->button == 1))
{ {
...@@ -350,7 +346,11 @@ gtk_hpaned_button_release (GtkWidget *widget, ...@@ -350,7 +346,11 @@ gtk_hpaned_button_release (GtkWidget *widget,
paned->position_set = TRUE; paned->position_set = TRUE;
gdk_pointer_ungrab (event->time); gdk_pointer_ungrab (event->time);
gtk_widget_queue_resize (GTK_WIDGET (paned)); gtk_widget_queue_resize (GTK_WIDGET (paned));
g_object_freeze_notify (object);
g_object_notify (object, "position");
g_object_notify (object, "position_set");
g_object_thaw_notify (object);
return TRUE; return TRUE;
} }
......
...@@ -28,32 +28,36 @@ ...@@ -28,32 +28,36 @@
#include "gtkpaned.h" #include "gtkpaned.h"
enum { enum {
ARG_0, PROP_0,
PROP_POSITION,
PROP_POSITION_SET
}; };
static void gtk_paned_class_init (GtkPanedClass *klass); static void gtk_paned_class_init (GtkPanedClass *klass);
static void gtk_paned_init (GtkPaned *paned); static void gtk_paned_init (GtkPaned *paned);
static void gtk_paned_set_arg (GtkObject *object, static void gtk_paned_set_property (GObject *object,
GtkArg *arg, guint prop_id,
guint arg_id); const GValue *value,
static void gtk_paned_get_arg (GtkObject *object, GParamSpec *pspec);
GtkArg *arg, static void gtk_paned_get_property (GObject *object,
guint arg_id); guint prop_id,
static void gtk_paned_realize (GtkWidget *widget); GValue *value,
static void gtk_paned_map (GtkWidget *widget); GParamSpec *pspec);
static void gtk_paned_unmap (GtkWidget *widget); static void gtk_paned_realize (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget); static void gtk_paned_map (GtkWidget *widget);
static gint gtk_paned_expose (GtkWidget *widget, static void gtk_paned_unmap (GtkWidget *widget);
GdkEventExpose *event); static void gtk_paned_unrealize (GtkWidget *widget);
static void gtk_paned_add (GtkContainer *container, static gint gtk_paned_expose (GtkWidget *widget,
GtkWidget *widget); GdkEventExpose *event);
static void gtk_paned_remove (GtkContainer *container, static void gtk_paned_add (GtkContainer *container,
GtkWidget *widget); GtkWidget *widget);
static void gtk_paned_forall (GtkContainer *container, static void gtk_paned_remove (GtkContainer *container,
gboolean include_internals, GtkWidget *widget);
GtkCallback callback, static void gtk_paned_forall (GtkContainer *container,
gpointer callback_data); gboolean include_internals,
static GtkType gtk_paned_child_type (GtkContainer *container); GtkCallback callback,
gpointer callback_data);
static GtkType gtk_paned_child_type (GtkContainer *container);
static GtkContainerClass *parent_class = NULL; static GtkContainerClass *parent_class = NULL;
...@@ -86,18 +90,18 @@ gtk_paned_get_type (void) ...@@ -86,18 +90,18 @@ gtk_paned_get_type (void)
static void static void
gtk_paned_class_init (GtkPanedClass *class) gtk_paned_class_init (GtkPanedClass *class)
{ {
GtkObjectClass *object_class; GObjectClass *object_class;
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class;
GtkContainerClass *container_class; GtkContainerClass *container_class;
object_class = (GtkObjectClass *) class; object_class = (GObjectClass *) class;
widget_class = (GtkWidgetClass *) class; widget_class = (GtkWidgetClass *) class;
container_class = (GtkContainerClass *) class; container_class = (GtkContainerClass *) class;
parent_class = gtk_type_class (GTK_TYPE_CONTAINER); parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
object_class->set_arg = gtk_paned_set_arg; object_class->set_property = gtk_paned_set_property;
object_class->get_arg = gtk_paned_get_arg; object_class->get_property = gtk_paned_get_property;
widget_class->realize = gtk_paned_realize; widget_class->realize = gtk_paned_realize;
widget_class->map = gtk_paned_map; widget_class->map = gtk_paned_map;
...@@ -110,6 +114,23 @@ gtk_paned_class_init (GtkPanedClass *class) ...@@ -110,6 +114,23 @@ gtk_paned_class_init (GtkPanedClass *class)
container_class->forall = gtk_paned_forall; container_class->forall = gtk_paned_forall;
container_class->child_type = gtk_paned_child_type; container_class->child_type = gtk_paned_child_type;
g_object_class_install_property (object_class,
PROP_POSITION,
g_param_spec_int ("position",
_("Position"),
_("Position of paned separator in pixels(0 means all the way to the left/top)"),
0,
G_MAXINT,
0,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_POSITION_SET,
g_param_spec_boolean ("position_set",
_("Position Set"),
_("TRUE if the Position property should be used"),
FALSE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
gtk_widget_class_install_style_property (widget_class, gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("handle_size", g_param_spec_int ("handle_size",
_("Handle Size"), _("Handle Size"),
...@@ -151,26 +172,46 @@ gtk_paned_init (GtkPaned *paned) ...@@ -151,26 +172,46 @@ gtk_paned_init (GtkPaned *paned)
} }
static void static void
gtk_paned_set_arg (GtkObject *object, gtk_paned_set_property (GObject *object,
GtkArg *arg, guint prop_id,
guint arg_id) const GValue *value,
GParamSpec *pspec)
{ {
switch (arg_id) GtkPaned *paned = GTK_PANED (object);
switch (prop_id)
{ {
case PROP_POSITION:
gtk_paned_set_position (paned, g_value_get_int (value));
break;
case PROP_POSITION_SET:
paned->position_set = g_value_get_boolean (value);
gtk_widget_queue_resize (GTK_WIDGET (paned));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
static void static void
gtk_paned_get_arg (GtkObject *object, gtk_paned_get_property (GObject *object,
GtkArg *arg, guint prop_id,
guint arg_id) GValue *value,
GParamSpec *pspec)
{ {
switch (arg_id) GtkPaned *paned = GTK_PANED (object);
switch (prop_id)
{ {
case PROP_POSITION:
g_value_set_int (value, paned->child1_size);
break;
case PROP_POSITION_SET:
g_value_set_boolean (value, paned->position_set);
break;
default: default:
arg->type = GTK_TYPE_INVALID; G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
...@@ -482,7 +523,8 @@ gtk_paned_get_position (GtkPaned *paned) ...@@ -482,7 +523,8 @@ gtk_paned_get_position (GtkPaned *paned)
/** /**
* gtk_paned_set_position: * gtk_paned_set_position:
* @paned: a #GtkPaned widget * @paned: a #GtkPaned widget
* @position: pixel position of divider * @position: pixel position of divider, a negative value means that the position
* is unset.
* *
* Sets the position of the divider between the two panes. * Sets the position of the divider between the two panes.
**/ **/
...@@ -490,9 +532,13 @@ void ...@@ -490,9 +532,13 @@ void
gtk_paned_set_position (GtkPaned *paned, gtk_paned_set_position (GtkPaned *paned,
gint position) gint position)
{ {
GObject *object;
g_return_if_fail (paned != NULL); g_return_if_fail (paned != NULL);
g_return_if_fail (GTK_IS_PANED (paned)); g_return_if_fail (GTK_IS_PANED (paned));
object = G_OBJECT (paned);
if (position >= 0) if (position >= 0)
{ {
/* We don't clamp here - the assumption is that /* We don't clamp here - the assumption is that
...@@ -501,6 +547,7 @@ gtk_paned_set_position (GtkPaned *paned, ...@@ -501,6 +547,7 @@ gtk_paned_set_position (GtkPaned *paned,
* to the new total size. If only the position changes, * to the new total size. If only the position changes,
* then clamping will occur in gtk_paned_compute_position() * then clamping will occur in gtk_paned_compute_position()
*/ */
paned->child1_size = position; paned->child1_size = position;
paned->position_set = TRUE; paned->position_set = TRUE;
} }
...@@ -509,6 +556,11 @@ gtk_paned_set_position (GtkPaned *paned, ...@@ -509,6 +556,11 @@ gtk_paned_set_position (GtkPaned *paned,
paned->position_set = FALSE; paned->position_set = FALSE;
} }
g_object_freeze_notify (object);
g_object_notify (object, "position");
g_object_notify (object, "position_set");
g_object_thaw_notify (object);
gtk_widget_queue_resize (GTK_WIDGET (paned)); gtk_widget_queue_resize (GTK_WIDGET (paned));
} }
...@@ -518,9 +570,13 @@ gtk_paned_compute_position(GtkPaned *paned, ...@@ -518,9 +570,13 @@ gtk_paned_compute_position(GtkPaned *paned,
gint child1_req, gint child1_req,
gint child2_req) gint child2_req)
{ {
gint old_position;
g_return_if_fail (paned != NULL); g_return_if_fail (paned != NULL);
g_return_if_fail (GTK_IS_PANED (paned)); g_return_if_fail (GTK_IS_PANED (paned));
old_position = paned->child1_size;
paned->min_position = paned->child1_shrink ? 0 : child1_req; paned->min_position = paned->child1_shrink ? 0 : child1_req;
paned->max_position = allocation; paned->max_position = allocation;
...@@ -556,5 +612,8 @@ gtk_paned_compute_position(GtkPaned *paned, ...@@ -556,5 +612,8 @@ gtk_paned_compute_position(GtkPaned *paned,
paned->min_position, paned->min_position,
paned->max_position); paned->max_position);
if (paned->child1_size != old_position)
g_object_notify (G_OBJECT (paned), "position");
paned->last_allocation = allocation; paned->last_allocation = allocation;
} }
...@@ -339,12 +339,8 @@ static gboolean ...@@ -339,12 +339,8 @@ static gboolean
gtk_vpaned_button_release (GtkWidget *widget, gtk_vpaned_button_release (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
GtkPaned *paned; GtkPaned *paned = GTK_PANED (widget);
GObject *object = G_OBJECT (widget);
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
if (paned->in_drag && (event->button == 1)) if (paned->in_drag && (event->button == 1))
{ {
...@@ -353,6 +349,10 @@ gtk_vpaned_button_release (GtkWidget *widget, ...@@ -353,6 +349,10 @@ gtk_vpaned_button_release (GtkWidget *widget,
paned->position_set = TRUE; paned->position_set = TRUE;
gdk_pointer_ungrab (event->time); gdk_pointer_ungrab (event->time);
gtk_widget_queue_resize (GTK_WIDGET (paned)); gtk_widget_queue_resize (GTK_WIDGET (paned));
g_object_freeze_notify (object);
g_object_notify (object, "position");
g_object_notify (object, "position_set");
g_object_thaw_notify (object);
return TRUE; return TRUE;
} }
......
...@@ -24,13 +24,19 @@ ...@@ -24,13 +24,19 @@
#include "prop-editor.h" #include "prop-editor.h"
static void static void
get_param_specs (GObject *object, get_param_specs (GType type,
GParamSpec ***specs, GParamSpec ***specs,
gint *n_specs) gint *n_specs)
{ {
GObjectClass *class = g_type_class_peek (type);
/* We count on the fact we have an instance, or else we'd have
* to use g_type_class_ref ();
*/
/* Use private interface for now, fix later */ /* Use private interface for now, fix later */
*specs = G_OBJECT_GET_CLASS (object)->property_specs; *specs = class->property_specs;
*n_specs = G_OBJECT_GET_CLASS (object)->n_property_specs; *n_specs = class->n_property_specs;
} }
typedef struct typedef struct
...@@ -93,6 +99,7 @@ typedef struct ...@@ -93,6 +99,7 @@ typedef struct
{ {
GObject *obj; GObject *obj;
gchar *prop; gchar *prop;
gint modified_id;
} ObjectProperty; } ObjectProperty;
static void static void
...@@ -115,9 +122,26 @@ connect_controller (GObject *controller, ...@@ -115,9 +122,26 @@ connect_controller (GObject *controller,
p->obj = model; p->obj = model;
p->prop = g_strdup (prop_name); p->prop = g_strdup (prop_name);
g_signal_connect_data (controller, signal, func, p, p->modified_id = g_signal_connect_data (controller, signal, func, p,
(GClosureNotify)free_object_property, (GClosureNotify)free_object_property,
FALSE, FALSE); FALSE, FALSE);
g_object_set_data (controller, "object-property", p);
}
static void
block_controller (GObject *controller)
{
ObjectProperty *p = g_object_get_data (controller, "object-property");
g_signal_handler_block (controller, p->modified_id);
}
static void
unblock_controller (GObject *controller)
{
ObjectProperty *p = g_object_get_data (controller, "object-property");
g_signal_handler_unblock (controller, p->modified_id);
} }
static void static void
...@@ -138,7 +162,11 @@ int_changed (GObject *object, GParamSpec *pspec, gpointer data) ...@@ -138,7 +162,11 @@ int_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_object_get_property (object, pspec->name, &val); g_object_get_property (object, pspec->name, &val);
if (g_value_get_int (&val) != (int)adj->value) if (g_value_get_int (&val) != (int)adj->value)
gtk_adjustment_set_value (adj, g_value_get_int (&val)); {
block_controller (G_OBJECT (adj));
gtk_adjustment_set_value (adj, g_value_get_int (&val));
unblock_controller (G_OBJECT (adj));
}
g_value_unset (&val); g_value_unset (&val);
} }
...@@ -161,7 +189,11 @@ float_changed (GObject *object, GParamSpec *pspec, gpointer data) ...@@ -161,7 +189,11 @@ float_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_object_get_property (object, pspec->name, &val); g_object_get_property (object, pspec->name, &val);
if (g_value_get_float (&val) != (float) adj->value) if (g_value_get_float (&val) != (float) adj->value)
gtk_adjustment_set_value (adj, g_value_get_float (&val)); {
block_controller (G_OBJECT (adj));
gtk_adjustment_set_value (adj, g_value_get_float (&val));
unblock_controller (G_OBJECT (adj));
}
g_value_unset (&val); g_value_unset (&val);
} }
...@@ -194,7 +226,11 @@ string_changed (GObject *object, GParamSpec *pspec, gpointer data) ...@@ -194,7 +226,11 @@ string_changed (GObject *object, GParamSpec *pspec, gpointer data)
text = gtk_entry_get_text (entry); text = gtk_entry_get_text (entry);
if (strcmp (str, text) != 0) if (strcmp (str, text) != 0)
gtk_entry_set_text (entry, str); {
block_controller (G_OBJECT (entry));
gtk_entry_set_text (entry, str);
unblock_controller (G_OBJECT (entry));
}
g_value_unset (&val); g_value_unset (&val);
} }
...@@ -217,7 +253,11 @@ bool_changed (GObject *object, GParamSpec *pspec, gpointer data) ...@@ -217,7 +253,11 @@ bool_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_object_get_property (object, pspec->name, &val); g_object_get_property (object, pspec->name, &val);
if (g_value_get_boolean (&val) != tb->active) if (g_value_get_boolean (&val) != tb->active)
gtk_toggle_button_set_active (tb, g_value_get_boolean (&val)); {
block_controller (G_OBJECT (tb));
gtk_toggle_button_set_active (tb, g_value_get_boolean (&val));
unblock_controller (G_OBJECT (tb));
}
gtk_label_set_text (GTK_LABEL (GTK_BIN (tb)->child), g_value_get_boolean (&val) ? gtk_label_set_text (GTK_LABEL (GTK_BIN (tb)->child), g_value_get_boolean (&val) ?
"TRUE" : "FALSE"); "TRUE" : "FALSE");
...@@ -266,7 +306,11 @@ enum_changed (GObject *object, GParamSpec *pspec, gpointer data) ...@@ -266,7 +306,11 @@ enum_changed (GObject *object, GParamSpec *pspec, gpointer data)
} }
if (gtk_option_menu_get_history (om) != i) if (gtk_option_menu_get_history (om) != i)
gtk_option_menu_set_history (om, i); {
block_controller (G_OBJECT (om));
gtk_option_menu_set_history (om, i);
unblock_controller (G_OBJECT (om));
}
g_value_unset (&val); g_value_unset (&val);
...@@ -312,7 +356,9 @@ unichar_changed (GObject *object, GParamSpec *pspec, gpointer data) ...@@ -312,7 +356,9 @@ unichar_changed (GObject *object, GParamSpec *pspec, gpointer data)
buf[len] = '\0'; buf[len] = '\0';
block_controller (G_OBJECT (entry));
gtk_entry_set_text (entry, buf); gtk_entry_set_text (entry, buf);
unblock_controller (G_OBJECT (entry));
} }
} }