add gtk version check + revert to gdk_window_get_toplevel()

This commit is contained in:
foudfou 2012-10-15 13:25:28 +02:00
parent 1ec5ccf950
commit 18fb980d49
4 changed files with 16 additions and 1 deletions

View File

@ -89,6 +89,7 @@ firetray.Handler = {
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailServerTypes);
VersionChange.applyHooksAndWatchUninstall();
firetray.Window.init();
firetray.StatusIcon.init();
firetray.Handler.showHideIcon();
log.debug('StatusIcon initialized');

View File

@ -302,6 +302,7 @@ function gdk_defines(lib) {
lib.lazy_bind("gdk_window_get_user_data", ctypes.void_t, this.GdkWindow.ptr, gobject.gpointer.ptr);
lib.lazy_bind("gdk_atom_intern", this.GdkAtom, gobject.gchar.ptr, gobject.gboolean);
lib.lazy_bind("gdk_property_change", ctypes.void_t, this.GdkWindow.ptr, this.GdkAtom, this.GdkAtom, gobject.gint, this.GdkPropMode, gobject.guchar.ptr, gobject.gint);
lib.lazy_bind("gdk_window_get_toplevel", this.GdkWindow.ptr, this.GdkWindow.ptr);
lib.lazy_bind("gdk_window_get_effective_toplevel", this.GdkWindow.ptr, this.GdkWindow.ptr);
lib.lazy_bind("gdk_display_get_n_screens", gobject.gint, this.GdkDisplay.ptr);

View File

@ -17,6 +17,10 @@ Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
Cu.import("resource://firetray/ctypes/linux/pango.jsm");
function gtk_defines(lib) {
this.FIRETRAY_REQUIRED_GTK_MAJOR_VERSION = 2;
this.FIRETRAY_REQUIRED_GTK_MINOR_VERSION = 20;
this.FIRETRAY_REQUIRED_GTK_MICRO_VERSION = 0;
this.GTK_ICON_SIZE_MENU = 1; // enum GtkIconSize
this.GTK_WINDOW_TOPLEVEL = 0; // enum GtkWindowType
@ -78,6 +82,7 @@ function gtk_defines(lib) {
ctypes.default_abi, gobject.gboolean,
[this.GtkWidget.ptr, gdk.GdkEventFocus.ptr, gobject.gpointer]).ptr;
lib.lazy_bind("gtk_check_version", gobject.gchar.ptr, gobject.guint, gobject.guint, gobject.guint);
lib.lazy_bind("gtk_icon_theme_get_default", this.GtkIconTheme.ptr);
lib.lazy_bind("gtk_icon_theme_get_for_screen", this.GtkIconTheme.ptr, gdk.GdkScreen.ptr);

View File

@ -60,6 +60,14 @@ firetray.Handler.gtkPopupMenuWindowItems = new ctypesMap(gtk.GtkImageMenuItem.pt
firetray.Window = {
init: function() {
let gtkVersionCheck = gtk.gtk_check_version(
gtk.FIRETRAY_REQUIRED_GTK_MAJOR_VERSION,
gtk.FIRETRAY_REQUIRED_GTK_MINOR_VERSION,
gtk.FIRETRAY_REQUIRED_GTK_MICRO_VERSION
);
if (!gtkVersionCheck.isNull())
log.error("gtk_check_version="+gtkVersionCheck.readString());
this.initialized = true;
},
@ -157,7 +165,7 @@ firetray.Window = {
getGdkWindowFromNativeHandle: function(nativeHandle) {
let gdkw = new gdk.GdkWindow.ptr(ctypes.UInt64(nativeHandle)); // a new pointer to the GdkWindow
gdkw = gdk.gdk_window_get_effective_toplevel(gdkw);
gdkw = gdk.gdk_window_get_toplevel(gdkw);
log.debug("gdkw="+gdkw+" *gdkw="+this.addrPointedByInHex(gdkw));
return gdkw;
},