[gnome-shell-extensions] apps-menu: Clean up code
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] apps-menu: Clean up code
- Date: Fri, 8 Feb 2013 12:25:20 +0000 (UTC)
commit c626cc2a1d412ef1000d2c74860bd19fb5711971
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Feb 1 14:51:25 2013 +0100
apps-menu: Clean up code
The empty array is created and inserted into the hashtable before
every call to _loadCategory. No need to check for it and create it
again inside the function.
Don't mix up negated if conditions with continue while skipping stuff
that should not be displayed. Follow one style for consistency.
https://bugzilla.gnome.org/show_bug.cgi?id=693346
extensions/apps-menu/extension.js | 36 ++++++++++++++++--------------------
1 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 0e05594..fd9c590 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -318,21 +318,18 @@ const ApplicationsButton = new Lang.Class({
if (!entry.get_app_info().get_nodisplay()) {
let app = appSys.lookup_app_by_tree_entry(entry);
let menu_id = dir.get_menu_id();
- if (!this.applicationsByCategory[menu_id])
- this.applicationsByCategory[menu_id] = new Array();
this.applicationsByCategory[menu_id].push(app);
}
} else if (nextType == GMenu.TreeItemType.DIRECTORY) {
let subdir = iter.get_directory();
- if (subdir.get_is_nodisplay())
- continue;
-
- let menu_id = subdir.get_menu_id();
- this.applicationsByCategory[menu_id] = new Array();
- this._loadCategory(subdir);
- if (this.applicationsByCategory[menu_id].length > 0) {
- let categoryMenuItem = new CategoryMenuItem(this, subdir);
- this.categoriesBox.add_actor(categoryMenuItem.actor);
+ if (!subdir.get_is_nodisplay()) {
+ let menu_id = subdir.get_menu_id();
+ this.applicationsByCategory[menu_id] = new Array();
+ this._loadCategory(subdir);
+ if (this.applicationsByCategory[menu_id].length > 0) {
+ let categoryMenuItem = new CategoryMenuItem(this, subdir);
+ this.categoriesBox.add_actor(categoryMenuItem.actor);
+ }
}
}
}
@@ -431,15 +428,14 @@ const ApplicationsButton = new Lang.Class({
while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
if (nextType == GMenu.TreeItemType.DIRECTORY) {
let dir = iter.get_directory();
- if (dir.get_is_nodisplay())
- continue;
-
- let menu_id = dir.get_menu_id();
- this.applicationsByCategory[menu_id] = new Array();
- this._loadCategory(dir);
- if (this.applicationsByCategory[menu_id].length > 0) {
- let categoryMenuItem = new CategoryMenuItem(this, dir);
- this.categoriesBox.add_actor(categoryMenuItem.actor);
+ if (!dir.get_is_nodisplay()) {
+ let menu_id = dir.get_menu_id();
+ this.applicationsByCategory[menu_id] = new Array();
+ this._loadCategory(dir);
+ if (this.applicationsByCategory[menu_id].length > 0) {
+ let categoryMenuItem = new CategoryMenuItem(this, dir);
+ this.categoriesBox.add_actor(categoryMenuItem.actor);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]