From dcf872b485914e7935c6167e257475de3b2f95f4 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 24 Jul 2012 14:47:39 -0300 Subject: [PATCH] js: Remove StatusIconDispatcher With IBus in the top panel, we don't need it any more https://bugzilla.gnome.org/show_bug.cgi?id=680800 --- js/Makefile.am | 1 - js/ui/main.js | 5 --- js/ui/notificationDaemon.js | 26 +++++++++++++-- js/ui/panel.js | 28 ---------------- js/ui/statusIconDispatcher.js | 63 ----------------------------------- 5 files changed, 24 insertions(+), 99 deletions(-) delete mode 100644 js/ui/statusIconDispatcher.js diff --git a/js/Makefile.am b/js/Makefile.am index 97d95a9e8..91dc84ca7 100644 --- a/js/Makefile.am +++ b/js/Makefile.am @@ -81,7 +81,6 @@ nobase_dist_js_DATA = \ ui/search.js \ ui/searchDisplay.js \ ui/shellDBus.js \ - ui/statusIconDispatcher.js \ ui/status/accessibility.js \ ui/status/keyboard.js \ ui/status/network.js \ diff --git a/js/ui/main.js b/js/ui/main.js index 790dd808f..766d8653d 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -40,7 +40,6 @@ const UnlockDialog = imports.ui.unlockDialog; const WindowManager = imports.ui.windowManager; const Magnifier = imports.ui.magnifier; const XdndHandler = imports.ui.xdndHandler; -const StatusIconDispatcher = imports.ui.statusIconDispatcher; const Util = imports.misc.util; const OVERRIDES_SCHEMA = 'org.gnome.shell.overrides'; @@ -71,7 +70,6 @@ let modalActorFocusStack = []; let uiGroup = null; let magnifier = null; let xdndHandler = null; -let statusIconDispatcher = null; let keyboard = null; let layoutManager = null; let networkAgent = null; @@ -214,7 +212,6 @@ function start() { ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager(); overview = new Overview.Overview(); magnifier = new Magnifier.Magnifier(); - statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher(); screenShield = new ScreenShield.ScreenShield(); screenSaverDBus = new ShellDBus.ScreenSaverDBus(); panel = new Panel.Panel(); @@ -256,8 +253,6 @@ function start() { Lang.bind(overview, overview.toggle)); } - statusIconDispatcher.start(messageTray.actor); - // Provide the bus object for gnome-session to // initiate logouts. EndSessionDialog.init(); diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index 49d1e0bc1..8fdb9e022 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -88,6 +88,21 @@ const rewriteRules = { ] }; +const STANDARD_TRAY_ICON_IMPLEMENTATIONS = { + 'bluetooth-applet': 'bluetooth', + 'gnome-volume-control-applet': 'volume', // renamed to gnome-sound-applet + // when moved to control center + 'gnome-sound-applet': 'volume', + 'nm-applet': 'network', + 'gnome-power-manager': 'battery', + 'keyboard': 'keyboard', + 'a11y-keyboard': 'a11y', + 'kbd-scrolllock': 'keyboard', + 'kbd-numlock': 'keyboard', + 'kbd-capslock': 'keyboard', + 'ibus-ui-gtk': 'keyboard' +}; + const NotificationDaemon = new Lang.Class({ Name: 'NotificationDaemon', @@ -100,13 +115,16 @@ const NotificationDaemon = new Lang.Class({ this._notifications = {}; this._busProxy = new Bus(); - Main.statusIconDispatcher.connect('message-icon-added', Lang.bind(this, this._onTrayIconAdded)); - Main.statusIconDispatcher.connect('message-icon-removed', Lang.bind(this, this._onTrayIconRemoved)); + this._trayManager = new Shell.TrayManager(); + this._trayManager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded)); + this._trayManager.connect('tray-icon-removed', Lang.bind(this, this._onTrayIconRemoved)); Shell.WindowTracker.get_default().connect('notify::focus-app', Lang.bind(this, this._onFocusAppChanged)); Main.overview.connect('hidden', Lang.bind(this, this._onFocusAppChanged)); + + this._trayManager.manage_stage(global.stage, Main.messageTray.actor); }, _iconForNotificationData: function(icon, hints) { @@ -481,6 +499,10 @@ const NotificationDaemon = new Lang.Class({ }, _onTrayIconAdded: function(o, icon) { + let wmClass = icon.wm_class.toLowerCase(); + if (STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass] !== undefined) + return; + let source = this._getSource(icon.title || icon.wm_class || C_("program", "Unknown"), icon.pid, null, null, icon); }, diff --git a/js/ui/panel.js b/js/ui/panel.js index 82c999662..d9cf5983c 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -967,10 +967,6 @@ const Panel = new Lang.Class({ this._centerBox.add(this._dateMenu.actor, { y_fill: true }); this._menus.addMenu(this._dateMenu.menu); - /* right */ - Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded)); - Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved)); - Main.layoutManager.panelBox.add(this.actor); Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'start-here', { sortGroup: CtrlAltTab.SortGroup.TOP }); @@ -1151,30 +1147,6 @@ const Panel = new Lang.Class({ return indicator; }, - _onTrayIconAdded: function(o, icon, role) { - if (Main.sessionMode.statusArea.implementation[role]) { - // This icon is legacy, and replaced by a Shell version - // Hide it - return; - } - - if (Main.sessionMode.statusArea.order.indexOf(role) == -1) - return; - - icon.height = PANEL_ICON_SIZE; - let buttonBox = new PanelMenu.ButtonBox(); - let box = buttonBox.actor; - box.add_actor(icon); - - this._insertStatusItem(box, Main.sessionMode.statusArea.order.indexOf(role)); - }, - - _onTrayIconRemoved: function(o, icon) { - let box = icon.get_parent(); - if (box && box._delegate instanceof PanelMenu.ButtonBox) - box.destroy(); - }, - _onLockStateChanged: function(shield, locked) { if (this._activitiesButton) this._activitiesButton.setLockedState(locked); diff --git a/js/ui/statusIconDispatcher.js b/js/ui/statusIconDispatcher.js deleted file mode 100644 index 91c9f619b..000000000 --- a/js/ui/statusIconDispatcher.js +++ /dev/null @@ -1,63 +0,0 @@ -// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- - -const Lang = imports.lang; -const Shell = imports.gi.Shell; -const Signals = imports.signals; - -const MessageTray = imports.ui.messageTray; -const NotificationDaemon = imports.ui.notificationDaemon; -const Util = imports.misc.util; - -const STANDARD_TRAY_ICON_IMPLEMENTATIONS = { - 'bluetooth-applet': 'bluetooth', - 'gnome-volume-control-applet': 'volume', // renamed to gnome-sound-applet - // when moved to control center - 'gnome-sound-applet': 'volume', - 'nm-applet': 'network', - 'gnome-power-manager': 'battery', - 'keyboard': 'keyboard', - 'a11y-keyboard': 'a11y', - 'kbd-scrolllock': 'keyboard', - 'kbd-numlock': 'keyboard', - 'kbd-capslock': 'keyboard', - 'ibus-ui-gtk': 'keyboard' -}; - -const StatusIconDispatcher = new Lang.Class({ - Name: 'StatusIconDispatcher', - - _init: function() { - this._traymanager = new Shell.TrayManager(); - this._traymanager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded)); - this._traymanager.connect('tray-icon-removed', Lang.bind(this, this._onTrayIconRemoved)); - - // Yet-another-Ubuntu-workaround - we have to kill their - // app-indicators, so that applications fall back to normal - // status icons - // http://bugzilla.gnome.org/show_bug.cgi=id=621382 - Util.killall('indicator-application-service'); - }, - - start: function(themeWidget) { - this._traymanager.manage_stage(global.stage, themeWidget); - }, - - _onTrayIconAdded: function(o, icon) { - let wmClass = (icon.wm_class || 'unknown').toLowerCase(); - let role = STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass]; - if (role) - this.emit('status-icon-added', icon, role); - else - this.emit('message-icon-added', icon); - }, - - _onTrayIconRemoved: function(o, icon) { - let wmClass = (icon.wm_class || 'unknown').toLowerCase(); - let role = STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass]; - if (role) - this.emit('status-icon-removed', icon); - else - this.emit('message-icon-removed', icon); - } -}); -Signals.addSignalMethods(StatusIconDispatcher.prototype);