Change actions naming scheme

Use _ instead of capital letters in words for actions names. This will make some other stuff much easier.
This commit is contained in:
Rafał Dzięgiel
2021-04-22 14:29:40 +02:00
parent c9b2f25192
commit 084f78a851
3 changed files with 10 additions and 10 deletions

View File

@@ -1,11 +1,11 @@
const Dialogs = imports.src.dialogs; const Dialogs = imports.src.dialogs;
var actions = { var actions = {
openLocal: { open_local: {
run: (window) => new Dialogs.FileChooser(window), run: (window) => new Dialogs.FileChooser(window),
accels: ['<Ctrl>O'], accels: ['<Ctrl>O'],
}, },
openUri: { open_uri: {
run: (window) => new Dialogs.UriDialog(window), run: (window) => new Dialogs.UriDialog(window),
accels: ['<Ctrl>U'], accels: ['<Ctrl>U'],
}, },
@@ -14,5 +14,5 @@ var actions = {
}, },
about: { about: {
run: (window) => new Dialogs.AboutDialog(window), run: (window) => new Dialogs.AboutDialog(window),
}, }
}; };

View File

@@ -1,8 +1,8 @@
const { Gio, GLib, GObject, Gtk } = imports.gi; const { Gio, GLib, GObject, Gtk } = imports.gi;
const Debug = imports.src.debug; const Debug = imports.src.debug;
const FileOps = imports.src.fileOps; const FileOps = imports.src.fileOps;
const Menu = imports.src.menu;
const Misc = imports.src.misc; const Misc = imports.src.misc;
const { actions } = imports.src.actions;
const { debug } = Debug; const { debug } = Debug;
const { settings } = Misc; const { settings } = Misc;
@@ -35,15 +35,15 @@ class ClapperAppBase extends Gtk.Application
if(!settings.get_boolean('render-shadows')) if(!settings.get_boolean('render-shadows'))
window.add_css_class('gpufriendly'); window.add_css_class('gpufriendly');
for(let name in Menu.actions) { for(let name in actions) {
const simpleAction = new Gio.SimpleAction({ name }); const simpleAction = new Gio.SimpleAction({ name });
simpleAction.connect( simpleAction.connect(
'activate', () => Menu.actions[name].run(this.active_window) 'activate', () => actions[name].run(this.active_window)
); );
this.add_action(simpleAction); this.add_action(simpleAction);
if(Menu.actions[name].accels) if(actions[name].accels)
this.set_accels_for_action(`app.${name}`, Menu.actions[name].accels); this.set_accels_for_action(`app.${name}`, actions[name].accels);
} }
} }

View File

@@ -4,11 +4,11 @@
<section> <section>
<item> <item>
<attribute name="label" translatable="yes">Open Local...</attribute> <attribute name="label" translatable="yes">Open Local...</attribute>
<attribute name="action">app.openLocal</attribute> <attribute name="action">app.open_local</attribute>
</item> </item>
<item> <item>
<attribute name="label" translatable="yes">Open URI...</attribute> <attribute name="label" translatable="yes">Open URI...</attribute>
<attribute name="action">app.openUri</attribute> <attribute name="action">app.open_uri</attribute>
</item> </item>
</section> </section>
<section> <section>