2009-02-25 Alberto Garcia <agarcia@igalia.com>
authorAlberto Garcia <agarcia@igalia.com>
Wed, 25 Feb 2009 18:25:58 +0000 (18:25 +0000)
committerAlberto Garcia <agarcia@igalia.com>
Wed, 25 Feb 2009 18:25:58 +0000 (18:25 +0000)
* doc/hildon-sections.txt
* src/hildon-picker-button.h
* src/hildon-picker-button.c (+hildon_picker_button_value_changed)
(_selection_changed, hildon_picker_button_on_dialog_response)
(hildon_picker_button_class_init, hildon_picker_button_set_selector):
New hildon_picker_button_value_changed() method.

* src/Makefile.am
* src/hildon-picker-button-private.h
* src/hildon-picker-button.c (hildon_picker_button_init)
(+hildon_picker_button_disable_value_changed): Add protected
function for disabling the "value-changed" signal.

* src/hildon-date-button.c (hildon_date_button_set_date):
Don't emit "value-changed" for each one of the three columns.

Fixes: NB#103242 ("HildonPickerButton:value-changed" is emitted
before actual change of values)

ChangeLog
doc/hildon-sections.txt
src/Makefile.am
src/hildon-date-button.c
src/hildon-picker-button-private.h [new file with mode: 0644]
src/hildon-picker-button.c
src/hildon-picker-button.h

index e7ac4f7..288b386 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2009-02-25  Alberto Garcia  <agarcia@igalia.com>
+
+       * doc/hildon-sections.txt
+       * src/hildon-picker-button.h
+       * src/hildon-picker-button.c (+hildon_picker_button_value_changed)
+       (_selection_changed, hildon_picker_button_on_dialog_response)
+       (hildon_picker_button_class_init, hildon_picker_button_set_selector):
+       New hildon_picker_button_value_changed() method.
+
+       * src/Makefile.am
+       * src/hildon-picker-button-private.h
+       * src/hildon-picker-button.c (hildon_picker_button_init)
+       (+hildon_picker_button_disable_value_changed): Add protected
+       function for disabling the "value-changed" signal.
+
+       * src/hildon-date-button.c (hildon_date_button_set_date):
+       Don't emit "value-changed" for each one of the three columns.
+
+       Fixes: NB#103242 ("HildonPickerButton:value-changed" is emitted
+       before actual change of values)
+
 2009-02-24  Alejandro G. Castro  <alex@igalia.com>
 
        * src/hildon-pannable-area.c,
index df4f8e0..6428b03 100644 (file)
@@ -1069,6 +1069,7 @@ hildon_picker_button_set_active
 hildon_picker_button_get_active
 hildon_picker_button_get_done_button_text
 hildon_picker_button_set_done_button_text
+hildon_picker_button_value_changed
 <SUBSECTION Standard>
 HILDON_PICKER_BUTTON
 HILDON_IS_PICKER_BUTTON
index 07dd516..10187f0 100644 (file)
@@ -167,6 +167,7 @@ noinst_HEADERS = hildon-banner-private.h            \
                hildon-private.h                        \
                hildon-caption-private.h                \
                hildon-code-dialog-private.h            \
+               hildon-picker-button-private.h          \
                hildon-color-button-private.h           \
                hildon-color-chooser-dialog-private.h   \
                hildon-color-chooser-private.h          \
index dd375bc..752e3cf 100644 (file)
@@ -19,6 +19,7 @@
 #include "hildon-date-button.h"
 #include "hildon-date-selector.h"
 #include "hildon-touch-selector.h"
+#include "hildon-picker-button-private.h"
 
 #define                                         _(String) \
                                                 dgettext("hildon-libs", String)
@@ -197,11 +198,16 @@ hildon_date_button_set_date (HildonDateButton * button,
 
   selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (button));
 
+  hildon_picker_button_disable_value_changed (HILDON_PICKER_BUTTON (button), TRUE);
   hildon_date_selector_select_current_date (HILDON_DATE_SELECTOR (selector),
                                             year, month, day);
+  hildon_picker_button_disable_value_changed (HILDON_PICKER_BUTTON (button), FALSE);
+
   date = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector));
 
   hildon_button_set_value (HILDON_BUTTON (button), date);
 
   g_free (date);
+
+  hildon_picker_button_value_changed (HILDON_PICKER_BUTTON (button));
 }
diff --git a/src/hildon-picker-button-private.h b/src/hildon-picker-button-private.h
new file mode 100644 (file)
index 0000000..6760288
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * This file is a part of hildon
+ *
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser Public License for more details.
+ *
+ */
+
+#ifndef                                         __HILDON_PICKER_BUTTON_PRIVATE__
+#define                                         __HILDON_PICKER_BUTTON_PRIVATE__
+
+#include "hildon-picker-button.h"
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL void
+hildon_picker_button_disable_value_changed      (HildonPickerButton *button,
+                                                 gboolean            disable);
+
+G_END_DECLS
+
+#endif /* __HILDON_PICKER_BUTTON_PRIVATE__ */
index f4835ad..d51017e 100644 (file)
@@ -68,6 +68,7 @@
  */
 
 #include "hildon-picker-button.h"
