[gnome-calendar] edit-dialog: Make the new alarm row have a label



commit 2be799d78d979e47ce43941730a72fe00fffc993
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Dec 6 16:33:43 2019 -0300

    edit-dialog: Make the new alarm row have a label
    
    With the introduction of the new event editor, Calendar
    saw it receive sections of editable properties of the
    events. One of these sections is the "Reminders" section,
    that contains the reminders (also called alarms) of an
    event.
    
    However, this section's row to add a new alarm does not
    match the proposed mockups for it. It currently has a
    combo box that shows the popover with selectable reminder
    times, instead of being a clickable row.
    
    Make it a clickable listbox row, and show the alarms popover
    when clicked.
    
    https://gitlab.gnome.org/GNOME/gnome-calendar/issues/502

 src/gui/gcal-edit-dialog.c  | 12 ++++++++++++
 src/gui/gcal-edit-dialog.ui | 40 +++++++++-------------------------------
 2 files changed, 21 insertions(+), 31 deletions(-)
---
diff --git a/src/gui/gcal-edit-dialog.c b/src/gui/gcal-edit-dialog.c
index 3c5e032d..993f868b 100644
--- a/src/gui/gcal-edit-dialog.c
+++ b/src/gui/gcal-edit-dialog.c
@@ -83,6 +83,7 @@ struct _GcalEditDialog
   GtkWidget        *notes_text;
 
   GtkWidget        *alarms_listbox;
+  GtkPopover       *alarms_popover;
   GtkListBoxRow    *new_alarm_row;
 
   GtkWidget        *repeat_combo;
@@ -1123,6 +1124,15 @@ on_add_alarm_button_clicked_cb (GtkWidget      *button,
   gtk_widget_set_sensitive (button, FALSE);
 }
 
+static void
+on_alarms_listbox_row_activated_cb (GtkListBox     *alarms_listbox,
+                                    GtkListBoxRow  *row,
+                                    GcalEditDialog *self)
+{
+  if (row == self->new_alarm_row)
+    gtk_popover_popup (self->alarms_popover);
+}
+
 
 /*
  * Gobject overrides
@@ -1302,6 +1312,7 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, two_days_button);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, three_days_button);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, one_week_button);
+  gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, alarms_popover);
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, new_alarm_row);
   /* Buttons */
   gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, done_button);
@@ -1339,6 +1350,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_alarms_listbox_row_activated_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);
diff --git a/src/gui/gcal-edit-dialog.ui b/src/gui/gcal-edit-dialog.ui
index 17e32600..a36d8ae6 100644
--- a/src/gui/gcal-edit-dialog.ui
+++ b/src/gui/gcal-edit-dialog.ui
@@ -457,44 +457,21 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="selection_mode">none</property>
+                        <signal name="row-activated" handler="on_alarms_listbox_row_activated_cb" 
object="GcalEditDialog" swapped="no" />
                         <property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" 
bind-flags="default" />
 
                         <child>
-                          <object class="HdyActionRow" id="new_alarm_row">
+                          <object class="GtkListBoxRow" id="new_alarm_row">
                             <property name="visible">True</property>
-                            <property name="title" translatable="yes">Reminder</property>
-                            <property name="activatable-widget">alarms_button</property>
+                            <property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" 
bind-flags="default" />
 
-                            <child type="action">
-                              <object class="GtkMenuButton" id="alarms_button">
+                            <child>
+                              <object class="GtkLabel">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property name="valign">center</property>
-                                <property name="popover">alarms_popover</property>
-                                <property name="sensitive" bind-source="GcalEditDialog" 
bind-property="writable" bind-flags="default" />
-                                <child>
-                                  <object class="GtkBox">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="orientation">horizontal</property>
-                                    <child>
-                                      <object class="GtkLabel">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="hexpand">True</property>
-                                        <property name="xalign">0.0</property>
-                                        <property name="label" translatable="yes">Add reminder…</property>
-                                      </object>
-                                    </child>
-                                    <child>
-                                      <object class="GtkImage">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="icon_name">pan-down-symbolic</property>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
+                                <property name="expand">True</property>
+                                <property name="margin">12</property>
+                                <property name="label" translatable="yes">Add a Reminder…</property>
                               </object>
                             </child>
 
@@ -581,6 +558,7 @@
   <object class="GtkPopoverMenu" id="alarms_popover">
     <property name="can_focus">False</property>
     <property name="width_request">175</property>
+    <property name="relative-to">new_alarm_row</property>
     <child>
       <object class="GtkBox">
         <property name="visible">True</property>


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