[california/wip/725763-manager] Basic infrastructure in place



commit 38f5b1b89378547233c7395d717941f4fe711d5d
Author: Jim Nelson <jim yorba org>
Date:   Tue Mar 11 19:50:33 2014 -0700

    Basic infrastructure in place

 src/Makefile.am                             |    9 ++++
 src/application/california-application.vala |    9 ++++
 src/backing/backing-manager.vala            |    2 +-
 src/california-resources.xml                |    9 ++++
 src/manager/manager-calendar-list-item.vala |   28 +++++++++++++
 src/manager/manager-calendar-list.vala      |   58 +++++++++++++++++++++++++++
 src/manager/manager-controller.vala         |   20 +++++++++
 src/manager/manager-dialog.vala             |   27 ++++++++++++
 src/manager/manager.vala                    |   25 +++++++++++
 src/rc/app-menu.interface                   |    7 +++
 src/rc/calendar-manager-dialog.ui           |   47 +++++++++++++++++++++
 src/rc/calendar-manager-list-item.ui        |   51 +++++++++++++++++++++++
 src/rc/calendar-manager-list.ui             |   42 +++++++++++++++++++
 13 files changed, 333 insertions(+), 1 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 44fa9ba..2c41ca1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,6 +68,12 @@ california_VALASOURCES = \
        host/host-popup.vala \
        host/host-show-event.vala \
        \
+       manager/manager.vala \
+       manager/manager-calendar-list.vala \
+       manager/manager-calendar-list-item.vala \
+       manager/manager-controller.vala \
+       manager/manager-dialog.vala \
+       \
        util/util-memory.vala \
        util/util-string.vala \
        \
@@ -87,6 +93,9 @@ california_SOURCES = \
 
 california_RC = \
        rc/app-menu.interface \
+       rc/calendar-manager-dialog.ui \
+       rc/calendar-manager-list.ui \
+       rc/calendar-manager-list-item.ui \
        rc/create-update-event.ui \
        rc/show-event.ui \
        $(NULL)
diff --git a/src/application/california-application.vala b/src/application/california-application.vala
index ebbfd82..4e60429 100644
--- a/src/application/california-application.vala
+++ b/src/application/california-application.vala
@@ -30,6 +30,7 @@ public class Application : Gtk.Application {
     };
     
     private static const ActionEntry[] action_entries = {
+        { "calendar-manager", on_calendar_manager },
         { "about", on_about },
         { "quit", on_quit }
     };
