appDisplay: do not show empty categories

Desktop files can specify if the application should only be shown for
specified desktops with OnlyShowIn and NotShowIn directives options.

If a menu category only contained entries for a different desktop, we
were still creating the category.

We now only add a category button if there is at least one application
to be displayed in this category.

https://bugzilla.gnome.org/show_bug.cgi?id=687970
This commit is contained in:
Stéphane Démurget 2012-11-16 08:22:58 +01:00
parent 59a7fdd2c9
commit e6a3958e45

View File

@ -216,6 +216,16 @@ const ViewByCategories = new Lang.Class({
}, },
_addCategory: function(name, index, dir) { _addCategory: function(name, index, dir) {
let apps;
if (dir != null) {
apps = [];
this._loadCategory(dir, apps);
if (apps.length == 0)
return;
}
let button = new St.Button({ label: GLib.markup_escape_text (name, -1), let button = new St.Button({ label: GLib.markup_escape_text (name, -1),
style_class: 'app-filter', style_class: 'app-filter',
x_align: St.Align.START, x_align: St.Align.START,
@ -225,12 +235,9 @@ const ViewByCategories = new Lang.Class({
this._selectCategory(index); this._selectCategory(index);
})); }));
var apps;
if (dir == null) { if (dir == null) {
this._allCategoryButton = button; this._allCategoryButton = button;
} else { } else {
apps = [];
this._loadCategory(dir, apps);
this._categories.push({ apps: apps, this._categories.push({ apps: apps,
name: name, name: name,
button: button }); button: button });