[gnome-maps] Utils: Make initActions wrap all of SimpleAction
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Utils: Make initActions wrap all of SimpleAction
- Date: Wed, 8 May 2013 22:53:42 +0000 (UTC)
commit ef5483a5e4b8fe3f43a1538d4a3d83a755dae9e3
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Fri May 3 03:43:12 2013 +0200
Utils: Make initActions wrap all of SimpleAction
Make Utils.initActions support all properties and signals that
Gio.SimpleAction does.
This makes it possible for us, in a general way, to add the
parameter_type and state parameters that are needed for creating
menu buttons and radio button menu items.
src/application.js | 9 +++++----
src/mainWindow.js | 9 +++++----
src/utils.js | 14 ++++++--------
3 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 7f148c2..10ec1dc 100644
--- a/src/application.js
+++ b/src/application.js
@@ -58,7 +58,7 @@ const Application = new Lang.Class({
this.parent({ application_id: 'org.gnome.Maps' });
},
- _onActionQuit: function() {
+ _onQuitActivate: function() {
this._mainWindow.window.destroy();
},
@@ -84,9 +84,10 @@ const Application = new Lang.Class({
application = this;
settings = new Gio.Settings({ schema: 'org.gnome.maps' });
- Utils.initActions(this, [
- { name: 'quit', callback: this._onActionQuit }
- ]);
+ Utils.initActions(this, [{
+ properties: { name: 'quit' },
+ signalHandlers: { activate: this._onQuitActivate }
+ }], this);
this._initAppMenu();
},
diff --git a/src/mainWindow.js b/src/mainWindow.js
index e9b8005..f101306 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -55,9 +55,10 @@ const MainWindow = new Lang.Class({
hide_titlebar_when_maximized: true,
title: _("Maps") });
- Utils.initActions(this.window, [
- { name: 'about', callback: this._onActionAbout }
- ]);
+ Utils.initActions(this.window, [{
+ properties: { name: 'about' },
+ signalHandlers: { activate: this._onAboutActivate }
+ }], this.window);
// apply the last saved window size and position
let size = Application.settings.get_value('window-size');
@@ -199,7 +200,7 @@ const MainWindow = new Lang.Class({
return false;
},
- _onActionAbout: function() {
+ _onAboutActivate: function() {
let aboutDialog = new Gtk.AboutDialog();
aboutDialog.artists = [ 'Jakub Steiner <jimmac gmail com>', 'Andreas Nilsson <nisses mail home se>'
];
diff --git a/src/utils.js b/src/utils.js
index dcc61b6..ccd0a29 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -76,16 +76,14 @@ function clearGtkClutterActorBg(actor) {
alpha: 0 }));
}
-function initActions(actionMap, simpleActionEntries) {
+function initActions(actionMap, simpleActionEntries, context) {
simpleActionEntries.forEach(function(entry) {
- let actionParams = { name: entry.name };
- if (entry.state)
- actionParams.state = entry.state;
+ let action = new Gio.SimpleAction(entry.properties);
- let action = new Gio.SimpleAction(actionParams);
-
- if (entry.callback)
- action.connect('activate', Lang.bind(actionMap, entry.callback));
+ for(let signalHandler in entry.signalHandlers) {
+ let callback = entry.signalHandlers[signalHandler];
+ action.connect(signalHandler, callback.bind(context));
+ }
actionMap.add_action(action);
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]