From b62cdf9b7870ee87261138d0cc80da25838c5040 Mon Sep 17 00:00:00 2001 From: foudfou Date: Sat, 10 Sep 2011 01:47:26 +0200 Subject: [PATCH] continue implementation for text icon --- src/modules/MoztHandler.jsm | 6 ++++-- src/modules/MoztIconLinux.jsm | 12 +++++++++++- src/modules/gdk.jsm | 30 +++++++++++++++++++++++++++--- src/modules/gtk.jsm | 5 ++--- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/modules/MoztHandler.jsm b/src/modules/MoztHandler.jsm index 33810f8..c741feb 100644 --- a/src/modules/MoztHandler.jsm +++ b/src/modules/MoztHandler.jsm @@ -206,8 +206,10 @@ mozt.Handler = { }, shutdown: function() { // NOT USED YET - if (this._inMailApp) - mozt.Messaging.disable(); + if (this._inMailApp) + mozt.Messaging.disable(); + + mozt.IconLinux.shutdown(); } }; // mozt.Handler diff --git a/src/modules/MoztIconLinux.jsm b/src/modules/MoztIconLinux.jsm index 5b3bf39..912fe2f 100644 --- a/src/modules/MoztIconLinux.jsm +++ b/src/modules/MoztIconLinux.jsm @@ -90,6 +90,13 @@ mozt.IconLinux = { return true; }, + shutdown: function() { + gobject.close(); + gdk.close(); + gtk.close(); + // glib.close(); + }, + setImage: function(filename) { if (!this.trayIcon) return false; @@ -152,7 +159,9 @@ mozt.IconLinux = { // { // GdkColormap* cmap=gdk_screen_get_system_colormap(gdk_screen_get_default()) // int screen_depth=24; - // if(cmap) screen_depth=cmap->visual->depth; + // if(cmap) + // GdkVisual* visual = gdk_colormap_get_visual(cmap); + // screen_depth=visual->depth; // GdkColor fore = { 0, 0, 0, 0 }; // GdkColor alpha = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; // if( gdk_color_parse (colorstr, &fore) ) DEBUGSTR("COLOR OK") @@ -161,6 +170,7 @@ mozt.IconLinux = { // alpha.red=0; //make sure alpha is different from fore // gdk_colormap_alloc_color (cmap, &fore,true,true); // gdk_colormap_alloc_color (cmap, &alpha,true,true); + // GdkPixmap *pm = gdk_pixmap_new (NULL, w, h, screen_depth); // GdkGC *gc = gdk_gc_new (pm); // gdk_gc_set_foreground(gc,&alpha); diff --git a/src/modules/gdk.jsm b/src/modules/gdk.jsm index bd36902..34feb4c 100644 --- a/src/modules/gdk.jsm +++ b/src/modules/gdk.jsm @@ -55,13 +55,31 @@ function gdk_defines(lib) { this.GDK_INTERP_NEAREST = 1, // GdkInterpType this.GdkWindow = ctypes.StructType("GdkWindow"); - this.GdkVisual = ctypes.StructType("GdkVisual"); - this.GdkColor = ctypes.StructType("GdkColor"), [ + this.GdkByteOrder = ctype.StructType("GdkByteOrder"); + this.GdkVisualType = ctype.StructType("GdkVisualType"); + this.GdkVisual = ctypes.StructType("GdkVisual", [ + { "parent_instance": gobject.GObject }, + { "type": this.GdkVisualType }, + { "depth": gobject.gint }, + { "byte": this.GdkByteOrder }, + { "colormap": gobject.gint }, + { "bits": gobject.gint }, + { "red_mask": gobject.guint32 }, + { "red_shift": gobject.gint }, + { "red_prec": gobject.gint }, + { "green_mask": gobject.guint32 }, + { "green_shift": gobject.gint }, + { "green_prec": gobject.gint }, + { "blue_mask": gobject.guint32 }, + { "blue_shift": gobject.gint }, + { "blue_prec": gobject.gint } + ]); + this.GdkColor = ctypes.StructType("GdkColor", [ { "pixel": gobject.guint32 }, { "red": gobject.guint16 }, { "green": gobject.guint16 }, { "blue": gobject.guint16 } - ]; + ]); this.GdkColormap = ctypes.StructType("GdkColormap", [ { "size": gobject.gint }, { "colors": this.GdkColor.ptr } @@ -101,6 +119,12 @@ function gdk_defines(lib) { lib.lazy_bind("gdk_pixbuf_get_height", ctypes.int, this.GdkPixbuf.ptr); lib.lazy_bind("gdk_pixbuf_composite", ctypes.void_t, this.GdkPixbuf.ptr, this.GdkPixbuf.ptr, ctypes.int, ctypes.int, ctypes.int, ctypes.int, ctypes.double, ctypes.double, ctypes.double, ctypes.double, ctypes.int, ctypes.int); lib.lazy_bind("gdk_screen_get_system_colormap", this.GdkColormap.ptr, this.GdkScreen.ptr); + lib.lazy_bind("gdk_colormap_get_visual", this.GdkVisual.ptr, this.GdkColormap.ptr); + lib.lazy_bind("gdk_color_parse", gobject.gboolean, gobject.gchar.ptr, this.GdkColor.ptr); + + lib.lazy_bind("gdk_colormap_alloc_color", gobject.gboolean, this.GdkColormap.ptr, this.GdkColor.ptr, gobject.gboolean, gobject.gboolean); +// gdk_pixmap_new +// gdk_gc_new } diff --git a/src/modules/gtk.jsm b/src/modules/gtk.jsm index 0eca501..57403e8 100644 --- a/src/modules/gtk.jsm +++ b/src/modules/gtk.jsm @@ -45,8 +45,7 @@ function gtk_defines(lib) { this.GtkMenuShell = ctypes.StructType("GtkMenuShell"); this.GtkImageMenuItem = ctypes.StructType("GtkImageMenuItem"); - // FIXME: rename to "_t" - this.GtkMenuPositionFunc = ctypes.FunctionType( + this.GtkMenuPositionFunc_t = ctypes.FunctionType( ctypes.default_abi, ctypes.void_t, [this.GtkMenu.ptr, gobject.gint.ptr, gobject.gint.ptr, gobject.gboolean.ptr, gobject.gpointer]).ptr; @@ -72,7 +71,7 @@ function gtk_defines(lib) { lib.lazy_bind("gtk_widget_show_all", ctypes.void_t, this.GtkWidget.ptr); lib.lazy_bind("gtk_menu_popup", ctypes.void_t, this.GtkMenu.ptr, this.GtkWidget.ptr, this.GtkWidget.ptr, - this.GtkMenuPositionFunc, gobject.gpointer, gobject.guint, + this.GtkMenuPositionFunc_t, gobject.gpointer, gobject.guint, gobject.guint); lib.lazy_bind("gtk_status_icon_position_menu", ctypes.void_t, this.GtkMenu.ptr, gobject.gint.ptr, gobject.gint.ptr,