Skip to content

Commit

Permalink
directory-menu@torchipeppo: Add support for keybindings (linuxmint#5690)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcalixte authored Apr 25, 2024
1 parent 01fe25e commit aa13b59
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const Cinnamon = imports.gi.Cinnamon;
const Settings = imports.ui.settings;
const Gettext = imports.gettext;


const UUID = "directory-menu@torchipeppo";

Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale");
Expand Down Expand Up @@ -51,6 +50,7 @@ class CassettoneApplet extends Applet.TextIconApplet {
this.settings.bind("icon-name", "icon_name", this.set_applet_icon_symbolic_name, null);
this.settings.bind("label", "label", this.set_applet_label, null);
this.settings.bind("tooltip", "tooltip_text", (txt) => this.set_applet_tooltip(_(txt)), null);
this.settings.bind("show-menu", "show_menu", this.set_keybinding, null);
this.settings.bind("limit-characters", "limit_characters", null, null);
this.settings.bind("character-limit", "character_limit", null, null);
this.starting_uri = this.normalize_tilde(this.starting_uri);
Expand All @@ -63,7 +63,8 @@ class CassettoneApplet extends Applet.TextIconApplet {
this.actor.connect('enter-event', Lang.bind(this, this.on_enter_event));
this.actor.connect('button-release-event', Lang.bind(this, this.on_button_release_event));

this.setAllowedLayout(Applet.AllowedLayout.BOTH);
this.setAllowedLayout(Applet.AllowedLayout.BOTH);
this.set_keybinding();
}

normalize_tilde(path) {
Expand All @@ -79,8 +80,8 @@ class CassettoneApplet extends Applet.TextIconApplet {

let x = Math.round(allocation.x1 / global.ui_scale);
let y = Math.round(allocation.y1 / global.ui_scale);
let w = Math.round((allocation.x2 - allocation.x1) / global.ui_scale)
let h = Math.round((allocation.y2 - allocation.y1) / global.ui_scale)
let w = Math.round((allocation.x2 - allocation.x1) / global.ui_scale);
let h = Math.round((allocation.y2 - allocation.y1) / global.ui_scale);

let final_x, final_y, final_o;

Expand Down Expand Up @@ -145,6 +146,18 @@ class CassettoneApplet extends Applet.TextIconApplet {
}
// end of Cinnamon wrappings

this.open_cassettone();
return true;
}

open_cassettone() {
// If we attempt to open this GTK menu while a Cinnamon panel menu is
// open, Cinnamon will freeze.
// This can happen with the panel's context menu (but not an applet's).
// Returning is a simple fix, but it would be nicer (and riskier?)
// if it caused the open menu to close.
if (global.menuStackLength) return false;

this._applet_tooltip.hide();
this._applet_tooltip.preventShow = true;

Expand All @@ -162,10 +175,17 @@ class CassettoneApplet extends Applet.TextIconApplet {
}

Util.spawn_async(['python3', `${this.metadata.path}/popup_menu.py`, JSON.stringify(args)]);
}

return true;
set_keybinding() {
Main.keybindingManager.addHotKey("show-directory-menu-" + this.instance_id,
this.show_menu,
Lang.bind(this, this.open_cassettone));
}

on_applet_removed_from_panel() {
Main.keybindingManager.removeHotKey("show-directory-menu-" + this.instance_id);
}
}

function main(metadata, orientation, panel_height, instance_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"uuid": "directory-menu@torchipeppo",
"name": "Directory Menu",
"description": "Quickly navigate through directories on your system using a dropdown menu.",
"version": "0.6.0",
"version": "0.7.0",
"author": "torchipeppo",
"max-instances": "-1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ msgstr ""
"Project-Id-Version: directory-menu@torchipeppo 0.5\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-04-07 18:39-0100\n"
"POT-Creation-Date: 2024-04-12 13:55-0400\n"
"PO-Revision-Date: 2024-03-29 23:13+0100\n"
"Last-Translator: Martin Posselt <[email protected]>\n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3\n"
"Last-Translator: Martin Posselt <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: de\n"

#: popup_menu.py:71
msgid "Open Folder"
msgstr "Ordner öffnen"

#: popup_menu.py:76
msgid "Open in Terminal"
msgstr "Im Terminal öffnen"

#. metadata.json->name
msgid "Directory Menu"
Expand All @@ -27,8 +35,8 @@ msgstr "Verzeichnis-Menü"
msgid ""
"Quickly navigate through directories on your system using a dropdown menu."
msgstr ""
"Mithilfe eines Dropdown-Menüs schnell durch die Verzeichnisse auf dem "
"System navigieren."
"Mithilfe eines Dropdown-Menüs schnell durch die Verzeichnisse auf dem System "
"navigieren."

#. settings-schema.json->starting-uri->description
msgid "Base Directory"
Expand All @@ -41,8 +49,7 @@ msgstr "Icon (für weitere Infos mit dem Mauszeiger berühren)"
#. settings-schema.json->icon-name->tooltip
msgid "Must be an icon name (no path), and should be symbolic."
msgstr ""
"Angabe eines Symbolnamens (kein Pfad). Es sollte ein symbolisches Icon "
"sein."
"Angabe eines Symbolnamens (kein Pfad). Es sollte ein symbolisches Icon sein."

#. settings-schema.json->tooltip->description
msgid "Tooltip Text"
Expand All @@ -52,6 +59,14 @@ msgstr "Tooltip-Text"
msgid "Panel Text"
msgstr ""

#. settings-schema.json->show-menu->description
msgid "Show menu"
msgstr ""

#. settings-schema.json->show-menu->tooltip
msgid "Set keybinding(s) to show the menu."
msgstr ""

#. settings-schema.json->limit-characters->description
msgid "Limit the Maximum Number of Characters on the Submenus"
msgstr ""
Expand All @@ -71,11 +86,3 @@ msgstr ""
#. settings-schema.json->show-hidden->description
msgid "Include hidden files"
msgstr "Versteckte Dateien anzeigen"

#. popup_menu.py:71
msgid "Open Folder"
msgstr "Ordner öffnen"

#. popup_menu.py:76
msgid "Open in Terminal"
msgstr "Im Terminal öffnen"
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# This file is put in the public domain.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: directory-menu@torchipeppo 0.6.0\n"
"Project-Id-Version: directory-menu@torchipeppo 0.7.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-04-07 18:39-0100\n"
"POT-Creation-Date: 2024-04-12 13:55-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -18,6 +17,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: popup_menu.py:71
msgid "Open Folder"
msgstr ""

#: popup_menu.py:76
msgid "Open in Terminal"
msgstr ""

#. metadata.json->name
msgid "Directory Menu"
msgstr ""
Expand Down Expand Up @@ -47,6 +54,14 @@ msgstr ""
msgid "Panel Text"
msgstr ""

#. settings-schema.json->show-menu->description
msgid "Show menu"
msgstr ""

#. settings-schema.json->show-menu->tooltip
msgid "Set keybinding(s) to show the menu."
msgstr ""

#. settings-schema.json->limit-characters->description
msgid "Limit the Maximum Number of Characters on the Submenus"
msgstr ""
Expand All @@ -64,11 +79,3 @@ msgstr ""
#. settings-schema.json->show-hidden->description
msgid "Include hidden files"
msgstr ""

#. popup_menu.py:71
msgid "Open Folder"
msgstr ""

#. popup_menu.py:76
msgid "Open in Terminal"
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-04-07 18:39-0100\n"
"PO-Revision-Date: 2024-04-12 20:53-0400\n"
"PO-Revision-Date: 2024-04-12 20:58-0400\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
Expand All @@ -18,6 +18,14 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.2\n"

#: popup_menu.py:71
msgid "Open Folder"
msgstr "Abrir carpeta"

#: popup_menu.py:76
msgid "Open in Terminal"
msgstr "Abrir en el terminal"

#. metadata.json->name
msgid "Directory Menu"
msgstr "Menú del Directorio"
Expand Down Expand Up @@ -49,6 +57,14 @@ msgstr "Texto de información sobre herramientas"
msgid "Panel Text"
msgstr "Texto del panel"

#. settings-schema.json->show-menu->description
msgid "Show menu"
msgstr ""

#. settings-schema.json->show-menu->tooltip
msgid "Set keybinding(s) to show the menu."
msgstr ""

#. settings-schema.json->limit-characters->description
msgid "Limit the Maximum Number of Characters on the Submenus"
msgstr "Limitar el número máximo de caracteres en los submenús"
Expand All @@ -68,11 +84,3 @@ msgstr ""
#. settings-schema.json->show-hidden->description
msgid "Include hidden files"
msgstr "Incluir archivos ocultos"

#. popup_menu.py:71
msgid "Open Folder"
msgstr "Abrir carpeta"

#. popup_menu.py:76
msgid "Open in Terminal"
msgstr "Abrir en el terminal"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: directory-menu@torchipeppo 0.5\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-04-07 18:39-0100\n"
"POT-Creation-Date: 2024-04-12 13:55-0400\n"
"PO-Revision-Date: 2024-02-11 17:20+0100\n"
"Last-Translator: Claudiux <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -19,6 +19,14 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.0.1\n"

#: popup_menu.py:71
msgid "Open Folder"
msgstr "Ouvrir le dossier"

#: popup_menu.py:76
msgid "Open in Terminal"
msgstr "Ouvrir dans un terminal"

#. metadata.json->name
msgid "Directory Menu"
msgstr "Menu de répertoires"
Expand All @@ -27,8 +35,8 @@ msgstr "Menu de répertoires"
msgid ""
"Quickly navigate through directories on your system using a dropdown menu."
msgstr ""
"Naviguez rapidement dans les répertoires de votre système à l'aide d'un "
"menu déroulant."
"Naviguez rapidement dans les répertoires de votre système à l'aide d'un menu "
"déroulant."

#. settings-schema.json->starting-uri->description
msgid "Base Directory"
Expand All @@ -51,6 +59,14 @@ msgstr "Texte de l'info-bulle"
msgid "Panel Text"
msgstr ""

#. settings-schema.json->show-menu->description
msgid "Show menu"
msgstr ""

#. settings-schema.json->show-menu->tooltip
msgid "Set keybinding(s) to show the menu."
msgstr ""

#. settings-schema.json->limit-characters->description
msgid "Limit the Maximum Number of Characters on the Submenus"
msgstr ""
Expand All @@ -70,11 +86,3 @@ msgstr ""
#. settings-schema.json->show-hidden->description
msgid "Include hidden files"
msgstr "Montrer également les fichiers cachés"

#. popup_menu.py:71
msgid "Open Folder"
msgstr "Ouvrir le dossier"

#. popup_menu.py:76
msgid "Open in Terminal"
msgstr "Ouvrir dans un terminal"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-04-07 18:39-0100\n"
"POT-Creation-Date: 2024-04-12 13:55-0400\n"
"PO-Revision-Date: 2024-02-13 18:12+0100\n"
"Last-Translator: Vajda Örs <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -19,6 +19,14 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"

#: popup_menu.py:71
msgid "Open Folder"
msgstr "Könyvtár megnyitása"

#: popup_menu.py:76
msgid "Open in Terminal"
msgstr "Megnyitás terminálban"

#. metadata.json->name
msgid "Directory Menu"
msgstr "Könyvtár menü"
Expand Down Expand Up @@ -51,6 +59,14 @@ msgstr "Eszköztipp szövege"
msgid "Panel Text"
msgstr ""

#. settings-schema.json->show-menu->description
msgid "Show menu"
msgstr ""

#. settings-schema.json->show-menu->tooltip
msgid "Set keybinding(s) to show the menu."
msgstr ""

#. settings-schema.json->limit-characters->description
msgid "Limit the Maximum Number of Characters on the Submenus"
msgstr ""
Expand All @@ -70,11 +86,3 @@ msgstr ""
#. settings-schema.json->show-hidden->description
msgid "Include hidden files"
msgstr "Tartalmazza a rejtett fájlokat is"

#. popup_menu.py:71
msgid "Open Folder"
msgstr "Könyvtár megnyitása"

#. popup_menu.py:76
msgid "Open in Terminal"
msgstr "Megnyitás terminálban"
Loading

0 comments on commit aa13b59

Please sign in to comment.