test-gapplication: update for latest gapplication changes
g_application_set_action_group is deprecated, we should use GActionMap. Also, GSimpleActions can now be constructed as normal GObjects.
This commit is contained in:
parent
8997aa45b1
commit
75e9fa9cfb
@ -30,35 +30,31 @@ function main() {
|
|||||||
print ("Activated");
|
print ("Activated");
|
||||||
});
|
});
|
||||||
|
|
||||||
let group = new Gio.SimpleActionGroup();
|
let action = new Gio.SimpleAction({ name: 'one' });
|
||||||
|
|
||||||
let action = Gio.SimpleAction.new('one', null);
|
|
||||||
action.connect('activate', do_action);
|
action.connect('activate', do_action);
|
||||||
group.insert(action);
|
app.add_action(action);
|
||||||
|
|
||||||
let action = Gio.SimpleAction.new('two', null);
|
let action = new Gio.SimpleAction({ name: 'two' });
|
||||||
action.connect('activate', do_action);
|
action.connect('activate', do_action);
|
||||||
group.insert(action);
|
app.add_action(action);
|
||||||
|
|
||||||
let action = Gio.SimpleAction.new_stateful('toggle', null, GLib.Variant.new('b', false));
|
let action = new Gio.SimpleAction({ name: 'toggle', state: GLib.Variant.new('b', false) });
|
||||||
action.connect('activate', do_action_toggle);
|
action.connect('activate', do_action_toggle);
|
||||||
action.connect('notify::state', do_action_state_change);
|
action.connect('notify::state', do_action_state_change);
|
||||||
group.insert(action);
|
app.add_action(action);
|
||||||
|
|
||||||
let action = Gio.SimpleAction.new('disable', null);
|
let action = new Gio.SimpleAction({ name: 'disable', enabled: false });
|
||||||
action.set_enabled(false);
|
action.set_enabled(false);
|
||||||
action.connect('activate', do_action);
|
action.connect('activate', do_action);
|
||||||
group.insert(action);
|
app.add_action(action);
|
||||||
|
|
||||||
let action = Gio.SimpleAction.new('parameter-int', GLib.VariantType.new('u'));
|
let action = new Gio.SimpleAction({ name: 'parameter-int', parameter_type: GLib.VariantType.new('u') });
|
||||||
action.connect('activate', do_action_param);
|
action.connect('activate', do_action_param);
|
||||||
group.insert(action);
|
app.add_action(action);
|
||||||
|
|
||||||
let action = Gio.SimpleAction.new('parameter-string', GLib.VariantType.new('s'));
|
let action = new Gio.SimpleAction({ name: 'parameter-string', parameter_type: GLib.VariantType.new('s') });
|
||||||
action.connect('activate', do_action_param);
|
action.connect('activate', do_action_param);
|
||||||
group.insert(action);
|
app.add_action(action);
|
||||||
|
|
||||||
app.action_group = group;
|
|
||||||
|
|
||||||
let menu = new Gio.Menu();
|
let menu = new Gio.Menu();
|
||||||
menu.append('An action', 'one');
|
menu.append('An action', 'one');
|
||||||
@ -91,10 +87,13 @@ function main() {
|
|||||||
item.set_action_and_target_value('parameter-int', GLib.Variant.new('u', 43));
|
item.set_action_and_target_value('parameter-int', GLib.Variant.new('u', 43));
|
||||||
menu.append_item(item);
|
menu.append_item(item);
|
||||||
|
|
||||||
app.menu = menu;
|
app.set_app_menu(menu);
|
||||||
|
|
||||||
app.connect('startup', function(app) {
|
let window = null;
|
||||||
let window = new Gtk.Window({ title: "Test Application", application: app });
|
|
||||||
|
app.connect('activate', function(app) {
|
||||||
|
if (!window)
|
||||||
|
window = new Gtk.Window({ title: "Test Application", application: app });
|
||||||
window.present();
|
window.present();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user