[Xfce4-commits] <postler:master> Implement a dashboard with a button box and a logo image

Christian Dywan noreply at xfce.org
Sun Jul 18 15:40:15 CEST 2010


Updating branch refs/heads/master
         to 5e46d0a9d5c2a56d47caeb500542177f0ad5a08f (commit)
       from 48261eaf5c68f5b37ea8f18191ab43d9134902bd (commit)

commit 5e46d0a9d5c2a56d47caeb500542177f0ad5a08f
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Jul 15 22:42:47 2010 +0200

    Implement a dashboard with a button box and a logo image

 postler/postler-viewer.vala |   50 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/postler/postler-viewer.vala b/postler/postler-viewer.vala
index 1a4df60..f46935f 100644
--- a/postler/postler-viewer.vala
+++ b/postler/postler-viewer.vala
@@ -15,6 +15,8 @@ public class Postler.Viewer : Gtk.VBox {
     Gtk.VBox message_parts;
     Gtk.Toolbar findbar;
     Gtk.Entry find_entry;
+    public Gtk.ButtonBox dashboard;
+    Gtk.EventBox dummy_plugin_widget;
 
     bool allow_external_images;
 
@@ -59,6 +61,16 @@ public class Postler.Viewer : Gtk.VBox {
         find_entry.changed.connect (find_entry_changed);
         find_entry.activate.connect (find_entry_changed);
         find_entry.focus_out_event.connect (find_entry_unfocus);
+
+        dashboard = new Gtk.VButtonBox ();
+        dashboard.layout_style = Gtk.ButtonBoxStyle.START;
+        dashboard.spacing = 8;
+        dashboard.show ();
+        dummy_plugin_widget = new Gtk.EventBox ();
+        content.create_plugin_widget.connect (create_plugin_widget);
+        content.settings.set ("enable-plugins", true);
+        content.clear.connect_after ((content) => { show_dashboard (); });
+        show_dashboard ();
     }
 
     void resource_request (WebKit.WebFrame frame, WebKit.WebResource resouce,
@@ -149,5 +161,43 @@ public class Postler.Viewer : Gtk.VBox {
         findbar.hide ();
         return false;
     }
+
+    void show_dashboard () {
+        string encoded_logo = "";
+        Gdk.Pixbuf pixbuf = null;
+        try {
+            var theme = Gtk.IconTheme.get_for_screen (Gdk.Screen.get_default ());
+            pixbuf = theme.load_icon (STOCK_INTERNET_MAIL, 128, 0);
+        } catch (GLib.Error error) { }
+        if (pixbuf != null) {
+            string buffer;
+            size_t buffer_size;
+            try {
+                if (Gdk.pixbuf_save_to_buffer (pixbuf, out buffer,
+                    out buffer_size, "png", null, null)) {
+                    encoded_logo = GLib.base64_encode (buffer, buffer_size);
+                }
+            } catch (GLib.Error error) { }
+        }
+
+        content.load_string ("""
+            <object type="application/x-gtk-vbox"
+                    style="width:33%; height:66%"></object>
+            <img style="position: absolute; right: 15px; bottom: 15px;"
+                 src="data:image/png;base64,%s">
+            """.
+            printf (encoded_logo), "text/html", "UTF-8", "about:blank");
+    }
+
+    unowned Gtk.Widget create_plugin_widget (string mime_type, string other,
+        GLib.HashTable values) {
+
+        if (mime_type == "application/x-gtk-vbox") {
+            return dashboard;
+        }
+
+        /* Block any unknown plugins */
+        return dummy_plugin_widget;
+    }
 }
 



More information about the Xfce4-commits mailing list