[gnome-shell] appDisplay: Don't show apps in NoDisplay categories in the All view
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] appDisplay: Don't show apps in NoDisplay categories in the All view
- Date: Mon, 11 Jun 2012 18:54:10 +0000 (UTC)
commit 196f6c241af935cb03d07c9ebc719c6ea38846d9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jun 11 13:53:32 2012 -0400
appDisplay: Don't show apps in NoDisplay categories in the All view
We explicitly include NoDisplay applications in the ShellAppSystem because
we want app tracking for them, but we explicitly filter NoDisplay applications
out when showing them to the user because we don't want to show them to the
user. We also based our "All" apps view on a flattened list of apps. While
we did check for NoDisplay on the app item itself, we didn't check against
its parents. Refactor the app display view to not use a separate flat list
of applications, but instead a concatenation of all the applications in all
the loaded categories.
https://bugzilla.gnome.org/show_bug.cgi?id=658176
js/ui/appDisplay.js | 41 ++++++++++++++++++-----------------------
js/ui/iconGrid.js | 7 +++++--
src/shell-app-system.c | 24 ------------------------
src/shell-app-system.h | 2 --
4 files changed, 23 insertions(+), 51 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 8ce1811..ad7b70d 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -22,6 +22,7 @@ const Search = imports.ui.search;
const Tweener = imports.ui.tweener;
const Workspace = imports.ui.workspace;
const Params = imports.misc.params;
+const Util = imports.misc.util;
const MAX_APPLICATION_WORK_MILLIS = 75;
const MENU_POPUP_TIMEOUT = 600;
@@ -36,6 +37,7 @@ const AlphabeticalView = new Lang.Class({
this._pendingAppLaterId = 0;
this._appIcons = {}; // desktop file id
+ this._allApps = [];
let box = new St.BoxLayout({ vertical: true });
box.add(this._grid.actor, { y_align: St.Align.START, expand: true });
@@ -60,16 +62,22 @@ const AlphabeticalView = new Lang.Class({
}));
},
- _removeAll: function() {
+ removeAll: function() {
this._grid.removeAll();
this._appIcons = {};
+ this._allApps = [];
},
- _addApp: function(app) {
+ addApp: function(app) {
var id = app.get_id();
- let appIcon = new AppWellIcon(app);
+ if (this._appIcons[id] !== undefined)
+ return;
- this._grid.addItem(appIcon.actor);
+ 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);
appIcon.actor.connect('key-focus-in', Lang.bind(this, this._ensureIconVisible));
this._appIcons[id] = appIcon;
@@ -120,14 +128,6 @@ const AlphabeticalView = new Lang.Class({
icon.actor.visible = true;
}
}
- },
-
- setAppList: function(apps) {
- this._removeAll();
- for (var i = 0; i < apps.length; i++) {
- var app = apps[i];
- this._addApp(app);
- }
}
});
@@ -147,7 +147,6 @@ const ViewByCategories = new Lang.Class({
// (used only before the actor is mapped the first time)
this._currentCategory = -2;
this._categories = [];
- this._apps = null;
this._categoryBox = new St.BoxLayout({ vertical: true,
reactive: true,
@@ -204,8 +203,10 @@ const ViewByCategories = new Lang.Class({
if (nextType == GMenu.TreeItemType.ENTRY) {
var entry = iter.get_entry();
var app = this._appSystem.lookup_app_by_tree_entry(entry);
- if (!entry.get_app_info().get_nodisplay())
+ if (!entry.get_app_info().get_nodisplay()) {
+ this._view.addApp(app);
appList.push(app);
+ }
} else if (nextType == GMenu.TreeItemType.DIRECTORY) {
if (!dir.get_is_nodisplay())
this._loadCategory(iter.get_directory(), appList);
@@ -213,7 +214,7 @@ const ViewByCategories = new Lang.Class({
}
},
- _addCategory: function(name, index, dir, allApps) {
+ _addCategory: function(name, index, dir) {
let button = new St.Button({ label: GLib.markup_escape_text (name, -1),
style_class: 'app-filter',
x_align: St.Align.START,
@@ -225,7 +226,6 @@ const ViewByCategories = new Lang.Class({
var apps;
if (dir == null) {
- apps = allApps;
this._allCategoryButton = button;
} else {
apps = [];
@@ -239,6 +239,7 @@ const ViewByCategories = new Lang.Class({
},
_removeAll: function() {
+ this._view.removeAll();
this._categories = [];
this._categoryBox.destroy_all_children();
},
@@ -246,13 +247,8 @@ const ViewByCategories = new Lang.Class({
refresh: function() {
this._removeAll();
- var allApps = Shell.AppSystem.get_default().get_all();
- allApps.sort(function(a, b) {
- return a.compare_by_name(b);
- });
-
/* Translators: Filter to display all applications */
- this._addCategory(_("All"), -1, null, allApps);
+ this._addCategory(_("All"), -1, null);
var tree = this._appSystem.get_tree();
var root = tree.get_root_directory();
@@ -270,7 +266,6 @@ const ViewByCategories = new Lang.Class({
}
}
- this._view.setAppList(allApps);
this._selectCategory(-1);
if (this._focusDummy) {
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 82a9552..81f5cef 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -313,8 +313,11 @@ const IconGrid = new Lang.Class({
this._grid.destroy_all_children();
},
- addItem: function(actor) {
- this._grid.add_actor(actor);
+ addItem: function(actor, index) {
+ if (index !== undefined)
+ this._grid.insert_child_at_index(actor, index);
+ else
+ this._grid.add_actor(actor);
},
getItemAtIndex: function(index) {
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index a7d1441..56ff9eb 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -644,30 +644,6 @@ shell_app_system_lookup_wmclass (ShellAppSystem *system,
return app;
}
-/**
- * shell_app_system_get_all:
- * @system:
- *
- * Returns: (transfer container) (element-type ShellApp): All installed applications
- */
-GSList *
-shell_app_system_get_all (ShellAppSystem *self)
-{
- GSList *result = NULL;
- GHashTableIter iter;
- gpointer key, value;
-
- g_hash_table_iter_init (&iter, self->priv->id_to_app);
- while (g_hash_table_iter_next (&iter, &key, &value))
- {
- ShellApp *app = value;
-
- if (!g_desktop_app_info_get_nodisplay (shell_app_get_app_info (app)))
- result = g_slist_prepend (result, app);
- }
- return result;
-}
-
void
_shell_app_system_notify_app_state_changed (ShellAppSystem *self,
ShellApp *app)
diff --git a/src/shell-app-system.h b/src/shell-app-system.h
index b76c642..d261fe4 100644
--- a/src/shell-app-system.h
+++ b/src/shell-app-system.h
@@ -52,8 +52,6 @@ ShellApp *shell_app_system_lookup_heuristic_basename (ShellAppSystem *
ShellApp *shell_app_system_lookup_wmclass (ShellAppSystem *system,
const char *wmclass);
-GSList *shell_app_system_get_all (ShellAppSystem *system);
-
GSList *shell_app_system_get_running (ShellAppSystem *self);
GSList *shell_app_system_initial_search (ShellAppSystem *system,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]