[gnome-documents/wip/cosimoc/view-rework: 28/28] view: move overview-related actions to ViewContainer
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/cosimoc/view-rework: 28/28] view: move overview-related actions to ViewContainer
- Date: Mon, 8 Aug 2016 15:11:59 +0000 (UTC)
commit db2ee32584569c394a8d00f735894b6c8f9eaed4
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Aug 7 18:35:25 2016 -0700
view: move overview-related actions to ViewContainer
Like we did for the preview classes, move the handling of view-related
actions to the view base class.
data/ui/selection-menu.ui | 4 +-
data/ui/view-menu.ui | 10 ++++----
src/application.js | 24 -------------------
src/searchbar.js | 8 ------
src/view.js | 57 +++++++++++++++++++++-----------------------
5 files changed, 34 insertions(+), 69 deletions(-)
---
diff --git a/data/ui/selection-menu.ui b/data/ui/selection-menu.ui
index 51cb412..7c77b50 100644
--- a/data/ui/selection-menu.ui
+++ b/data/ui/selection-menu.ui
@@ -2,12 +2,12 @@
<menu id="selection-menu">
<section>
<item>
- <attribute name="action">app.select-all</attribute>
+ <attribute name="action">view.select-all</attribute>
<attribute name="label" translatable="yes">Select All</attribute>
<attribute name="accel"><Primary>a</attribute>
</item>
<item>
- <attribute name="action">app.select-none</attribute>
+ <attribute name="action">view.select-none</attribute>
<attribute name="label" translatable="yes">Select None</attribute>
</item>
</section>
diff --git a/data/ui/view-menu.ui b/data/ui/view-menu.ui
index 301b42f..c6d8706 100644
--- a/data/ui/view-menu.ui
+++ b/data/ui/view-menu.ui
@@ -21,7 +21,7 @@
<property name="visible">True</property>
<property name="text">Grid</property>
<property name="tooltip-text" translatable="yes">View items as a grid of icons</property>
- <property name="action-name">app.view-as</property>
+ <property name="action-name">view.view-as</property>
<property name="action-target">'icon'</property>
<property name="iconic">True</property>
<property name="centered">True</property>
@@ -38,7 +38,7 @@
<property name="visible">True</property>
<property name="text">List</property>
<property name="tooltip-text" translatable="yes">View items as a list</property>
- <property name="action-name">app.view-as</property>
+ <property name="action-name">view.view-as</property>
<property name="action-target">'list'</property>
<property name="iconic">True</property>
<property name="centered">True</property>
@@ -82,7 +82,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">Author</property>
- <property name="action-name">app.sort-by</property>
+ <property name="action-name">view.sort-by</property>
<property name="action-target">'secondary-text'</property>
</object>
</child>
@@ -91,7 +91,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">Date</property>
- <property name="action-name">app.sort-by</property>
+ <property name="action-name">view.sort-by</property>
<property name="action-target">'mtime'</property>
</object>
</child>
@@ -100,7 +100,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">Name</property>
- <property name="action-name">app.sort-by</property>
+ <property name="action-name">view.sort-by</property>
<property name="action-target">'primary-text'</property>
</object>
</child>
diff --git a/src/application.js b/src/application.js
index 611f724..5f210a2 100644
--- a/src/application.js
+++ b/src/application.js
@@ -482,34 +482,10 @@ const Application = new Lang.Class({
callback: Lang.bind(this, this._onActionNightMode),
create_hook: Lang.bind(this, this._nightModeCreateHook),
state: settings.get_value('night-mode') },
- { name: 'view-as',
- callback: Lang.bind(this, this._onActionViewAs),
- create_hook: Lang.bind(this, this._viewAsCreateHook),
- parameter_type: 's',
- state: settings.get_value('view-as'),
- window_modes: [WindowMode.WindowMode.COLLECTIONS,
- WindowMode.WindowMode.DOCUMENTS,
- WindowMode.WindowMode.SEARCH] },
- { name: 'sort-by',
- callback: Lang.bind(this, this._onActionSortBy),
- create_hook: Lang.bind(this, this._sortByCreateHook),
- parameter_type: 's',
- state: settings.get_value('sort-by'),
- window_modes: [WindowMode.WindowMode.COLLECTIONS,
- WindowMode.WindowMode.DOCUMENTS,
- WindowMode.WindowMode.SEARCH] },
{ name: 'search',
callback: Utils.actionToggleCallback,
state: GLib.Variant.new('b', false),
accels: ['<Primary>f'] },
- { name: 'select-all', accels: ['<Primary>a'],
- window_modes: [WindowMode.WindowMode.COLLECTIONS,
- WindowMode.WindowMode.DOCUMENTS,
- WindowMode.WindowMode.SEARCH] },
- { name: 'select-none',
- window_modes: [WindowMode.WindowMode.COLLECTIONS,
- WindowMode.WindowMode.DOCUMENTS,
- WindowMode.WindowMode.SEARCH] },
{ name: 'search-source',
parameter_type: 's',
state: GLib.Variant.new('s', Search.SearchSourceStock.ALL),
diff --git a/src/searchbar.js b/src/searchbar.js
index 67634c6..d1fe31a 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -151,8 +151,6 @@ const OverviewSearchbar = new Lang.Class({
Extends: Searchbar,
_init: function() {
- this._selectAll = Application.application.lookup_action('select-all');
-
this.parent();
let sourcesId = Application.sourceManager.connect('active-changed',
@@ -287,14 +285,8 @@ const OverviewSearchbar = new Lang.Class({
this._dropdownButton.set_active(true);
},
- reveal: function() {
- this._selectAll.enabled = false;
- this.parent();
- },
-
conceal: function() {
this._dropdownButton.set_active(false);
- this._selectAll.enabled = true;
Application.searchTypeManager.setActiveItemById('all');
Application.searchMatchManager.setActiveItemById('all');
diff --git a/src/view.js b/src/view.js
index 7525b3b..4d67475 100644
--- a/src/view.js
+++ b/src/view.js
@@ -348,6 +348,10 @@ const ViewContainer = new Lang.Class({
this.parent({ homogeneous: true,
transition_type: Gtk.StackTransitionType.CROSSFADE });
+ let actions = this._getDefaultActions();
+ this.actionGroup = new Gio.SimpleActionGroup();
+ Utils.populateActionGroup(this.actionGroup, actions, 'view');
+
this.view = new Gd.MainView({ shadow_type: Gtk.ShadowType.NONE });
this.add_named(this.view, 'view');
@@ -373,13 +377,7 @@ const ViewContainer = new Lang.Class({
this.view.connect('view-selection-changed',
Lang.bind(this, this._onViewSelectionChanged));
- // connect to settings change for list/grid view
- let viewSettingsId = Application.application.connect('action-state-changed::view-as',
- Lang.bind(this, this._updateTypeForSettings));
this._updateTypeForSettings();
-
- this._sortSettingsId = Application.application.connect('action-state-changed::sort-by',
- Lang.bind(this, this._updateSortForSettings));
this._updateSortForSettings();
// setup selection controller => view
@@ -391,19 +389,6 @@ const ViewContainer = new Lang.Class({
Lang.bind(this, this._onWindowModeChanged));
this._onWindowModeChanged();
- let selectAll = Application.application.lookup_action('select-all');
- let selectAllId = selectAll.connect('activate', Lang.bind(this,
- function() {
- Application.selectionController.setSelectionMode(true);
- this.view.select_all();
- }));
-
- let selectNone = Application.application.lookup_action('select-none');
- let selectNoneId = selectNone.connect('activate', Lang.bind(this,
- function() {
- this.view.unselect_all();
- }));
-
[ this._offsetController, this._trackerController ] = getController(this._mode);
this._offsetController.connect('item-count-changed', Lang.bind(this,
@@ -423,13 +408,29 @@ const ViewContainer = new Lang.Class({
// this will create the model if we're done querying
this._onQueryStatusChanged();
+ },
- this.connect('destroy', Lang.bind(this,
- function() {
- Application.application.disconnect(viewSettingsId);
- selectAll.disconnect(selectAllId);
- selectNone.disconnect(selectNoneId);
- }));
+ _getDefaultActions: function() {
+ return [
+ { name: 'select-all',
+ callback: Lang.bind(this, this._selectAll),
+ accels: ['<Primary>a'] },
+ { name: 'select-none',
+ callback: Lang.bind(this, this._selectNone) },
+ { settingsKey: 'view-as',
+ stateChanged: Lang.bind(this, this._updateTypeForSettings) },
+ { settingsKey: 'sort-by',
+ stateChanged: Lang.bind(this, this._updateSortForSettings) }
+ ];
+ },
+
+ _selectAll: function() {
+ Application.selectionController.setSelectionMode(true);
+ this.view.select_all();
+ },
+
+ _selectNone: function() {
+ this.view.unselect_all();
},
_updateTypeForSettings: function() {
@@ -787,11 +788,7 @@ const View = new Lang.Class({
}
this._stack.set_visible_child(visibleChild);
-
- if (visibleChild.actionGroup)
- this._window.insert_action_group('view', visibleChild.actionGroup);
- else
- this._window.insert_action_group('view', null);
+ this._window.insert_action_group('view', visibleChild.actionGroup);
},
get view() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]