[gnome-shell-extensions] New Extension: Places Menu Status Indicator



commit a78e42e4fc28efc42ed47d698584c558335fe4f5
Author: Vamsi Krishna Brahmajosyula <vamsikrishna brahmajosyula gmail com>
Date:   Wed May 4 19:31:26 2011 +0530

    New Extension: Places Menu Status Indicator
    
    Signed-off-by: Vamsi Krishna Brahmajosyula <vamsikrishna brahmajosyula gmail com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=648724

 README                                  |    4 +
 configure.ac                            |    7 +-
 extensions/places-menu/Makefile.am      |    3 +
 extensions/places-menu/extension.js     |  122 +++++++++++++++++++++++++++++++
 extensions/places-menu/metadata.json.in |    8 ++
 extensions/places-menu/stylesheet.css   |    1 +
 6 files changed, 142 insertions(+), 3 deletions(-)
---
diff --git a/README b/README
index 1e0ecf9..0e18540 100644
--- a/README
+++ b/README
@@ -48,6 +48,10 @@ gajim
 
   Integration with Gajim, a Jabber/XMPP instant messaging client.
 
+places-menu
+
+  Shows a status Indicator for navigating to Places.
+
 user-theme
 
   Loads a shell theme from ~/.themes/<name>/gnome-shell.
diff --git a/configure.ac b/configure.ac
index 2e66abc..be59e71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,9 +21,9 @@ GLIB_GSETTINGS
 ADDITIONAL_PACKAGES=
 
 dnl keep this in sync with extensions/Makefile.am
-ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme alternative-status-menu gajim drive-menu"
+ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme alternative-status-menu gajim drive-menu places-menu"
 AC_SUBST(ALL_EXTENSIONS, [$ALL_EXTENSIONS])
