mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Support accels for menu items
Add support for keyboard shortcuts for menu items. Additionally enable a common Ctrl+O for opening new file(s) and Ctrl+U for opening an URI. Closes #45
This commit is contained in:
@@ -44,9 +44,12 @@ class ClapperAppBase extends Gtk.Application
|
||||
name: action
|
||||
});
|
||||
simpleAction.connect(
|
||||
'activate', () => Menu.actions[action](this.active_window)
|
||||
'activate', () => Menu.actions[action].run(this.active_window)
|
||||
);
|
||||
this.add_action(simpleAction);
|
||||
|
||||
if(Menu.actions[action].accels)
|
||||
this.set_accels_for_action(`app.${action}`, Menu.actions[action].accels);
|
||||
}
|
||||
}
|
||||
|
||||
|
22
src/menu.js
22
src/menu.js
@@ -2,12 +2,18 @@ const { GObject, Gtk } = imports.gi;
|
||||
const Dialogs = imports.src.dialogs;
|
||||
|
||||
var actions = {
|
||||
openLocal: (window) => new Dialogs.FileChooser(window),
|
||||
openUri: (window) => new Dialogs.UriDialog(window),
|
||||
prefs: (window) => new Dialogs.PrefsDialog(window),
|
||||
about: (window) => new Dialogs.AboutDialog(window),
|
||||
openLocal: {
|
||||
run: (window) => new Dialogs.FileChooser(window),
|
||||
accels: ['<Ctrl>O'],
|
||||
},
|
||||
openUri: {
|
||||
run: (window) => new Dialogs.UriDialog(window),
|
||||
accels: ['<Ctrl>U'],
|
||||
},
|
||||
prefs: {
|
||||
run: (window) => new Dialogs.PrefsDialog(window),
|
||||
},
|
||||
about: {
|
||||
run: (window) => new Dialogs.AboutDialog(window),
|
||||
},
|
||||
};
|
||||
|
||||
var accels = [
|
||||
['app.quit', ['q']],
|
||||
];
|
||||
|
Reference in New Issue
Block a user