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.
This commit is contained in:
Owen Taylor 2001-05-14 19:14:57 +00:00 committed by Owen Taylor
parent 0466a7afce
commit 6d2ce70689
14 changed files with 243 additions and 70 deletions

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -1,3 +1,10 @@
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>
* gdk/gdkpixmap.h: Remove creative formatting.

View File

@ -336,12 +336,8 @@ static gboolean
gtk_hpaned_button_release (GtkWidget *widget,
GdkEventButton *event)
{
GtkPaned *paned;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
GtkPaned *paned = GTK_PANED (widget);
GObject *object = G_OBJECT (widget);
if (paned->in_drag && (event->button == 1))
{
@ -350,7 +346,11 @@ gtk_hpaned_button_release (GtkWidget *widget,
paned->position_set = TRUE;
gdk_pointer_ungrab (event->time);
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;
}

View File

@ -28,32 +28,36 @@
#include "gtkpaned.h"
enum {
ARG_0,
PROP_0,
PROP_POSITION,
PROP_POSITION_SET
};
static void gtk_paned_class_init (GtkPanedClass *klass);
static void gtk_paned_init (GtkPaned *paned);
static void gtk_paned_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_paned_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_paned_realize (GtkWidget *widget);
static void gtk_paned_map (GtkWidget *widget);
static void gtk_paned_unmap (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget);
static gint gtk_paned_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_paned_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_paned_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_paned_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static GtkType gtk_paned_child_type (GtkContainer *container);
static void gtk_paned_class_init (GtkPanedClass *klass);
static void gtk_paned_init (GtkPaned *paned);
static void gtk_paned_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_paned_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_paned_realize (GtkWidget *widget);
static void gtk_paned_map (GtkWidget *widget);
static void gtk_paned_unmap (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget);
static gint gtk_paned_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_paned_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_paned_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_paned_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static GtkType gtk_paned_child_type (GtkContainer *container);
static GtkContainerClass *parent_class = NULL;
@ -86,18 +90,18 @@ gtk_paned_get_type (void)
static void
gtk_paned_class_init (GtkPanedClass *class)
{
GtkObjectClass *object_class;
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
object_class = (GtkObjectClass *) class;
object_class = (GObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
container_class = (GtkContainerClass *) class;
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
object_class->set_arg = gtk_paned_set_arg;
object_class->get_arg = gtk_paned_get_arg;
object_class->set_property = gtk_paned_set_property;
object_class->get_property = gtk_paned_get_property;
widget_class->realize = gtk_paned_realize;
widget_class->map = gtk_paned_map;
@ -110,6 +114,23 @@ gtk_paned_class_init (GtkPanedClass *class)
container_class->forall = gtk_paned_forall;
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,
g_param_spec_int ("handle_size",
_("Handle Size"),
@ -151,26 +172,46 @@ gtk_paned_init (GtkPaned *paned)
}
static void
gtk_paned_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
gtk_paned_set_property (GObject *object,
guint prop_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:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_paned_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
gtk_paned_get_property (GObject *object,
guint prop_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:
arg->type = GTK_TYPE_INVALID;
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
@ -482,7 +523,8 @@ gtk_paned_get_position (GtkPaned *paned)
/**
* gtk_paned_set_position:
* @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.
**/
@ -490,9 +532,13 @@ void
gtk_paned_set_position (GtkPaned *paned,
gint position)
{
GObject *object;
g_return_if_fail (paned != NULL);
g_return_if_fail (GTK_IS_PANED (paned));
object = G_OBJECT (paned);
if (position >= 0)
{
/* We don't clamp here - the assumption is that
@ -501,6 +547,7 @@ gtk_paned_set_position (GtkPaned *paned,
* to the new total size. If only the position changes,
* then clamping will occur in gtk_paned_compute_position()
*/
paned->child1_size = position;
paned->position_set = TRUE;
}
@ -509,6 +556,11 @@ gtk_paned_set_position (GtkPaned *paned,
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));
}
@ -518,9 +570,13 @@ gtk_paned_compute_position(GtkPaned *paned,
gint child1_req,
gint child2_req)
{
gint old_position;
g_return_if_fail (paned != NULL);
g_return_if_fail (GTK_IS_PANED (paned));
old_position = paned->child1_size;
paned->min_position = paned->child1_shrink ? 0 : child1_req;
paned->max_position = allocation;
@ -556,5 +612,8 @@ gtk_paned_compute_position(GtkPaned *paned,
paned->min_position,
paned->max_position);
if (paned->child1_size != old_position)
g_object_notify (G_OBJECT (paned), "position");
paned->last_allocation = allocation;
}

View File

@ -339,12 +339,8 @@ static gboolean
gtk_vpaned_button_release (GtkWidget *widget,
GdkEventButton *event)
{
GtkPaned *paned;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
GtkPaned *paned = GTK_PANED (widget);
GObject *object = G_OBJECT (widget);
if (paned->in_drag && (event->button == 1))
{
@ -353,6 +349,10 @@ gtk_vpaned_button_release (GtkWidget *widget,
paned->position_set = TRUE;
gdk_pointer_ungrab (event->time);
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;
}

View File

@ -24,13 +24,19 @@
#include "prop-editor.h"
static void
get_param_specs (GObject *object,
get_param_specs (GType type,
GParamSpec ***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 */
*specs = G_OBJECT_GET_CLASS (object)->property_specs;
*n_specs = G_OBJECT_GET_CLASS (object)->n_property_specs;
*specs = class->property_specs;
*n_specs = class->n_property_specs;
}
typedef struct
@ -93,6 +99,7 @@ typedef struct
{
GObject *obj;
gchar *prop;
gint modified_id;
} ObjectProperty;
static void
@ -115,9 +122,26 @@ connect_controller (GObject *controller,
p->obj = model;
p->prop = g_strdup (prop_name);
g_signal_connect_data (controller, signal, func, p,
(GClosureNotify)free_object_property,
FALSE, FALSE);
p->modified_id = g_signal_connect_data (controller, signal, func, p,
(GClosureNotify)free_object_property,
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
@ -138,7 +162,11 @@ int_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_object_get_property (object, pspec->name, &val);
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);
}
@ -161,7 +189,11 @@ float_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_object_get_property (object, pspec->name, &val);
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);
}
@ -194,7 +226,11 @@ string_changed (GObject *object, GParamSpec *pspec, gpointer data)
text = gtk_entry_get_text (entry);
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);
}
@ -217,7 +253,11 @@ bool_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_object_get_property (object, pspec->name, &val);
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) ?
"TRUE" : "FALSE");
@ -266,7 +306,11 @@ enum_changed (GObject *object, GParamSpec *pspec, gpointer data)
}
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);
@ -312,7 +356,9 @@ unichar_changed (GObject *object, GParamSpec *pspec, gpointer data)
buf[len] = '\0';
block_controller (G_OBJECT (entry));
gtk_entry_set_text (entry, buf);
unblock_controller (G_OBJECT (entry));
}
}
@ -330,7 +376,8 @@ window_destroy (gpointer data)
}
GtkWidget*
create_prop_editor (GObject *object)
create_prop_editor (GObject *object,
GType type)
{
GtkWidget *win;
GtkWidget *vbox;
@ -363,7 +410,7 @@ create_prop_editor (GObject *object)
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), vbox);
gtk_container_add (GTK_CONTAINER (win), sw);
get_param_specs (object, &specs, &n_specs);
get_param_specs (type, &specs, &n_specs);
i = 0;
while (i < n_specs)