-DEFAULT_EXTENSIONS="alternate-tab windowsNavigator dock alternative-status-menu drive-menu"
+DEFAULT_EXTENSIONS="alternate-tab windowsNavigator dock alternative-status-menu drive-menu places-menu"
 AC_ARG_ENABLE([extensions],
 	[AS_HELP_STRING([--enable-extensions],[Space separated list of extensions to enable.
 	The default is to build all extensions that can be installed in the home directory and have no external depedencies.
@@ -43,7 +43,7 @@ for e in $enable_extensions; do
 			ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
 			ADDITIONAL_PACKAGES="$ADDITIONAL_PAGKAGES gnome-desktop-3.0 >= 2.91.6"
 			;;
-		alternate-tab|example|windowsNavigator|auto-move-windows|dock|user-theme|alternative-status-menu|gajim|drive-menu)
+		alternate-tab|example|windowsNavigator|auto-move-windows|dock|user-theme|alternative-status-menu|gajim|drive-menu|places-menu)
 			ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
 			;;
 		*)
@@ -70,6 +70,7 @@ AC_CONFIG_FILES([
   extensions/example/Makefile
   extensions/windowsNavigator/Makefile
   extensions/gajim/Makefile
+  extensions/places-menu/Makefile
   extensions/xrandr-indicator/Makefile
   extensions/user-theme/Makefile
   extensions/Makefile
diff --git a/extensions/places-menu/Makefile.am b/extensions/places-menu/Makefile.am
new file mode 100644
index 0000000..19b537f
--- /dev/null
+++ b/extensions/places-menu/Makefile.am
@@ -0,0 +1,3 @@
+EXTENSION_ID = places-menu
+
+include ../../extension.mk
diff --git a/extensions/places-menu/extension.js b/extensions/places-menu/extension.js
new file mode 100644
index 0000000..1c2bac2
--- /dev/null
+++ b/extensions/places-menu/extension.js
@@ -0,0 +1,122 @@
+/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
+
+const Gdk = imports.gi.Gdk;
+const GLib = imports.gi.GLib;
+const Lang = imports.lang;
+const Shell = imports.gi.Shell;
+const St = imports.gi.St;
+
+const Main = imports.ui.main;
+const PanelMenu = imports.ui.panelMenu;
+const PopupMenu = imports.ui.popupMenu;
+const Panel = imports.ui.panel;
+
+const Gettext = imports.gettext.domain('gnome-shell-extensions');
+const _ = Gettext.gettext;
+
+const PLACE_ICON_SIZE = 22;
+
+function PlacesMenu() {
+    this._init.apply(this, arguments);
+}
+
+PlacesMenu.prototype = {
+    __proto__: PanelMenu.SystemStatusButton.prototype,
+
+    _init: function() {
+
+        PanelMenu.SystemStatusButton.prototype._init.call(this, 'folder');
+
+        this.defaultItems = [];
+        this.bookmarkItems = [];
+        this.deviceItems = [];
+        this._createDefaultPlaces();
+        this._bookmarksSection = new PopupMenu.PopupMenuSection();
+        this.menu.addMenuItem(this._bookmarksSection);
+        this._createBookmarks();
+        this._devicesMenuItem = new PopupMenu.PopupSubMenuMenuItem('Removable Devices');
+        this.menu.addMenuItem(this._devicesMenuItem);
+        this._createDevices();
+        Main.placesManager.connect('bookmarks-updated',Lang.bind(this,this._redisplayBookmarks));
+        Main.placesManager.connect('mounts-updated',Lang.bind(this,this._redisplayDevices));
+
+    },
+
+    _redisplayBookmarks: function(){
+
+        this._clearBookmarks();
+        this._createBookmarks();
+    },
+    _redisplayDevices: function(){
+        this._clearDevices();
+        this._createDevices();
+
+    },
+
+    _createDefaultPlaces : function() {
+
+        this.defaultPlaces = Main.placesManager.getDefaultPlaces();
+          for (let placeid = 0; placeid < this.defaultPlaces.length; placeid++) {
+            this.defaultItems[placeid] = new PopupMenu.PopupMenuItem(_(this.defaultPlaces[placeid].name));
+            let icon = this.defaultPlaces[placeid].iconFactory(PLACE_ICON_SIZE);
+            this.defaultItems[placeid].addActor(icon, { align: St.Align.END});
+            this.defaultItems[placeid].place = this.defaultPlaces[placeid];
+            this.menu.addMenuItem(this.defaultItems[placeid]);
+            this.defaultItems[placeid].connect('activate', function(actor,event) {
+                actor.place.launch();
+            });
+
+        }
+    }
+    ,
+    _createBookmarks : function() {
+
+        this.bookmarks     = Main.placesManager.getBookmarks();
+        for (let bookmarkid = 0; bookmarkid < this.bookmarks.length; bookmarkid++) {
+            this.bookmarkItems[bookmarkid] = new PopupMenu.PopupMenuItem(_(this.bookmarks[bookmarkid].name));
+            let icon = this.bookmarks[bookmarkid].iconFactory(PLACE_ICON_SIZE);
+            this.bookmarkItems[bookmarkid].addActor(icon, { align: St.Align.END});
+            this.bookmarkItems[bookmarkid].place = this.bookmarks[bookmarkid];
+            this._bookmarksSection.addMenuItem(this.bookmarkItems[bookmarkid]);
+            this.bookmarkItems[bookmarkid].connect('activate', function(actor,event) {
+                actor.place.launch();
+            });
+
+    }
+    },
+    _createDevices : function() {
+
+        this.devices = Main.placesManager.getMounts();
+        for (let devid = 0; devid < this.devices.length; devid++) {
+            this.deviceItems[devid] = new PopupMenu.PopupMenuItem(_(this.devices[devid].name));
+            let icon = this.devices[devid].iconFactory(PLACE_ICON_SIZE);
+            this.deviceItems[devid].addActor(icon, { align: St.Align.END});
+            this.deviceItems[devid].place = this.devices[devid];
+            this._devicesMenuItem.menu.addMenuItem(this.deviceItems[devid]);
+            this.deviceItems[devid].connect('activate', function(actor,event) {
+                actor.place.launch();
+            });
+        }
+
+    },
+
+    _clearBookmarks : function(){
+
+        this._bookmarksSection.removeAll();
+        this.bookmarkItems = [];
+
+    },
+
+    _clearDevices : function(){
+        this._devicesMenuItem.menu.removeAll();
+        this.DeviceItems = [];
+    },
+
+};
+
+
+function main(metadata) {
+    imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
+    Panel.STANDARD_TRAY_ICON_ORDER.unshift('places-menu');
+    Panel.STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION['places-menu'] = PlacesMenu;
+}
diff --git a/extensions/places-menu/metadata.json.in b/extensions/places-menu/metadata.json.in
new file mode 100644
index 0000000..c32bf8e
--- /dev/null
+++ b/extensions/places-menu/metadata.json.in
@@ -0,0 +1,8 @@
+{
+"uuid": "@uuid@",
+"name": "Places Status Indicator",
+"description": "Add a systems status menu for quickly navigating places in the system",
+"shell-version": [ "@shell_current@" ],
+"localedir": "@LOCALEDIR@",
+"url": "@url@"
+}
diff --git a/extensions/places-menu/stylesheet.css b/extensions/places-menu/stylesheet.css
new file mode 100644
index 0000000..db99e0c
--- /dev/null
+++ b/extensions/places-menu/stylesheet.css
@@ -0,0 +1 @@
+/* none used*/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]