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
This commit is contained in:
committed by
Giovanni Campagna
parent
5b212bd1fd
commit
a78e42e4fc
4
README
4
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.
|
||||
|
||||
@@ -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
|
||||
|
||||
3
extensions/places-menu/Makefile.am
Normal file
3
extensions/places-menu/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
||||
EXTENSION_ID = places-menu
|
||||
|
||||
include ../../extension.mk
|
||||
122
extensions/places-menu/extension.js
Normal file
122
extensions/places-menu/extension.js
Normal file
@@ -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;
|
||||
}
|
||||
8
extensions/places-menu/metadata.json.in
Normal file
8
extensions/places-menu/metadata.json.in
Normal file
@@ -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@"
|
||||
}
|
||||
1
extensions/places-menu/stylesheet.css
Normal file
1
extensions/places-menu/stylesheet.css
Normal file
@@ -0,0 +1 @@
|
||||
/* none used*/
|
||||
Reference in New Issue
Block a user