[Xfce4-commits] <postler:master> Implement a method for errors in the message view
Christian Dywan
noreply at xfce.org
Fri Dec 31 00:52:02 CET 2010
Updating branch refs/heads/master
to d909de51dd2ebc3d14f25a5f72d7fca720502874 (commit)
from 731a9fed389f0b170ee6a0b023d97b0b175cf136 (commit)
commit d909de51dd2ebc3d14f25a5f72d7fca720502874
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Dec 30 16:12:56 2010 +0100
Implement a method for errors in the message view
The error is shown if reading failed or a search didn't
yield any results.
Fixes: https://bugs.launchpad.net/postler/+bug/675723
postler/postler-messages.vala | 61 ++++++++++++++++++++++++++++++-----------
1 files changed, 45 insertions(+), 16 deletions(-)
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index d5e24ec..e89a9c6 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -117,22 +117,33 @@ public class Postler.Messages : Gtk.TreeView {
Gtk.TreeModel model, Gtk.TreeIter iter) {
string charset, subject;
int weight = Pango.Weight.NORMAL;
+ time_t timestamp;
var renderer = cell as Gtk.CellRendererText;
+ model.get (iter, Columns.SUBJECT, out subject,
+ Columns.WEIGHT, out weight,
+ Columns.TIMESTAMP, out timestamp);
+
+ if (timestamp == 0) {
+ model.get (iter, Columns.SUBJECT, out subject);
+ renderer.markup = subject;
+ renderer.xpad = renderer.ypad = 8;
+ renderer.xalign = renderer.yalign = 0.5f;
+ return;
+ }
+
+ renderer.xpad = renderer.ypad = 0;
+ renderer.xalign = renderer.yalign = 0.0f;
+
if (!rich_rows) {
- model.get (iter, Columns.SUBJECT, out subject,
- Columns.WEIGHT, out weight);
+ model.get (iter, Columns.WEIGHT, out weight);
renderer.text = parse_encoded (subject, out charset);
renderer.weight = weight;
return;
}
string from;
- time_t timestamp;
- model.get (iter, Columns.SUBJECT, out subject,
- Columns.WEIGHT, out weight,
- Columns.TIMESTAMP, out timestamp,
- Columns.FROM, out from);
+ model.get (iter, Columns.FROM, out from);
subject = escape_text (parse_encoded (subject, out charset));
var now = GLib.Date ();
@@ -154,10 +165,13 @@ public class Postler.Messages : Gtk.TreeView {
if (rich_rows)
renderer.text = "";
else {
- string from;
+ string? from;
model.get (iter, Columns.FROM, out from);
- string charset;
- renderer.text = parse_address (parse_encoded (from, out charset))[0];
+ if (from != null) {
+ string charset;
+ from = parse_address (parse_encoded (from, out charset))[0];
+ }
+ renderer.text = from;
}
}
@@ -728,6 +742,14 @@ public class Postler.Messages : Gtk.TreeView {
}
}
+ /* Show error for failed search, ie. no results */
+ int n_messages = store.iter_n_children (null);
+ if (location.has_prefix ("search:") && n_messages == 0) {
+ display_error (_("No messages found"),
+ _("Check the spelling or try a different filter."));
+ return false;
+ }
+
sort = new Gtk.TreeModelSort.with_model (store);
sort.set_sort_column_id (Columns.TIMESTAMP,
newest_at_the_bottom ? Gtk.SortType.ASCENDING : Gtk.SortType.DESCENDING);
@@ -735,7 +757,7 @@ public class Postler.Messages : Gtk.TreeView {
hadjustment.value = 0;
if (newest_at_the_bottom) {
- int last_child = sort.iter_n_children (null) - 1;
+ int last_child = n_messages - 1;
if (last_child > 0)
scroll_to_cell (new Gtk.TreePath.from_indices (last_child),
null, false, 0, 0);
@@ -744,11 +766,8 @@ public class Postler.Messages : Gtk.TreeView {
vadjustment.value = 0;
} catch (GLib.Error error) {
- folder_monitors = {};
- sort = new Gtk.TreeModelSort.with_model (store);
- model = sort;
- GLib.critical (_("Failed to read folder \"%s\": %s"),
- location, error.message);
+ display_error (_("Failed to read folder \"%s\".").printf (location),
+ error.message);
}
/* Avoid changing 'location' to not cause property notification */
@@ -758,6 +777,16 @@ public class Postler.Messages : Gtk.TreeView {
return false;
}
+ public void display_error (string title, string message) {
+ clear ();
+ string markup = "<big><b>%s</b></big>\n\n%s".printf (title, message);
+ store.insert_with_values (null, null, 0,
+ Columns.SUBJECT, markup,
+ Columns.FROM, null);
+ sort = new Gtk.TreeModelSort.with_model (store);
+ model = sort;
+ }
+
internal static string toggle_flag (string location, char flag) {
string folder = Path.get_dirname (location);
string bare_filename;
More information about the Xfce4-commits
mailing list