[Xfce4-commits] <postler:master> No tree paths for unread and use display column
Christian Dywan
noreply at xfce.org
Thu Jan 27 22:54:01 CET 2011
Updating branch refs/heads/master
to 63cc198a4395326bc4404bac3cde17f160aa7d0d (commit)
from 002a00a94a964e4cf363672b3392fd1eccd2b474 (commit)
commit 63cc198a4395326bc4404bac3cde17f160aa7d0d
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Jan 27 22:49:16 2011 +0100
No tree paths for unread and use display column
Fixes: https://bugs.launchpad.net/postler/+bug/708373
postler/postler-folders.vala | 60 ++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 02deafa..b678466 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2010 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2011 Christian Dywan <christian at twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,7 @@ public class Postler.Folders : Gtk.TreeView {
enum Columns {
ICON,
NAME,
+ DISPLAY_NAME,
ELLIPSIZE,
LOCATION,
INFO,
@@ -62,15 +63,16 @@ public class Postler.Folders : Gtk.TreeView {
}
}
- store = new Gtk.TreeStore (9,
- typeof (string), typeof (string), typeof (int), typeof (string),
+ store = new Gtk.TreeStore (10,
+ typeof (string), typeof (string), typeof (string),
+ typeof (int), typeof (string),
typeof (AccountInfo), typeof (GLib.FileMonitor),
typeof (GLib.FileMonitor), typeof (GLib.FileMonitor), typeof (FolderType));
set_model (store);
insert_column_with_attributes (-1, "Icon",
new Gtk.CellRendererPixbuf (), "stock-id", Columns.ICON);
insert_column_with_attributes (-1, "Folder",
- new Gtk.CellRendererText (), "markup", Columns.NAME,
+ new Gtk.CellRendererText (), "markup", Columns.DISPLAY_NAME,
"ellipsize", Columns.ELLIPSIZE);
GLib.Idle.add (populate);
@@ -102,28 +104,44 @@ public class Postler.Folders : Gtk.TreeView {
assert_not_reached ();
}
- void unread_monitor_changed (File msg_dir, string path, string label) {
+ void unread_count_update (Gtk.TreeIter iter, File msg_dir, string label) {
try {
var msg_enumerator = msg_dir.enumerate_children ("", 0, null);
int unread = 0;
FileInfo info;
while ((info = msg_enumerator.next_file (null)) != null)
unread++;
-
- Gtk.TreeIter iter;
- if (store.get_iter_from_string (out iter, path)) {
- string escaped = GLib.Markup.escape_text (label);
- if (unread == 0)
- store.set (iter, Columns.NAME, "%s".printf (escaped));
- else
- store.set (iter, Columns.NAME, "<b>%s (%d)</b>".printf (escaped, unread));
- }
+ string escaped = GLib.Markup.escape_text (label);
+ if (unread == 0)
+ store.set (iter, Columns.DISPLAY_NAME, "%s".printf (escaped));
+ else
+ store.set (iter, Columns.DISPLAY_NAME,
+ "<b>%s (%d)</b>".printf (escaped, unread));
} catch (GLib.Error error) {
GLib.critical (_("Failed to monitor folder \"%s\": %s"),
msg_dir.get_path (), error.message);
}
}
+ void unread_monitor_changed (File msg_dir, string label) {
+ string location = msg_dir.get_path ();
+ location = location.substring (0, location.len () - 4); /* - /new */
+
+ Gtk.TreeIter account_iter;
+ if (!store.iter_children (out account_iter, null))
+ return;
+ do {
+ string existing_location;
+ store.get (account_iter, Columns.LOCATION, out existing_location);
+ Gtk.TreeIter iter = account_iter;
+ if (existing_location == location
+ || get_folder_iter (location, account_iter, out iter)) {
+ unread_count_update (iter, msg_dir, label);
+ break;
+ }
+ } while (store.iter_next (ref account_iter));
+ }
+
public bool populate () {
store.clear ();
@@ -177,6 +195,7 @@ public class Postler.Folders : Gtk.TreeView {
store.insert_with_values (null, null, -1,
Columns.ICON, STOCK_FOLDER_SAVED_SEARCH,
Columns.NAME, account_info.name,
+ Columns.DISPLAY_NAME, account_info.name,
Columns.ELLIPSIZE, Pango.EllipsizeMode.MIDDLE,
Columns.INFO, account_info,
Columns.LOCATION, account_info.path,
@@ -218,6 +237,7 @@ public class Postler.Folders : Gtk.TreeView {
store.insert_with_values (out account_iter, null, -1,
Columns.ICON, Gtk.STOCK_DIALOG_ERROR,
Columns.NAME, account_info.display_name,
+ Columns.DISPLAY_NAME, account_info.display_name,
Columns.ELLIPSIZE, Pango.EllipsizeMode.MIDDLE,
Columns.LOCATION, null,
Columns.INFO, account_info,
@@ -265,6 +285,7 @@ public class Postler.Folders : Gtk.TreeView {
store.insert_with_values (out parent_iter, account_iter, -1,
Columns.ICON, Gtk.STOCK_DIRECTORY,
Columns.NAME, parent,
+ Columns.DISPLAY_NAME, parent,
Columns.ELLIPSIZE, Pango.EllipsizeMode.MIDDLE,
Columns.LOCATION, folder_dir_path + "/" + parent_path,
Columns.INFO, account_info,
@@ -278,10 +299,9 @@ public class Postler.Folders : Gtk.TreeView {
var msg_dir = folder_dir.resolve_relative_path (
account_info.path + "/" + name + "/new");
var monitor = msg_dir.monitor_directory (0, null);
- string path = store.get_string_from_iter (account_iter);
string label = account_info.display_name;
monitor.changed.connect ((monitor, file, other, event) => {
- unread_monitor_changed (msg_dir, path, label);
+ unread_monitor_changed (msg_dir, label);
});
account_info.folders[FolderType.INBOX] = name;
@@ -291,7 +311,7 @@ public class Postler.Folders : Gtk.TreeView {
Columns.LOCATION, account_info.path + "/" + name,
Columns.UNREAD_MONITOR, monitor,
Columns.FOLDER_TYPE, FolderType.INBOX);
- unread_monitor_changed (msg_dir, path, label);
+ unread_count_update (account_iter, msg_dir, label);
continue;
}
@@ -325,11 +345,10 @@ public class Postler.Folders : Gtk.TreeView {
var msg_dir = folder_dir.resolve_relative_path (
account_info.path + "/" + name + "/new");
monitor = msg_dir.monitor_directory (0, null);
- string path = store.get_string_from_iter (folder_iter);
monitor.changed.connect ((monitor, file, other, event) => {
- unread_monitor_changed (msg_dir, path, display_name);
+ unread_monitor_changed (msg_dir, display_name);
});
- unread_monitor_changed (msg_dir, path, display_name);
+ unread_count_update (folder_iter, msg_dir, display_name);
store.set (folder_iter, Columns.UNREAD_MONITOR, monitor);
}
@@ -342,6 +361,7 @@ public class Postler.Folders : Gtk.TreeView {
store.set (folder_iter,
Columns.ICON, folder.stock_id ?? Gtk.STOCK_DIRECTORY,
Columns.NAME, folder.label,
+ Columns.DISPLAY_NAME, folder.label,
Columns.FOLDER_TYPE, folder.type);
need_update = true;
} else {
More information about the Xfce4-commits
mailing list