[Pkg-mozext-commits] [firetray] 32/399: * add Quit functionallity to item in popupMenu * fix Makefile for stripping LOG() calls

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:09 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 8ab870aadb4810e08693dd0db8bc12ce0558dd1f
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sat Sep 3 01:07:14 2011 +0200

    * add Quit functionallity to item in popupMenu
    * fix Makefile for stripping LOG() calls
---
 src/Makefile                               |    9 ++---
 src/chrome/locale/en-US/overlay.properties |    3 +-
 src/modules/LibGtkStatusIcon.jsm           |   16 ++++++--
 src/modules/MoztHandler.jsm                |   55 ++++++++++++++++------------
 src/modules/commons.js                     |   26 -------------
 5 files changed, 48 insertions(+), 61 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 0c51c1e..05180ac 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -141,18 +141,17 @@ $(build_dir)/$(chrome_source_root)/%.js: $(chrome_source_root)/%.js
     cp -f $< $@; \
   else \
     echo "Stripping debug calls from JS file $<"; \
-    sed '/mozt\.Debug\.dump/d' $< > $@; \
-    sed '/mozt\.Debug\.debug/d' $< > $@; \
+    sed '/LOG(/d' $< > $@; \
   fi
 
-$(build_dir)/$(modules_dir)/commons.js: $(modules_dir)/commons.js
+$(build_dir)/$(modules_dir)/%: $(modules_dir)/%
 	@mkdir -p $(dir $@)
 	@if [[ "$(DEBUG)" =~ $(YES_RE) ]]; \
   then \
     cp -f $< $@; \
   else \
-    echo "Turning DEBUG_MODE off."; \
-    sed 's/DEBUG_MODE: true/DEBUG_MODE: false/' $< > $@; \
+    echo "Stripping debug calls from module $<"; \
+    sed '/LOG(/d' $< > $@; \
   fi
 
 $(build_dir):
diff --git a/src/chrome/locale/en-US/overlay.properties b/src/chrome/locale/en-US/overlay.properties
index 1ba65d5..2d4f601 100644
--- a/src/chrome/locale/en-US/overlay.properties
+++ b/src/chrome/locale/en-US/overlay.properties
@@ -1,3 +1,2 @@
 extensions.moztray at foudil.fr.description=A system tray extension for linux.
-popupMenu.itemLabel.View=Foudil
-popupMenu.itemLabel.Exit=Exit
+popupMenu.itemLabel.Quit=Quit
diff --git a/src/modules/LibGtkStatusIcon.jsm b/src/modules/LibGtkStatusIcon.jsm
index 1a76612..02342d6 100644
--- a/src/modules/LibGtkStatusIcon.jsm
+++ b/src/modules/LibGtkStatusIcon.jsm
@@ -77,9 +77,9 @@ var LibGtkStatusIcon = {
       ]);
 
     this.GtkMenu = ctypes.StructType("GtkMenu");
-
     this.GtkMenuShell = ctypes.StructType("GtkMenuShell");
     // use ctypes.cast(menu, LibGtkStatusIcon.GtkMenuShell.ptr);
+    this.GtkImageMenuItem = ctypes.StructType("GtkImageMenuItem");
 
     this.GtkMenuPositionFunc = ctypes.FunctionType(
       ctypes.default_abi, ctypes.void_t,
@@ -92,7 +92,7 @@ var LibGtkStatusIcon = {
        LibGObject.gpointer]).ptr;
 
     // Consts
-    // this.INDICATOR_MESSAGES_SERVER_TYPE = "message";
+    this.GTK_ICON_SIZE_MENU = 1;
 
     // Functions
 
@@ -111,12 +111,20 @@ var LibGtkStatusIcon = {
       "gtk_menu_new", ctypes.default_abi, this.GtkMenu.ptr);
 
     this.gtk_image_menu_item_new_with_label = this._lib.declare(
-      "gtk_image_menu_item_new_with_label", ctypes.default_abi, this.GtkWidget.ptr,
+      "gtk_image_menu_item_new_with_label", ctypes.default_abi, this.GtkImageMenuItem.ptr,
       LibGObject.gchar.ptr);
 
