2022-09-13 09:34:33 +02:00
|
|
|
Index: gnome-shell-extensions-43.rc/extensions/apps-menu/extension.js
|
2019-10-04 17:46:50 +02:00
|
|
|
===================================================================
|
2022-09-13 09:34:33 +02:00
|
|
|
--- gnome-shell-extensions-43.rc.orig/extensions/apps-menu/extension.js
|
|
|
|
+++ gnome-shell-extensions-43.rc/extensions/apps-menu/extension.js
|
2019-10-04 17:46:50 +02:00
|
|
|
@@ -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;
|
2022-09-13 09:34:33 +02:00
|
|
|
const {EventEmitter} = imports.misc.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;
|
2022-03-21 10:16:32 +01:00
|
|
|
@@ -48,8 +50,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
|
|
|
|
2022-03-21 10:16:32 +01:00
|
|
|
@@ -64,6 +77,107 @@ 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();
|
2020-04-30 11:45:54 +02:00
|
|
|
+ return Clutter.EVENT_STOP;
|
2016-09-01 12:12:54 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let button = event.get_button();
|
|
|
|
+ if (button == 3) {
|
|
|
|
+ this.popupMenu();
|
2020-04-30 11:45:54 +02:00
|
|
|
+ return Clutter.EVENT_STOP;
|
2016-09-01 12:12:54 +02:00
|
|
|
+ }
|
2020-04-30 11:45:54 +02:00
|
|
|
+ return Clutter.EVENT_PROPAGATE
|
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', () => {
|
2020-04-30 11:45:54 +02:00
|
|
|
+ this._menu.destroy();
|
|
|
|
+ this._menu = null;
|
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());
|
2020-04-30 11:45:54 +02:00
|
|
|
+ if (sourceFile.copy(destFile, Gio.FileCopyFlags.OVERWRITE, 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.
|
2020-04-30 11:45:54 +02:00
|
|
|
+ let info = new Gio.FileInfo();
|
|
|
|
+ info.set_attribute_string('metadata::trusted', 'true');
|
|
|
|
+ destFile.set_attributes_from_info(info,
|
|
|
|
+ Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
|
|
|
+ destFile.set_attribute_uint32( Gio.FILE_ATTRIBUTE_UNIX_MODE, parseInt("0755", 8),
|
|
|
|
+ Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
2016-09-01 12:12:54 +02:00
|
|
|
+ }
|
2020-04-30 11:45:54 +02:00
|
|
|
+ this._menu.destroy();
|
|
|
|
+ this._menu = null;
|
2016-09-01 12:12:54 +02:00
|
|
|
+ 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);
|