[gnome-calendar/wip/gbsneto/sidebar: 25/26] window: integrate sidebar



commit 0c50c8b04c3ef9065ef56027f2e6316d85bfd2ab
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jun 8 07:57:25 2017 -0300

    window: integrate sidebar
    
    After introducing the sidebar, it is now time
    to integrate it proper with GcalWindow. This
    commit then adapts window to have a sidebar,
    and assigns F9 as the toggle key - for consistency
    with the rest of the desktop.

 data/ui/menus.ui  |    7 +
 data/ui/window.ui |  427 ++++++++++++++++++++++++++++-------------------------
 src/gcal-utils.h  |    1 +
 src/gcal-window.c |   46 ++++++
 4 files changed, 280 insertions(+), 201 deletions(-)
---
diff --git a/data/ui/menus.ui b/data/ui/menus.ui
index cea2f5d..eafd276 100644
--- a/data/ui/menus.ui
+++ b/data/ui/menus.ui
@@ -10,6 +10,13 @@
     </section>
     <section>
       <item>
+        <attribute name="label" translatable="yes">_Sidebar</attribute>
+        <attribute name="action">win.toggle-sidebar</attribute>
+        <attribute name="accel">F9</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
         <attribute name="label" translatable="yes">_Calendars</attribute>
         <attribute name="action">win.show-calendars</attribute>
       </item>
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 6c06078..cc16619 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -11,281 +11,306 @@
     <signal name="window-state-event" handler="window_state_changed" object="GcalWindow" swapped="no"/>
     <property name="active-date" bind-source="search_view" bind-property="active-date" 
bind-flags="default|sync-create"/>
     <child>
-      <object class="GtkOverlay" id="views_overlay">
+      <object class="GtkBox">
         <property name="visible">True</property>
+        <property name="can_focus">False</property>
         <child>
-          <object class="GtkBox" id="main_box">
+          <object class="GcalSidebar" id="sidebar">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="reveal_child">False</property>
+            <property name="transition_type">slide-left</property>
+            <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
+            <signal name="notify::reveal-child" handler="save_settings" object="GcalWindow" swapped="yes" />
+          </object>
+        </child>
+        <child>
+          <object class="GtkOverlay" id="views_overlay">
             <property name="visible">True</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="orientation">vertical</property>
-            <child>
-              <object class="GtkSearchBar" id="search_bar">
-                <property name="visible">True</property>
-                <property name="hexpand">True</property>
-                <property name="show_close_button">True</property>
-                <property name="search-mode-enabled" bind-source="search_button" bind-property="active" 
bind-flags="bidirectional"/>
-                <signal name="notify::search-mode-enabled" handler="search_toggled" object="GcalWindow" 
swapped="no"/>
-                <child>
-                  <object class="GtkSearchEntry" id="search_entry">
-                    <property name="width_request">500</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="halign">center</property>
-                    <property name="hexpand">True</property>
-                    <property name="primary_icon_name">edit-find-symbolic</property>
-                    <property name="primary_icon_activatable">False</property>
-                    <property name="primary_icon_sensitive">False</property>
-                    <signal name="search-changed" handler="search_changed" object="GcalWindow" swapped="no"/>
-                  </object>
-                </child>
-              </object>
-            </child>
             <child>
-              <object class="GtkStack" id="views_stack">
+              <object class="GtkBox" id="main_box">
                 <property name="visible">True</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="transition_duration">250</property>
-                <property name="transition_type">crossfade</property>
-                <signal name="notify::visible-child" handler="view_changed" object="GcalWindow" 
swapped="no"/>
-                <style>
-                  <class name="view"/>
-                </style>
+                <property name="orientation">vertical</property>
                 <child>
-                  <object class="GcalWeekView" id="week_view">
+                  <object class="GtkSearchBar" id="search_bar">
                     <property name="visible">True</property>
