1
0
mirror of https://github.com/moparisthebest/FireTray synced 2025-01-09 12:38:04 -05:00

add preferences item to popup menu

This commit is contained in:
foudfou 2013-10-25 17:49:01 +02:00
parent 80b0384397
commit c96ff01ebd
3 changed files with 23 additions and 4 deletions

View File

@ -1,5 +1,6 @@
extensions.{9533f794-00b4-4354-aa15-c2bbda6989f8}.description=A system tray extension for linux. extensions.{9533f794-00b4-4354-aa15-c2bbda6989f8}.description=A system tray extension for linux.
popupMenu.itemLabel.ResetIcon=Reset icon popupMenu.itemLabel.ResetIcon=Reset icon
popupMenu.itemLabel.Preferences=Preferences
popupMenu.itemLabel.Quit=Quit popupMenu.itemLabel.Quit=Quit
popupMenu.itemLabel.NewWindow=New window popupMenu.itemLabel.NewWindow=New window
popupMenu.itemLabel.NewMessage=New message popupMenu.itemLabel.NewMessage=New message

View File

@ -392,6 +392,19 @@ firetray.Handler = {
return url; return url;
}, },
openPrefWindow: function() {
if (null == firetray.Handler._preferencesWindow ||
firetray.Handler._preferencesWindow.closed) {
for(var first in firetray.Handler.windows) break;
firetray.Handler._preferencesWindow =
firetray.Handler.windows[first].chromeWin.openDialog(
"chrome://firetray/content/options.xul", null,
"chrome,titlebar,toolbar,centerscreen", null);
}
firetray.Handler._preferencesWindow.focus();
},
openBrowserWindow: function() { openBrowserWindow: function() {
try { try {
var home = firetray.Handler._getHomePage(); var home = firetray.Handler._getHomePage();
@ -402,8 +415,8 @@ firetray.Handler = {
firetray.Handler.timers['open-browser-window'] = firetray.Handler.timers['open-browser-window'] =
firetray.Utils.timer(FIRETRAY_DELAY_NOWAIT_MILLISECONDS, firetray.Utils.timer(FIRETRAY_DELAY_NOWAIT_MILLISECONDS,
Ci.nsITimer.TYPE_ONE_SHOT, function() { Ci.nsITimer.TYPE_ONE_SHOT, function() {
for(var key in firetray.Handler.windows) break; for(var first in firetray.Handler.windows) break;
firetray.Handler.windows[key].chromeWin.open(home); firetray.Handler.windows[first].chromeWin.open(home);
}); });
} catch (x) { log.error(x); } } catch (x) { log.error(x); }
}, },

View File

@ -43,11 +43,16 @@ firetray.PopupMenu = {
addMenuSeparator = true; addMenuSeparator = true;
} }
var menuSeparator;
if (addMenuSeparator) { if (addMenuSeparator) {
var menuSeparator = gtk.gtk_separator_menu_item_new(); menuSeparator = gtk.gtk_separator_menu_item_new();
gtk.gtk_menu_shell_append(this.menuShell, ctypes.cast(menuSeparator, gtk.GtkWidget.ptr)); gtk.gtk_menu_shell_append(this.menuShell, ctypes.cast(menuSeparator, gtk.GtkWidget.ptr));
} }
this.addItem("Preferences", "gtk-preferences", "activate", firetray.Handler.openPrefWindow);
menuSeparator = gtk.gtk_separator_menu_item_new();
gtk.gtk_menu_shell_append(this.menuShell, ctypes.cast(menuSeparator, gtk.GtkWidget.ptr));
this.addItem("Quit", "gtk-quit", "activate", firetray.Handler.quitApplication); this.addItem("Quit", "gtk-quit", "activate", firetray.Handler.quitApplication);
var menuWidget = ctypes.cast(this.menu, gtk.GtkWidget.ptr); var menuWidget = ctypes.cast(this.menu, gtk.GtkWidget.ptr);
@ -67,7 +72,7 @@ firetray.PopupMenu = {
}, },
addItem: function(itemName, iconName, action, callback) { addItem: function(itemName, iconName, action, callback) {
var menuItemLabel = firetray.Utils.strings.GetStringFromName("popupMenu.itemLabel."+itemName); // shouldn't need to convert to utf8 later thank to js-ctypes var menuItemLabel = firetray.Utils.strings.GetStringFromName("popupMenu.itemLabel."+itemName); // shouldn't need to convert to utf8 later thank to js-ctypes
var menuItem = gtk.gtk_image_menu_item_new_with_label(menuItemLabel); var menuItem = gtk.gtk_image_menu_item_new_with_label(menuItemLabel);
var menuItemIcon = gtk.gtk_image_new_from_stock(iconName, gtk.GTK_ICON_SIZE_MENU); var menuItemIcon = gtk.gtk_image_new_from_stock(iconName, gtk.GTK_ICON_SIZE_MENU);
gtk.gtk_image_menu_item_set_image(menuItem, menuItemIcon); gtk.gtk_image_menu_item_set_image(menuItem, menuItemIcon);