Store date info in the next30 list items
authorEnrico Zini <enrico@enricozini.org>
Sat, 7 Nov 2009 00:10:34 +0000 (00:10 +0000)
committerEnrico Zini <enrico@enricozini.org>
Sat, 7 Nov 2009 00:10:34 +0000 (00:10 +0000)
README
src/widgets/calendar.vala

diff --git a/README b/README
index a0b44903320ce575d95fd344e714a7471f4483dc..ad603d9234e693d67d1a69c095a574aedba596c9 100644 (file)
--- a/README
+++ b/README
@@ -154,6 +154,8 @@ TODO list / wish list
  * Features to add:
  - calendar: show preview of next 30 days
    (not among the notes: it replaces the calendar view; unless we skip the empty dates, which is a good idea)
+   next30: when clicking on an item, show that day without updating next30
+   next30: don't update if not shown currently on the notebook
  - contacts: show as a fancy focus+context list (see prefuse)
  - GSM power and network
     - link to open SHR-dialer
index 8f2c662717a8ecb00479b6f88346a3474ce2b0a5..353f8a919d2743f62afaa6d013b4e607886b0536 100644 (file)
@@ -110,7 +110,7 @@ public class Next30 : Gtk.ScrolledWindow
        public Next30()
        {
                set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
-               model = new Gtk.ListStore(2, typeof(string), typeof(string));
+               model = new Gtk.ListStore(5, typeof(string), typeof(string), typeof(int), typeof(int), typeof(int));
                list = new Gtk.TreeView.with_model(model);
                list.insert_column_with_attributes (-1, "Day", new Gtk.CellRendererText(), "text", 0);
                list.insert_column_with_attributes (-1, "Notes", new Gtk.CellRendererText(), "text", 1);
@@ -122,12 +122,17 @@ public class Next30 : Gtk.ScrolledWindow
                model.clear();
        }
 
-       public void add_day(string day, string notes)
+       public void add_day(Date date, string notes)
        {
+               var buffer = new char[64];
+               date.strftime(buffer, "%d %a");
                Gtk.TreeIter iter;
                model.append (out iter);
-               model.set(iter, 0, day);
+               model.set(iter, 0, (string)buffer);
                model.set(iter, 1, notes);
+               model.set(iter, 2, date.get_day());
+               model.set(iter, 3, date.get_month());
+               model.set(iter, 4, date.get_year());
        }
 }
 
@@ -153,6 +158,8 @@ public class Calendar : Gtk.VBox
 
                notebook = new Gtk.Notebook();
 
+               next_30 = new Next30();
+               notebook.append_page(next_30, new Gtk.Label("Next 30"));
                day_notes = new FileNotes();
                notebook.append_page(day_notes, new Gtk.Label("Day"));
                month_notes = new FileNotes();
@@ -160,8 +167,6 @@ public class Calendar : Gtk.VBox
                general_notes = new FileNotes();
                general_notes.load(zavai.config.homedir + "/cal/notes.txt");
                notebook.append_page(general_notes, new Gtk.Label("General"));
-               next_30 = new Next30();
-               notebook.append_page(next_30, new Gtk.Label("Next 30"));
 
                pack_start(notebook, true, true, 0);
 
@@ -219,7 +224,6 @@ public class Calendar : Gtk.VBox
                next_30.clear();
                Date date = Date();
                date.set_dmy((DateDay)cur_day, cur_month, (DateYear)cur_year);
-               var buffer = new char[64];
                for (uint i = 0; i < 30; ++i)
                {
                        path = day_path(date.get_year(), date.get_month(), date.get_day());
@@ -236,8 +240,7 @@ public class Calendar : Gtk.VBox
                        }
                        if (text != "")
                        {
-                               date.strftime(buffer, "%d %a");
-                               next_30.add_day((string)buffer, text);
+                               next_30.add_day(date, text);
                        }
                        date.add_days(1);
                }