[Pkg-mozext-commits] [firetray] 147/399: refactoring

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:31 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 b4b9813d25d775cd32dcaf882f2bf486fe0fb37f
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sat Jan 21 09:14:03 2012 +0100

    refactoring
---
 src/modules/gtk2/FiretrayStatusIcon.jsm |   46 +++++++++++++++++++------------
 src/modules/gtk2/FiretrayWindow.jsm     |   45 ++++++++++++++----------------
 2 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/src/modules/gtk2/FiretrayStatusIcon.jsm b/src/modules/gtk2/FiretrayStatusIcon.jsm
index 850d188..1e92f7f 100644
--- a/src/modules/gtk2/FiretrayStatusIcon.jsm
+++ b/src/modules/gtk2/FiretrayStatusIcon.jsm
@@ -170,6 +170,7 @@ firetray.StatusIcon = {
   addPopupMenuWindowItem: function(xid) { // on registerWindow
     var menuItemWindow = gtk.gtk_image_menu_item_new();
     firetray.Handler.gtkPopupMenuWindowItems.insert(xid, menuItemWindow);
+    this.setPopupMenuWindowItemLabel(menuItemWindow, xid);
 
     var menuShell = ctypes.cast(firetray.StatusIcon.menu, gtk.GtkMenuShell.ptr);
     gtk.gtk_menu_shell_prepend(menuShell,
@@ -183,6 +184,14 @@ firetray.StatusIcon = {
     LOG("add gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
   },
 
+  setPopupMenuWindowItemLabel: function(menuItem, xid) {
+    let title = firetray.Handler.windows[xid].baseWin.title;
+    let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appNameOriginal);
+    if (tailIndex !== -1)
+      title = title.substring(0, tailIndex);
+    gtk.gtk_menu_item_set_label(ctypes.cast(menuItem, gtk.GtkMenuItem.ptr), title);
+  },
+
   removePopupMenuWindowItem: function(xid) { // on unregisterWindow
     let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
     firetray.Handler.gtkPopupMenuWindowItems.remove(xid);
@@ -191,17 +200,22 @@ firetray.StatusIcon = {
     LOG("remove gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
   },
 
+  showAllPopupMenuWindowItems: function(filterVisibleWindows) {
+    for (let xid in firetray.Handler.windows)
+      if (!filterVisibleWindows || !firetray.Handler.windows[xid].visibility)
+        this.showSinglePopupMenuWindowItem(xid);
+  },
+
   showSinglePopupMenuWindowItem: function(xid) {
     LOG("showSinglePopupMenuWindowItem");
     let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
-
-    let title = firetray.Handler.windows[xid].baseWin.title;
-    let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appNameOriginal);
-    if (tailIndex !== -1)
-      title = title.substring(0, tailIndex);
-    gtk.gtk_menu_item_set_label(ctypes.cast(menuItemWindow, gtk.GtkMenuItem.ptr), title);
     gtk.gtk_widget_show(ctypes.cast(menuItemWindow, gtk.GtkWidget.ptr));
-    gtk.gtk_widget_show(ctypes.cast(firetray.StatusIcon.menuSeparatorWindows, gtk.GtkWidget.ptr));
+    this.showPopupMenuWindowSeparator();
+  },
+
+  hideAllPopupMenuWindowItems: function(forceHideSeparator) {
+    for (let xid in firetray.Handler.windows)
+      this.hideSinglePopupMenuWindowItem(xid, forceHideSeparator);
   },
 
   hideSinglePopupMenuWindowItem: function(xid, forceHideSeparator) {
@@ -210,21 +224,17 @@ firetray.StatusIcon = {
     gtk.gtk_widget_hide(ctypes.cast(menuItemWindow, gtk.GtkWidget.ptr)); // on hideSingleWindow
 
     if (!forceHideSeparator || (firetray.Handler.visibleWindowsCount === firetray.Handler.windowsCount)) {
-      LOG("hiding menuSeparatorWindows");
-      gtk.gtk_widget_hide(
-        ctypes.cast(firetray.StatusIcon.menuSeparatorWindows, gtk.GtkWidget.ptr));
+      this.hidePopupMenuWindowSeparator();
     }
   },
 
-  showAllPopupMenuWindowItems: function(filterVisibleWindows) {
-    for (let xid in firetray.Handler.windows)
-      if (!filterVisibleWindows || !firetray.Handler.windows[xid].visibility)
-        this.showSinglePopupMenuWindowItem(xid);
+  showPopupMenuWindowSeparator: function() {
+    LOG("showing menuSeparatorWindows");
+    gtk.gtk_widget_show(ctypes.cast(firetray.StatusIcon.menuSeparatorWindows, gtk.GtkWidget.ptr));
   },
-
-  hideAllPopupMenuWindowItems: function(forceHideSeparator) {
-    for (let xid in firetray.Handler.windows)
-      this.hideSinglePopupMenuWindowItem(xid, forceHideSeparator);
+  hidePopupMenuWindowSeparator: function() {
+    LOG("hiding menuSeparatorWindows");
+    gtk.gtk_widget_hide(ctypes.cast(firetray.StatusIcon.menuSeparatorWindows, gtk.GtkWidget.ptr));
   },
 
   onScroll: function(icon, event, data) {
diff --git a/src/modules/gtk2/FiretrayWindow.jsm b/src/modules/gtk2/FiretrayWindow.jsm
index bfa3f0f..5336599 100644
--- a/src/modules/gtk2/FiretrayWindow.jsm
+++ b/src/modules/gtk2/FiretrayWindow.jsm
@@ -164,6 +164,23 @@ firetray.Window = {
     return null;
   },
 
+  unregisterWindowByXID: function(xid) {
+    firetray.Handler.windowsCount -= 1;
+    if (firetray.Handler.windows[xid].visibility) firetray.Handler.visibleWindowsCount -= 1;
+    if (firetray.Handler.windows.hasOwnProperty(xid)) {
+      if (!delete firetray.Handler.windows[xid])
+        throw new DeleteError();
+      firetray.Handler.gtkWindows.remove(xid);
+      firetray.Handler.gdkWindows.remove(xid);
+      firetray.StatusIcon.removePopupMenuWindowItem(xid);
+    } else {
+      ERROR("can't unregister unknown window "+xid);
+      return false;
+    }
+    LOG("window "+xid+" unregistered");
+    return true;
+  },
+
   saveWindowPositionAndSize: function(xid) {
     let gx = {}, gy = {}, gwidth = {}, gheight = {};
     firetray.Handler.windows[xid].baseWin.getPositionAndSize(gx, gy, gwidth, gheight);
@@ -420,6 +437,8 @@ firetray.Handler.dumpWindows = function() {
   for (let winId in firetray.Handler.windows) LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
 };
 
+firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow;
+
 firetray.Handler.registerWindow = function(win) {
   LOG("register window");
 
@@ -461,7 +480,7 @@ firetray.Handler.registerWindow = function(win) {
     gdk.gdk_window_add_filter(gdkWin, this.windows[xid].filterWindowCb, null);
 
   } catch (x) {
-    this._unregisterWindowByXID(xid);
+    firetray.Window.unregisterWindowByXID(xid);
     ERROR(x);
     return false;
   }
@@ -471,30 +490,11 @@ firetray.Handler.registerWindow = function(win) {
   return true;
 };
 
-firetray.Handler._unregisterWindowByXID = function(xid) {
-  this.windowsCount -= 1;
-  if (this.windows[xid].visibility) this.visibleWindowsCount -= 1;
-  if (this.windows.hasOwnProperty(xid)) {
-    if (!delete this.windows[xid])
-      throw new DeleteError();
-    this.gtkWindows.remove(xid);
-    this.gdkWindows.remove(xid);
-    firetray.StatusIcon.removePopupMenuWindowItem(xid);
-  } else {
-    ERROR("can't unregister unknown window "+xid);
-    return false;
-  }
-  LOG("window "+xid+" unregistered");
-  return true;
-};
-
-firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow;
-
 firetray.Handler.unregisterWindow = function(win) {
   LOG("unregister window");
 
   let xid = firetray.Window.getXIDFromChromeWindow(win);
-  return this._unregisterWindowByXID(xid);
+  return firetray.Window.unregisterWindowByXID(xid);
 };
 
 firetray.Handler.showSingleWindow = function(xid) {
@@ -510,12 +510,9 @@ firetray.Handler.showSingleWindow = function(xid) {
   firetray.Handler.windows[xid].visibility = true;
   firetray.Handler.visibleWindowsCount += 1;
 
-    try {
-  LOG("popupMenuWindowItemsHandled="+firetray.StatusIcon.popupMenuWindowItemsHandled());
   if (firetray.StatusIcon.popupMenuWindowItemsHandled())
     firetray.StatusIcon.hideSinglePopupMenuWindowItem(xid);
   firetray.Handler.showHideIcon();
-    } catch(x) {ERROR(x);}
 };
 
 // NOTE: we keep using high-level cross-plat BaseWindow.visibility (instead of

-- 
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