[california/wip/725764-ics] Final touches



commit 76c85c6fb83997f0d05cdd6bf9c5182e95093075
Author: Jim Nelson <jim yorba org>
Date:   Tue Apr 15 13:54:17 2014 -0700

    Final touches

 src/Makefile.am                             |    3 ++-
 src/application/california-application.vala |    2 ++
 src/host/host-calendar-list-item.vala       |    3 ++-
 src/toolkit/toolkit-listbox-model.vala      |   12 ++++++++++--
 src/toolkit/toolkit-mutable-widget.vala     |   25 +++++++++++++++++++++++++
 5 files changed, 41 insertions(+), 4 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index da81cca..ee35640 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,8 +95,9 @@ california_VALASOURCES = \
        toolkit/toolkit-calendar-popup.vala \
        toolkit/toolkit-card.vala \
        toolkit/toolkit-deck.vala \
-       toolkit/toolkit-listbox-model.vala \
        toolkit/toolkit-deck-window.vala \
+       toolkit/toolkit-listbox-model.vala \
+       toolkit/toolkit-mutable-widget.vala \
        toolkit/toolkit-popup.vala \
        \
        util/util-gfx.vala \
diff --git a/src/application/california-application.vala b/src/application/california-application.vala
index e6d3e18..3b7387b 100644
--- a/src/application/california-application.vala
+++ b/src/application/california-application.vala
@@ -182,6 +182,8 @@ public class Application : Gtk.Application {
         
         debug("Parsed %s", ical.to_string());
         
+        // Ask the user to select a calendar to import it into
+        main_window.present_with_time(Gdk.CURRENT_TIME);
         Host.ImportCalendar importer = new Host.ImportCalendar(main_window, ical);
         Gtk.ResponseType response_type = (Gtk.ResponseType) importer.run();
         importer.destroy();
diff --git a/src/host/host-calendar-list-item.vala b/src/host/host-calendar-list-item.vala
index 6e19fb4..9fc5213 100644
--- a/src/host/host-calendar-list-item.vala
+++ b/src/host/host-calendar-list-item.vala
@@ -7,7 +7,7 @@
 namespace California.Host {
 
 [GtkTemplate (ui = "/org/yorba/california/rc/calendar-list-item.ui")]
-public class CalendarListItem : Gtk.Grid {
+public class CalendarListItem : Gtk.Grid, Toolkit.MutableWidget {
     public Backing.CalendarSource calendar_source { get; private set; }
     
     [GtkChild]
@@ -33,6 +33,7 @@ public class CalendarListItem : Gtk.Grid {
     
     private void set_title() {
         title_label.label = calendar_source.title;
+        mutated();
     }
     
     private void set_color() {
diff --git a/src/toolkit/toolkit-listbox-model.vala b/src/toolkit/toolkit-listbox-model.vala
index d20b28f..6c46b74 100644
--- a/src/toolkit/toolkit-listbox-model.vala
+++ b/src/toolkit/toolkit-listbox-model.vala
@@ -11,6 +11,10 @@ namespace California.Toolkit {
  *
  * ListBoxModel is designed to make it easier to maintain a sorted list of objects and make sure
  * the associated Gtk.ListBox is always up-to-date reflecting the state of the model.
+ *
+ * ListModelModel watches for Gtk.Widgets generated by { link ModelPresentation} to implement the
+ * { link MutableWidget} interface.  If they do, they can fire its "mutate" signal to indicate that
+ * the model needs to re-sort or re-filter the item.
  */
 
 public class ListBoxModel<G> : BaseObject {
@@ -107,9 +111,13 @@ public class ListBoxModel<G> : BaseObject {
         if (items.has_key(item))
             return false;
         
-        // item -> Gtk.ListBoxRow
+        // item -> Gtk.ListBoxRow, with MutableWidget support
         Gtk.ListBoxRow row = new Gtk.ListBoxRow();
-        row.add(model_presentation(item));
+        Gtk.Widget widget = model_presentation(item);
+        MutableWidget? mutable = widget as MutableWidget;
+        if (mutable != null)
+            mutable.mutated.connect(() => { row.changed(); });
+        row.add(mutable);
         
         // mappings
         row.set_data<G>(KEY, item);
diff --git a/src/toolkit/toolkit-mutable-widget.vala b/src/toolkit/toolkit-mutable-widget.vala
new file mode 100644
index 0000000..597eb08
--- /dev/null
+++ b/src/toolkit/toolkit-mutable-widget.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.Toolkit {
+
+/**
+ * A { link MutableWidget} is a Gtk.Widget whose internal state can change and affect its sort
+ * order or filtering.
+ */
+
+public interface MutableWidget : Gtk.Widget {
+    /**
+     * Fired when internal state has changed which may affect sorting or filtering.
+     *
+     * This can be used by collections and other containers to update their own state, such as
+     * re-sorting or re-applying filters.
+     */
+    public signal void mutated();
+}
+
+}
+


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