[maemo-commits] [maemo-commits] r16891 - in projects/haf/trunk/gtk+: . gtk
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Dec 8 18:19:54 EET 2008
- Previous message: [maemo-commits] r16890 - projects/haf/tags/epeg
- Next message: [maemo-commits] r16892 - in projects/haf/trunk/hildon-thumbnail/daemon: . plugins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kalikiana Date: 2008-12-08 18:19:51 +0200 (Mon, 08 Dec 2008) New Revision: 16891 Modified: projects/haf/trunk/gtk+/ChangeLog projects/haf/trunk/gtk+/gtk/gtk.symbols projects/haf/trunk/gtk+/gtk/gtkadjustment.c projects/haf/trunk/gtk+/gtk/gtkadjustment.h Log: 2008-12-08 Christian Dywan <christian at imendio.com> Merged from 2.14, in the context of NB#93744: * gtk/gtk.symbols: * gtk/gtkadjustment.c (gtk_adjustment_class_init), (gtk_adjustment_dispatch_properties_changed), (gtk_adjustment_configure): * gtk/gtkadjustment.h: Add gtk_adjustment_configure to efficiently modify adjustments without a dozen notifications. Modified: projects/haf/trunk/gtk+/ChangeLog =================================================================== --- projects/haf/trunk/gtk+/ChangeLog 2008-12-08 15:33:36 UTC (rev 16890) +++ projects/haf/trunk/gtk+/ChangeLog 2008-12-08 16:19:51 UTC (rev 16891) @@ -1,3 +1,14 @@ +2008-12-08 Christian Dywan <christian at imendio.com> + + Merged from 2.14, in the context of NB#93744: + + * gtk/gtk.symbols: + * gtk/gtkadjustment.c (gtk_adjustment_class_init), + (gtk_adjustment_dispatch_properties_changed), + (gtk_adjustment_configure): + * gtk/gtkadjustment.h: Add gtk_adjustment_configure to efficiently + modify adjustments without a dozen notifications. + 2008-12-05 14:38:56 Tim Janik <timj at imendio.com> * gtk/gtkwidget.c, gtk/gtkwidget.h, gtk/gtkenums.h: Modified: projects/haf/trunk/gtk+/gtk/gtk.symbols =================================================================== --- projects/haf/trunk/gtk+/gtk/gtk.symbols 2008-12-08 15:33:36 UTC (rev 16890) +++ projects/haf/trunk/gtk+/gtk/gtk.symbols 2008-12-08 16:19:51 UTC (rev 16891) @@ -196,6 +196,7 @@ #if IN_FILE(__GTK_ADJUSTMENT_C__) gtk_adjustment_changed gtk_adjustment_clamp_page +gtk_adjustment_configure gtk_adjustment_get_type G_GNUC_CONST gtk_adjustment_get_value gtk_adjustment_new Modified: projects/haf/trunk/gtk+/gtk/gtkadjustment.c =================================================================== --- projects/haf/trunk/gtk+/gtk/gtkadjustment.c 2008-12-08 15:33:36 UTC (rev 16890) +++ projects/haf/trunk/gtk+/gtk/gtkadjustment.c 2008-12-08 16:19:51 UTC (rev 16891) @@ -57,9 +57,14 @@ guint prop_id, const GValue *value, GParamSpec *pspec); +static void gtk_adjustment_dispatch_properties_changed (GObject *object, + guint n_pspecs, + GParamSpec **pspecs); static guint adjustment_signals[LAST_SIGNAL] = { 0 }; +static guint64 adjustment_changed_stamp = 0; /* protected by global gdk lock */ + G_DEFINE_TYPE (GtkAdjustment, gtk_adjustment, GTK_TYPE_OBJECT) static void @@ -69,6 +74,7 @@ gobject_class->set_property = gtk_adjustment_set_property; gobject_class->get_property = gtk_adjustment_get_property; + gobject_class->dispatch_properties_changed = gtk_adjustment_dispatch_properties_changed; class->changed = NULL; class->value_changed = NULL; @@ -296,6 +302,37 @@ } } +static void +gtk_adjustment_dispatch_properties_changed (GObject *object, + guint n_pspecs, + GParamSpec **pspecs) +{ + gboolean changed = FALSE; + gint i; + + G_OBJECT_CLASS (gtk_adjustment_parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs); + + for (i = 0; i < n_pspecs; i++) + switch (pspecs[i]->param_id) + { + case PROP_LOWER: + case PROP_UPPER: + case PROP_STEP_INCREMENT: + case PROP_PAGE_INCREMENT: + case PROP_PAGE_SIZE: + changed = TRUE; + break; + default: + break; + } + + if (changed) + { + adjustment_changed_stamp++; + gtk_adjustment_changed (GTK_ADJUSTMENT (object)); + } +} + GtkObject* gtk_adjustment_new (gdouble value, gdouble lower, @@ -347,7 +384,73 @@ } } +/** + * gtk_adjustment_configure: + * @adjustment: a #GtkAdjustment + * @value: the new value + * @lower: the new minimum value + * @upper: the new maximum value + * @step_increment: the new step increment + * @page_increment: the new page increment + * @page_size: the new page size + * + * Sets all properties of the adjustment at once. + * + * Use this function to avoid multiple emissions of the "changed" + * signal. See gtk_adjustment_set_lower() for an alternative way + * of compressing multiple emissions of "changed" into one. + * + * Since: 2.14 + **/ void +gtk_adjustment_configure (GtkAdjustment *adjustment, + gdouble value, + gdouble lower, + gdouble upper, + gdouble step_increment, + gdouble page_increment, + gdouble page_size) +{ + gboolean value_changed = FALSE; + guint64 old_stamp = adjustment_changed_stamp; + + g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); + + g_object_freeze_notify (G_OBJECT (adjustment)); + + g_object_set (adjustment, + "lower", lower, + "upper", upper, + "step-increment", step_increment, + "page-increment", page_increment, + "page-size", page_size, + NULL); + + /* don't use CLAMP() so we don't end up below lower if upper - page_size + * is smaller than lower + */ + value = MIN (value, upper - page_size); + value = MAX (value, lower); + + if (value != adjustment->value) + { + /* set value manually to make sure "changed" is emitted with the + * new value in place and is emitted before "value-changed" + */ + adjustment->value = value; + value_changed = TRUE; + } + + g_object_thaw_notify (G_OBJECT (adjustment)); + + if (old_stamp == adjustment_changed_stamp) + gtk_adjustment_changed (adjustment); /* force emission before ::value-changed */ + + if (value_changed) + gtk_adjustment_value_changed (adjustment); +} + +void gtk_adjustment_changed (GtkAdjustment *adjustment) { g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); Modified: projects/haf/trunk/gtk+/gtk/gtkadjustment.h =================================================================== --- projects/haf/trunk/gtk+/gtk/gtkadjustment.h 2008-12-08 15:33:36 UTC (rev 16890) +++ projects/haf/trunk/gtk+/gtk/gtkadjustment.h 2008-12-08 16:19:51 UTC (rev 16891) @@ -86,6 +86,13 @@ gdouble gtk_adjustment_get_value (GtkAdjustment *adjustment); void gtk_adjustment_set_value (GtkAdjustment *adjustment, gdouble value); +void gtk_adjustment_configure (GtkAdjustment *adjustment, + gdouble value, + gdouble lower, + gdouble upper, + gdouble step_increment, + gdouble page_increment, + gdouble page_size); G_END_DECLS
- Previous message: [maemo-commits] r16890 - projects/haf/tags/epeg
- Next message: [maemo-commits] r16892 - in projects/haf/trunk/hildon-thumbnail/daemon: . plugins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]