[Xfce4-commits] <postler:master> Show one Add Contact icon next to replies
Christian Dywan
noreply at xfce.org
Thu Jun 30 03:46:02 CEST 2011
Updating branch refs/heads/master
to 3633919cfd1e2767b19c3f7c4ef6a36f326065d3 (commit)
from ab098c2a8c74e0a2b7036007195d27d7afbd225b (commit)
commit 3633919cfd1e2767b19c3f7c4ef6a36f326065d3
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Jun 30 01:41:12 2011 +0200
Show one Add Contact icon next to replies
postler/postler-content.vala | 44 ++++++++++++++++++++++++++---------------
1 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 314ec57..49b36c1 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -191,19 +191,24 @@ public class Postler.Content : WebKit.WebView {
.replace ("<", "<").replace (">", ">");
}
- internal static string linkify_address (string addresses, string? arguments, bool inherit=false) {
- var linkified = new StringBuilder ();
-
- string edit_icon = "";
+ string linkify_icon (string icon_name, string label, string uri) {
+ string markup = label;
+ string? real_icon_name = null;
var screen = Gdk.Screen.get_default ();
if (screen != null) {
var icon_theme = Gtk.IconTheme.get_for_screen (screen);
- if (icon_theme.has_icon ("not-starred"))
- edit_icon = "<img src=\""
- + icon_name_to_data_uri ("not-starred") + "\">";
- else
- edit_icon = "<b>←</b>";
+ if (icon_theme.has_icon (icon_name + "-symbolic"))
+ real_icon_name + "-symbolic";
+ else if (icon_theme.has_icon (icon_name))
+ real_icon_name = icon_name;
+ markup = "<img src=\"%s\" title=\"%s\">".printf (
+ icon_name_to_data_uri (real_icon_name, Gtk.IconSize.BUTTON), label);
}
+ return "<a href=\"%s\">%s</a>".printf (uri, markup);
+ }
+
+ internal static string linkify_address (string addresses, string? arguments, bool inherit=false) {
+ var linkified = new StringBuilder ();
int count = 0;
foreach (string address in addresses.split (",")) {
@@ -226,9 +231,6 @@ public class Postler.Content : WebKit.WebView {
if (inherit)
linkified.append (" style=\"color:inherit\"");
linkified.append ("\" title=\"" + quoted + "\">" + name + "</a>");
- if (edit_icon != "")
- linkified.append ((" <a href=\"contact:%s:%s\">%s</a>").printf (
- name, html_escape (parsed[1]), edit_icon));
}
/* FIXME: provide a way to see those others */
if (count > 12)
@@ -345,7 +347,9 @@ public class Postler.Content : WebKit.WebView {
{ "^_~", "face-wink" }
};
- static string? icon_name_to_data_uri (string icon_name) {
+ static string? icon_name_to_data_uri (string icon_name,
+ int icon_size=Gtk.IconSize.MENU) {
+
Gdk.Pixbuf? pixbuf = null;
var toplevels = Gtk.Window.list_toplevels ();
if (toplevels.nth_data (0) != null)
@@ -355,7 +359,7 @@ public class Postler.Content : WebKit.WebView {
try {
pixbuf = Gtk.IconTheme.get_for_screen (
Gdk.Screen.get_default ()).load_icon (icon_name,
- Gtk.IconSize.MENU, Gtk.IconLookupFlags.FORCE_SIZE);
+ icon_size, Gtk.IconLookupFlags.FORCE_SIZE);
} catch (GLib.Error error) { }
}
if (pixbuf == null) {
@@ -714,6 +718,14 @@ public class Postler.Content : WebKit.WebView {
reply_chunk.append (render_plain_text (text_part.body.str, child.project));
else
reply_chunk.append (child.parts.nth_data (0).body.str);
+ string sender_name = Contact.name_from_string (child.sender);
+ if (sender_name != _("You")) {
+ reply_chunk.append_printf ("""
+ <span class="contact">%s</span>
+ """.printf (
+ linkify_icon ("contact-new", _("Add contact"), "contact:%s:%s".printf (
+ sender_name, html_escape (Contact.address_from_string (child.sender))))));
+ }
/* FIXME: Move Bureau.compose_message () here */
reply_chunk.append ("""
<div class="actions">
@@ -724,7 +736,7 @@ public class Postler.Content : WebKit.WebView {
child.sender, child.subject, _("Forward")));
string reply_markup;
- if (Contact.name_from_string (child.sender) == _("You"))
+ if (sender_name == _("You"))
reply_markup = outgoing_template.replace ("%message%", reply_chunk.str);
else
reply_markup = content_template.replace ("%message%", reply_chunk.str);
More information about the Xfce4-commits
mailing list