From adadcba73ad8bbee2fa7af88fa86c2cadab8df5c Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Sat, 27 Mar 2010 23:51:41 +0000 Subject: [PATCH 1/1] Facility for acking/unacking log entries --- src/app_log.vala | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/src/app_log.vala b/src/app_log.vala index 884c007..fa247b4 100644 --- a/src/app_log.vala +++ b/src/app_log.vala @@ -32,6 +32,9 @@ public class Log : Applet protected Gtk.ScrolledWindow details_scroll; protected Gtk.TextBuffer details; protected Gtk.TextView details_view; + protected BigButton read_unread; + protected Gtk.TreeIter cur_iter; + protected zavai.log.Log cur_log; public Log() { @@ -65,6 +68,12 @@ public class Log : Applet pack_start(details_frame, true, true, 0); list.cursor_changed += on_row_selected; + + read_unread = new BigButton(); + update_read_unread(false); + read_unread.set_sensitive(false); + read_unread.clicked += on_read_unread; + button_box.pack_start(read_unread, true, true, 0); } private void render_details(zavai.log.Log l) @@ -88,23 +97,44 @@ public class Log : Applet Gtk.TreePath path; list.get_cursor(out path, null); - Gtk.TreeIter iter; - if (!model.get_iter(out iter, path)) return; + if (!model.get_iter(out cur_iter, path)) return; Value vdir, vname; - model.get_value(iter, 0, out vdir); - model.get_value(iter, 1, out vname); + model.get_value(cur_iter, 0, out vdir); + model.get_value(cur_iter, 1, out vname); string pathname = vdir.get_string() + "/" + vname.get_string(); - zavai.log.Log l = zavai.log.log.load(pathname); - render_details(l); + cur_log = zavai.log.log.load(pathname); + render_details(cur_log); - // l.acked + read_unread.set_sensitive(true); + update_read_unread(cur_log.acked); // model.set(iter, 0, d); // set new dir //selected((int)year, (int)month, (int)day); } + private void on_read_unread(Gtk.Button b) + { + if (cur_log.acked) + { + cur_log.acked = false; + } else { + cur_log.acked = true; + } + model.set(cur_iter, 2, cur_log.acked, -1); + + update_read_unread(cur_log.acked); + } + + private void update_read_unread(bool acked) + { + if (acked) + read_unread.set_label("Mark as unread"); + else + read_unread.set_label("Mark as read"); + } + public void refresh() { model.clear(); -- 2.39.5