-                    <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
-                    <signal name="create-event" handler="show_new_event_widget" object="GcalWindow" 
swapped="no"/>
-                    <signal name="event-activated" handler="event_activated" object="GcalWindow" 
swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="name">week</property>
-                    <property name="title" translatable="yes">Week</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GcalMonthView" id="month_view">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
-                    <signal name="create-event" handler="show_new_event_widget" object="GcalWindow" 
swapped="no"/>
-                    <signal name="create-event-detailed" handler="create_event_detailed_cb" 
object="GcalWindow" swapped="no"/>
-                    <signal name="event-activated" handler="event_activated" object="GcalWindow" 
swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                    <property name="name">month</property>
-                    <property name="title" translatable="yes">Month</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GcalYearView" id="year_view">
-                    <property name="visible">True</property>
-                    <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
-                    <signal name="create-event" handler="show_new_event_widget" object="GcalWindow" 
swapped="no"/>
-                    <signal name="create-event-detailed" handler="create_event_detailed_cb" 
object="GcalWindow" swapped="no"/>
-                    <signal name="event-activated" handler="event_activated" object="GcalWindow" 
swapped="no"/>
+                    <property name="hexpand">True</property>
+                    <property name="show_close_button">True</property>
+                    <property name="search-mode-enabled" bind-source="search_button" bind-property="active" 
bind-flags="bidirectional"/>
+                    <signal name="notify::search-mode-enabled" handler="search_toggled" object="GcalWindow" 
swapped="no"/>
+                    <child>
+                      <object class="GtkSearchEntry" id="search_entry">
+                        <property name="width_request">500</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="halign">center</property>
+                        <property name="hexpand">True</property>
+                        <property name="primary_icon_name">edit-find-symbolic</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">False</property>
+                        <signal name="search-changed" handler="search_changed" object="GcalWindow" 
swapped="no"/>
+                      </object>
+                    </child>
                   </object>
-                  <packing>
-                    <property name="position">2</property>
-                    <property name="name">year</property>
-                    <property name="title" translatable="yes">Year</property>
-                  </packing>
                 </child>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child type="overlay">
-          <object class="GtkRevealer" id="notification">
-            <property name="visible">True</property>
-            <property name="halign">center</property>
-            <property name="valign">start</property>
-            <property name="transition_duration">100</property>
-            <signal name="notify::child-revealed" handler="remove_event" object="GcalWindow" swapped="no"/>
-            <child>
-              <object class="GtkFrame">
-                <property name="visible">True</property>
                 <child>
-                  <object class="GtkGrid">
+                  <object class="GtkStack" id="views_stack">
                     <property name="visible">True</property>
-                    <property name="margin_start">12</property>
-                    <property name="margin_end">12</property>
-                    <property name="margin_top">2</property>
-                    <property name="margin_bottom">2</property>
-                    <property name="column_spacing">12</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="transition_duration">250</property>
+                    <property name="transition_type">crossfade</property>
+                    <signal name="notify::visible-child" handler="view_changed" object="GcalWindow" 
swapped="no"/>
+                    <style>
+                      <class name="view"/>
+                    </style>
                     <child>
-                      <object class="GtkLabel" id="notification_label">
+                      <object class="GcalWeekView" id="week_view">
                         <property name="visible">True</property>
