[gnome-calendar/wip/gbsneto/gdatetime: 5/5] date-selector: deprecate ::modified signal



commit b2788006deb3ab794e3da68d5200e8742805dc9b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Dec 31 14:24:24 2015 -0200

    date-selector: deprecate ::modified signal
    
    Since we have a property, we don't need to send
    a custom signal. Instead, use notify::date to track
    date changes.

 data/ui/edit-dialog.ui   |    4 ++--
 src/gcal-date-selector.c |   19 ++-----------------
 src/gcal-edit-dialog.c   |   27 ++++++++++++---------------
 3 files changed, 16 insertions(+), 34 deletions(-)
---
diff --git a/data/ui/edit-dialog.ui b/data/ui/edit-dialog.ui
index d281189..b5f55d2 100644
--- a/data/ui/edit-dialog.ui
+++ b/data/ui/edit-dialog.ui
@@ -229,7 +229,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" 
bind-flags="default" />
-                    <signal name="modified" handler="update_date" object="GcalEditDialog" swapped="no"/>
+                    <signal name="notify::date" handler="update_date" object="GcalEditDialog" swapped="no"/>
                   </object>
                   <packing>
                     <property name="position">1</property>
@@ -265,7 +265,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" 
bind-flags="default" />
-                    <signal name="modified" handler="update_date" object="GcalEditDialog" swapped="no"/>
+                    <signal name="notify::date" handler="update_date" object="GcalEditDialog" swapped="no"/>
                   </object>
                   <packing>
                     <property name="position">1</property>
diff --git a/src/gcal-date-selector.c b/src/gcal-date-selector.c
index d25fb0a..75f2c2b 100644
--- a/src/gcal-date-selector.c
+++ b/src/gcal-date-selector.c
@@ -57,19 +57,11 @@ struct _GcalDateSelector
 
 enum
 {
-  MODIFIED,
-  NUM_SIGNALS
-};
-
-enum
-{
   PROP_0,
   PROP_DATE,
   NUM_PROPS
 };
 
-static guint signals[NUM_SIGNALS] = { 0, };
-
 static void     calendar_day_selected                             (GtkCalendar          *calendar,
                                                                    gpointer              user_data);
 
@@ -271,13 +263,6 @@ gcal_date_selector_class_init (GcalDateSelectorClass *klass)
                                                        G_TYPE_DATE,
                                                        G_PARAM_READWRITE));
 
-  signals[MODIFIED] = g_signal_new ("modified",
-                                    GCAL_TYPE_DATE_SELECTOR,
-                                    G_SIGNAL_RUN_LAST,
-                                    0,
-                                    NULL, NULL, NULL,
-                                    G_TYPE_NONE, 0);
-
   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 
"/org/gnome/calendar/date-selector.ui");
 
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GcalDateSelector, date_label);
@@ -480,8 +465,8 @@ gcal_date_selector_set_date (GcalDateSelector *selector,
 
   gtk_entry_set_text (GTK_ENTRY (selector->entries[YEAR]), label);
 
-  /* emit the MODIFIED signal */
-  g_signal_emit (selector, signals[MODIFIED], 0);
+  /* Notify about the changed property */
+  g_object_notify (G_OBJECT (selector), "date");
 
   g_free (label);
   g_date_time_unref (dt);
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index 54f47a6..fbf6c4c 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -78,9 +78,6 @@ static void        on_calendar_selected                   (GtkWidget         *me
                                                            GVariant          *value,
                                                            gpointer           user_data);
 
-static void        update_date                            (GtkEntry          *entry,
-                                                           gpointer           user_data);
-
 static void        update_location                        (GtkEntry          *entry,
                                                            GParamSpec        *pspec,
                                                            gpointer           user_data);
@@ -220,28 +217,28 @@ on_calendar_selected (GtkWidget *menu_item,
 }
 
 static void
-update_date (GtkEntry   *entry,
-             gpointer    user_data)
+update_date (GcalDateSelector *selector,
+             GParamSpec       *pspec,
+             GcalEditDialog   *dialog)
 {
   ECalComponentDateTime dtstart;
   ECalComponentDateTime dtend;
-  GcalEditDialog *dialog;
   icaltimetype *start_date;
   icaltimetype *end_date;
 
-  dialog = GCAL_EDIT_DIALOG (user_data);
-
   if (dialog->setting_event)
     return;
 
-  start_date = gcal_edit_dialog_get_start_date (GCAL_EDIT_DIALOG (user_data));
-  end_date = gcal_edit_dialog_get_end_date (GCAL_EDIT_DIALOG (user_data));
+  g_message ("updating date");
+
+  start_date = gcal_edit_dialog_get_start_date (dialog);
+  end_date = gcal_edit_dialog_get_end_date (dialog);
 
   /* check if the start & end dates are sane */
   if (icaltime_compare (*start_date, *end_date) != -1)
     {
       /* change the non-editing entry */
-      if (GTK_WIDGET (entry) == dialog->start_date_selector)
+      if (GTK_WIDGET (selector) == dialog->start_date_selector)
         {
           end_date->day = start_date->day;
           end_date->month = start_date->month;
@@ -269,10 +266,10 @@ update_date (GtkEntry   *entry,
       /* update the entries with the new sane values */
       g_signal_handlers_block_by_func (dialog->start_date_selector,
                                        update_date,
-                                       user_data);
+                                       dialog);
       g_signal_handlers_block_by_func (dialog->end_date_selector,
                                        update_date,
-                                       user_data);
+                                       dialog);
 
       gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->start_date_selector),
                                    start_date->day,
@@ -285,10 +282,10 @@ update_date (GtkEntry   *entry,
 
       g_signal_handlers_unblock_by_func (dialog->start_date_selector,
                                          update_date,
-                                         user_data);
+                                         dialog);
       g_signal_handlers_unblock_by_func (dialog->end_date_selector,
                                          update_date,
-                                         user_data);
+                                         dialog);
     }
 
   /* update component */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]