+    this.gtk_image_new_from_stock = this._lib.declare(
+      "gtk_image_new_from_stock", ctypes.default_abi, this.GtkWidget.ptr,
+      LibGObject.gchar.ptr, ctypes.int); // enum
+
+    this.gtk_image_menu_item_set_image = this._lib.declare(
+      "gtk_image_menu_item_set_image", ctypes.default_abi, ctypes.void_t,
+      this.GtkImageMenuItem.ptr, this.GtkWidget.ptr);
+
     this.gtk_menu_shell_append = this._lib.declare(
       "gtk_menu_shell_append", ctypes.default_abi, ctypes.void_t,
-      this.GtkMenuShell.ptr, this.GtkWidget.ptr);
+      this.GtkMenuShell.ptr, this.GtkImageMenuItem.ptr);
 
     this.gtk_widget_show_all = this._lib.declare(
       "gtk_widget_show_all", ctypes.default_abi, ctypes.void_t,
diff --git a/src/modules/MoztHandler.jsm b/src/modules/MoztHandler.jsm
index 6b83ed8..33eb354 100644
--- a/src/modules/MoztHandler.jsm
+++ b/src/modules/MoztHandler.jsm
@@ -22,10 +22,11 @@ if ("undefined" == typeof(mozt)) {
   var mozt = {};
 };
 
-// pointer to JS functions. should not be eaten by GC ("Running global cleanup
-// code from study base classes" ?)
-var mozt_activateCb;
+// pointers to JS functions. should *not* be eaten by GC ("Running global
+// cleanup code from study base classes" ?)
+var mozt_iconActivateCb;
 var mozt_popupMenuCb;
+var mozt_menuItemQuitActivateCb;
 
 /**
  * Singleton object for tray icon management
@@ -162,6 +163,17 @@ mozt.Handler = {
     }
   },
 
+  quitApplication: function() {
+    try {
+      let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
+        .getService(Ci.nsIAppStartup);
+      appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
+    } catch (x) {
+      Components.utils.reportError(x);
+      return;
+    }
+  },
+
   /*
    * @param strings l10n Strings passed from the XUL overlay
    */
@@ -197,22 +209,21 @@ mozt.Handler = {
 
       // build icon popup menu
       this.menu = LibGtkStatusIcon.gtk_menu_new();
-      // TODO: intl labels,
-      // gtk_image_menu_item_new_with_label ?
-		  var menuItemViewLabel = this.strings.GetStringFromName("popupMenu.itemLabel.View");
-      var menuItemView = LibGtkStatusIcon.gtk_image_menu_item_new_with_label(
-        menuItemViewLabel);
-/*
-      let image = LibGtkStatusIcon.gtk_image_new_from_file("myfile.png");
-      LibGtkStatusIcon.gtk_image_set_pixel_size( GTK_IMAGE ( image ), GTK_ICON_SIZE_MENU );
-      LibGtkStatusIcon.gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( menu_item ), image );
-*/
-		  var menuItemViewExit = this.strings.GetStringFromName("popupMenu.itemLabel.Exit");
-      var menuItemExit = LibGtkStatusIcon.gtk_image_menu_item_new_with_label(
-        menuItemViewExit);
+      // shouldn't need to g_utf16_to_utf8() thank to js-ctypes
+		  var menuItemQuitLabel = this.strings.GetStringFromName("popupMenu.itemLabel.Quit");
+      var menuItemQuit = LibGtkStatusIcon.gtk_image_menu_item_new_with_label(
+        menuItemQuitLabel);
+      var menuItemQuitIcon = LibGtkStatusIcon.gtk_image_new_from_stock(
+        "gtk-quit", LibGtkStatusIcon.GTK_ICON_SIZE_MENU);
+      LibGtkStatusIcon.gtk_image_menu_item_set_image(menuItemQuit, menuItemQuitIcon);
       var menuShell = ctypes.cast(this.menu, LibGtkStatusIcon.GtkMenuShell.ptr);
-      LibGtkStatusIcon.gtk_menu_shell_append(menuShell, menuItemView);
-      LibGtkStatusIcon.gtk_menu_shell_append(menuShell, menuItemExit);
+      LibGtkStatusIcon.gtk_menu_shell_append(menuShell, menuItemQuit);
+
+      mozt_menuItemQuitActivateCb = LibGObject.GCallback_t(
+        function(){mozt.Handler.quitApplication();});
+      LibGObject.g_signal_connect(menuItemQuit, "activate",
+                                  mozt_menuItemQuitActivateCb, null);
+
       var menuWidget = ctypes.cast(this.menu, LibGtkStatusIcon.GtkWidget.ptr);
       LibGtkStatusIcon.gtk_widget_show_all(menuWidget);
 
@@ -223,10 +234,6 @@ mozt.Handler = {
       LibGObject.g_signal_connect(this.trayIcon, "popup-menu",
                                   mozt_popupMenuCb, this.menu);
 
-/*
-    g_signal_connect (G_OBJECT (menuItemView), "activate", G_CALLBACK (trayView), window);
-    g_signal_connect (G_OBJECT (menuItemExit), "activate", G_CALLBACK (trayExit), NULL);
-*/
       // set tooltip.
       // GTK bug:
       // (firefox-bin:5302): Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
@@ -239,10 +246,10 @@ mozt.Handler = {
 
       // watch out for binding problems ! here we prefer to keep 'this' in
       // showHideToTray() and abandon the args.
-      mozt_activateCb = LibGObject.GCallback_t(
+      mozt_iconActivateCb = LibGObject.GCallback_t(
         function(){mozt.Handler.showHideToTray();});
       LibGObject.g_signal_connect(this.trayIcon, "activate",
-                                  mozt_activateCb, null);
+                                  mozt_iconActivateCb, null);
 
     } catch (x) {
       Components.utils.reportError(x);
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 49d5ab6..87a140e 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -34,29 +34,3 @@ if ("undefined" == typeof(mozt)) {
 mozt.Utils = {
   prefService: Services.prefs.getBranch("extensions.moztray.")
 };
-
-
-// var xpcomShutdownObserver = {
-// 	observe: function(subject, topic, data) {
-// 		if (topic == "xpcom-will-shutdown") {
-// 			mozt.Debug.debug('event: '
-//                        + 'subj: ' + subject
-//                        + 'topic ' + topic
-//                        + 'data ' + data);
-// 		}
-// 	},
-
-// 	get observerService() {
-// 		return Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
-// 	},
-
-// 	register: function() {
-// 		this.observerService.addObserver(this, "xpcom-will-shutdown", false);
-// 	},
-
-// 	unregister: function() {
-// 		this.observerService.removeObserver(this, "xpcom-will-shutdown");
-// 	},
-// };
-
-// xpcomShutdownObserver.register();

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