[Pkg-mozext-commits] [firetray] 48/399: added _getGdkWindowFromGtkWindow() and illustration code
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:12 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit fcab4872970a875f7330d76c6b74cfc3eafcbc97
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Wed Sep 21 11:52:14 2011 +0200
added _getGdkWindowFromGtkWindow() and illustration code
---
src/modules/MoztIconLinux.jsm | 47 +++++++++++++++++++++++++++++++----------
src/modules/gdk.jsm | 6 ++++++
src/modules/gtk.jsm | 14 +++++++++---
3 files changed, 53 insertions(+), 14 deletions(-)
diff --git a/src/modules/MoztIconLinux.jsm b/src/modules/MoztIconLinux.jsm
index 2542478..23d74b6 100644
--- a/src/modules/MoztIconLinux.jsm
+++ b/src/modules/MoztIconLinux.jsm
@@ -40,7 +40,7 @@ var mozt_findGtkWindowByTitleCb;
*/
var _find_data_t = ctypes.StructType("_find_data_t", [
{ inTitle: ctypes.char.ptr },
- { outWindow: ctypes.void_t.ptr }
+ { outWindow: gtk.GtkWindow.ptr }
]);
@@ -86,11 +86,6 @@ mozt.IconLinux = {
return false;
}
- // // TEST
- // let win = Services.wm.getMostRecentWindow(null);
- // let gtkWin = ctypes.cast(this._getGtkWindowHandle(win), gtk.GtkWindow.ptr);
- // gtk.gtk_window_set_decorated(gtkWin, false);
-
return true;
},
@@ -138,7 +133,6 @@ mozt.IconLinux = {
LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
try {
- // TODO: move to MoztIconLinux
var gtkMenuPtr = ctypes.cast(menu, gtk.GtkMenu.ptr);
var iconGpointer = ctypes.cast(icon, gobject.gpointer);
gtk.gtk_menu_popup(
@@ -147,6 +141,7 @@ mozt.IconLinux = {
} catch (x) {
LOG(x);
}
+
},
setImage: function(filename) {
@@ -305,7 +300,7 @@ mozt.IconLinux = {
*
* @author Nils Maier (stolen from MiniTrayR)
* @param window nsIDOMWindow from Services.wm
- * @return a ctypes.void_t.ptr to a GtkWindow
+ * @return a gtk.GtkWindow.ptr
*/
_getGtkWindowHandle: function(window) {
let baseWindow = window
@@ -319,7 +314,7 @@ mozt.IconLinux = {
try {
// Search the window by the *temporary* title
- let tl = gtk.gtk_window_list_toplevels();
+ let widgets = gtk.gtk_window_list_toplevels();
let that = this;
mozt_findGtkWindowByTitleCb = gobject.GFunc_t(that._findGtkWindowByTitle);
var userData = new _find_data_t(
@@ -327,8 +322,8 @@ mozt.IconLinux = {
null
).address();
LOG("userData="+userData);
- gobject.g_list_foreach(tl, mozt_findGtkWindowByTitleCb, userData);
- gobject.g_list_free(tl);
+ gobject.g_list_foreach(widgets, mozt_findGtkWindowByTitleCb, userData);
+ gobject.g_list_free(widgets);
if (userData.contents.outWindow.isNull()) {
throw new Error("Window not found!");
@@ -368,6 +363,36 @@ mozt.IconLinux = {
} catch (x) {
ERROR(x);
}
+ },
+
+ _getGdkWindowFromGtkWindow: function(gtkWin) {
+ try {
+ let gtkWid = ctypes.cast(gtkWin, gtk.GtkWidget.ptr);
+ var gdkWin = gtk.gtk_widget_get_window(gtkWid);
+ } catch (x) {
+ ERROR(x);
+ }
+ return gdkWin;
+ },
+
+ // NOTE: doesn't work during initialization probably since windows aren't
+ // fully realized (?)
+ testWindowHandle: function() {
+ try {
+ let win = Services.wm.getMostRecentWindow(null);
+ let gtkWin = mozt.IconLinux._getGtkWindowHandle(win);
+ LOG("FOUND: "+gtk.gtk_window_get_title(gtkWin).readString());
+ gtk.gtk_window_set_decorated(gtkWin, false);
+
+ let gdkWin = this._getGdkWindowFromGtkWindow(gtkWin);
+ if (!gdkWin.isNull()) {
+ LOG("has window");
+ LOG(gdk.gdk_window_get_width(gdkWin));
+ gdk.gdk_window_iconify(gdkWin);
+ }
+ } catch (x) {
+ ERROR(x);
+ }
}
}; // mozt.IconLinux
diff --git a/src/modules/gdk.jsm b/src/modules/gdk.jsm
index 52029ca..a0e710e 100644
--- a/src/modules/gdk.jsm
+++ b/src/modules/gdk.jsm
@@ -142,6 +142,12 @@ function gdk_defines(lib) {
lib.lazy_bind("gdk_pixbuf_add_alpha", this.GdkPixbuf.ptr, this.GdkPixbuf.ptr, gobject.gboolean, gobject.guchar, gobject.guchar, gobject.guchar);
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, this.GdkInterpType, ctypes.int);
+ lib.lazy_bind("gdk_window_stick", ctypes.void_t, this.GdkWindow.ptr);
+ lib.lazy_bind("gdk_window_iconify", ctypes.void_t, this.GdkWindow.ptr);
+ lib.lazy_bind("gdk_window_set_title", ctypes.void_t, this.GdkWindow.ptr, gobject.gchar.ptr);
+ lib.lazy_bind("gdk_window_beep", ctypes.void_t, this.GdkWindow.ptr);
+ lib.lazy_bind("gdk_window_get_width", ctypes.int, this.GdkWindow.ptr);
+
}
if (!gdk) {
diff --git a/src/modules/gtk.jsm b/src/modules/gtk.jsm
index 9b23989..0bec694 100644
--- a/src/modules/gtk.jsm
+++ b/src/modules/gtk.jsm
@@ -82,13 +82,21 @@ function gtk_defines(lib) {
gobject.gboolean.ptr, gobject.gpointer);
lib.lazy_bind("gtk_window_new", this.GtkWidget.ptr, this.GtkWindowType);
- lib.lazy_bind("gtk_widget_create_pango_layout", pango.PangoLayout.ptr, this.GtkWidget.ptr, gobject.gchar.ptr);
+ lib.lazy_bind("gtk_widget_create_pango_layout", pango.PangoLayout.ptr,
+ this.GtkWidget.ptr, gobject.gchar.ptr);
lib.lazy_bind("gtk_widget_destroy", ctypes.void_t, this.GtkWidget.ptr);
- lib.lazy_bind("gtk_status_icon_set_from_pixbuf", ctypes.void_t, this.GtkStatusIcon.ptr, gdk.GdkPixbuf.ptr);
+ lib.lazy_bind("gtk_status_icon_set_from_pixbuf", ctypes.void_t,
+ this.GtkStatusIcon.ptr, gdk.GdkPixbuf.ptr);
lib.lazy_bind("gtk_window_list_toplevels", gobject.GList.ptr);
lib.lazy_bind("gtk_window_get_title", gobject.gchar.ptr, this.GtkWindow.ptr);
- lib.lazy_bind("gtk_window_set_decorated", ctypes.void_t, this.GtkWindow.ptr, gobject.gboolean);
+ lib.lazy_bind("gtk_widget_get_has_window", gobject.gboolean,
+ this.GtkWidget.ptr);
+ lib.lazy_bind("gtk_widget_get_window", gdk.GdkWindow.ptr, this.GtkWidget.ptr);
+ lib.lazy_bind("gtk_widget_get_parent_window", gdk.GdkWindow.ptr, this.GtkWidget.ptr);
+ lib.lazy_bind("gtk_window_set_decorated", ctypes.void_t, this.GtkWindow.ptr,
+ gobject.gboolean);
+
}
if (!gtk) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list