[gnome-documents/wip/cosimoc/view-rework: 24/42] utils: support creating a GSettingsAction
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/cosimoc/view-rework: 24/42] utils: support creating a GSettingsAction
- Date: Sat, 3 Sep 2016 17:01:11 +0000 (UTC)
commit 7059ec6e07b288299df615acb665c36c8817169c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Jul 31 21:16:38 2016 -0700
utils: support creating a GSettingsAction
When a settingsKey attribute is passed in the action entry description,
create a settings action instead of a regular action.
src/utils.js | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 9de8618..dfdcd97 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -128,17 +128,22 @@ function actionToggleCallback(action) {
function populateActionGroup(actionGroup, actionEntries, prefix) {
actionEntries.forEach(function(actionEntry) {
+ let settingsKey = actionEntry.settingsKey;
let state = actionEntry.state;
let parameterType = actionEntry.parameter_type ?
GLib.VariantType.new(actionEntry.parameter_type) : null;
let action;
- if (state)
- action = Gio.SimpleAction.new_stateful(actionEntry.name,
- parameterType, actionEntry.state);
- else
- action = new Gio.SimpleAction({ name: actionEntry.name,
- parameter_type: parameterType });
+ if (settingsKey) {
+ action = Application.settings.create_action(settingsKey);
+ } else {
+ if (state)
+ action = Gio.SimpleAction.new_stateful(actionEntry.name,
+ parameterType, actionEntry.state);
+ else
+ action = new Gio.SimpleAction({ name: actionEntry.name,
+ parameter_type: parameterType });
+ }
if (actionEntry.create_hook)
actionEntry.create_hook(action);
@@ -150,7 +155,7 @@ function populateActionGroup(actionGroup, actionEntries, prefix) {
action.connect('notify::state', actionEntry.stateChanged);
if (actionEntry.accels)
- Application.application.set_accels_for_action(prefix + '.' + actionEntry.name,
actionEntry.accels);
+ Application.application.set_accels_for_action(prefix + '.' + action.name, actionEntry.accels);
actionGroup.add_action(action);
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]