Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 27 additions & 33 deletions QuickLaunch@github.com/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,15 @@ const Atk = imports.gi.Atk;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Lang = imports.lang;
const ExtensionUtils = imports.misc.extensionUtils;
const FileUtils = imports.misc.fileUtils;
const Util = imports.misc.util;

const AppsPath = GLib.get_home_dir() + '/.local/share/gnome-shell/quicklaunch';
const AppsPaths = [ GLib.get_home_dir() + '/.local/user/apps', AppsPath ];

const IndicatorName = 'QuickLaunch';

/**
* Gicon Menu Item Object
*/
function PopupGiconMenuItem() {
this._init.apply(this, arguments);
}

PopupGiconMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,

_init: function (text, gIcon, params) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, params);

this.label = new St.Label({ text: text });
this._icon = new St.Icon({
gicon: gIcon,
style_class: 'popup-menu-icon' });
this.actor.add_child(this._icon, { align: St.Align.END });
this.actor.add_child(this.label);
},
};
const Me = ExtensionUtils.getCurrentExtension();
const IndicatorName = Me.metadata.name;

/**
* QuickLaunch Object
Expand All @@ -50,18 +30,24 @@ const QuickLaunch = new Lang.Class({
Name: IndicatorName,
Extends: PanelMenu.Button,

_init: function(metadata, params) {
_init: function(menuAlignment, nameText, dontCreateMenu) {
this.item = new PanelMenu.Button(arguments);
this.parent(null, IndicatorName);
this.actor.accessible_role = Atk.Role.TOGGLE_BUTTON;
this.item.accessible_role = Atk.Role.TOGGLE_BUTTON;
this.item.add_style_class_name('panel-status-button');

this._icon = new St.Icon({ icon_name: 'system-run-symbolic', style_class: 'system-status-icon' });
this.actor.add_actor(this._icon);
this.actor.add_style_class_name('panel-status-button');
this._icon = new St.Icon({
icon_name: 'user-bookmarks-symbolic',
style_class: 'system-status-icon' });
this._indicators = new St.BoxLayout( {style_class: 'panel-status-indicators-box'} );
this._indicators.add(this._icon);
this.actor.add_child(this._indicators);

this.connect('destroy', Lang.bind(this, this._onDestroy));
this.item.connect('destroy', Lang.bind(this, this._onDestroy));
this._setupDirectory();
this._setupAppMenuItems();
this._setupNewEntryDialog();
//### disabled
//### this._setupNewEntryDialog();
this._setupDirectoryMonitor();
},

Expand All @@ -88,7 +74,8 @@ const QuickLaunch = new Lang.Class({
_reloadAppMenu: function() {
this.menu.removeAll();
this._setupAppMenuItems();
this._setupNewEntryDialog();
//### disabled
//### this._setupNewEntryDialog();
},

/**
Expand Down Expand Up @@ -146,6 +133,7 @@ const QuickLaunch = new Lang.Class({
continue;
let name = info.get_name();
if( name.indexOf('.desktop') > -1) {
global.log('Add menu entry: ' + name);
let desktopPath = GLib.build_filenamev([path, name]);
this._addAppItem(desktopPath);
i++;
Expand Down Expand Up @@ -187,7 +175,8 @@ const QuickLaunch = new Lang.Class({
* create popoup menu item with callback
*/
_createAppItem: function(appInfo, callback) {
let menuItem = new PopupGiconMenuItem(appInfo.get_name(), appInfo.get_icon(), {});
let menuItem = new PopupMenu.PopupImageMenuItem(
appInfo.get_name(), appInfo.get_icon(), {});
menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
callback(menuItem, event);
}));
Expand Down Expand Up @@ -221,6 +210,9 @@ const QuickLaunch = new Lang.Class({
* DesktopEntryCreator
*
* use gnome-dekstop-item-edit to create a new desktop entry file
*
* FIXME: not available in default Ubuntu 20.04
*
*/
const DesktopEntryCreator = new Lang.Class({
Name: 'DesktopEntryCreator',
Expand Down Expand Up @@ -256,12 +248,14 @@ const DesktopEntryCreator = new Lang.Class({
* Extension Setup
*/
function init() {
global.log(`Initializing ${Me.metadata.name} version ${Me.metadata.version}`);
}

let _indicator;

function enable() {
_indicator = new QuickLaunch();
_indicator = new QuickLaunch(0, IndicatorName);
// Default to position = 0 and _rightBox boxContainer
Main.panel.addToStatusArea(IndicatorName, _indicator);
}

Expand Down
2 changes: 1 addition & 1 deletion QuickLaunch@github.com/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shell-version": ["3.4", "3.6", "3.8", "3.10","3.11.5","3.12", "3.14", "3.16", "3.18"], "uuid": "QuickLaunch@github.com", "name": "QuickLaunch", "description": "Quick Launch - Launch custom made .desktop files from a directory", "url": "https://github.com/manno/gnome-shell-extension-quicklaunch"}
{"shell-version": ["3.36"], "uuid": "QuickLaunch@github.com", "name": "QuickLaunch", "description": "Quick Launch - Launch custom made .desktop files from a directory", "version": 11, "url": "https://github.com/manno/gnome-shell-extension-quicklaunch"}