-                        <property name="use_markup">True</property>
+                        <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
+                        <signal name="create-event" handler="show_new_event_widget" object="GcalWindow" 
swapped="no"/>
+                        <signal name="event-activated" handler="event_activated" object="GcalWindow" 
swapped="no"/>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
+                        <property name="name">week</property>
+                        <property name="title" translatable="yes">Week</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="notification_action_button">
-                        <property name="label" translatable="no">button</property>
+                      <object class="GcalMonthView" id="month_view">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="no_show_all">True</property>
-                        <signal name="clicked" handler="undo_remove_action" object="GcalWindow" 
swapped="no"/>
-                        <style>
-                          <class name="text-button"/>
-                        </style>
+                        <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
+                        <signal name="create-event" handler="show_new_event_widget" object="GcalWindow" 
swapped="no"/>
+                        <signal name="create-event-detailed" handler="create_event_detailed_cb" 
object="GcalWindow" swapped="no"/>
+                        <signal name="event-activated" handler="event_activated" object="GcalWindow" 
swapped="no"/>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">0</property>
+                        <property name="position">1</property>
+                        <property name="name">month</property>
+                        <property name="title" translatable="yes">Month</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkButton" id="notification_close_button">
+                      <object class="GcalYearView" id="year_view">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="relief">none</property>
-                        <property name="focus_on_click">False</property>
-                        <signal name="clicked" handler="hide_notification" object="GcalWindow" 
swapped="yes"/>
+                        <property name="active-date" bind-source="GcalWindow" bind-property="active-date" 
bind-flags="bidirectional"/>
+                        <signal name="create-event" handler="show_new_event_widget" object="GcalWindow" 
swapped="no"/>
+                        <signal name="create-event-detailed" handler="create_event_detailed_cb" 
object="GcalWindow" swapped="no"/>
+                        <signal name="event-activated" handler="event_activated" object="GcalWindow" 
swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="position">2</property>
+                        <property name="name">year</property>
+                        <property name="title" translatable="yes">Year</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="overlay">
+              <object class="GtkRevealer" id="notification">
+                <property name="visible">True</property>
+                <property name="halign">center</property>
+                <property name="valign">start</property>
+                <property name="transition_duration">100</property>
+                <signal name="notify::child-revealed" handler="remove_event" object="GcalWindow" 
swapped="no"/>
+                <child>
+                  <object class="GtkFrame">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkGrid">
+                        <property name="visible">True</property>
+                        <property name="margin_start">12</property>
+                        <property name="margin_end">12</property>
+                        <property name="margin_top">2</property>
+                        <property name="margin_bottom">2</property>
+                        <property name="column_spacing">12</property>
+                        <child>
+                          <object class="GtkLabel" id="notification_label">
+                            <property name="visible">True</property>
+                            <property name="use_markup">True</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="notification_action_button">
+                            <property name="label" translatable="no">button</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="no_show_all">True</property>
+                            <signal name="clicked" handler="undo_remove_action" object="GcalWindow" 
swapped="no"/>
+                            <style>
+                              <class name="text-button"/>
+                            </style>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">0</property>
+                          </packing>
+                        </child>
                         <child>
-                          <object class="GtkImage">
+                          <object class="GtkButton" id="notification_close_button">
                             <property name="visible">True</property>
-                            <property name="icon_name">window-close-symbolic</property>
-                            <property name="icon_size">2</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="relief">none</property>
+                            <property name="focus_on_click">False</property>
+                            <signal name="clicked" handler="hide_notification" object="GcalWindow" 
swapped="yes"/>
+                            <child>
+                              <object class="GtkImage">
+                                <property name="visible">True</property>
+                                <property name="icon_name">window-close-symbolic</property>
+                                <property name="icon_size">2</property>
+                              </object>
+                            </child>
+                            <style>
+                              <class name="image-button"/>
+                            </style>
                           </object>
+                          <packing>
+                            <property name="left_attach">2</property>
+                            <property name="top_attach">0</property>
+                          </packing>
                         </child>
-                        <style>
-                          <class name="image-button"/>
-                        </style>
                       </object>
-                      <packing>
-                        <property name="left_attach">2</property>
-                        <property name="top_attach">0</property>
-                      </packing>
                     </child>
+                    <style>
+                      <class name="app-notification"/>
+                    </style>
                   </object>
                 </child>
-                <style>
-                  <class name="app-notification"/>
-                </style>
               </object>
             </child>
           </object>
         </child>
+
       </object>
     </child>
     <child type="titlebar">
