mirror of
https://github.com/moparisthebest/FireTray
synced 2024-11-10 19:15:08 -05:00
* add Quit functionallity to item in popupMenu
* fix Makefile for stripping LOG() calls
This commit is contained in:
parent
4d19bb51d3
commit
8ab870aadb
@ -141,18 +141,17 @@ $(build_dir)/$(chrome_source_root)/%.js: $(chrome_source_root)/%.js
|
|||||||
cp -f $< $@; \
|
cp -f $< $@; \
|
||||||
else \
|
else \
|
||||||
echo "Stripping debug calls from JS file $<"; \
|
echo "Stripping debug calls from JS file $<"; \
|
||||||
sed '/mozt\.Debug\.dump/d' $< > $@; \
|
sed '/LOG(/d' $< > $@; \
|
||||||
sed '/mozt\.Debug\.debug/d' $< > $@; \
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(build_dir)/$(modules_dir)/commons.js: $(modules_dir)/commons.js
|
$(build_dir)/$(modules_dir)/%: $(modules_dir)/%
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@if [[ "$(DEBUG)" =~ $(YES_RE) ]]; \
|
@if [[ "$(DEBUG)" =~ $(YES_RE) ]]; \
|
||||||
then \
|
then \
|
||||||
cp -f $< $@; \
|
cp -f $< $@; \
|
||||||
else \
|
else \
|
||||||
echo "Turning DEBUG_MODE off."; \
|
echo "Stripping debug calls from module $<"; \
|
||||||
sed 's/DEBUG_MODE: true/DEBUG_MODE: false/' $< > $@; \
|
sed '/LOG(/d' $< > $@; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(build_dir):
|
$(build_dir):
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
extensions.moztray@foudil.fr.description=A system tray extension for linux.
|
extensions.moztray@foudil.fr.description=A system tray extension for linux.
|
||||||
popupMenu.itemLabel.View=Foudil
|
popupMenu.itemLabel.Quit=Quit
|
||||||
popupMenu.itemLabel.Exit=Exit
|
|
||||||
|
@ -77,9 +77,9 @@ var LibGtkStatusIcon = {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
this.GtkMenu = ctypes.StructType("GtkMenu");
|
this.GtkMenu = ctypes.StructType("GtkMenu");
|
||||||
|
|
||||||
this.GtkMenuShell = ctypes.StructType("GtkMenuShell");
|
this.GtkMenuShell = ctypes.StructType("GtkMenuShell");
|
||||||
// use ctypes.cast(menu, LibGtkStatusIcon.GtkMenuShell.ptr);
|
// use ctypes.cast(menu, LibGtkStatusIcon.GtkMenuShell.ptr);
|
||||||
|
this.GtkImageMenuItem = ctypes.StructType("GtkImageMenuItem");
|
||||||
|
|
||||||
this.GtkMenuPositionFunc = ctypes.FunctionType(
|
this.GtkMenuPositionFunc = ctypes.FunctionType(
|
||||||
ctypes.default_abi, ctypes.void_t,
|
ctypes.default_abi, ctypes.void_t,
|
||||||
@ -92,7 +92,7 @@ var LibGtkStatusIcon = {
|
|||||||
LibGObject.gpointer]).ptr;
|
LibGObject.gpointer]).ptr;
|
||||||
|
|
||||||
// Consts
|
// Consts
|
||||||
// this.INDICATOR_MESSAGES_SERVER_TYPE = "message";
|
this.GTK_ICON_SIZE_MENU = 1;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
|
||||||
@ -111,12 +111,20 @@ var LibGtkStatusIcon = {
|
|||||||
"gtk_menu_new", ctypes.default_abi, this.GtkMenu.ptr);
|
"gtk_menu_new", ctypes.default_abi, this.GtkMenu.ptr);
|
||||||
|
|
||||||
this.gtk_image_menu_item_new_with_label = this._lib.declare(
|
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);
|
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(
|
this.gtk_menu_shell_append = this._lib.declare(
|
||||||
"gtk_menu_shell_append", ctypes.default_abi, ctypes.void_t,
|
"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(
|
this.gtk_widget_show_all = this._lib.declare(
|
||||||
"gtk_widget_show_all", ctypes.default_abi, ctypes.void_t,
|
"gtk_widget_show_all", ctypes.default_abi, ctypes.void_t,
|
||||||
|
@ -22,10 +22,11 @@ if ("undefined" == typeof(mozt)) {
|
|||||||
var mozt = {};
|
var mozt = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
// pointer to JS functions. should not be eaten by GC ("Running global cleanup
|
// pointers to JS functions. should *not* be eaten by GC ("Running global
|
||||||
// code from study base classes" ?)
|
// cleanup code from study base classes" ?)
|
||||||
var mozt_activateCb;
|
var mozt_iconActivateCb;
|
||||||
var mozt_popupMenuCb;
|
var mozt_popupMenuCb;
|
||||||
|
var mozt_menuItemQuitActivateCb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton object for tray icon management
|
* 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
|
* @param strings l10n Strings passed from the XUL overlay
|
||||||
*/
|
*/
|
||||||
@ -197,22 +209,21 @@ mozt.Handler = {
|
|||||||
|
|
||||||
// build icon popup menu
|
// build icon popup menu
|
||||||
this.menu = LibGtkStatusIcon.gtk_menu_new();
|
this.menu = LibGtkStatusIcon.gtk_menu_new();
|
||||||
// TODO: intl labels,
|
// shouldn't need to g_utf16_to_utf8() thank to js-ctypes
|
||||||
// gtk_image_menu_item_new_with_label ?
|
var menuItemQuitLabel = this.strings.GetStringFromName("popupMenu.itemLabel.Quit");
|
||||||
var menuItemViewLabel = this.strings.GetStringFromName("popupMenu.itemLabel.View");
|
var menuItemQuit = LibGtkStatusIcon.gtk_image_menu_item_new_with_label(
|
||||||
var menuItemView = LibGtkStatusIcon.gtk_image_menu_item_new_with_label(
|
menuItemQuitLabel);
|
||||||
menuItemViewLabel);
|
var menuItemQuitIcon = LibGtkStatusIcon.gtk_image_new_from_stock(
|
||||||
/*
|
"gtk-quit", LibGtkStatusIcon.GTK_ICON_SIZE_MENU);
|
||||||
let image = LibGtkStatusIcon.gtk_image_new_from_file("myfile.png");
|
LibGtkStatusIcon.gtk_image_menu_item_set_image(menuItemQuit, menuItemQuitIcon);
|
||||||
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);
|
|
||||||
var menuShell = ctypes.cast(this.menu, LibGtkStatusIcon.GtkMenuShell.ptr);
|
var menuShell = ctypes.cast(this.menu, LibGtkStatusIcon.GtkMenuShell.ptr);
|
||||||
LibGtkStatusIcon.gtk_menu_shell_append(menuShell, menuItemView);
|
LibGtkStatusIcon.gtk_menu_shell_append(menuShell, menuItemQuit);
|
||||||
LibGtkStatusIcon.gtk_menu_shell_append(menuShell, menuItemExit);
|
|
||||||
|
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);
|
var menuWidget = ctypes.cast(this.menu, LibGtkStatusIcon.GtkWidget.ptr);
|
||||||
LibGtkStatusIcon.gtk_widget_show_all(menuWidget);
|
LibGtkStatusIcon.gtk_widget_show_all(menuWidget);
|
||||||
|
|
||||||
@ -223,10 +234,6 @@ mozt.Handler = {
|
|||||||
LibGObject.g_signal_connect(this.trayIcon, "popup-menu",
|
LibGObject.g_signal_connect(this.trayIcon, "popup-menu",
|
||||||
mozt_popupMenuCb, this.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.
|
// set tooltip.
|
||||||
// GTK bug:
|
// GTK bug:
|
||||||
// (firefox-bin:5302): Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
|
// (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
|
// watch out for binding problems ! here we prefer to keep 'this' in
|
||||||
// showHideToTray() and abandon the args.
|
// showHideToTray() and abandon the args.
|
||||||
mozt_activateCb = LibGObject.GCallback_t(
|
mozt_iconActivateCb = LibGObject.GCallback_t(
|
||||||
function(){mozt.Handler.showHideToTray();});
|
function(){mozt.Handler.showHideToTray();});
|
||||||
LibGObject.g_signal_connect(this.trayIcon, "activate",
|
LibGObject.g_signal_connect(this.trayIcon, "activate",
|
||||||
mozt_activateCb, null);
|
mozt_iconActivateCb, null);
|
||||||
|
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
Components.utils.reportError(x);
|
Components.utils.reportError(x);
|
||||||
|
@ -34,29 +34,3 @@ if ("undefined" == typeof(mozt)) {
|
|||||||
mozt.Utils = {
|
mozt.Utils = {
|
||||||
prefService: Services.prefs.getBranch("extensions.moztray.")
|
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();
|
|
||||||
|
Loading…
Reference in New Issue
Block a user