From daf24a906b9cc661901d85d7ab3f08658aa6f5af Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 8 Feb 2007 12:07:46 +0000 Subject: [PATCH] emit property change notifications. 2007-02-08 Sven Neumann * libgimpwidgets/gimpratioentry.c (gimp_ratio_entry_set_fraction): emit property change notifications. svn path=/trunk/; revision=21869 --- ChangeLog | 5 +++++ libgimpwidgets/gimpratioentry.c | 35 +++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd51cf506c..ab3f6a8abf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-02-08 Sven Neumann + + * libgimpwidgets/gimpratioentry.c (gimp_ratio_entry_set_fraction): + emit property change notifications. + 2007-02-08 Sven Neumann * libgimpwidgets/gimpenumwidgets.c diff --git a/libgimpwidgets/gimpratioentry.c b/libgimpwidgets/gimpratioentry.c index 32d00bcdb0..294f96cf41 100644 --- a/libgimpwidgets/gimpratioentry.c +++ b/libgimpwidgets/gimpratioentry.c @@ -23,18 +23,21 @@ #include "config.h" -#include #include #include #include +#include "libgimpmath/gimpmath.h" + #include "gimpwidgetstypes.h" #include "gimpratioentry.h" + #define EPSILON 0.000001 + enum { RATIO_CHANGED, @@ -73,7 +76,7 @@ static void gimp_ratio_entry_format_text (GimpRatioEntry *entry); static void gimp_ratio_entry_parse_text (GimpRatioEntry *entry, const gchar *text); -static gboolean gimp_ratio_entry_history_select (GtkEntryCompletion *completion, +static gboolean gimp_ratio_entry_history_select (GtkEntryCompletion *completion, GtkTreeModel *model, GtkTreeIter *iter, GimpRatioEntry *entry); @@ -346,13 +349,15 @@ gimp_ratio_entry_set_fraction (GimpRatioEntry *entry, gdouble numerator, gdouble denominator) { - gdouble old_ratio; + GimpAspectType old_aspect; + gdouble old_ratio; g_return_if_fail (GIMP_IS_RATIO_ENTRY (entry)); - old_ratio = entry->numerator / entry->denominator; + old_aspect = gimp_ratio_entry_get_aspect (entry); + old_ratio = gimp_ratio_entry_get_ratio (entry); - entry->numerator = numerator; + entry->numerator = numerator; entry->denominator = denominator; if (entry->denominator < 0) @@ -366,8 +371,26 @@ gimp_ratio_entry_set_fraction (GimpRatioEntry *entry, gimp_ratio_entry_format_text (entry); + g_object_freeze_notify (G_OBJECT (entry)); + + g_object_notify (G_OBJECT (entry), "numerator"); + g_object_notify (G_OBJECT (entry), "denominator"); + if (fabs (old_ratio - entry->numerator / entry->denominator) > EPSILON) - g_signal_emit (entry, entry_signals[RATIO_CHANGED], 0); + { + g_object_notify (G_OBJECT (entry), "ratio"); + + if (old_aspect != gimp_ratio_entry_get_aspect (entry)) + g_object_notify (G_OBJECT (entry), "aspect"); + + g_object_thaw_notify (G_OBJECT (entry)); + + g_signal_emit (entry, entry_signals[RATIO_CHANGED], 0); + } + else + { + g_object_thaw_notify (G_OBJECT (entry)); + } } /**