-      <object class="GtkHeaderBar" id="header_bar">
+      <object class="GtkBox" id="titlebar_box">
         <property name="visible">True</property>
-        <property name="show_close_button">True</property>
-        <property name="title" translatable="yes">Calendar</property>
-        <child>
-          <object class="GtkButton" id="today_button">
-            <property name="label" translatable="yes">Today</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="action_name">win.today</property>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
         <child>
-          <object class="GtkBox" id="button_box">
+          <object class="GtkHeaderBar" id="header_bar">
             <property name="visible">True</property>
+            <property name="show_close_button">True</property>
+            <property name="hexpand">True</property>
+            <property name="title" translatable="yes">Calendar</property>
             <child>
-              <object class="GtkButton" id="back_button">
+              <object class="GtkButton" id="today_button">
+                <property name="label" translatable="yes">Today</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="action_name">win.previous</property>
+                <property name="action_name">win.today</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="button_box">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkButton" id="back_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="action_name">win.previous</property>
+                    <child>
+                      <object class="GtkImage" id="go_back_image">
+                        <property name="visible">True</property>
+                        <property name="icon_name">go-previous-symbolic</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
                 <child>
-                  <object class="GtkImage" id="go_back_image">
+                  <object class="GtkButton" id="forward_button">
                     <property name="visible">True</property>
-                    <property name="icon_name">go-previous-symbolic</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="action_name">win.next</property>
+                    <child>
+                      <object class="GtkImage" id="go_next_image">
+                        <property name="visible">True</property>
+                        <property name="icon_name">go-next-symbolic</property>
+                      </object>
+                    </child>
                   </object>
                 </child>
+                <style>
+                  <class name="linked"/>
+                </style>
+              </object>
+            </child>
+            <child type="title">
+              <object class="GtkStackSwitcher" id="views_switcher">
+                <property name="visible">True</property>
+                <property name="stack">views_stack</property>
               </object>
             </child>
             <child>
-              <object class="GtkButton" id="forward_button">
+              <object class="GtkMenuButton" id="menu_button">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="action_name">win.next</property>
                 <child>
-                  <object class="GtkImage" id="go_next_image">
+                  <object class="GtkImage" id="menu_image">
                     <property name="visible">True</property>
-                    <property name="icon_name">go-next-symbolic</property>
+                    <property name="icon_name">open-menu-symbolic</property>
                   </object>
                 </child>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+              </packing>
             </child>
-            <style>
-              <class name="linked"/>
-            </style>
-          </object>
-        </child>
-        <child type="title">
-          <object class="GtkStackSwitcher" id="views_switcher">
-            <property name="visible">True</property>
-            <property name="stack">views_stack</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkMenuButton" id="menu_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <child>
-              <object class="GtkImage" id="menu_image">
-                <property name="visible">True</property>
-                <property name="icon_name">open-menu-symbolic</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="pack_type">end</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkMenuButton" id="calendars_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="popover">calendar_popover</property>
-            <property name="tooltip_text" translatable="yes">Manage your calendars</property>
             <child>
-              <object class="GtkImage" id="calendars_button_image">
+              <object class="GtkMenuButton" id="calendars_button">
                 <property name="visible">True</property>
-                <property name="icon_name">x-office-calendar-symbolic</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="popover">calendar_popover</property>
+                <property name="tooltip_text" translatable="yes">Manage your calendars</property>
+                <child>
+                  <object class="GtkImage" id="calendars_button_image">
+                    <property name="visible">True</property>
+                    <property name="icon_name">x-office-calendar-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+              </packing>
             </child>
-          </object>
-          <packing>
-            <property name="pack_type">end</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkToggleButton" id="search_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="tooltip_text" translatable="yes" context="tooltip">Search for events</property>
             <child>
