[Xfce4-commits] <postler:master> Show an infobar when external images were blocked, and allow loading
Christian Dywan
noreply at xfce.org
Tue Jul 13 00:54:09 CEST 2010
Updating branch refs/heads/master
to 97e925c2c0be97ab5f4b38dc1f6c60b309e90852 (commit)
from 3f4ea1695f22f979a70802ab97fdc5bc13c99102 (commit)
commit 97e925c2c0be97ab5f4b38dc1f6c60b309e90852
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Jul 5 22:08:22 2010 +0200
Show an infobar when external images were blocked, and allow loading
postler/postler-app.vala | 2 ++
postler/postler-content.vala | 8 --------
postler/postler-viewer.vala | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/postler/postler-app.vala b/postler/postler-app.vala
index 0fe17b0..b120249 100644
--- a/postler/postler-app.vala
+++ b/postler/postler-app.vala
@@ -18,6 +18,7 @@ namespace Postler {
const string STOCK_FACE_SAD = "face-sad";
const string STOCK_FACE_WINK = "face-wink";
const string STOCK_FOLDER_SAVED_SEARCH = "folder-saved-search";
+ const string STOCK_IMAGE = "image-x-generic";
const string STOCK_INTERNET_MAIL = "internet-mail";
const string STOCK_MAIL_ATTACHMENT = "mail-attachment";
const string STOCK_MAIL_FORWARD = "mail-forward";
@@ -60,6 +61,7 @@ public class Postler.App : Unique.App {
{ STOCK_MAIL_REPLY_ALL, N_("Reply to _All") },
{ STOCK_MAIL_SEND, N_("_Send Message"), 0, 0, STOCK_MAIL_SEND_RECEIVE },
{ STOCK_MAIL_SEND_RECEIVE, N_("_Receive Mail") },
+ { STOCK_IMAGE, null, 0, 0, "gnome-mime-image" },
{ STOCK_INBOX, null, 0, 0, "stock_inbox" },
{ STOCK_OUTBOX, null, 0, 0, "stock_outbox" },
{ STOCK_SENT_MAIL, null, 0, 0, "stock_sent-mail" },
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 08f9cb9..e0111b2 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -26,7 +26,6 @@ public class Postler.Content : WebKit.WebView {
string x_mailer;
public string default_charset { get; set; default = "ISO-8859-1"; }
- public bool allow_external_images { get; set; default = false; }
public string? last_location { get; set; }
public string? sender { get; set; }
@@ -102,7 +101,6 @@ public class Postler.Content : WebKit.WebView {
if (settings.get_class ().find_property ("enable-private-browsing") != null) {
settings.set ("enable-private-browsing", true);
}
- resource_request_starting.connect (resource_request);
navigation_policy_decision_requested.connect (navigation_decision);
create_web_view.connect (new_window_created);
populate_popup.connect (populate_menu);
@@ -692,12 +690,6 @@ public class Postler.Content : WebKit.WebView {
}
}
- void resource_request (WebKit.WebFrame frame, WebKit.WebResource resouce,
- WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
- if (!allow_external_images && request.uri.has_prefix ("http"))
- request.uri = "about:blank";
- }
-
bool navigation_decision (WebKit.WebFrame web_frame,
WebKit.NetworkRequest request, WebKit.WebNavigationAction action,
WebKit.WebPolicyDecision decision) {
diff --git a/postler/postler-viewer.vala b/postler/postler-viewer.vala
index 30f0174..28e0467 100644
--- a/postler/postler-viewer.vala
+++ b/postler/postler-viewer.vala
@@ -10,12 +10,30 @@
*/
public class Postler.Viewer : Gtk.VBox {
+ Gtk.InfoBar infobar;
Postler.Content content;
Gtk.VBox message_parts;
+ bool allow_external_images;
+
public Viewer (Postler.Content content) {
this.content = content;
+ infobar = new Gtk.InfoBar ();
+ pack_start (infobar, false, false, 0);
+ var infobox = infobar.get_content_area () as Gtk.Box;
+ var image = new Gtk.Image.from_stock (STOCK_IMAGE, Gtk.IconSize.BUTTON);
+ infobox.pack_start (image, false, false, 0);
+ var infolabel = new Gtk.Label (_("External images were blocked."));
+ var attrlist = new Pango.AttrList ();
+ attrlist.insert (Pango.attr_weight_new (Pango.Weight.BOLD));
+ infolabel.attributes = attrlist;
+ infobox.pack_start (infolabel, true, true, 0);
+ infobar.add_button (_("Load external _Images"), Gtk.ResponseType.OK);
+ infobar.response.connect (infobar_response);
+ infobar.set_no_show_all (true);
+ content.resource_request_starting.connect (resource_request);
+
var content_box = new Gtk.HBox (false, 0);
pack_start (content_box, true, true, 0);
var scrolled = new Postler.ScrolledWindow (content);
@@ -27,6 +45,21 @@ public class Postler.Viewer : Gtk.VBox {
message_parts.parent.parent.set_no_show_all (true);
}
+ void resource_request (WebKit.WebFrame frame, WebKit.WebResource resouce,
+ WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
+ if (!allow_external_images && request.uri.has_prefix ("http")) {
+ request.uri = "about:blank";
+ infobar.set_no_show_all (false);
+ infobar.show_all ();
+ }
+ }
+
+ void infobar_response (Gtk.InfoBar infobar, int response) {
+ infobar.hide ();
+ allow_external_images = true;
+ content.display_part (0);
+ }
+
static string icon_name_for_mime_type (string mime_type, Gtk.Widget widget) {
var icon_theme = Gtk.IconTheme.get_for_screen (widget.get_screen ());
var parts = mime_type.split ("/", 2);
@@ -46,6 +79,9 @@ public class Postler.Viewer : Gtk.VBox {
}
void notify_n_parts (GLib.Object object, GLib.ParamSpec pspec) {
+ infobar.hide ();
+ allow_external_images = false;
+
var scrollable = message_parts.parent.parent;
if (content.n_parts == 1) {
scrollable.hide ();
More information about the Xfce4-commits
mailing list