[Xfce4-commits] <xfce4-notes-plugin:master> Cache menu image inside two pixbufs

Mike Massonnet noreply at xfce.org
Sat Nov 6 21:52:02 CET 2010


Updating branch refs/heads/master
         to c66f67c893c9cf63a14428dbe7413151ff9e04d4 (commit)
       from c26515e175810fbc1b7af76c2dc89aac64331086 (commit)

commit c66f67c893c9cf63a14428dbe7413151ff9e04d4
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sat Nov 6 15:08:31 2010 +0100

    Cache menu image inside two pixbufs
    
    The menu icon (top left corner) was always loaded from the files.
    Instead of loading from the files, cache the two files inside pixbufs.

 lib/window.vala |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/window.vala b/lib/window.vala
index 329d7ee..e545b2a 100644
--- a/lib/window.vala
+++ b/lib/window.vala
@@ -33,6 +33,8 @@ namespace Xnp {
 		private Gtk.CheckMenuItem mi_above;
 		private Gtk.CheckMenuItem mi_sticky;
 		private Gtk.Image menu_image;
+		private Gdk.Pixbuf menu_pixbuf;
+		private Gdk.Pixbuf menu_hover_pixbuf;
 		private Gtk.Label title_label;
 		private Gtk.VBox content_box;
 		private Gtk.Notebook notebook;
@@ -220,14 +222,21 @@ namespace Xnp {
 			var menu_evbox = new Gtk.EventBox ();
 			menu_evbox.tooltip_text = _("Menu");
 			menu_evbox.set_visible_window (false);
-			this.menu_image = new Gtk.Image.from_file ("%s/pixmaps/notes-menu.png".printf (Config.PKGDATADIR));
+			try {
+				this.menu_pixbuf = new Gdk.Pixbuf.from_file ("%s/pixmaps/notes-menu.png".printf (Config.PKGDATADIR));
+				this.menu_hover_pixbuf = new Gdk.Pixbuf.from_file ("%s/pixmaps/notes-menu-active.png".printf (Config.PKGDATADIR));
+			}
+			catch (Error e) {
+				this.menu_pixbuf = this.menu_hover_pixbuf = null;
+			}
+			this.menu_image = new Gtk.Image.from_pixbuf (this.menu_pixbuf);
 			menu_evbox.add (this.menu_image);
 			menu_evbox.enter_notify_event.connect (() => {
-				this.menu_image.set_from_file ("%s/pixmaps/notes-menu-active.png".printf (Config.PKGDATADIR));
+				this.menu_image.set_from_pixbuf (this.menu_hover_pixbuf);
 				return false;
 			});
 			menu_evbox.leave_notify_event.connect (() => {
-				this.menu_image.set_from_file ("%s/pixmaps/notes-menu.png".printf (Config.PKGDATADIR));
+				this.menu_image.set_from_pixbuf (this.menu_pixbuf);
 				return false;
 			});
 			title_box.pack_start (menu_evbox, false, false, 2);



More information about the Xfce4-commits mailing list