[gnome-shell] Add a FocusApp method to org.gnome.Shell
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Add a FocusApp method to org.gnome.Shell
- Date: Mon, 2 Sep 2013 09:03:28 +0000 (UTC)
commit 415563dc6e9b0efe9935780b1b733d08c51a4d10
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sat Jul 9 15:30:42 2011 +0200
Add a FocusApp method to org.gnome.Shell
This method, which accepts a .desktop filename, is used to highlight
a specific application in the overview, for example because it has
just been created or installed.
https://bugzilla.gnome.org/show_bug.cgi?id=654086
js/ui/appDisplay.js | 37 ++++++++++++++++++++++++++++++++++++-
js/ui/overview.js | 12 ++++++------
js/ui/shellDBus.js | 12 ++++++++++++
js/ui/viewSelector.js | 11 +++++++++--
4 files changed, 63 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 4520bdf..2e2fc27 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -108,8 +108,38 @@ const AlphabeticalView = new Lang.Class({
continue;
this._grid.addItem(this._items[id].actor);
}
+
+ this.emit('view-loaded');
+ },
+
+ _selectAppInternal: function(id) {
+ if (this._items[id])
+ this._items[id].actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
+ else
+ log('No such application ' + id);
+ },
+
+ selectApp: function(id) {
+ if (this._items[id] && this._items[id].actor.mapped) {
+ this._selectAppInternal(id);
+ } else if (this._items[id]) {
+ // Need to wait until the view is mapped
+ let signalId = this._items[id].actor.connect('notify::mapped', Lang.bind(this, function(actor) {
+ if (actor.mapped) {
+ actor.disconnect(signalId);
+ this._selectAppInternal(id);
+ }
+ }));
+ } else {
+ // Need to wait until the view is built
+ let signalId = this.connect('view-loaded', Lang.bind(this, function() {
+ this.disconnect(signalId);
+ this.selectApp(id);
+ }));
+ }
}
});
+Signals.addSignalMethods(AlphabeticalView.prototype);
const FolderView = new Lang.Class({
Name: 'FolderView',
@@ -509,7 +539,12 @@ const AppDisplay = new Lang.Class({
if (focused)
this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
}
- }
+ },
+
+ selectApp: function(id) {
+ this._showView(Views.ALL);
+ this._views[Views.ALL].view.selectApp(id);
+ },
});
const AppSearchProvider = new Lang.Class({
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 3fd3aa1..78dcf53 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -265,7 +265,7 @@ const Overview = new Lang.Class({
// Create controls
this._controls = new OverviewControls.ControlsManager(this._searchEntry);
this._dash = this._controls.dash;
- this._viewSelector = this._controls.viewSelector;
+ this.viewSelector = this._controls.viewSelector;
// Add our same-line elements after the search entry
this._overview.add(this._controls.actor, { y_fill: true, expand: true });
@@ -285,11 +285,11 @@ const Overview = new Lang.Class({
},
addSearchProvider: function(provider) {
- this._viewSelector.addSearchProvider(provider);
+ this.viewSelector.addSearchProvider(provider);
},
removeSearchProvider: function(provider) {
- this._viewSelector.removeSearchProvider(provider);
+ this.viewSelector.removeSearchProvider(provider);
},
//
@@ -513,7 +513,7 @@ const Overview = new Lang.Class({
this._activationTime = Date.now() / 1000;
Meta.disable_unredirect_for_screen(global.screen);
- this._viewSelector.show();
+ this.viewSelector.show();
this._stack.opacity = 0;
Tweener.addTween(this._stack,
@@ -620,7 +620,7 @@ const Overview = new Lang.Class({
this.animationInProgress = true;
this.visibleTarget = false;
- this._viewSelector.zoomFromOverview();
+ this.viewSelector.zoomFromOverview();
// Make other elements fade out.
Tweener.addTween(this._stack,
@@ -655,7 +655,7 @@ const Overview = new Lang.Class({
// Re-enable unredirection
Meta.enable_unredirect_for_screen(global.screen);
- this._viewSelector.hide();
+ this.viewSelector.hide();
this._desktopFade.hide();
this._coverPane.hide();
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 78a9c5b..802640b 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -13,6 +13,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Hash = imports.misc.hash;
const Main = imports.ui.main;
const Screenshot = imports.ui.screenshot;
+const ViewSelector = imports.ui.viewSelector;
const GnomeShellIface = <interface name="org.gnome.Shell">
<method name="Eval">
@@ -24,6 +25,9 @@ const GnomeShellIface = <interface name="org.gnome.Shell">
<method name="ShowOSD">
<arg type="a{sv}" direction="in" name="params"/>
</method>
+<method name="FocusApp">
+ <arg type="s" direction="in" name="id"/>
+</method>
<method name="GrabAccelerator">
<arg type="s" direction="in" name="accelerator"/>
<arg type="u" direction="in" name="flags"/>
@@ -135,6 +139,14 @@ const GnomeShell = new Lang.Class({
Main.osdWindow.show();
},
+ FocusApp: function(id) {
+ let overview = Main.overview;
+
+ overview.show();
+ overview.viewSelector.setActivePage(ViewSelector.ViewPage.APPS);
+ overview.viewSelector.appDisplay.selectApp(id);
+ },
+
GrabAcceleratorAsync: function(params, invocation) {
let [accel, flags] = params;
let sender = invocation.get_sender();
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 7062329..414dd33 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -95,8 +95,8 @@ const ViewSelector = new Lang.Class({
this._workspacesPage = this._addPage(this._workspacesDisplay.actor,
_("Windows"), 'emblem-documents-symbolic');
- this._appDisplay = new AppDisplay.AppDisplay();
- this._appsPage = this._addPage(this._appDisplay.actor,
+ this.appDisplay = new AppDisplay.AppDisplay();
+ this._appsPage = this._addPage(this.appDisplay.actor,
_("Applications"), 'view-grid-symbolic');
this._searchResults = new SearchDisplay.SearchResults(this._searchSystem);
@@ -525,6 +525,13 @@ const ViewSelector = new Lang.Class({
return ViewPage.SEARCH;
},
+ setActivePage: function(page) {
+ if (page == ViewPage.WINDOWS)
+ this._showPage(this._workspacesPage);
+ else
+ this._showPage(this._appsPage);
+ },
+
fadeIn: function() {
let actor = this._activePage;
Tweener.addTween(actor, { opacity: 255,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]