View File

@ -23,7 +23,8 @@
G_BEGIN_DECLS
GtkWidget *create_prop_editor (GObject *object);
GtkWidget *create_prop_editor (GObject *object,
GType type);
G_END_DECLS

View File

@ -3530,7 +3530,7 @@ static void
entry_props_clicked (GtkWidget *button,
GObject *entry)
{
GtkWidget *window = create_prop_editor (entry);
GtkWidget *window = create_prop_editor (entry, GTK_TYPE_ENTRY);
gtk_window_set_title (GTK_WINDOW (window), "Entry Properties");
}
@ -3763,7 +3763,7 @@ static gint
spin_button_hex_input_func (GtkSpinButton *spin_button,
gdouble *new_val)
{
gchar *buf;
const gchar *buf;
gchar *err;
gdouble res;
@ -7317,8 +7317,17 @@ toggle_shrink (GtkWidget *widget, GtkWidget *child)
gtk_widget_unref (child);
}
static void
paned_props_clicked (GtkWidget *button,
GObject *paned)
{
GtkWidget *window = create_prop_editor (paned, GTK_TYPE_PANED);
gtk_window_set_title (GTK_WINDOW (window), "Paned Properties");
}
GtkWidget *
create_pane_options (GtkPaned *paned,
create_pane_options (GtkPaned *paned,
const gchar *frame_label,
const gchar *label1,
const gchar *label2)
@ -7326,12 +7335,13 @@ create_pane_options (GtkPaned *paned,
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *button;
GtkWidget *check_button;
frame = gtk_frame_new (frame_label);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
table = gtk_table_new (3, 2, 4);
table = gtk_table_new (4, 2, 4);
gtk_container_add (GTK_CONTAINER (frame), table);
label = gtk_label_new (label1);
@ -7376,6 +7386,13 @@ create_pane_options (GtkPaned *paned,
GTK_SIGNAL_FUNC (toggle_shrink),
paned->child2);
button = gtk_button_new_with_mnemonic ("_Properties");
gtk_table_attach_defaults (GTK_TABLE (table), button,
0, 2, 3, 4);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (paned_props_clicked),
paned);
return frame;
}

View File

@ -150,7 +150,7 @@ col_clicked_cb (GtkTreeViewColumn *col, gpointer data)
{
GtkWindow *win;
win = GTK_WINDOW (create_prop_editor (G_OBJECT (col)));
win = GTK_WINDOW (create_prop_editor (G_OBJECT (col), GTK_TYPE_TREE_VIEW_COLUMN));
gtk_window_set_title (win, gtk_tree_view_column_get_title (col));
}