From 08eaa3034e040c6d3b0d855fdf7433c3a10d797f Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Sat, 7 Nov 2009 00:10:34 +0000 Subject: [PATCH] Store date info in the next30 list items --- README | 2 ++ src/widgets/calendar.vala | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README b/README index a0b4490..ad603d9 100644 --- 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 diff --git a/src/widgets/calendar.vala b/src/widgets/calendar.vala index 8f2c662..353f8a9 100644 --- a/src/widgets/calendar.vala +++ b/src/widgets/calendar.vala @@ -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); } -- 2.39.5