-              <object class="GtkImage" id="search_button_image">
-                <property name="visible">True</property>
-                <property name="icon_name">edit-find-symbolic</property>
+              <object class="GtkToggleButton" id="search_button">
+                <property name="visible" bind-source="sidebar" bind-property="reveal-child" 
bind-flags="default|invert-boolean" />
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes" context="tooltip">Search for 
events</property>
+                <child>
+                  <object class="GtkImage" id="search_button_image">
+                    <property name="visible">True</property>
+                    <property name="icon_name">edit-find-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+              </packing>
             </child>
           </object>
-          <packing>
-            <property name="pack_type">end</property>
-          </packing>
         </child>
       </object>
     </child>
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
index 96e9156..3b925d2 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -50,6 +50,7 @@ typedef enum
   GCAL_WINDOW_VIEW_WEEK,
   GCAL_WINDOW_VIEW_MONTH,
   GCAL_WINDOW_VIEW_YEAR,
+  GCAL_WINDOW_VIEW_SIDEBAR,
   GCAL_WINDOW_VIEW_LIST,
   GCAL_WINDOW_VIEW_SEARCH,
 } GcalWindowViewType;
diff --git a/src/gcal-window.c b/src/gcal-window.c
index adf8594..dfeac7c 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -28,6 +28,7 @@
 #include "gcal-month-view.h"
 #include "gcal-quick-add-popover.h"
 #include "gcal-search-view.h"
+#include "gcal-sidebar.h"
 #include "gcal-source-dialog.h"
 #include "gcal-view.h"
 #include "gcal-week-view.h"
@@ -117,6 +118,7 @@ struct _GcalWindow
   GtkWidget           *notification_label;
   GtkWidget           *notification_action_button;
   GtkWidget           *notification_close_button;
+  GtkWidget           *sidebar;
 
   /* header_bar widets */
   GtkWidget           *menu_button;
@@ -127,6 +129,7 @@ struct _GcalWindow
   GtkWidget           *today_button;
   GtkWidget           *forward_button;
   GtkWidget           *views_switcher;
+  GtkWidget           *titlebar_box;
 
   /* new event popover widgets */
   GtkWidget           *quick_add_popover;
@@ -192,6 +195,10 @@ static void           on_show_calendars_action_activated (GSimpleAction       *a
                                                           GVariant            *param,
                                                           gpointer             user_data);
 
+static void           on_toggle_sidebar_action_changed   (GSimpleAction       *action,
+                                                          GVariant            *param,
+                                                          gpointer             user_data);
+
 static void           on_date_action_activated           (GSimpleAction       *action,
                                                           GVariant            *param,
                                                           gpointer             user_data);
@@ -208,6 +215,7 @@ static const GActionEntry actions[] = {
   {"today",    on_date_action_activated },
   {"change-view", on_view_action_activated, "i" },
   {"show-calendars", on_show_calendars_action_activated },
+  {"toggle-sidebar", NULL, NULL, "true", on_toggle_sidebar_action_changed },
 };
 
 /*
@@ -301,6 +309,7 @@ update_active_date (GcalWindow   *window,
   gcal_view_set_date (GCAL_VIEW (window->views[GCAL_WINDOW_VIEW_WEEK]), new_date);
   gcal_view_set_date (GCAL_VIEW (window->views[GCAL_WINDOW_VIEW_MONTH]), new_date);
   gcal_view_set_date (GCAL_VIEW (window->views[GCAL_WINDOW_VIEW_YEAR]), new_date);
+  gcal_view_set_date (GCAL_VIEW (window->views[GCAL_WINDOW_VIEW_SIDEBAR]), new_date);
 
   /* year_view */
   if (previous_date->year != new_date->year)
@@ -421,6 +430,7 @@ date_updated (GtkButton  *button,
   GCAL_EXIT;
 }
 
