[gnome-sound-recorder] row:move rename button to revealer
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] row:move rename button to revealer
- Date: Sat, 4 Jul 2020 20:14:18 +0000 (UTC)
commit 971f2d2652e27e53851c4d40ceaec238eed75060
Author: Kavan Mevada <kavanmevada gmail com>
Date: Sat Jul 4 22:42:19 2020 +0530
row:move rename button to revealer
data/ui/row.ui | 76 +++++++++++++++++++++++-------------------------
src/recordingsListBox.js | 5 ++--
src/row.js | 27 +++++++++++++++--
3 files changed, 62 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/row.ui b/data/ui/row.ui
index bb905fb..69bd9ab 100644
--- a/data/ui/row.ui
+++ b/data/ui/row.ui
@@ -83,13 +83,14 @@
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="margin_left">12</property>
- <property name="margin_right">12</property>
<property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="duration">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
<style>
<class name="dim-label"/>
</style>
@@ -155,42 +156,14 @@
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkEntry" id="entry">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
- <child>
- <object class="GtkEntry" id="entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="valign">center</property>
- <property name="activates_default">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="saveBtn">
- <property name="label" translatable="yes">Save</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="valign">center</property>
- <property name="margin_left">12</property>
- <signal name="clicked" handler="onSaveRecording" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="name">edit</property>
@@ -246,22 +219,45 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="renameBtn">
- <property name="label" translatable="yes">Rename</property>
+ <object class="GtkStack" id="renameStack">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="can_focus">False</property>
<property name="margin_right">12</property>
+ <child>
+ <object class="GtkButton" id="renameBtn">
+ <property name="label" translatable="yes">Rename</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="name">rename</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="saveBtn">
+ <property name="label" translatable="yes">Save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="onSaveRecording" swapped="no"/>
+ </object>
+ <packing>
+ <property name="name">save</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
diff --git a/src/recordingsListBox.js b/src/recordingsListBox.js
index 7e003c2..a22fc70 100644
--- a/src/recordingsListBox.js
+++ b/src/recordingsListBox.js
@@ -46,10 +46,9 @@ var RecordingsListBox = new GObject.registerClass(class RecordingsListBox extend
vfunc_row_activated(row) {
if (this.activeRow && this.activeRow !== row)
- this.activeRow._revealer.reveal_child = false;
+ this.activeRow.expanded = false;
- row._revealer.reveal_child = !row._revealer.reveal_child;
+ row.expanded = !row.expanded;
this.activeRow = row;
}
-
});
diff --git a/src/row.js b/src/row.js
index 9af2a54..0edd38c 100644
--- a/src/row.js
+++ b/src/row.js
@@ -9,19 +9,28 @@ var RowState = {
var Row = GObject.registerClass({
Template: 'resource:///org/gnome/SoundRecorder/ui/row.ui',
- InternalChildren: ['playbackStack', 'mainStack', 'playButton', 'pauseButton', 'name', 'entry', 'date',
'duration', 'saveBtn', 'revealer', 'renameBtn', 'deleteBtn'],
+ InternalChildren: ['playbackStack', 'mainStack', 'playButton', 'pauseButton', 'name', 'entry', 'date',
'duration', 'saveBtn', 'revealer', 'renameStack', 'renameBtn', 'deleteBtn'],
Signals: {
'play': { param_types: [GObject.TYPE_STRING] },
'pause': {},
'deleted': {},
},
+ Properties: {
+ 'expanded': GObject.ParamSpec.boolean(
+ 'expanded',
+ 'Row active status', 'Row active status',
+ GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT,
+ false),
+ },
}, class Row extends Gtk.ListBoxRow {
_init(recording) {
super._init({});
this._recording = recording;
+ this._expanded = false;
recording.bind_property('name', this._name, 'label', GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.DEFAULT);
recording.bind_property('name', this._entry, 'text', GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.DEFAULT);
+ this.bind_property('expanded', this._revealer, 'reveal_child', GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.DEFAULT);
this._editMode = false;
@@ -88,13 +97,25 @@ var Row = GObject.registerClass({
if (state) {
this._entry.grab_focus();
this._saveBtn.grab_default();
- this._renameBtn.hide();
+ this._renameStack.visible_child_name = 'save';
+
+ if (!this.expanded)
+ this.activate();
} else {
- this._renameBtn.show();
+ this._renameStack.visible_child_name = 'rename';
}
}
get editMode() {
return this._editMode;
}
+
+ set expanded(state) {
+ this._expanded = state;
+ this.notify('expanded');
+ }
+
+ get expanded() {
+ return this._expanded;
+ }
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]