@@ -72,6 +73,7 @@ public class Application : Gtk.Application {
         // unit initialization
         try {
             Host.init();
+            Manager.init();
         } catch (Error err) {
             error_message(_("Unable to open California: %s").printf(err.message));
             quit();
@@ -87,6 +89,7 @@ public class Application : Gtk.Application {
         main_window = null;
         
         // unit termination
+        Manager.terminate();
         Host.terminate();
         
         base.shutdown();
@@ -113,6 +116,12 @@ public class Application : Gtk.Application {
         dialog.destroy();
     }
     
+    private void on_calendar_manager() {
+        Manager.Dialog dialog = new Manager.Dialog(main_window);
+        dialog.run();
+        dialog.destroy();
+    }
+    
     private void on_about() {
         Gtk.show_about_dialog(main_window,
             "program-name", TITLE,
diff --git a/src/backing/backing-manager.vala b/src/backing/backing-manager.vala
index 7238528..99478b1 100644
--- a/src/backing/backing-manager.vala
+++ b/src/backing/backing-manager.vala
@@ -116,7 +116,7 @@ public class Manager : BaseObject {
      *
      * The list will be sorted by the Sources title in lexiographic order.
      *
-     * Must only be called wheil the { link Manager} is open.
+     * Must only be called while the { link Manager} is open.
      *
      * @see Store.get_sources_of_type
      */
diff --git a/src/california-resources.xml b/src/california-resources.xml
index 8f5d8d5..4c390e8 100644
--- a/src/california-resources.xml
+++ b/src/california-resources.xml
@@ -4,6 +4,15 @@
         <file compressed="true">rc/app-menu.interface</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
+        <file compressed="false">rc/calendar-manager-dialog.ui</file>
+    </gresource>
+    <gresource prefix="/org/yorba/california">
+        <file compressed="false">rc/calendar-manager-list.ui</file>
+    </gresource>
+    <gresource prefix="/org/yorba/california">
+        <file compressed="false">rc/calendar-manager-list-item.ui</file>
+    </gresource>
+    <gresource prefix="/org/yorba/california">
         <file compressed="false">rc/create-update-event.ui</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
diff --git a/src/manager/manager-calendar-list-item.vala b/src/manager/manager-calendar-list-item.vala
new file mode 100644
index 0000000..856c8f8
--- /dev/null
+++ b/src/manager/manager-calendar-list-item.vala
@@ -0,0 +1,28 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+namespace California.Manager {
+
+[GtkTemplate (ui = "/org/yorba/california/rc/calendar-manager-list-item.ui")]
+public class CalendarListItem : Gtk.Grid {
+    public Backing.CalendarSource source { get; private set; }
+    
+    [GtkChild]
+    private Gtk.CheckButton enabled_check_button;
+    
+    [GtkChild]
+    private Gtk.Label title_label;
+    
+    public CalendarListItem(Backing.CalendarSource source) {
+        this.source = source;
+        
+        enabled_check_button.active = source.is_available;
+        title_label.label = source.title;
+    }
+}
+
+}
+
diff --git a/src/manager/manager-calendar-list.vala b/src/manager/manager-calendar-list.vala
new file mode 100644
index 0000000..8da3a0f
--- /dev/null
+++ b/src/manager/manager-calendar-list.vala
@@ -0,0 +1,58 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+namespace California.Manager {
+
+[GtkTemplate (ui = "/org/yorba/california/rc/calendar-manager-list.ui")]
+public class CalendarList : Gtk.Grid {
+    [GtkChild]
+    private Gtk.ListBox calendar_list_box;
+    
+    public CalendarList() {
+        // if already open, initialize now
+        if (Backing.Manager.instance.is_open)
+            init();
+        
+        // otherwise, initialize when it does open
+        Backing.Manager.instance.notify[Backing.Manager.PROP_IS_OPEN].connect(on_manager_opened_closed);
+    }
+    
+    ~CalendarList() {
+        Backing.Manager.instance.notify[Backing.Manager.PROP_IS_OPEN].disconnect(on_manager_opened_closed);
+    }
+    
+    private void on_manager_opened_closed() {
+        if (Backing.Manager.instance.is_open)
+            init();
+        /* else
+            clear();
+            */
+    }
+    
+    private void init() {
+        assert(Backing.Manager.instance.is_open);
+        
+        foreach (Backing.CalendarSource source in
+            Backing.Manager.instance.get_sources_of_type<Backing.CalendarSource>()) {
+            calendar_list_box.add(new CalendarListItem(source));
+        }
+    }
+    
+    [GtkCallback]
+    private void on_new_button_clicked() {
+        debug("new");
+    }
+    
+    [GtkCallback]
+    private void on_calendar_list_box_row_activated(Gtk.ListBoxRow row) {
+        CalendarListItem item = (CalendarListItem) row.get_child();
+        debug("activated %s", item.source.to_string());
+        item = null;
+    }
+}
+
+}
+
diff --git a/src/manager/manager-controller.vala b/src/manager/manager-controller.vala
new file mode 100644
index 0000000..0c18da3
--- /dev/null
+++ b/src/manager/manager-controller.vala
@@ -0,0 +1,20 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+namespace California.Manager {
+
+public class Controller : Gtk.Stack {
+    private CalendarList calendar_list = new CalendarList();
+    
+    public Controller() {
+        add(calendar_list);
+        
+        set_visible_child(calendar_list);
+    }
+}
+
+}
+
diff --git a/src/manager/manager-dialog.vala b/src/manager/manager-dialog.vala
new file mode 100644
index 0000000..4d533c2
--- /dev/null
+++ b/src/manager/manager-dialog.vala
@@ -0,0 +1,27 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+namespace California.Manager {
+
+[GtkTemplate (ui = "/org/yorba/california/rc/calendar-manager-dialog.ui")]
+public class Dialog : Gtk.Dialog {
+    private Manager.Controller controller = new Manager.Controller();
+    
+    public Dialog(Gtk.Window? parent) {
+        transient_for = parent;
+        
+        ((Gtk.Box) get_content_area()).pack_start(controller, true, true, 8);
+        show_all();
+    }
+    
+    [GtkCallback]
+    private void on_close_button_clicked() {
+        response(Gtk.ResponseType.CLOSE);
+    }
+}
+
+}
+
diff --git a/src/manager/manager.vala b/src/manager/manager.vala
new file mode 100644
index 0000000..5369d25
--- /dev/null
+++ b/src/manager/manager.vala
@@ -0,0 +1,25 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+namespace California.Manager {
+
+private int init_count = 0;
+
+public void init() throws Error {
+    if (!Unit.do_init(ref init_count))
+        return;
+    
+    Backing.init();
+}
+
+public void terminate() {
+    if (!Unit.do_terminate(ref init_count))
+        return;
+    
+    Backing.terminate();
+}
+
+}
diff --git a/src/rc/app-menu.interface b/src/rc/app-menu.interface
index 19cc62f..386e414 100644
--- a/src/rc/app-menu.interface
+++ b/src/rc/app-menu.interface
@@ -3,6 +3,13 @@
     <menu id="app-menu">
         <section>
             <item>
+                <attribute name="label" translatable="yes">_Calendars</attribute>
+                <attribute name="action">app.calendar-manager</attribute>
+                <attribute name="accel">&lt;Primary&gt;m</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
                 <attribute name="label" translatable="yes">_About</attribute>
                 <attribute name="action">app.about</attribute>
             </item>
diff --git a/src/rc/calendar-manager-dialog.ui b/src/rc/calendar-manager-dialog.ui
new file mode 100644
index 0000000..7258a19
--- /dev/null
+++ b/src/rc/calendar-manager-dialog.ui
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="CaliforniaManagerDialog" parent="GtkDialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Calendar Manager</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="close_button">
+                <property name="label" translatable="yes">_Close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="on_close_button_clicked" object="CaliforniaManagerDialog" 
swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/rc/calendar-manager-list-item.ui b/src/rc/calendar-manager-list-item.ui
new file mode 100644
index 0000000..a65688d
--- /dev/null
+++ b/src/rc/calendar-manager-list-item.ui
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="CaliforniaManagerCalendarListItem" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="column_spacing">4</property>
+    <child>
+      <object class="GtkCheckButton" id="enabled_check_button">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="halign">start</property>
+        <property name="valign">center</property>
+        <property name="xalign">0</property>
+        <property name="yalign">0.50999999046325684</property>
+        <property name="draw_indicator">True</property>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="title_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="valign">center</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="xalign">0</property>
+        <property name="yalign">0</property>
+        <property name="label">calendar name</property>
+        <property name="ellipsize">end</property>
+        <property name="single_line_mode">True</property>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+  </template>
+</interface>
diff --git a/src/rc/calendar-manager-list.ui b/src/rc/calendar-manager-list.ui
new file mode 100644
index 0000000..3727c21
--- /dev/null
+++ b/src/rc/calendar-manager-list.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="CaliforniaManagerCalendarList" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkListBox" id="calendar_list_box">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <signal name="row-activated" handler="on_calendar_list_box_row_activated" 
object="CaliforniaManagerCalendarList" swapped="no"/>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkButton" id="new_button">
+        <property name="label" translatable="yes">_New calendar...</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">True</property>
+        <property name="halign">end</property>
+        <property name="margin_top">8</property>
+        <property name="use_underline">True</property>
+        <signal name="clicked" handler="on_new_button_clicked" object="CaliforniaManagerCalendarList" 
swapped="no"/>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">1</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+  </template>
+</interface>


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