[gnome-calendar/gbsneto/event-editor: 8/16] edit-dialog: Turn the All Day check a switch



commit 948447d8bfb6f5d50237ede143a0c36c26ea2c51
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Nov 14 12:47:58 2019 -0300

    edit-dialog: Turn the All Day check a switch

 src/gui/gcal-edit-dialog.c  | 25 +++++++++++++------------
 src/gui/gcal-edit-dialog.ui | 10 +++++-----
 2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/gui/gcal-edit-dialog.c b/src/gui/gcal-edit-dialog.c
index 55a14066..bdf1fe6a 100644
--- a/src/gui/gcal-edit-dialog.c
+++ b/src/gui/gcal-edit-dialog.c
@@ -72,7 +72,7 @@ struct _GcalEditDialog
 
   GtkWidget        *start_date_selector;
   GtkWidget        *end_date_selector;
-  GtkWidget        *all_day_check;
+  GtkSwitch        *all_day_switch;
   GtkWidget        *start_time_selector;
   GtkWidget        *end_time_selector;
   GtkWidget        *location_entry;
@@ -238,7 +238,7 @@ find_best_timezones_for_event (GcalEditDialog  *self,
   gboolean all_day;
 
   /* Update all day */
-  all_day = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->all_day_check));
+  all_day = gtk_switch_get_active (self->all_day_switch);
   was_all_day = gcal_event_get_all_day (self->event);
 
   GCAL_TRACE_MSG ("Finding best timezone with all_day=%d, was_all_day=%d, event_is_new=%d",
@@ -305,7 +305,7 @@ return_datetime_for_widgets (GcalEditDialog   *self,
   GDateTime *retval;
   gboolean all_day;
 
-  all_day = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->all_day_check));
+  all_day = gtk_switch_get_active (self->all_day_switch);
   date = gcal_date_selector_get_date (date_selector);
   time = gcal_time_selector_get_time (time_selector);
 
@@ -367,7 +367,7 @@ set_writable (GcalEditDialog *self,
   if (self->writable == writable)
     return;
 
-  all_day = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->all_day_check));
+  all_day = gtk_switch_get_active (self->all_day_switch);
 
   gtk_widget_set_sensitive (self->start_time_selector, !all_day && writable);
   gtk_widget_set_sensitive (self->end_time_selector, !all_day && writable);
@@ -402,7 +402,7 @@ sync_datetimes (GcalEditDialog *self,
   GCAL_ENTRY;
 
   is_start = (widget == self->start_time_selector || widget == self->start_date_selector);
-  is_all_day = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->all_day_check));
+  is_all_day = gtk_switch_get_active (self->all_day_switch);
   start = get_date_start (self);
   end = get_date_end (self);
 
@@ -760,7 +760,7 @@ on_action_button_clicked_cb (GtkWidget *widget,
       gcal_event_set_description (self->event, note_text);
       g_free (note_text);
 
-      all_day = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->all_day_check));
+      all_day = gtk_switch_get_active (self->all_day_switch);
       was_all_day = gcal_event_get_all_day (self->event);
 
       if (!was_all_day && all_day)
@@ -934,10 +934,11 @@ on_repeat_type_changed_cb (GtkComboBox    *combobox,
 }
 
 static void
-on_all_day_check_changed_cb (GtkToggleButton *button,
-                             GcalEditDialog  *self)
+on_all_day_switch_active_changed_cb (GtkSwitch      *all_day_switch,
+                                     GParamSpec     *pspec,
+                                     GcalEditDialog *self)
 {
-  gboolean active = gtk_toggle_button_get_active (button);
+  gboolean active = gtk_switch_get_active (all_day_switch);
 
   gtk_widget_set_sensitive (self->start_time_selector, !active);
   gtk_widget_set_sensitive (self->end_time_selector, !active);
@@ -1296,7 +1297,7 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
   /* Other */
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, alarms_listbox);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, notes_text);
-  gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, all_day_check);
+  gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, all_day_switch);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, titlebar);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, title_label);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, subtitle_label);
@@ -1317,7 +1318,7 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, sync_datetimes);
   gtk_widget_class_bind_template_callback (widget_class, on_action_button_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_add_alarm_button_clicked_cb);
-  gtk_widget_class_bind_template_callback (widget_class, on_all_day_check_changed_cb);
+  gtk_widget_class_bind_template_callback (widget_class, on_all_day_switch_active_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_repeat_duration_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_repeat_type_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_summary_entry_changed_cb);
@@ -1518,7 +1519,7 @@ gcal_edit_dialog_set_event (GcalEditDialog *self,
   g_signal_handlers_unblock_by_func (self->end_time_selector, sync_datetimes, self);
 
   /* all_day  */
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->all_day_check), all_day);
+  gtk_switch_set_active (self->all_day_switch, all_day);
 
   /* recurrence_changed */
   self->recurrence_changed = FALSE;
diff --git a/src/gui/gcal-edit-dialog.ui b/src/gui/gcal-edit-dialog.ui
index feb84644..061aff99 100644
--- a/src/gui/gcal-edit-dialog.ui
+++ b/src/gui/gcal-edit-dialog.ui
@@ -284,16 +284,16 @@
                       <object class="HdyActionRow">
                         <property name="visible">True</property>
                         <property name="title" translatable="yes">All Day</property>
-                        <property name="activatable-widget">all_day_check</property>
+                        <property name="activatable-widget">all_day_switch</property>
 
                         <child type="action">
-                          <object class="GtkCheckButton" id="all_day_check">
+                          <object class="GtkSwitch" id="all_day_switch">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="draw_indicator">True</property>
-                            <property name="label" translatable="yes">All Day</property>
+                            <property name="valign">center</property>
+                            <property name="halign">end</property>
                             <property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" 
bind-flags="default" />
-                            <signal name="toggled" handler="on_all_day_check_changed_cb" 
object="GcalEditDialog" swapped="no"/>
+                            <signal name="notify::active" handler="on_all_day_switch_active_changed_cb" 
object="GcalEditDialog" swapped="no"/>
                           </object>
                         </child>
 


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