+#include "hildon-picker-button-private.h"
 #include "hildon-picker-dialog.h"
 
 G_DEFINE_TYPE (HildonPickerButton, hildon_picker_button, HILDON_TYPE_BUTTON)
@@ -82,6 +83,7 @@ struct _HildonPickerButtonPrivate
   GtkWidget *selector;
   GtkWidget *dialog;
   gchar *done_button_text;
+  guint disable_value_changed : 1;
 };
 
 /* Signals */
@@ -178,6 +180,35 @@ hildon_picker_button_finalize (GObject * object)
   G_OBJECT_CLASS (hildon_picker_button_parent_class)->finalize (object);
 }
 
+/**
+ * hildon_picker_button_value_changed:
+ * @button: a #HildonPickerButton
+ *
+ * Emits a "#HildonPickerButton::value-changed" signal to the given
+ * #HildonPickerButton
+ **/
+void
+hildon_picker_button_value_changed              (HildonPickerButton *button)
+{
+  HildonPickerButtonPrivate *priv;
+  g_return_if_fail (HILDON_IS_PICKER_BUTTON (button));
+  priv = GET_PRIVATE (button);
+
+  if (!priv->disable_value_changed)
+    g_signal_emit (button, picker_button_signals[VALUE_CHANGED], 0);
+}
+
+G_GNUC_INTERNAL void
+hildon_picker_button_disable_value_changed      (HildonPickerButton *button,
+                                                 gboolean            disable)
+{
+  HildonPickerButtonPrivate *priv;
+  g_return_if_fail (HILDON_IS_PICKER_BUTTON (button));
+  priv = GET_PRIVATE (button);
+
+  priv->disable_value_changed = disable;
+}
+
 static void
 _selection_changed (HildonPickerButton *button)
 {
@@ -189,7 +220,7 @@ _selection_changed (HildonPickerButton *button)
     if (value) {
       hildon_button_set_value (HILDON_BUTTON (button), value);
       g_free (value);
-      g_signal_emit (button, picker_button_signals[VALUE_CHANGED], 0);
+      hildon_picker_button_value_changed (button);
     }
   }
 }
@@ -211,7 +242,7 @@ hildon_picker_button_on_dialog_response (GtkDialog *dialog,
            (HILDON_TOUCH_SELECTOR (priv->selector));
     hildon_button_set_value (HILDON_BUTTON (button), value);
     g_free (value);
-    g_signal_emit (button, picker_button_signals[VALUE_CHANGED], 0);
+    hildon_picker_button_value_changed (button);
   }
 
   gtk_widget_hide (GTK_WIDGET (dialog));
@@ -293,6 +324,8 @@ hildon_picker_button_class_init (HildonPickerButtonClass * klass)
 
   button_class->clicked = hildon_picker_button_clicked;
 
+  klass->value_changed = NULL;
+
   g_object_class_install_property (object_class,
                                    PROP_SELECTOR,
                                    g_param_spec_object ("touch-selector",
@@ -321,7 +354,7 @@ hildon_picker_button_class_init (HildonPickerButtonClass * klass)
     g_signal_new ("value-changed",
                   G_TYPE_FROM_CLASS (klass),
                   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                  0,
+                  G_STRUCT_OFFSET (HildonPickerButtonClass, value_changed),
                   NULL, NULL,
                   g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
 }
@@ -336,6 +369,7 @@ hildon_picker_button_init (HildonPickerButton * self)
   priv->dialog = NULL;
   priv->selector = NULL;
   priv->done_button_text = NULL;
+  priv->disable_value_changed = FALSE;
 
   hildon_button_set_style (HILDON_BUTTON (self),
                            HILDON_BUTTON_STYLE_PICKER);
@@ -441,8 +475,7 @@ hildon_picker_button_set_selector (HildonPickerButton * button,
   if (value) {
     hildon_button_set_value (HILDON_BUTTON (button), value);
     g_free (value);
-    g_signal_emit (HILDON_PICKER_BUTTON (button),
-                   picker_button_signals[VALUE_CHANGED], 0);
+    hildon_picker_button_value_changed (button);
   }
 }
 
index 9a5c63e..7306cd2 100644 (file)
@@ -56,6 +56,8 @@ struct                                          _HildonPickerButton
 struct                                          _HildonPickerButtonClass
 {
   HildonButtonClass parent_class;
+
+  void (* value_changed) (HildonPickerButton *button);
 };
 
 GType
@@ -86,6 +88,9 @@ void
 hildon_picker_button_set_done_button_text       (HildonPickerButton *button,
                                                  const gchar *done_button_text);
 
+void
+hildon_picker_button_value_changed              (HildonPickerButton *button);
+
 G_END_DECLS
 
 #endif /* __HILDON_PICKER_BUTTON__ */