mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +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
|
name: action
|
||||||
});
|
});
|
||||||
simpleAction.connect(
|
simpleAction.connect(
|
||||||
'activate', () => Menu.actions[action](this.active_window)
|
'activate', () => Menu.actions[action].run(this.active_window)
|
||||||
);
|
);
|
||||||
this.add_action(simpleAction);
|
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;
|
const Dialogs = imports.src.dialogs;
|
||||||
|
|
||||||
var actions = {
|
var actions = {
|
||||||
openLocal: (window) => new Dialogs.FileChooser(window),
|
openLocal: {
|
||||||
openUri: (window) => new Dialogs.UriDialog(window),
|
run: (window) => new Dialogs.FileChooser(window),
|
||||||
prefs: (window) => new Dialogs.PrefsDialog(window),
|
accels: ['<Ctrl>O'],
|
||||||
about: (window) => new Dialogs.AboutDialog(window),
|
},
|
||||||
|
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