2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2008-11-20 19:53:11 -05:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2012-11-26 17:01:44 -05:00
|
|
|
const Gio = imports.gi.Gio;
|
2011-02-25 11:50:39 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
2008-11-20 19:53:11 -05:00
|
|
|
const Gtk = imports.gi.Gtk;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
const GMenu = imports.gi.GMenu;
|
2008-11-20 19:53:11 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-04-01 15:51:17 -04:00
|
|
|
const Lang = imports.lang;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Signals = imports.signals;
|
2011-04-25 15:42:03 -04:00
|
|
|
const Meta = imports.gi.Meta;
|
2009-11-12 17:46:59 -05:00
|
|
|
const St = imports.gi.St;
|
2009-06-30 16:35:39 -04:00
|
|
|
const Mainloop = imports.mainloop;
|
2012-02-17 20:40:40 -05:00
|
|
|
const Atk = imports.gi.Atk;
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-10-15 19:28:29 -04:00
|
|
|
const AppFavorites = imports.ui.appFavorites;
|
2009-06-30 16:35:39 -04:00
|
|
|
const DND = imports.ui.dnd;
|
2010-07-20 22:22:19 -04:00
|
|
|
const IconGrid = imports.ui.iconGrid;
|
2009-07-31 17:20:26 -04:00
|
|
|
const Main = imports.ui.main;
|
2010-06-06 14:20:00 -04:00
|
|
|
const Overview = imports.ui.overview;
|
2010-05-20 11:18:46 -04:00
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
2010-06-06 14:20:00 -04:00
|
|
|
const Tweener = imports.ui.tweener;
|
2010-01-21 21:33:48 -05:00
|
|
|
const Workspace = imports.ui.workspace;
|
2010-06-22 12:39:14 -04:00
|
|
|
const Params = imports.misc.params;
|
2012-06-11 13:53:32 -04:00
|
|
|
const Util = imports.misc.util;
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2011-04-25 15:42:03 -04:00
|
|
|
const MAX_APPLICATION_WORK_MILLIS = 75;
|
2010-03-10 08:52:28 -05:00
|
|
|
const MENU_POPUP_TIMEOUT = 600;
|
2011-02-23 14:21:47 -05:00
|
|
|
const SCROLL_TIME = 0.1;
|
2009-04-23 10:41:24 -04:00
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const AlphabeticalView = new Lang.Class({
|
|
|
|
Name: 'AlphabeticalView',
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2010-06-04 18:01:32 -04:00
|
|
|
_init: function() {
|
2010-11-29 13:16:20 -05:00
|
|
|
this._grid = new IconGrid.IconGrid({ xAlign: St.Align.START });
|
2010-02-15 19:50:36 -05:00
|
|
|
this._appSystem = Shell.AppSystem.get_default();
|
2010-12-18 14:18:10 -05:00
|
|
|
|
2011-04-25 15:42:03 -04:00
|
|
|
this._pendingAppLaterId = 0;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._appIcons = {}; // desktop file id
|
2012-06-11 13:53:32 -04:00
|
|
|
this._allApps = [];
|
2010-12-18 14:18:10 -05:00
|
|
|
|
|
|
|
let box = new St.BoxLayout({ vertical: true });
|
|
|
|
box.add(this._grid.actor, { y_align: St.Align.START, expand: true });
|
|
|
|
|
|
|
|
this.actor = new St.ScrollView({ x_fill: true,
|
|
|
|
y_fill: false,
|
|
|
|
y_align: St.Align.START,
|
2011-06-03 17:44:57 -04:00
|
|
|
style_class: 'vfade' });
|
2010-12-18 14:18:10 -05:00
|
|
|
this.actor.add_actor(box);
|
|
|
|
this.actor.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
|
2012-11-25 23:33:44 -05:00
|
|
|
let action = new Clutter.PanAction({ interpolate: true });
|
|
|
|
action.connect('pan', Lang.bind(this, this._onPan));
|
|
|
|
this.actor.add_action(action);
|
|
|
|
},
|
2011-01-21 17:01:07 -05:00
|
|
|
|
2012-11-25 23:33:44 -05:00
|
|
|
_onPan: function(action) {
|
|
|
|
let [dist, dx, dy] = action.get_motion_delta(0);
|
|
|
|
let adjustment = this.actor.vscroll.adjustment;
|
|
|
|
adjustment.value -= (dy / this.actor.height) * adjustment.page_size;
|
|
|
|
return false;
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
2008-12-19 23:27:57 -05:00
|
|
|
|
2012-06-11 13:53:32 -04:00
|
|
|
removeAll: function() {
|
2010-02-15 19:50:36 -05:00
|
|
|
this._grid.removeAll();
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._appIcons = {};
|
2012-06-11 13:53:32 -04:00
|
|
|
this._allApps = [];
|
2009-07-02 00:35:26 -04:00
|
|
|
},
|
|
|
|
|
2012-06-11 13:53:32 -04:00
|
|
|
addApp: function(app) {
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
var id = app.get_id();
|
2012-06-11 13:53:32 -04:00
|
|
|
if (this._appIcons[id] !== undefined)
|
|
|
|
return;
|
2009-03-20 12:06:34 -04:00
|
|
|
|
2012-06-11 13:53:32 -04:00
|
|
|
let appIcon = new AppWellIcon(app);
|
|
|
|
let pos = Util.insertSorted(this._allApps, app, function(a, b) {
|
|
|
|
return a.compare_by_name(b);
|
|
|
|
});
|
|
|
|
this._grid.addItem(appIcon.actor, pos);
|
2011-02-23 14:21:47 -05:00
|
|
|
appIcon.actor.connect('key-focus-in', Lang.bind(this, this._ensureIconVisible));
|
2009-03-20 12:06:34 -04:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._appIcons[id] = appIcon;
|
2009-06-29 15:08:48 -04:00
|
|
|
},
|
|
|
|
|
2011-02-23 14:21:47 -05:00
|
|
|
_ensureIconVisible: function(icon) {
|
|
|
|
let adjustment = this.actor.vscroll.adjustment;
|
|
|
|
let [value, lower, upper, stepIncrement, pageIncrement, pageSize] = adjustment.get_values();
|
|
|
|
|
|
|
|
let offset = 0;
|
|
|
|
let vfade = this.actor.get_effect("vfade");
|
|
|
|
if (vfade)
|
|
|
|
offset = vfade.fade_offset;
|
|
|
|
|
2011-03-18 14:33:45 -04:00
|
|
|
// If this gets called as part of a right-click, the actor
|
|
|
|
// will be needs_allocation, and so "icon.y" would return 0
|
|
|
|
let box = icon.get_allocation_box();
|
|
|
|
|
|
|
|
if (box.y1 < value + offset)
|
|
|
|
value = Math.max(0, box.y1 - offset);
|
|
|
|
else if (box.y2 > value + pageSize - offset)
|
|
|
|
value = Math.min(upper, box.y2 + offset - pageSize);
|
2011-02-23 14:21:47 -05:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
Tweener.addTween(adjustment,
|
|
|
|
{ value: value,
|
|
|
|
time: SCROLL_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
|
|
|
},
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
setVisibleApps: function(apps) {
|
|
|
|
if (apps == null) { // null implies "all"
|
|
|
|
for (var id in this._appIcons) {
|
|
|
|
var icon = this._appIcons[id];
|
|
|
|
icon.actor.visible = true;
|
|
|
|
}
|
2011-04-25 15:42:03 -04:00
|
|
|
} else {
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
// Set everything to not-visible, then set to visible what we should see
|
|
|
|
for (var id in this._appIcons) {
|
|
|
|
var icon = this._appIcons[id];
|
|
|
|
icon.actor.visible = false;
|
|
|
|
}
|
|
|
|
for (var i = 0; i < apps.length; i++) {
|
|
|
|
var app = apps[i];
|
|
|
|
var id = app.get_id();
|
|
|
|
var icon = this._appIcons[id];
|
|
|
|
icon.actor.visible = true;
|
|
|
|
}
|
2011-04-25 15:42:03 -04:00
|
|
|
}
|
2009-03-20 12:06:34 -04:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const ViewByCategories = new Lang.Class({
|
|
|
|
Name: 'ViewByCategories',
|
2010-06-04 18:01:32 -04:00
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._appSystem = Shell.AppSystem.get_default();
|
2010-12-18 14:18:10 -05:00
|
|
|
this.actor = new St.BoxLayout({ style_class: 'all-app' });
|
2010-06-04 18:01:32 -04:00
|
|
|
this.actor._delegate = this;
|
2010-12-18 14:18:10 -05:00
|
|
|
|
|
|
|
this._view = new AlphabeticalView();
|
|
|
|
|
2011-02-27 15:46:17 -05:00
|
|
|
// categories can be -1 (the All view) or 0...n-1, where n
|
|
|
|
// is the number of sections
|
|
|
|
// -2 is a flag to indicate that nothing is selected
|
|
|
|
// (used only before the actor is mapped the first time)
|
|
|
|
this._currentCategory = -2;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._categories = [];
|
|
|
|
|
2012-02-17 20:40:40 -05:00
|
|
|
this._categoryBox = new St.BoxLayout({ vertical: true,
|
|
|
|
reactive: true,
|
|
|
|
accessible_role: Atk.Role.LIST });
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._categoryScroll = new St.ScrollView({ x_fill: false,
|
|
|
|
y_fill: false,
|
|
|
|
style_class: 'vfade' });
|
|
|
|
this._categoryScroll.add_actor(this._categoryBox);
|
2010-12-18 14:18:10 -05:00
|
|
|
this.actor.add(this._view.actor, { expand: true, x_fill: true, y_fill: true });
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this.actor.add(this._categoryScroll, { expand: false, y_fill: false, y_align: St.Align.START });
|
2010-12-18 14:18:10 -05:00
|
|
|
|
2011-02-09 17:39:28 -05:00
|
|
|
// Always select the "All" filter when switching to the app view
|
|
|
|
this.actor.connect('notify::mapped', Lang.bind(this,
|
|
|
|
function() {
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (this.actor.mapped && this._allCategoryButton)
|
2011-02-09 17:39:28 -05:00
|
|
|
this._selectCategory(-1);
|
|
|
|
}));
|
|
|
|
|
2011-02-23 14:21:47 -05:00
|
|
|
// We need a dummy actor to catch the keyboard focus if the
|
|
|
|
// user Ctrl-Alt-Tabs here before the deferred work creates
|
|
|
|
// our real contents
|
|
|
|
this._focusDummy = new St.Bin({ can_focus: true });
|
|
|
|
this.actor.add(this._focusDummy);
|
2010-06-04 18:01:32 -04:00
|
|
|
},
|
|
|
|
|
2010-12-18 14:18:10 -05:00
|
|
|
_selectCategory: function(num) {
|
2011-02-27 15:46:17 -05:00
|
|
|
if (this._currentCategory == num) // nothing to do
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._currentCategory = num;
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (num != -1) {
|
|
|
|
var category = this._categories[num];
|
|
|
|
this._allCategoryButton.remove_style_pseudo_class('selected');
|
|
|
|
this._view.setVisibleApps(category.apps);
|
|
|
|
} else {
|
|
|
|
this._allCategoryButton.add_style_pseudo_class('selected');
|
|
|
|
this._view.setVisibleApps(null);
|
|
|
|
}
|
2010-12-18 14:18:10 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
for (var i = 0; i < this._categories.length; i++) {
|
2010-12-18 14:18:10 -05:00
|
|
|
if (i == num)
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._categories[i].button.add_style_pseudo_class('selected');
|
2010-12-18 14:18:10 -05:00
|
|
|
else
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._categories[i].button.remove_style_pseudo_class('selected');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Recursively load a GMenuTreeDirectory; we could put this in ShellAppSystem too
|
|
|
|
_loadCategory: function(dir, appList) {
|
|
|
|
var iter = dir.iter();
|
|
|
|
var nextType;
|
|
|
|
while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
|
|
|
|
if (nextType == GMenu.TreeItemType.ENTRY) {
|
|
|
|
var entry = iter.get_entry();
|
|
|
|
var app = this._appSystem.lookup_app_by_tree_entry(entry);
|
2012-06-11 13:53:32 -04:00
|
|
|
if (!entry.get_app_info().get_nodisplay()) {
|
|
|
|
this._view.addApp(app);
|
2011-08-29 15:29:49 -04:00
|
|
|
appList.push(app);
|
2012-06-11 13:53:32 -04:00
|
|
|
}
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
} else if (nextType == GMenu.TreeItemType.DIRECTORY) {
|
2012-06-19 13:02:38 -04:00
|
|
|
var itemDir = iter.get_directory();
|
|
|
|
if (!itemDir.get_is_nodisplay())
|
|
|
|
this._loadCategory(itemDir, appList);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
}
|
2010-06-04 18:01:32 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-06-11 13:53:32 -04:00
|
|
|
_addCategory: function(name, index, dir) {
|
2012-11-16 02:22:58 -05:00
|
|
|
let apps;
|
|
|
|
|
|
|
|
if (dir != null) {
|
|
|
|
apps = [];
|
|
|
|
this._loadCategory(dir, apps);
|
|
|
|
|
|
|
|
if (apps.length == 0)
|
2012-11-29 19:21:41 -05:00
|
|
|
return false;
|
2012-11-16 02:22:58 -05:00
|
|
|
}
|
|
|
|
|
2011-02-25 11:50:39 -05:00
|
|
|
let button = new St.Button({ label: GLib.markup_escape_text (name, -1),
|
2010-12-18 14:18:10 -05:00
|
|
|
style_class: 'app-filter',
|
2011-02-23 14:21:47 -05:00
|
|
|
x_align: St.Align.START,
|
2012-02-17 20:40:40 -05:00
|
|
|
can_focus: true ,
|
|
|
|
accessible_role: Atk.Role.LIST_ITEM });
|
2010-12-18 14:18:10 -05:00
|
|
|
button.connect('clicked', Lang.bind(this, function() {
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._selectCategory(index);
|
2010-12-18 14:18:10 -05:00
|
|
|
}));
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (dir == null) {
|
|
|
|
this._allCategoryButton = button;
|
|
|
|
} else {
|
|
|
|
this._categories.push({ apps: apps,
|
|
|
|
name: name,
|
|
|
|
button: button });
|
|
|
|
}
|
|
|
|
|
|
|
|
this._categoryBox.add(button, { expand: true, x_fill: true, y_fill: false });
|
2012-11-29 19:21:41 -05:00
|
|
|
return true;
|
2010-12-18 14:18:10 -05:00
|
|
|
},
|
2010-06-04 18:01:32 -04:00
|
|
|
|
2010-12-18 14:18:10 -05:00
|
|
|
_removeAll: function() {
|
2012-06-11 13:53:32 -04:00
|
|
|
this._view.removeAll();
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._categories = [];
|
2012-02-16 13:27:09 -05:00
|
|
|
this._categoryBox.destroy_all_children();
|
2010-06-04 18:01:32 -04:00
|
|
|
},
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
refresh: function() {
|
2010-12-18 14:18:10 -05:00
|
|
|
this._removeAll();
|
|
|
|
|
2010-12-21 12:23:54 -05:00
|
|
|
/* Translators: Filter to display all applications */
|
2012-06-11 13:53:32 -04:00
|
|
|
this._addCategory(_("All"), -1, null);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
|
|
|
|
var tree = this._appSystem.get_tree();
|
|
|
|
var root = tree.get_root_directory();
|
|
|
|
|
|
|
|
var iter = root.iter();
|
|
|
|
var nextType;
|
|
|
|
var i = 0;
|
|
|
|
while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
|
|
|
|
if (nextType == GMenu.TreeItemType.DIRECTORY) {
|
|
|
|
var dir = iter.get_directory();
|
2011-09-04 19:15:13 -04:00
|
|
|
if (dir.get_is_nodisplay())
|
|
|
|
continue;
|
2012-11-29 19:21:41 -05:00
|
|
|
|
|
|
|
if (this._addCategory(dir.get_name(), i, dir))
|
|
|
|
i++;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
2010-12-18 14:18:10 -05:00
|
|
|
|
|
|
|
this._selectCategory(-1);
|
2011-02-23 14:21:47 -05:00
|
|
|
|
|
|
|
if (this._focusDummy) {
|
|
|
|
let focused = this._focusDummy.has_key_focus();
|
|
|
|
this._focusDummy.destroy();
|
|
|
|
this._focusDummy = null;
|
|
|
|
if (focused)
|
|
|
|
this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
|
|
|
}
|
2010-06-04 18:01:32 -04:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-06-04 18:01:32 -04:00
|
|
|
|
2008-12-19 23:27:57 -05:00
|
|
|
/* This class represents a display containing a collection of application items.
|
2010-02-15 19:50:36 -05:00
|
|
|
* The applications are sorted based on their name.
|
2008-12-19 23:27:57 -05:00
|
|
|
*/
|
2011-11-20 12:56:27 -05:00
|
|
|
const AllAppDisplay = new Lang.Class({
|
|
|
|
Name: 'AllAppDisplay',
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2010-02-15 19:50:36 -05:00
|
|
|
_init: function() {
|
2009-06-18 12:27:19 -04:00
|
|
|
this._appSystem = Shell.AppSystem.get_default();
|
2010-02-15 19:50:36 -05:00
|
|
|
this._appSystem.connect('installed-changed', Lang.bind(this, function() {
|
|
|
|
Main.queueDeferredWork(this._workId);
|
2009-04-23 10:41:24 -04:00
|
|
|
}));
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2010-06-04 18:01:32 -04:00
|
|
|
this._appView = new ViewByCategories();
|
2010-12-18 14:18:10 -05:00
|
|
|
this.actor = new St.Bin({ child: this._appView.actor, x_fill: true, y_fill: true });
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2010-02-15 19:50:36 -05:00
|
|
|
this._workId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._redisplay));
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2010-02-15 19:50:36 -05:00
|
|
|
_redisplay: function() {
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._appView.refresh();
|
2009-04-01 15:51:17 -04:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-02-22 11:39:10 -05:00
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
const AppSearchProvider = new Lang.Class({
|
|
|
|
Name: 'AppSearchProvider',
|
2009-11-29 17:45:30 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
_init: function() {
|
2009-11-29 17:45:30 -05:00
|
|
|
this._appSys = Shell.AppSystem.get_default();
|
2012-08-09 17:52:36 -04:00
|
|
|
this.id = 'applications';
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2012-05-02 15:54:25 -04:00
|
|
|
getResultMetas: function(apps, callback) {
|
2012-02-17 10:39:27 -05:00
|
|
|
let metas = [];
|
|
|
|
for (let i = 0; i < apps.length; i++) {
|
|
|
|
let app = apps[i];
|
|
|
|
metas.push({ 'id': app,
|
|
|
|
'name': app.get_name(),
|
|
|
|
'createIcon': function(size) {
|
|
|
|
return app.create_icon_texture(size);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2012-05-02 15:45:37 -04:00
|
|
|
callback(metas);
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2012-05-02 15:54:25 -04:00
|
|
|
getInitialResultSet: function(terms) {
|
2012-05-02 15:45:37 -04:00
|
|
|
this.searchSystem.pushResults(this, this._appSys.initial_search(terms));
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
},
|
|
|
|
|
2012-05-02 15:54:25 -04:00
|
|
|
getSubsearchResultSet: function(previousResults, terms) {
|
2012-05-02 15:45:37 -04:00
|
|
|
this.searchSystem.pushResults(this, this._appSys.subsearch(previousResults, terms));
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
},
|
|
|
|
|
2012-12-05 10:05:48 -05:00
|
|
|
activateResult: function(app) {
|
2011-07-16 15:27:05 -04:00
|
|
|
let event = Clutter.get_current_event();
|
2012-02-28 11:01:48 -05:00
|
|
|
let modifiers = event ? event.get_state() : 0;
|
2011-07-16 15:27:05 -04:00
|
|
|
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
|
|
|
|
|
|
|
|
if (openNewWindow)
|
2012-12-05 10:05:48 -05:00
|
|
|
app.open_new_window(-1);
|
2011-07-16 15:27:05 -04:00
|
|
|
else
|
2012-12-05 10:05:48 -05:00
|
|
|
app.activate();
|
2010-02-15 17:11:09 -05:00
|
|
|
},
|
|
|
|
|
2011-01-30 16:09:58 -05:00
|
|
|
dragActivateResult: function(id, params) {
|
2011-08-11 05:35:23 -04:00
|
|
|
params = Params.parse(params, { workspace: -1,
|
|
|
|
timestamp: 0 });
|
2011-01-30 16:09:58 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
let app = this._appSys.lookup_app(id);
|
2011-08-11 05:35:23 -04:00
|
|
|
app.open_new_window(workspace);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
createResultActor: function (resultMeta, terms) {
|
|
|
|
let app = resultMeta['id'];
|
|
|
|
let icon = new AppWellIcon(app);
|
|
|
|
return icon.actor;
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2009-11-29 17:45:30 -05:00
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
const SettingsSearchProvider = new Lang.Class({
|
|
|
|
Name: 'SettingsSearchProvider',
|
2009-11-29 17:45:30 -05:00
|
|
|
|
|
|
|
_init: function() {
|
2012-12-06 14:10:44 -05:00
|
|
|
this.appInfo = Gio.DesktopAppInfo.new('gnome-control-center.desktop');
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
this._appSys = Shell.AppSystem.get_default();
|
|
|
|
},
|
|
|
|
|
2012-05-02 15:54:25 -04:00
|
|
|
getResultMetas: function(prefs, callback) {
|
2012-02-17 10:39:27 -05:00
|
|
|
let metas = [];
|
|
|
|
for (let i = 0; i < prefs.length; i++) {
|
|
|
|
let pref = prefs[i];
|
|
|
|
metas.push({ 'id': pref,
|
|
|
|
'name': pref.get_name(),
|
2012-08-16 22:28:13 -04:00
|
|
|
'createIcon': function() { return null; }
|
2012-02-17 10:39:27 -05:00
|
|
|
});
|
|
|
|
}
|
2012-05-02 15:45:37 -04:00
|
|
|
callback(metas);
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2012-05-02 15:54:25 -04:00
|
|
|
getInitialResultSet: function(terms) {
|
2012-05-02 15:45:37 -04:00
|
|
|
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2012-05-02 15:54:25 -04:00
|
|
|
getSubsearchResultSet: function(previousResults, terms) {
|
2012-05-02 15:45:37 -04:00
|
|
|
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2012-12-05 10:05:48 -05:00
|
|
|
activateResult: function(pref) {
|
|
|
|
pref.activate();
|
2009-11-29 17:45:30 -05:00
|
|
|
},
|
|
|
|
|
2012-11-26 17:01:44 -05:00
|
|
|
launchSearch: function(terms) {
|
|
|
|
// FIXME: this should be a remote search provider
|
|
|
|
this.appInfo.launch([], global.create_app_launch_context());
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
const AppIcon = new Lang.Class({
|
|
|
|
Name: 'AppIcon',
|
|
|
|
Extends: IconGrid.BaseIcon,
|
2010-07-20 22:22:19 -04:00
|
|
|
|
2011-01-13 10:02:55 -05:00
|
|
|
_init : function(app, params) {
|
2009-11-12 17:46:59 -05:00
|
|
|
this.app = app;
|
2009-09-11 17:13:50 -04:00
|
|
|
|
2010-07-20 22:22:19 -04:00
|
|
|
let label = this.app.get_name();
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
this.parent(label, params);
|
2010-07-20 22:22:19 -04:00
|
|
|
},
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2010-07-20 22:22:19 -04:00
|
|
|
createIcon: function(iconSize) {
|
|
|
|
return this.app.create_icon_texture(iconSize);
|
2009-12-08 12:51:05 -05:00
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2009-12-08 12:51:05 -05:00
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const AppWellIcon = new Lang.Class({
|
|
|
|
Name: 'AppWellIcon',
|
2009-12-08 12:51:05 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
_init : function(app, iconParams, onActivateOverride) {
|
2009-12-08 12:51:05 -05:00
|
|
|
this.app = app;
|
2011-01-25 16:22:00 -05:00
|
|
|
this.actor = new St.Button({ style_class: 'app-well-app',
|
|
|
|
reactive: true,
|
|
|
|
button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO,
|
2011-02-03 12:38:03 -05:00
|
|
|
can_focus: true,
|
2011-01-25 16:22:00 -05:00
|
|
|
x_fill: true,
|
|
|
|
y_fill: true });
|
2009-12-08 12:51:05 -05:00
|
|
|
this.actor._delegate = this;
|
|
|
|
|
2011-01-13 10:02:55 -05:00
|
|
|
this.icon = new AppIcon(app, iconParams);
|
2010-07-21 19:29:02 -04:00
|
|
|
this.actor.set_child(this.icon.actor);
|
2009-12-08 12:51:05 -05:00
|
|
|
|
2011-03-08 13:33:57 -05:00
|
|
|
this.actor.label_actor = this.icon.label;
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
// A function callback to override the default "app.activate()"; used by preferences
|
|
|
|
this._onActivateOverride = onActivateOverride;
|
2011-01-26 11:15:41 -05:00
|
|
|
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
|
2009-12-08 12:51:05 -05:00
|
|
|
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
2011-02-03 12:38:03 -05:00
|
|
|
this.actor.connect('popup-menu', Lang.bind(this, this._onKeyboardPopupMenu));
|
2010-05-20 11:18:46 -04:00
|
|
|
|
2009-12-08 12:51:05 -05:00
|
|
|
this._menu = null;
|
2010-05-20 11:18:46 -04:00
|
|
|
this._menuManager = new PopupMenu.PopupMenuManager(this);
|
2009-12-08 12:51:05 -05:00
|
|
|
|
2010-03-26 21:35:34 -04:00
|
|
|
this._draggable = DND.makeDraggable(this.actor);
|
|
|
|
this._draggable.connect('drag-begin', Lang.bind(this,
|
|
|
|
function () {
|
|
|
|
this._removeMenuTimeout();
|
2010-05-08 10:06:28 -04:00
|
|
|
Main.overview.beginItemDrag(this);
|
|
|
|
}));
|
2011-03-09 10:40:48 -05:00
|
|
|
this._draggable.connect('drag-cancelled', Lang.bind(this,
|
|
|
|
function () {
|
|
|
|
Main.overview.cancelledItemDrag(this);
|
|
|
|
}));
|
2010-05-08 10:06:28 -04:00
|
|
|
this._draggable.connect('drag-end', Lang.bind(this,
|
|
|
|
function () {
|
|
|
|
Main.overview.endItemDrag(this);
|
2010-03-26 21:35:34 -04:00
|
|
|
}));
|
2009-12-08 12:51:05 -05:00
|
|
|
|
2010-06-05 18:35:26 -04:00
|
|
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
2010-01-07 00:40:21 -05:00
|
|
|
|
2010-03-10 08:52:28 -05:00
|
|
|
this._menuTimeoutId = 0;
|
Major ShellApp API cleanup, startup notification, window focus handling
This patch combines several high level changes which are conceptually
independent but in practice rather intertwined.
* Add a "state" property to ShellApp which reflects whether it's
stopped, starting, or started. This will allow us to later clean
up all the callers that are using ".get_windows().length > 0" as
a proxy for this property
* Replace shell_app_launch with shell_app_activate and shell_app_open_new_window
A lot of code was calling .launch, but it's signficantly clearer
if we call this ".open_new_window()", and later if we gain the ability
to call into an application's menu, we can implement this correctly rather
than trying to update all .launch callers.
* Because ShellApp now has a "starting" state, rebase panel.js on top of
this so that when we get a startup-notification sequence for an app
and transition it to starting, it becomes the focus app, and panel.js
cleanly just tracks the focus app, rather than bouncing between SN
sequences. This removes display of non-app startup sequences, which
I consider an acceptable action in light of the committed changes
to startup-notification and GTK+.
https://bugzilla.gnome.org/show_bug.cgi?id=614755
2010-04-03 14:07:44 -04:00
|
|
|
this._stateChangedId = this.app.connect('notify::state',
|
|
|
|
Lang.bind(this,
|
|
|
|
this._onStateChanged));
|
|
|
|
this._onStateChanged();
|
2010-01-07 00:40:21 -05:00
|
|
|
},
|
|
|
|
|
2010-06-05 18:35:26 -04:00
|
|
|
_onDestroy: function() {
|
Major ShellApp API cleanup, startup notification, window focus handling
This patch combines several high level changes which are conceptually
independent but in practice rather intertwined.
* Add a "state" property to ShellApp which reflects whether it's
stopped, starting, or started. This will allow us to later clean
up all the callers that are using ".get_windows().length > 0" as
a proxy for this property
* Replace shell_app_launch with shell_app_activate and shell_app_open_new_window
A lot of code was calling .launch, but it's signficantly clearer
if we call this ".open_new_window()", and later if we gain the ability
to call into an application's menu, we can implement this correctly rather
than trying to update all .launch callers.
* Because ShellApp now has a "starting" state, rebase panel.js on top of
this so that when we get a startup-notification sequence for an app
and transition it to starting, it becomes the focus app, and panel.js
cleanly just tracks the focus app, rather than bouncing between SN
sequences. This removes display of non-app startup sequences, which
I consider an acceptable action in light of the committed changes
to startup-notification and GTK+.
https://bugzilla.gnome.org/show_bug.cgi?id=614755
2010-04-03 14:07:44 -04:00
|
|
|
if (this._stateChangedId > 0)
|
|
|
|
this.app.disconnect(this._stateChangedId);
|
2010-06-05 18:35:26 -04:00
|
|
|
this._stateChangedId = 0;
|
2010-03-10 08:52:28 -05:00
|
|
|
this._removeMenuTimeout();
|
|
|
|
},
|
|
|
|
|
|
|
|
_removeMenuTimeout: function() {
|
|
|
|
if (this._menuTimeoutId > 0) {
|
|
|
|
Mainloop.source_remove(this._menuTimeoutId);
|
|
|
|
this._menuTimeoutId = 0;
|
|
|
|
}
|
2010-01-07 00:40:21 -05:00
|
|
|
},
|
|
|
|
|
Major ShellApp API cleanup, startup notification, window focus handling
This patch combines several high level changes which are conceptually
independent but in practice rather intertwined.
* Add a "state" property to ShellApp which reflects whether it's
stopped, starting, or started. This will allow us to later clean
up all the callers that are using ".get_windows().length > 0" as
a proxy for this property
* Replace shell_app_launch with shell_app_activate and shell_app_open_new_window
A lot of code was calling .launch, but it's signficantly clearer
if we call this ".open_new_window()", and later if we gain the ability
to call into an application's menu, we can implement this correctly rather
than trying to update all .launch callers.
* Because ShellApp now has a "starting" state, rebase panel.js on top of
this so that when we get a startup-notification sequence for an app
and transition it to starting, it becomes the focus app, and panel.js
cleanly just tracks the focus app, rather than bouncing between SN
sequences. This removes display of non-app startup sequences, which
I consider an acceptable action in light of the committed changes
to startup-notification and GTK+.
https://bugzilla.gnome.org/show_bug.cgi?id=614755
2010-04-03 14:07:44 -04:00
|
|
|
_onStateChanged: function() {
|
|
|
|
if (this.app.state != Shell.AppState.STOPPED)
|
|
|
|
this.actor.add_style_class_name('running');
|
|
|
|
else
|
|
|
|
this.actor.remove_style_class_name('running');
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onButtonPress: function(actor, event) {
|
2010-03-10 08:52:28 -05:00
|
|
|
let button = event.get_button();
|
|
|
|
if (button == 1) {
|
|
|
|
this._removeMenuTimeout();
|
|
|
|
this._menuTimeoutId = Mainloop.timeout_add(MENU_POPUP_TIMEOUT,
|
|
|
|
Lang.bind(this, function() {
|
2010-05-20 11:18:46 -04:00
|
|
|
this.popupMenu();
|
2010-03-10 08:52:28 -05:00
|
|
|
}));
|
2011-01-26 11:15:41 -05:00
|
|
|
} else if (button == 3) {
|
|
|
|
this.popupMenu();
|
|
|
|
return true;
|
2010-03-10 08:52:28 -05:00
|
|
|
}
|
2011-01-26 11:15:41 -05:00
|
|
|
return false;
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
2011-01-25 16:22:00 -05:00
|
|
|
_onClicked: function(actor, button) {
|
2010-03-10 08:52:28 -05:00
|
|
|
this._removeMenuTimeout();
|
|
|
|
|
2009-11-12 17:46:59 -05:00
|
|
|
if (button == 1) {
|
2011-01-25 16:22:00 -05:00
|
|
|
this._onActivate(Clutter.get_current_event());
|
2010-04-14 16:22:41 -04:00
|
|
|
} else if (button == 2) {
|
2011-01-25 16:45:58 -05:00
|
|
|
// Last workspace is always empty
|
|
|
|
let launchWorkspace = global.screen.get_workspace_by_index(global.screen.n_workspaces - 1);
|
|
|
|
launchWorkspace.activate(global.get_current_time());
|
|
|
|
this.emit('launching');
|
2011-01-30 16:09:58 -05:00
|
|
|
this.app.open_new_window(-1);
|
2011-01-25 16:45:58 -05:00
|
|
|
Main.overview.hide();
|
2009-11-12 17:46:59 -05:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2011-02-03 12:38:03 -05:00
|
|
|
_onKeyboardPopupMenu: function() {
|
|
|
|
this.popupMenu();
|
|
|
|
this._menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
|
|
|
},
|
|
|
|
|
2010-02-15 19:50:36 -05:00
|
|
|
getId: function() {
|
|
|
|
return this.app.get_id();
|
|
|
|
},
|
|
|
|
|
2010-05-20 11:18:46 -04:00
|
|
|
popupMenu: function() {
|
2010-03-10 08:52:28 -05:00
|
|
|
this._removeMenuTimeout();
|
|
|
|
this.actor.fake_release();
|
|
|
|
|
2009-11-12 17:46:59 -05:00
|
|
|
if (!this._menu) {
|
|
|
|
this._menu = new AppIconMenu(this);
|
|
|
|
this._menu.connect('activate-window', Lang.bind(this, function (menu, window) {
|
|
|
|
this.activateWindow(window);
|
|
|
|
}));
|
2011-09-15 15:49:13 -04:00
|
|
|
this._menu.connect('open-state-changed', Lang.bind(this, function (menu, isPoppedUp) {
|
2011-02-12 14:03:44 -05:00
|
|
|
if (!isPoppedUp)
|
2009-11-12 17:46:59 -05:00
|
|
|
this._onMenuPoppedDown();
|
|
|
|
}));
|
2011-02-03 12:38:03 -05:00
|
|
|
Main.overview.connect('hiding', Lang.bind(this, function () { this._menu.close(); }));
|
2010-05-20 11:18:46 -04:00
|
|
|
|
2010-10-07 14:15:51 -04:00
|
|
|
this._menuManager.addMenu(this._menu);
|
2009-11-12 17:46:59 -05:00
|
|
|
}
|
|
|
|
|
2012-11-03 16:03:33 -04:00
|
|
|
this.emit('menu-state-changed', true);
|
|
|
|
|
2011-03-22 10:43:27 -04:00
|
|
|
this.actor.set_hover(true);
|
2010-05-20 11:18:46 -04:00
|
|
|
this._menu.popup();
|
2012-02-29 19:09:41 -05:00
|
|
|
this._menuManager.ignoreRelease();
|
2009-11-12 17:46:59 -05:00
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2009-12-08 12:51:05 -05:00
|
|
|
activateWindow: function(metaWindow) {
|
|
|
|
if (metaWindow) {
|
2010-02-17 14:05:06 -05:00
|
|
|
Main.activateWindow(metaWindow);
|
Major ShellApp API cleanup, startup notification, window focus handling
This patch combines several high level changes which are conceptually
independent but in practice rather intertwined.
* Add a "state" property to ShellApp which reflects whether it's
stopped, starting, or started. This will allow us to later clean
up all the callers that are using ".get_windows().length > 0" as
a proxy for this property
* Replace shell_app_launch with shell_app_activate and shell_app_open_new_window
A lot of code was calling .launch, but it's signficantly clearer
if we call this ".open_new_window()", and later if we gain the ability
to call into an application's menu, we can implement this correctly rather
than trying to update all .launch callers.
* Because ShellApp now has a "starting" state, rebase panel.js on top of
this so that when we get a startup-notification sequence for an app
and transition it to starting, it becomes the focus app, and panel.js
cleanly just tracks the focus app, rather than bouncing between SN
sequences. This removes display of non-app startup sequences, which
I consider an acceptable action in light of the committed changes
to startup-notification and GTK+.
https://bugzilla.gnome.org/show_bug.cgi?id=614755
2010-04-03 14:07:44 -04:00
|
|
|
} else {
|
2009-12-08 12:51:05 -05:00
|
|
|
Main.overview.hide();
|
Major ShellApp API cleanup, startup notification, window focus handling
This patch combines several high level changes which are conceptually
independent but in practice rather intertwined.
* Add a "state" property to ShellApp which reflects whether it's
stopped, starting, or started. This will allow us to later clean
up all the callers that are using ".get_windows().length > 0" as
a proxy for this property
* Replace shell_app_launch with shell_app_activate and shell_app_open_new_window
A lot of code was calling .launch, but it's signficantly clearer
if we call this ".open_new_window()", and later if we gain the ability
to call into an application's menu, we can implement this correctly rather
than trying to update all .launch callers.
* Because ShellApp now has a "starting" state, rebase panel.js on top of
this so that when we get a startup-notification sequence for an app
and transition it to starting, it becomes the focus app, and panel.js
cleanly just tracks the focus app, rather than bouncing between SN
sequences. This removes display of non-app startup sequences, which
I consider an acceptable action in light of the committed changes
to startup-notification and GTK+.
https://bugzilla.gnome.org/show_bug.cgi?id=614755
2010-04-03 14:07:44 -04:00
|
|
|
}
|
2009-12-08 12:51:05 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onMenuPoppedDown: function() {
|
2010-03-19 13:47:34 -04:00
|
|
|
this.actor.sync_hover();
|
2012-11-03 16:03:33 -04:00
|
|
|
this.emit('menu-state-changed', false);
|
2009-12-08 12:51:05 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onActivate: function (event) {
|
2010-02-15 19:50:36 -05:00
|
|
|
this.emit('launching');
|
2012-02-28 11:01:48 -05:00
|
|
|
let modifiers = event.get_state();
|
2009-12-08 12:51:05 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (this._onActivateOverride) {
|
|
|
|
this._onActivateOverride(event);
|
2009-12-08 12:51:05 -05:00
|
|
|
} else {
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (modifiers & Clutter.ModifierType.CONTROL_MASK
|
|
|
|
&& this.app.state == Shell.AppState.RUNNING) {
|
|
|
|
this.app.open_new_window(-1);
|
|
|
|
} else {
|
2011-08-11 05:35:23 -04:00
|
|
|
this.app.activate();
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
}
|
2009-12-08 12:51:05 -05:00
|
|
|
}
|
Major ShellApp API cleanup, startup notification, window focus handling
This patch combines several high level changes which are conceptually
independent but in practice rather intertwined.
* Add a "state" property to ShellApp which reflects whether it's
stopped, starting, or started. This will allow us to later clean
up all the callers that are using ".get_windows().length > 0" as
a proxy for this property
* Replace shell_app_launch with shell_app_activate and shell_app_open_new_window
A lot of code was calling .launch, but it's signficantly clearer
if we call this ".open_new_window()", and later if we gain the ability
to call into an application's menu, we can implement this correctly rather
than trying to update all .launch callers.
* Because ShellApp now has a "starting" state, rebase panel.js on top of
this so that when we get a startup-notification sequence for an app
and transition it to starting, it becomes the focus app, and panel.js
cleanly just tracks the focus app, rather than bouncing between SN
sequences. This removes display of non-app startup sequences, which
I consider an acceptable action in light of the committed changes
to startup-notification and GTK+.
https://bugzilla.gnome.org/show_bug.cgi?id=614755
2010-04-03 14:07:44 -04:00
|
|
|
Main.overview.hide();
|
2009-09-01 14:15:29 -04:00
|
|
|
},
|
|
|
|
|
2011-01-30 16:09:58 -05:00
|
|
|
shellWorkspaceLaunch : function(params) {
|
2011-08-11 05:35:23 -04:00
|
|
|
params = Params.parse(params, { workspace: -1,
|
|
|
|
timestamp: 0 });
|
2011-01-30 16:09:58 -05:00
|
|
|
|
2011-08-11 05:35:23 -04:00
|
|
|
this.app.open_new_window(params.workspace);
|
2009-08-17 20:29:54 -04:00
|
|
|
},
|
|
|
|
|
2009-09-11 17:13:50 -04:00
|
|
|
getDragActor: function() {
|
2011-08-28 09:35:13 -04:00
|
|
|
return this.app.create_icon_texture(Main.overview.dashIconSize);
|
2009-06-30 16:35:39 -04:00
|
|
|
},
|
|
|
|
|
2010-02-04 16:57:38 -05:00
|
|
|
// Returns the original actor that should align with the actor
|
|
|
|
// we show as the item is being dragged.
|
2009-06-30 16:35:39 -04:00
|
|
|
getDragActorSource: function() {
|
2010-07-21 19:29:02 -04:00
|
|
|
return this.icon.icon;
|
2009-09-01 14:15:29 -04:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2009-12-08 12:51:05 -05:00
|
|
|
Signals.addSignalMethods(AppWellIcon.prototype);
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2011-11-20 08:10:48 -05:00
|
|
|
const AppIconMenu = new Lang.Class({
|
|
|
|
Name: 'AppIconMenu',
|
|
|
|
Extends: PopupMenu.PopupMenu,
|
2010-05-20 11:18:46 -04:00
|
|
|
|
2009-11-12 17:46:59 -05:00
|
|
|
_init: function(source) {
|
2010-11-29 16:07:10 -05:00
|
|
|
let side = St.Side.LEFT;
|
2012-02-13 20:37:28 -05:00
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
|
2010-11-29 16:07:10 -05:00
|
|
|
side = St.Side.RIGHT;
|
|
|
|
|
2011-11-20 08:10:48 -05:00
|
|
|
this.parent(source.actor, 0.5, side);
|
2010-05-20 11:18:46 -04:00
|
|
|
|
2011-03-22 10:43:27 -04:00
|
|
|
// We want to keep the item hovered while the menu is up
|
|
|
|
this.blockSourceEvents = true;
|
|
|
|
|
2009-11-12 17:46:59 -05:00
|
|
|
this._source = source;
|
|
|
|
|
2010-05-20 11:18:46 -04:00
|
|
|
this.connect('activate', Lang.bind(this, this._onActivate));
|
|
|
|
|
|
|
|
this.actor.add_style_class_name('app-well-menu');
|
2009-11-12 17:46:59 -05:00
|
|
|
|
|
|
|
// Chain our visibility and lifecycle to that of the source
|
|
|
|
source.actor.connect('notify::mapped', Lang.bind(this, function () {
|
|
|
|
if (!source.actor.mapped)
|
2010-05-20 11:18:46 -04:00
|
|
|
this.close();
|
2009-11-12 17:46:59 -05:00
|
|
|
}));
|
|
|
|
source.actor.connect('destroy', Lang.bind(this, function () { this.actor.destroy(); }));
|
|
|
|
|
2010-05-06 17:18:10 -04:00
|
|
|
Main.uiGroup.add_actor(this.actor);
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_redisplay: function() {
|
2010-05-20 11:18:46 -04:00
|
|
|
this.removeAll();
|
2009-11-12 17:46:59 -05:00
|
|
|
|
|
|
|
let windows = this._source.app.get_windows();
|
|
|
|
|
|
|
|
// Display the app windows menu items and the separator between windows
|
|
|
|
// of the current desktop and other windows.
|
|
|
|
let activeWorkspace = global.screen.get_active_workspace();
|
|
|
|
let separatorShown = windows.length > 0 && windows[0].get_workspace() != activeWorkspace;
|
|
|
|
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
if (!separatorShown && windows[i].get_workspace() != activeWorkspace) {
|
|
|
|
this._appendSeparator();
|
|
|
|
separatorShown = true;
|
|
|
|
}
|
2010-05-20 11:18:46 -04:00
|
|
|
let item = this._appendMenuItem(windows[i].title);
|
|
|
|
item._window = windows[i];
|
2009-11-12 17:46:59 -05:00
|
|
|
}
|
|
|
|
|
2011-08-11 06:06:38 -04:00
|
|
|
if (!this._source.app.is_window_backed()) {
|
|
|
|
if (windows.length > 0)
|
|
|
|
this._appendSeparator();
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2011-08-11 06:06:38 -04:00
|
|
|
let isFavorite = AppFavorites.getAppFavorites().isFavorite(this._source.app.get_id());
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2011-08-11 06:06:38 -04:00
|
|
|
this._newWindowMenuItem = this._appendMenuItem(_("New Window"));
|
|
|
|
this._appendSeparator();
|
2009-11-12 17:46:59 -05:00
|
|
|
|
2011-08-11 06:06:38 -04:00
|
|
|
this._toggleFavoriteMenuItem = this._appendMenuItem(isFavorite ? _("Remove from Favorites")
|
|
|
|
: _("Add to Favorites"));
|
|
|
|
}
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_appendSeparator: function () {
|
2010-05-20 11:18:46 -04:00
|
|
|
let separator = new PopupMenu.PopupSeparatorMenuItem();
|
|
|
|
this.addMenuItem(separator);
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_appendMenuItem: function(labelText) {
|
2010-05-20 11:18:46 -04:00
|
|
|
// FIXME: app-well-menu-item style
|
|
|
|
let item = new PopupMenu.PopupMenuItem(labelText);
|
|
|
|
this.addMenuItem(item);
|
|
|
|
return item;
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
popup: function(activatingButton) {
|
|
|
|
this._redisplay();
|
2010-05-20 11:18:46 -04:00
|
|
|
this.open();
|
2009-11-12 17:46:59 -05:00
|
|
|
},
|
|
|
|
|
2010-05-20 11:18:46 -04:00
|
|
|
_onActivate: function (actor, child) {
|
2009-11-12 17:46:59 -05:00
|
|
|
if (child._window) {
|
|
|
|
let metaWindow = child._window;
|
|
|
|
this.emit('activate-window', metaWindow);
|
|
|
|
} else if (child == this._newWindowMenuItem) {
|
2011-01-30 16:09:58 -05:00
|
|
|
this._source.app.open_new_window(-1);
|
2009-11-12 17:46:59 -05:00
|
|
|
this.emit('activate-window', null);
|
|
|
|
} else if (child == this._toggleFavoriteMenuItem) {
|
|
|
|
let favs = AppFavorites.getAppFavorites();
|
|
|
|
let isFavorite = favs.isFavorite(this._source.app.get_id());
|
|
|
|
if (isFavorite)
|
|
|
|
favs.removeFavorite(this._source.app.get_id());
|
|
|
|
else
|
|
|
|
favs.addFavorite(this._source.app.get_id());
|
|
|
|
}
|
2010-05-20 11:18:46 -04:00
|
|
|
this.close();
|
2009-11-12 17:46:59 -05:00
|
|
|
}
|
2011-11-20 08:10:48 -05:00
|
|
|
});
|
2009-11-12 17:46:59 -05:00
|
|
|
Signals.addSignalMethods(AppIconMenu.prototype);
|