+/* GAction implementations */
 
 static void
 on_show_calendars_action_activated (GSimpleAction *action,
@@ -437,6 +447,22 @@ on_show_calendars_action_activated (GSimpleAction *action,
 }
 
 static void
+on_toggle_sidebar_action_changed (GSimpleAction *action,
+                                  GVariant      *param,
+                                  gpointer       user_data)
+{
+  GcalWindow *self;
+  gboolean reveal;
+
+  self = GCAL_WINDOW (user_data);
+  reveal = gtk_revealer_get_reveal_child (GTK_REVEALER (self->sidebar));
+
+  gtk_revealer_set_reveal_child (GTK_REVEALER (self->sidebar), !reveal);
+
+  g_simple_action_set_state (action, g_variant_new_boolean (!reveal));
+}
+
+static void
 on_date_action_activated (GSimpleAction *action,
                           GVariant      *param,
                           gpointer       user_data)
@@ -1381,6 +1407,9 @@ gcal_window_set_property (GObject      *object,
           gcal_source_dialog_set_manager (GCAL_SOURCE_DIALOG (self->source_dialog), self->manager);
           gcal_search_view_connect (GCAL_SEARCH_VIEW (self->search_view), self->manager);
 
+          /* TODO: fix GcalWindow and bind all those manager properties */
+          g_object_set (self->sidebar, "manager", self->manager, NULL);
+
           g_object_notify (object, "manager");
         }
       return;
@@ -1485,6 +1514,9 @@ gcal_window_class_init(GcalWindowClass *klass)
   widget_class = GTK_WIDGET_CLASS (klass);
   widget_class->configure_event = gcal_window_configure_event;
   widget_class->window_state_event = gcal_window_state_event;
+
+  g_type_ensure (GCAL_TYPE_SIDEBAR);
+
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/window.ui");
 
   g_object_class_install_property (
@@ -1537,6 +1569,7 @@ gcal_window_class_init(GcalWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, source_dialog);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, search_entry);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, back_button);
+  gtk_widget_class_bind_template_child (widget_class, GcalWindow, titlebar_box);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, today_button);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, forward_button);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, views_overlay);
@@ -1547,6 +1580,7 @@ gcal_window_class_init(GcalWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, views_switcher);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, quick_add_popover);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, search_view);
+  gtk_widget_class_bind_template_child (widget_class, GcalWindow, sidebar);
 
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, notification);
   gtk_widget_class_bind_template_child (widget_class, GcalWindow, notification_label);
@@ -1626,6 +1660,7 @@ gcal_window_init (GcalWindow *self)
   self->views[GCAL_WINDOW_VIEW_WEEK] = self->week_view;
   self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
   self->views[GCAL_WINDOW_VIEW_YEAR] = self->year_view;
+  self->views[GCAL_WINDOW_VIEW_SIDEBAR] = self->sidebar;
 
   gcal_edit_dialog_set_time_format (GCAL_EDIT_DIALOG (self->edit_dialog), use_24h_format);
 
@@ -1653,6 +1688,15 @@ gcal_window_init (GcalWindow *self)
   self->active_date = g_new0 (icaltimetype, 1);
   self->rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
 
+  /* Add the sidebar header */
+  gtk_container_add (GTK_CONTAINER (self->titlebar_box),
+                     gcal_sidebar_get_header_widget (GCAL_SIDEBAR (self->sidebar)));
+
+  gtk_container_child_set (GTK_CONTAINER (self->titlebar_box),
+                           gcal_sidebar_get_header_widget (GCAL_SIDEBAR (self->sidebar)),
+                           "position", 0,
+                           NULL);
+
   /* setup accels */
   app = g_application_get_default ();
 
@@ -1665,6 +1709,8 @@ gcal_window_init (GcalWindow *self)
   gcal_window_add_accelerator (app, "win.change-view(1)",  "<Ctrl>1")
   gcal_window_add_accelerator (app, "win.change-view(2)",  "<Ctrl>2");
   gcal_window_add_accelerator (app, "win.change-view(3)",  "<Ctrl>3");
+
+  gcal_window_add_accelerator (app, "win.show-sidebar", "F9");
 }
 
 /* Public API */


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