1
0
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:
foudfou 2011-09-03 01:07:14 +02:00
parent 4d19bb51d3
commit 8ab870aadb
5 changed files with 48 additions and 61 deletions

View File

@ -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):

View File

@ -1,3 +1,2 @@
extensions.moztray@foudil.fr.description=A system tray extension for linux.
popupMenu.itemLabel.View=Foudil
popupMenu.itemLabel.Exit=Exit
popupMenu.itemLabel.Quit=Quit

View File

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

View File

@ -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);

View File

@ -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();