2019-10-04 17:46:50 +02:00
|
|
|
Index: gnome-shell-extensions-3.33.91/extensions/apps-menu/extension.js
|
|
|
|
===================================================================
|
|
|
|
--- gnome-shell-extensions-3.33.91.orig/extensions/apps-menu/extension.js
|
|
|
|
+++ gnome-shell-extensions-3.33.91/extensions/apps-menu/extension.js
|
|
|
|
@@ -5,6 +5,8 @@ const {
|
|
|
|
Atk, Clutter, Gio, GLib, GMenu, GObject, Gtk, Meta, Shell, St,
|
2019-04-17 14:56:20 +02:00
|
|
|
} = imports.gi;
|
2019-10-04 17:46:50 +02:00
|
|
|
const Signals = imports.signals;
|
2016-09-01 12:12:54 +02:00
|
|
|
+const BoxPointer = imports.ui.boxpointer;
|
|
|
|
+const AppFavorites = imports.ui.appFavorites;
|
2019-10-04 17:46:50 +02:00
|
|
|
|
2019-04-17 14:56:20 +02:00
|
|
|
const DND = imports.ui.dnd;
|
2019-10-04 17:46:50 +02:00
|
|
|
const ExtensionUtils = imports.misc.extensionUtils;
|
|
|
|
@@ -46,8 +48,19 @@ class ApplicationMenuItem extends PopupM
|
2016-09-01 12:12:54 +02:00
|
|
|
let textureCache = St.TextureCache.get_default();
|
|
|
|
let iconThemeChangedId = textureCache.connect('icon-theme-changed',
|
2019-10-04 17:46:50 +02:00
|
|
|
this._updateIcon.bind(this));
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
2018-03-09 11:02:15 +01:00
|
|
|
+ this.actor.connect('button-press-event', this._onButtonPress.bind(this));
|
|
|
|
+ this.actor.connect('popup-menu', this._onKeyboardPopupMenu.bind(this));
|
2016-09-01 12:12:54 +02:00
|
|
|
+ this._menu = null;
|
|
|
|
+ this._menuManager = new PopupMenu.PopupMenuManager(this);
|
|
|
|
+
|
2019-10-04 17:46:50 +02:00
|
|
|
this.connect('destroy', () => {
|
2018-03-09 11:02:15 +01:00
|
|
|
textureCache.disconnect(iconThemeChangedId);
|
2019-10-04 17:46:50 +02:00
|
|
|
+ if (this._menu) {
|
|
|
|
+ this._menu.destroy();
|
|
|
|
+ this._menu = null;
|
|
|
|
+ this._menuManager = null;
|
|
|
|
+ }
|
2018-03-09 11:02:15 +01:00
|
|
|
});
|
2016-09-01 12:12:54 +02:00
|
|
|
this._updateIcon();
|
2017-08-05 14:05:19 +02:00
|
|
|
|
2019-10-04 17:46:50 +02:00
|
|
|
@@ -62,6 +75,106 @@ class ApplicationMenuItem extends PopupM
|
2019-04-17 14:56:20 +02:00
|
|
|
};
|
2018-03-09 11:02:15 +01:00
|
|
|
}
|
2016-09-01 12:12:54 +02:00
|
|
|
|
2018-03-09 11:02:15 +01:00
|
|
|
+ _onKeyboardPopupMenu() {
|
2016-09-01 12:12:54 +02:00
|
|
|
+ this.popupMenu();
|
|
|
|
+ this._menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
2018-03-09 11:02:15 +01:00
|
|
|
+ }
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
2018-03-09 11:02:15 +01:00
|
|
|
+ _onButtonPress(actor, event) {
|
2016-09-01 12:12:54 +02:00
|
|
|
+ // close any opened menu to avoid input focus grab
|
|
|
|
+ if (this._menu && this._menu.isOpen) {
|
|
|
|
+ this._menu.close();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let button = event.get_button();
|
|
|
|
+ if (button == 3) {
|
|
|
|
+ this.popupMenu();
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
2018-03-09 11:02:15 +01:00
|
|
|
+ }
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
2018-03-09 11:02:15 +01:00
|
|
|
+ popupMenu() {
|
2016-09-01 12:12:54 +02:00
|
|
|
+ if (!this._menu) {
|
|
|
|
+ this._menu = new PopupMenu.PopupMenu(this.actor, 0.0, St.Side.TOP, 0);
|
|
|
|
+ let openItem = new PopupMenu.PopupMenuItem(_("Open"));
|
|
|
|
+ this._menu.addMenuItem(openItem);
|
2018-03-09 11:02:15 +01:00
|
|
|
+ openItem.connect('activate', () => {
|
2016-09-01 12:12:54 +02:00
|
|
|
+ this._app.open_new_window(-1);
|
|
|
|
+ this._button.selectCategory(null, null);
|
|
|
|
+ this._button.menu.toggle();
|
2018-03-09 11:02:15 +01:00
|
|
|
+ });
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
|
|
|
+ let sepItem = new PopupMenu.PopupSeparatorMenuItem();
|
|
|
|
+ this._menu.addMenuItem(sepItem);
|
|
|
|
+
|
|
|
|
+ let isFavorite = AppFavorites.getAppFavorites().isFavorite(this._app.get_id());
|
|
|
|
+ let favText = null;
|
|
|
|
+ if (isFavorite)
|
|
|
|
+ favText = _("Remove from Favorites");
|
|
|
|
+ else
|
|
|
|
+ favText = _("Add to Favorites");
|
|
|
|
+
|
|
|
|
+ let favItem = new PopupMenu.PopupMenuItem(favText);
|
|
|
|
+ this._menu.addMenuItem(favItem);
|
2018-03-09 11:02:15 +01:00
|
|
|
+ favItem.connect('activate', () => {
|
2016-09-01 12:12:54 +02:00
|
|
|
+ let favs = AppFavorites.getAppFavorites();
|
|
|
|
+ let isFavorite = favs.isFavorite(this._app.get_id());
|
|
|
|
+ if (isFavorite)
|
|
|
|
+ favs.removeFavorite(this._app.get_id());
|
|
|
|
+ else
|
|
|
|
+ favs.addFavorite(this._app.get_id());
|
|
|
|
+
|
|
|
|
+ /*As the item text changes, we need to re-generate the menu */
|
|
|
|
+ this._menu.destroy();
|
|
|
|
+ this._menu = null;
|
|
|
|
+
|
|
|
|
+ this._button.selectCategory(null, null);
|
|
|
|
+ this._button.menu.toggle();
|
2018-03-09 11:02:15 +01:00
|
|
|
+ });
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
|
|
|
+ let desktopItem = new PopupMenu.PopupMenuItem(_("Add to Desktop"));
|
|
|
|
+ this._menu.addMenuItem(desktopItem);
|
2018-03-09 11:02:15 +01:00
|
|
|
+ desktopItem.connect('activate', () => {
|
2016-09-01 12:12:54 +02:00
|
|
|
+ let desktopApp = this._app.get_app_info();
|
|
|
|
+ let sourcePath = desktopApp.get_filename();
|
|
|
|
+ let sourceFile = Gio.File.new_for_path(sourcePath);
|
|
|
|
+ let destDirPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
|
|
|
|
+ let destDir = Gio.File.new_for_path(destDirPath);
|
|
|
|
+
|
|
|
|
+ if (!destDir.query_exists(null)) {
|
|
|
|
+ destDirPath = Glib.build_filenamev([GLib.get_home_dir(), "Desktop"]);
|
|
|
|
+ }
|
|
|
|
+ let destFile = Gio.File.new_for_path(destDirPath + '/' + sourceFile.get_basename());
|
2018-03-09 11:02:15 +01:00
|
|
|
+ if (sourceFile.copy(destFile, Gio.FileCopyFlags.OVERWRITE,
|
|
|
|
+ null, null, null)) {
|
2017-11-07 10:42:17 +01:00
|
|
|
+ // In order to make the general monitor recognize the setting of metadata,
|
2017-10-17 23:26:55 +02:00
|
|
|
+ // this function call should before the setting of unix mode.
|
|
|
|
+ destFile.set_attribute_string("metadata::trusted",
|
|
|
|
+ "yes",
|
|
|
|
+ Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
|
|
|
+ null);
|
2016-09-01 12:12:54 +02:00
|
|
|
+ destFile.set_attribute_uint32(
|
2017-08-05 14:05:19 +02:00
|
|
|
+ Gio.FILE_ATTRIBUTE_UNIX_MODE, parseInt("0755", 8),
|
2016-09-01 12:12:54 +02:00
|
|
|
+ Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
|
|
|
+ null);
|
|
|
|
+ }
|
|
|
|
+ this._button.selectCategory(null, null);
|
|
|
|
+ this._button.menu.toggle();
|
2018-03-09 11:02:15 +01:00
|
|
|
+ });
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
|
|
|
+ Main.uiGroup.add_actor(this._menu.actor);
|
|
|
|
+
|
|
|
|
+ this._menuManager.addMenu(this._menu);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this._menu.open(BoxPointer.PopupAnimation.NONE);
|
|
|
|
+ this._menuManager.ignoreRelease();
|
|
|
|
+
|
|
|
|
+ return false;
|
2018-03-09 11:02:15 +01:00
|
|
|
+ }
|
2016-09-01 12:12:54 +02:00
|
|
|
+
|
2018-03-09 11:02:15 +01:00
|
|
|
activate(event) {
|
|
|
|
this._app.open_new_window(-1);
|
2019-04-17 14:56:20 +02:00
|
|
|
this._button.selectCategory(null);
|