From 389e6cec5129f55f75f20b7091d4c29d5b11f3bb Mon Sep 17 00:00:00 2001 From: foudfou Date: Sat, 22 Nov 2014 18:47:51 +0100 Subject: [PATCH] Add 'middle_click' option. Mainly intended for AppIndicator. Not used in winnt yet. --- src/chrome/content/options.js | 4 +- src/chrome/content/options.xul | 10 +++++ src/chrome/locale/de-DE/options.dtd | 4 ++ src/chrome/locale/de-DE/overlay.properties | 1 + src/chrome/locale/en-US/options.dtd | 4 ++ src/chrome/locale/en-US/overlay.properties | 1 + src/chrome/locale/es-AR/options.dtd | 4 ++ src/chrome/locale/es-AR/overlay.properties | 1 + src/chrome/locale/fr/options.dtd | 4 ++ src/chrome/locale/fr/overlay.properties | 1 + src/chrome/locale/hr-HR/options.dtd | 4 ++ src/chrome/locale/hr-HR/overlay.properties | 1 + src/chrome/locale/it/options.dtd | 4 ++ src/chrome/locale/it/overlay.properties | 1 + src/chrome/locale/nl/options.dtd | 4 ++ src/chrome/locale/nl/overlay.properties | 1 + src/chrome/locale/pl-PL/options.dtd | 4 ++ src/chrome/locale/pl-PL/overlay.properties | 1 + src/chrome/locale/ru-RU/options.dtd | 4 ++ src/chrome/locale/ru-RU/overlay.properties | 1 + src/chrome/locale/sk-SK/options.dtd | 4 ++ src/chrome/locale/sk-SK/overlay.properties | 1 + src/chrome/locale/uk-UA/options.dtd | 4 ++ src/chrome/locale/uk-UA/overlay.properties | 1 + src/chrome/locale/zh-TW/options.dtd | 4 ++ src/chrome/locale/zh-TW/overlay.properties | 1 + src/chrome/skin/overlay.css | 4 +- src/defaults/preferences/prefs.js | 1 + src/modules/FiretrayHandler.jsm | 4 ++ src/modules/commons.js | 8 +++- src/modules/linux/FiretrayAppIndicator.jsm | 37 +++++++++++++---- src/modules/linux/FiretrayGtkStatusIcon.jsm | 44 ++++++++++++++++++--- src/modules/linux/FiretrayPopupMenu.jsm | 20 ++++++---- src/modules/linux/FiretrayWindow.jsm | 1 + src/modules/winnt/FiretrayStatusIcon.jsm | 8 ++++ 35 files changed, 176 insertions(+), 25 deletions(-) diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index 67809f0..131e6ff 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -53,7 +53,8 @@ var firetrayUIOptions = { this.hideUnsupportedOptions([ 'ui_hides_last_only', 'ui_show_activates', 'ui_remember_desktop', 'app_icon_default', 'ui_show_icon_on_hide', 'ui_scroll_hides', - 'ui_radiogroup_scroll', 'ui_scroll_hides', 'newmail_icon_names' + 'ui_radiogroup_scroll', 'ui_scroll_hides', 'ui_middle_click', + 'newmail_icon_names' ]); } else if (firetray.AppIndicator) { this.hideUnsupportedOptions([ @@ -88,6 +89,7 @@ var firetrayUIOptions = { case 'ui_show_icon_on_hide': case 'ui_scroll_hides': case 'ui_radiogroup_scroll': + case 'ui_middle_click': document.getElementById(id).hidden = true; break; case 'ui_scroll_hides': diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul index fb2c868..e01be25 100644 --- a/src/chrome/content/options.xul +++ b/src/chrome/content/options.xul @@ -71,6 +71,7 @@ + @@ -120,6 +121,15 @@ + + + + + diff --git a/src/chrome/locale/de-DE/options.dtd b/src/chrome/locale/de-DE/options.dtd index 6900ffd..c540eae 100644 --- a/src/chrome/locale/de-DE/options.dtd +++ b/src/chrome/locale/de-DE/options.dtd @@ -42,6 +42,10 @@ + + + + diff --git a/src/chrome/locale/de-DE/overlay.properties b/src/chrome/locale/de-DE/overlay.properties index 7f8d3e0..9cd9ce3 100644 --- a/src/chrome/locale/de-DE/overlay.properties +++ b/src/chrome/locale/de-DE/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Beenden popupMenu.itemLabel.NewWindow=Neues Fenster popupMenu.itemLabel.NewMessage=Neue Nachricht popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 ungelesene Nachricht;#1 ungelesene Nachrichten tooltip.new_messages=Neue Nachrichten! diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd index f512b3a..b88d4b9 100644 --- a/src/chrome/locale/en-US/options.dtd +++ b/src/chrome/locale/en-US/options.dtd @@ -43,6 +43,10 @@ + + + + diff --git a/src/chrome/locale/en-US/overlay.properties b/src/chrome/locale/en-US/overlay.properties index 3ad0107..331b4ec 100644 --- a/src/chrome/locale/en-US/overlay.properties +++ b/src/chrome/locale/en-US/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Quit popupMenu.itemLabel.NewWindow=New window popupMenu.itemLabel.NewMessage=New message popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 unread message;#1 unread messages tooltip.new_messages=New messages ! diff --git a/src/chrome/locale/es-AR/options.dtd b/src/chrome/locale/es-AR/options.dtd index 52c6f4f..6bc9a41 100644 --- a/src/chrome/locale/es-AR/options.dtd +++ b/src/chrome/locale/es-AR/options.dtd @@ -38,6 +38,10 @@ + + + + diff --git a/src/chrome/locale/es-AR/overlay.properties b/src/chrome/locale/es-AR/overlay.properties index 112bf61..8331e54 100644 --- a/src/chrome/locale/es-AR/overlay.properties +++ b/src/chrome/locale/es-AR/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Salir popupMenu.itemLabel.NewWindow=Nueva ventana popupMenu.itemLabel.NewMessage=Nuevo mensaje popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 mensaje no leido;#1 mensajes no leídos tooltip.new_messages=Nuevos mensajes ! diff --git a/src/chrome/locale/fr/options.dtd b/src/chrome/locale/fr/options.dtd index 03cdeba..befbd1a 100644 --- a/src/chrome/locale/fr/options.dtd +++ b/src/chrome/locale/fr/options.dtd @@ -38,6 +38,10 @@ + + + + diff --git a/src/chrome/locale/fr/overlay.properties b/src/chrome/locale/fr/overlay.properties index 47a7800..4767df7 100644 --- a/src/chrome/locale/fr/overlay.properties +++ b/src/chrome/locale/fr/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Quitter popupMenu.itemLabel.NewWindow=Nouvelle fenêtre popupMenu.itemLabel.NewMessage=Nouveau message popupMenu.itemLabel.ShowHide=Montrer/Cacher +popupMenu.itemLabel.ActivateLast=Activer la dernière fenêtre tooltip.unread_messages=#1 mesage non lu;#1 messages non lus tooltip.new_messages=Nouveaux messages ! diff --git a/src/chrome/locale/hr-HR/options.dtd b/src/chrome/locale/hr-HR/options.dtd index 4178099..1e85e05 100644 --- a/src/chrome/locale/hr-HR/options.dtd +++ b/src/chrome/locale/hr-HR/options.dtd @@ -38,6 +38,10 @@ + + + + diff --git a/src/chrome/locale/hr-HR/overlay.properties b/src/chrome/locale/hr-HR/overlay.properties index b3f4e8c..a606e4b 100644 --- a/src/chrome/locale/hr-HR/overlay.properties +++ b/src/chrome/locale/hr-HR/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Zatvori popupMenu.itemLabel.NewWindow=Novi prozor popupMenu.itemLabel.NewMessage=Nova poruka popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 nepročitana poruka;#1 nepročitano poruka tooltip.new_messages=Nove poruke! diff --git a/src/chrome/locale/it/options.dtd b/src/chrome/locale/it/options.dtd index 8e09ffb..22f61c4 100644 --- a/src/chrome/locale/it/options.dtd +++ b/src/chrome/locale/it/options.dtd @@ -38,6 +38,10 @@ + + + + diff --git a/src/chrome/locale/it/overlay.properties b/src/chrome/locale/it/overlay.properties index f3c4013..cb44057 100644 --- a/src/chrome/locale/it/overlay.properties +++ b/src/chrome/locale/it/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Esci popupMenu.itemLabel.NewWindow=Nuova finestra popupMenu.itemLabel.NewMessage=Nuovo messaggio popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 messaggio non letto;#1 messaggi non letti tooltip.new_messages=Nuovi messaggi diff --git a/src/chrome/locale/nl/options.dtd b/src/chrome/locale/nl/options.dtd index f17b722..15504d0 100644 --- a/src/chrome/locale/nl/options.dtd +++ b/src/chrome/locale/nl/options.dtd @@ -38,6 +38,10 @@ + + + + diff --git a/src/chrome/locale/nl/overlay.properties b/src/chrome/locale/nl/overlay.properties index df22f86..6b5c61e 100644 --- a/src/chrome/locale/nl/overlay.properties +++ b/src/chrome/locale/nl/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Stoppen popupMenu.itemLabel.NewWindow=Nieuw venster popupMenu.itemLabel.NewMessage=Nieuw bericht popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 ongelezen bericht;#1 ongelezen berichten tooltip.new_messages=Nieuwe berichten! diff --git a/src/chrome/locale/pl-PL/options.dtd b/src/chrome/locale/pl-PL/options.dtd index e9f185a..b30732b 100644 --- a/src/chrome/locale/pl-PL/options.dtd +++ b/src/chrome/locale/pl-PL/options.dtd @@ -43,6 +43,10 @@ + + + + diff --git a/src/chrome/locale/pl-PL/overlay.properties b/src/chrome/locale/pl-PL/overlay.properties index 215e3d1..500dd10 100644 --- a/src/chrome/locale/pl-PL/overlay.properties +++ b/src/chrome/locale/pl-PL/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Wyjdź popupMenu.itemLabel.NewWindow=Nowe okno popupMenu.itemLabel.NewMessage=Nowa wiadomość popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 nieprzeczytana wiadomość;#1 nieprzeczytane wiadomości tooltip.new_messages=Nowe wiadomości ! diff --git a/src/chrome/locale/ru-RU/options.dtd b/src/chrome/locale/ru-RU/options.dtd index 3e031b8..19461f5 100644 --- a/src/chrome/locale/ru-RU/options.dtd +++ b/src/chrome/locale/ru-RU/options.dtd @@ -43,6 +43,10 @@ + + + + diff --git a/src/chrome/locale/ru-RU/overlay.properties b/src/chrome/locale/ru-RU/overlay.properties index 899f3cd..201a719 100644 --- a/src/chrome/locale/ru-RU/overlay.properties +++ b/src/chrome/locale/ru-RU/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Выход popupMenu.itemLabel.NewWindow=Новое окно popupMenu.itemLabel.NewMessage=Создать сообщение popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 непрочитанных сообщений;#1 непрочитанных сообщений tooltip.new_messages=Новые сообщения ! diff --git a/src/chrome/locale/sk-SK/options.dtd b/src/chrome/locale/sk-SK/options.dtd index 513f480..7566d09 100644 --- a/src/chrome/locale/sk-SK/options.dtd +++ b/src/chrome/locale/sk-SK/options.dtd @@ -43,6 +43,10 @@ + + + + diff --git a/src/chrome/locale/sk-SK/overlay.properties b/src/chrome/locale/sk-SK/overlay.properties index bbab61c..9107a71 100644 --- a/src/chrome/locale/sk-SK/overlay.properties +++ b/src/chrome/locale/sk-SK/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Koniec popupMenu.itemLabel.NewWindow=Nové okno popupMenu.itemLabel.NewMessage=Nová správa popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 neprečítaná správa;#1 neprečítané správy;#1 neprečítaných správ tooltip.new_messages=Nové správy! diff --git a/src/chrome/locale/uk-UA/options.dtd b/src/chrome/locale/uk-UA/options.dtd index c09d625..a630060 100644 --- a/src/chrome/locale/uk-UA/options.dtd +++ b/src/chrome/locale/uk-UA/options.dtd @@ -43,6 +43,10 @@ + + + + diff --git a/src/chrome/locale/uk-UA/overlay.properties b/src/chrome/locale/uk-UA/overlay.properties index c814946..bf6e569 100644 --- a/src/chrome/locale/uk-UA/overlay.properties +++ b/src/chrome/locale/uk-UA/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=Вийти popupMenu.itemLabel.NewWindow=Нове вікно popupMenu.itemLabel.NewMessage=Нове повідомлення popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 непрочитане повідомлення;#1 непрочитані повідомлення tooltip.new_messages=Нові повідомлення! diff --git a/src/chrome/locale/zh-TW/options.dtd b/src/chrome/locale/zh-TW/options.dtd index 76e17ef..910ead7 100644 --- a/src/chrome/locale/zh-TW/options.dtd +++ b/src/chrome/locale/zh-TW/options.dtd @@ -38,6 +38,10 @@ + + + + diff --git a/src/chrome/locale/zh-TW/overlay.properties b/src/chrome/locale/zh-TW/overlay.properties index 75f1758..7103478 100644 --- a/src/chrome/locale/zh-TW/overlay.properties +++ b/src/chrome/locale/zh-TW/overlay.properties @@ -5,5 +5,6 @@ popupMenu.itemLabel.Quit=結束 popupMenu.itemLabel.NewWindow=開新視窗 popupMenu.itemLabel.NewMessage=新增訊息 popupMenu.itemLabel.ShowHide=Show/Hide +popupMenu.itemLabel.ActivateLast=Activate last window tooltip.unread_messages=#1 封未讀訊息;#1 封未讀訊息 tooltip.new_messages=有新訊息! diff --git a/src/chrome/skin/overlay.css b/src/chrome/skin/overlay.css index 7e5e64d..028fb12 100644 --- a/src/chrome/skin/overlay.css +++ b/src/chrome/skin/overlay.css @@ -15,12 +15,12 @@ treechildren::-moz-tree-checkbox(checked, disabled) { /* properties="disabled" */ treechildren::-moz-tree-cell-text(disabled) { - color: GrayText; + color: GrayText; } /* treechildren::-moz-tree-cell(disabled) { - background-color: #eeeeee; + background-color: #eeeeee; } */ diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js index 7d0e508..b00e6e1 100644 --- a/src/defaults/preferences/prefs.js +++ b/src/defaults/preferences/prefs.js @@ -21,6 +21,7 @@ pref("extensions.firetray.new_mail_icon_names", '["indicator-messages-new", "mai pref("extensions.firetray.show_icon_on_hide", false); pref("extensions.firetray.scroll_hides", true); pref("extensions.firetray.scroll_mode", "down_hides"); +pref("extensions.firetray.middle_click", 0); pref("extensions.firetray.chat_icon_enable", true); pref("extensions.firetray.chat_icon_blink", true); pref("extensions.firetray.chat_icon_blink_style", 0); diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 4c1f67f..b3bdeeb 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -571,6 +571,10 @@ firetray.PrefListener = new PrefListener( firetray.Messaging.updateMsgCountWithCb(); break; + case 'middle_click': + firetray.StatusIcon.middleClickActionChanged(); + break; + case 'chat_icon_enable': firetray.Handler.toggleChat(firetray.Handler.isChatEnabled()); break; diff --git a/src/modules/commons.js b/src/modules/commons.js index 7e9bec4..09b49f9 100644 --- a/src/modules/commons.js +++ b/src/modules/commons.js @@ -3,10 +3,11 @@ /* for now, logging facilities (imported from logging.jsm) and Services are automatically provided by this module */ var EXPORTED_SYMBOLS = - [ "firetray", "FIRETRAY_VERSION", "FIRETRAY_OS_SUPPORT", - "FIRETRAY_ID", "FIRETRAY_PREF_BRANCH", "FIRETRAY_SPLASH_PAGE", + [ "firetray", "FIRETRAY_VERSION", "FIRETRAY_OS_SUPPORT", "FIRETRAY_ID", + "FIRETRAY_PREF_BRANCH", "FIRETRAY_SPLASH_PAGE", "FIRETRAY_APPLICATION_ICON_TYPE_THEMED", "FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM", + "FIRETRAY_MIDDLE_CLICK_ACTIVATE_LAST", "FIRETRAY_MIDDLE_CLICK_SHOW_HIDE", "FIRETRAY_NOTIFICATION_MESSAGE_COUNT", "FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON", "FIRETRAY_IM_STATUS_AVAILABLE", "FIRETRAY_IM_STATUS_AWAY", @@ -33,6 +34,9 @@ const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/"; const FIRETRAY_APPLICATION_ICON_TYPE_THEMED = 0; const FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM = 1; +const FIRETRAY_MIDDLE_CLICK_ACTIVATE_LAST = 0; +const FIRETRAY_MIDDLE_CLICK_SHOW_HIDE = 1; + const FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD = 0; const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1; diff --git a/src/modules/linux/FiretrayAppIndicator.jsm b/src/modules/linux/FiretrayAppIndicator.jsm index a48ce23..b07311c 100644 --- a/src/modules/linux/FiretrayAppIndicator.jsm +++ b/src/modules/linux/FiretrayAppIndicator.jsm @@ -40,14 +40,11 @@ firetray.AppIndicator = { this.addCallbacks(); - for (let item in firetray.PopupMenu.menuShowHide) { - firetray.PopupMenu.showItem(firetray.PopupMenu.menuShowHide[item]); + for (let item in firetray.PopupMenu.menuItem) { + firetray.PopupMenu.showItem(firetray.PopupMenu.menuItem[item]); } - let menuItemShowHideWidget = ctypes.cast( - firetray.PopupMenu.menuShowHide.item, gtk.GtkWidget.ptr); - // FIXME: XXX should be option ShowHide or ActivateLast - appind3.app_indicator_set_secondary_activate_target( - this.indicator, menuItemShowHideWidget); + + this.attachMiddleClickCallback(); firetray.Handler.setIconTooltipDefault(); this.initialized = true; @@ -72,6 +69,24 @@ firetray.AppIndicator = { firetray.AppIndicator.callbacks.onScroll, null); }, + attachMiddleClickCallback: function(pref) { + let pref = firetray.Utils.prefService.getIntPref("middle_click"); + if (pref === FIRETRAY_MIDDLE_CLICK_ACTIVATE_LAST) { + item = firetray.PopupMenu.menuItem.activateLast; + firetray.PopupMenu.showItem(firetray.PopupMenu.menuItem.activateLast); + } else if (pref === FIRETRAY_MIDDLE_CLICK_SHOW_HIDE) { + item = firetray.PopupMenu.menuItem.showHide; + firetray.PopupMenu.hideItem(firetray.PopupMenu.menuItem.activateLast); + } else { + log.error("Unknown pref value for 'middle_click': "+pref); + return false; + } + let menuItemShowHideWidget = ctypes.cast(item, gtk.GtkWidget.ptr); + appind3.app_indicator_set_secondary_activate_target( + this.indicator, menuItemShowHideWidget); + return true; + }, + onConnectionChanged: function(indicator, connected, data) { log.debug("AppIndicator connection-changed: "+connected); }, @@ -90,6 +105,12 @@ firetray.StatusIcon.initImpl = firetray.StatusIcon.shutdownImpl = firetray.AppIndicator.shutdown.bind(firetray.AppIndicator); +firetray.StatusIcon.middleClickActionChanged = function() { + log.debug("middleClickActionChanged"); + firetray.AppIndicator.attachMiddleClickCallback(); +}; + + firetray.Handler.setIconImageDefault = function() { log.debug("setIconImageDefault"); appind3.app_indicator_set_icon(firetray.AppIndicator.indicator, @@ -116,7 +137,7 @@ firetray.Handler.setIconTooltip = function(toolTipStr) { log.debug("setIconTooltip"); if (!firetray.AppIndicator.indicator) return false; - firetray.PopupMenu.setItemLabel(firetray.PopupMenu.menuShowHide.tip, + firetray.PopupMenu.setItemLabel(firetray.PopupMenu.menuItem.tip, toolTipStr); return true; }; diff --git a/src/modules/linux/FiretrayGtkStatusIcon.jsm b/src/modules/linux/FiretrayGtkStatusIcon.jsm index 2182f2d..87ceaab 100644 --- a/src/modules/linux/FiretrayGtkStatusIcon.jsm +++ b/src/modules/linux/FiretrayGtkStatusIcon.jsm @@ -104,11 +104,37 @@ firetray.GtkStatusIcon = { "activate", firetray.GtkStatusIcon.callbacks.iconActivate, null); log.debug("g_connect activate="+handlerId); - this.callbacks.iconMiddleClick = gtk.GCallbackStatusIconMiddleClick_t( - firetray.Handler.activateLastWindowCb, null, FIRETRAY_CB_SENTINEL); - handlerId = gobject.g_signal_connect(firetray.GtkStatusIcon.trayIcon, - "button-press-event", firetray.GtkStatusIcon.callbacks.iconMiddleClick, null); - log.debug("g_connect middleClick="+handlerId); + let pref = firetray.Utils.prefService.getIntPref("middle_click"); + this.attachMiddleClickCallback(pref); + }, + + attachMiddleClickCallback: function(pref) { + log.debug("attachMiddleClickCallback pref="+pref); + if (pref === FIRETRAY_MIDDLE_CLICK_ACTIVATE_LAST) { + this.callbacks.iconMiddleClick = gtk.GCallbackStatusIconMiddleClick_t( + firetray.Handler.activateLastWindowCb, null, FIRETRAY_CB_SENTINEL); + } else if (pref === FIRETRAY_MIDDLE_CLICK_SHOW_HIDE) { + this.callbacks.iconMiddleClick = gtk.GCallbackStatusIconMiddleClick_t( + function(widget, event, data) {firetray.Handler.showHideAllWindows(); return true;}, + null, FIRETRAY_CB_SENTINEL); + } else { + log.error("Unknown pref value for 'middle_click': "+pref); + return; + } + this.callbacks.iconMiddleClickId = gobject.g_signal_connect( + firetray.GtkStatusIcon.trayIcon, + "button-press-event", firetray.GtkStatusIcon.callbacks.iconMiddleClick, + null); + log.debug("g_connect middleClick="+this.callbacks.iconMiddleClickId); + }, + + detachMiddleClickCallback: function() { + log.debug("detachMiddleClickCallback"); + gobject.g_signal_handler_disconnect( + firetray.GtkStatusIcon.trayIcon, + gobject.gulong(this.callbacks.iconMiddleClickId) + ); + delete this.callbacks.iconMiddleClickId; }, onScroll: function(icon, event, data) { @@ -150,6 +176,14 @@ firetray.StatusIcon.initImpl = firetray.StatusIcon.shutdownImpl = firetray.GtkStatusIcon.shutdown.bind(firetray.GtkStatusIcon); +firetray.StatusIcon.middleClickActionChanged = function() { + log.debug("middleClickActionChanged"); + let pref = firetray.Utils.prefService.getIntPref("middle_click"); + firetray.GtkStatusIcon.detachMiddleClickCallback(); + firetray.GtkStatusIcon.attachMiddleClickCallback(pref); +}; + + firetray.Handler.loadIcons = firetray.GtkStatusIcon.loadThemedIcons; firetray.Handler.setIconImageDefault = function() { diff --git a/src/modules/linux/FiretrayPopupMenu.jsm b/src/modules/linux/FiretrayPopupMenu.jsm index 40957b0..6a8621a 100644 --- a/src/modules/linux/FiretrayPopupMenu.jsm +++ b/src/modules/linux/FiretrayPopupMenu.jsm @@ -21,14 +21,14 @@ if ("undefined" == typeof(firetray.StatusIcon)) firetray.PopupMenu = { - MENU_ITEM_WINDOWS_POSITION: 3, + MENU_ITEM_WINDOWS_POSITION: 4, initialized: false, callbacks: {menuItemWindowActivate: {}}, // FIXME: try to store them into a ctypes array/struct. menu: null, menuShell: null, menuSeparatorWindows: null, - menuShowHide: {tip: null, sep: null, item: null}, + menuItem: {tip: null, showHide: null, activateLast: null, sep: null}, init: function() { this.menu = gtk.gtk_menu_new(); @@ -113,15 +113,21 @@ firetray.PopupMenu = { }, prependAppIndicatorItems: function() { - this.menuShowHide.sep = gtk.gtk_separator_menu_item_new(); - gtk.gtk_menu_shell_prepend(this.menuShell, ctypes.cast(this.menuShowHide.sep, + this.menuItem.sep = gtk.gtk_separator_menu_item_new(); + gtk.gtk_menu_shell_prepend(this.menuShell, ctypes.cast(this.menuItem.sep, gtk.GtkWidget.ptr)); - this.menuShowHide.item = this.addItem({ + + this.menuItem.activateLast = this.addItem({ + itemName:"ActivateLast", iconName:null, action:"activate", callback: + firetray.Handler.showAllWindowsAndActivate, inFront: true}); + + this.menuItem.showHide = this.addItem({ itemName:"ShowHide", iconName:"gtk-go-down", action:"activate", callback: firetray.Handler.showHideAllWindows, inFront: true}); - this.menuShowHide.tip = this.createAndAddItemToMenuAt(0); + + this.menuItem.tip = this.createAndAddItemToMenuAt(0); gtk.gtk_widget_set_sensitive( - ctypes.cast(this.menuShowHide.tip, gtk.GtkWidget.ptr), false); + ctypes.cast(this.menuItem.tip, gtk.GtkWidget.ptr), false); }, popup: function(icon, button, activateTime, menu) { diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index 8e6147f..1a53252 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -391,6 +391,7 @@ firetray.Window.xSendClientMessgeEvent = function(xid, atom, data, dataSize) { * raises window on top and give focus. */ firetray.Window.activate = function(xid) { + // broken in KDE ? gtk.gtk_window_present(firetray.Handler.gtkWindows.get(xid)); log.debug("window raised"); }; diff --git a/src/modules/winnt/FiretrayStatusIcon.jsm b/src/modules/winnt/FiretrayStatusIcon.jsm index 8d9b63d..51be569 100644 --- a/src/modules/winnt/FiretrayStatusIcon.jsm +++ b/src/modules/winnt/FiretrayStatusIcon.jsm @@ -258,6 +258,14 @@ firetray.StatusIcon = { user32.SetForegroundWindow(hWnd); user32.TrackPopupMenu(firetray.PopupMenu.menu, user32.TPM_RIGHTALIGN|user32.TPM_BOTTOMALIGN, xPos, yPos, 0, hWnd, null); break; + case win32.WM_MBUTTONUP: + log.debug("WM_MBUTTONUP"); + break; + // case win32.WM_VSCROLL: + // case win32.WM_MOUSEWHEEL: + /* getting scroll event from the icon is not straight-forward: + SetWindowsHookEx, http://stackoverflow.com/a/90793/421846, + http://www.codeproject.com/Articles/21218/Tray-Me */ default: }