Commit df151f2d authored by Kavan Mevada's avatar Kavan Mevada 🦊

expand row

parent 931ce61d
Pipeline #192266 failed with stage
in 1 minute and 14 seconds
......@@ -4,94 +4,175 @@
<requires lib="gtk+" version="3.20"/>
<template class="Gjs_Row" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<object class="GtkEventBox" id="eventBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<child>
<object class="GtkStack" id="playbackStack">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">12</property>
<property name="no_show_all">True</property>
<property name="margin_top">12</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="playButton">
<property name="name">playButton</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="always_show_image">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">12</property>
<child>
<object class="GtkImage" id="playIcon">
<object class="GtkStack" id="playbackStack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-playback-start-symbolic</property>
<property name="margin_start">12</property>
<child>
<object class="GtkButton" id="playButton">
<property name="name">playButton</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="always_show_image">True</property>
<child>
<object class="GtkImage" id="playIcon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-playback-start-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="name">play</property>
</packing>
</child>
<child>
<object class="GtkButton" id="pauseButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="always_show_image">True</property>
<child>
<object class="GtkImage" id="pauseIcon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-playback-pause-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="name">pause</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="name">play</property>
</packing>
</child>
<child>
<object class="GtkButton" id="pauseButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="always_show_image">True</property>
<child>
<object class="GtkImage" id="pauseIcon">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-playback-pause-symbolic</property>
<property name="valign">center</property>
<property name="margin_left">12</property>
<property name="hexpand">True</property>
<child>
<object class="GtkStack" id="infoStack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="date">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<style>
<class name="subtitle"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">display</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="name">edit</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<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_right">12</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">pause</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="margin_left">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>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="infoStack">
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
......@@ -100,10 +181,10 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="name">
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="margin_bottom">12</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -112,13 +193,62 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="date">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<style>
<class name="subtitle"/>
</style>
<property name="margin_bottom">12</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Export</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">12</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="deleteButton">
<property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_right">12</property>
<style>
<class name="destructive-action"/>
</style>
</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>
<child>
<object class="GtkButton" id="editLabelBtn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">8</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-edit-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -127,19 +257,6 @@
</packing>
</child>
</object>
<packing>
<property name="name">display</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="name">edit</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
......@@ -149,11 +266,6 @@
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
......
......@@ -155,7 +155,7 @@ var Recorder = new GObject.registerClass({
this.recordBus = null;
}
return this.file.query_exists(null) ? new Recording(this.file) : null;
return this.file ? new Recording(this.file) : null;
}
_onMessageReceived(message) {
......
......@@ -9,11 +9,12 @@ const RowState = {
var Row = GObject.registerClass({
Template: 'resource:///org/gnome/SoundRecorder/ui/row.ui',
InternalChildren: ['playbackStack', 'infoStack', 'playButton', 'pauseButton', 'name', 'entry', 'date', 'duration'],
InternalChildren: ['playbackStack', 'infoStack', 'playButton', 'pauseButton', 'name', 'entry', 'date', 'duration', 'eventBox', 'revealer', 'editLabelBtn', 'deleteButton'],
Signals: {
'play': { param_types: [GObject.TYPE_STRING] },
'pause': {},
'deleted': {},
'expand-row': {},
},
}, class Row extends Gtk.ListBoxRow {
_init(recording) {
......@@ -22,10 +23,20 @@ var Row = GObject.registerClass({
this._entry.text = recording.name;
this._name.label = recording.name;
recording.connect('notify::name', () => {
this._name.label = recording.name;
});
this._editMode = false;
this._editLabelBtn.connect('clicked', () => {
this.editMode = true;
});
this._eventBox.connect('button-press-event', () => {
this.emit('expand-row');
});
this._entry.connect('key-press-event', (_, event) => {
const key = event.get_keyval()[1];
this._entry.get_style_context().remove_class('error');
......@@ -35,10 +46,11 @@ var Row = GObject.registerClass({
if (this._name.label !== this._entry.text)
recording.name = this._entry.text;
if (key === Gdk.KEY_Return || key === Gdk.KEY_Escape)
if (key === Gdk.KEY_Return || key === Gdk.KEY_Escape) {
this.editMode = false;
this._editLabelBtn.set_sensitive(true);
}
} catch (e) {
log(e)
this._entry.get_style_context().add_class('error');
}
}
......@@ -65,10 +77,10 @@ var Row = GObject.registerClass({
this.emit('pause');
});
// this._deleteButton.connect('clicked', () => {
// recording.delete();
// this.emit('deleted');
// });
this._deleteButton.connect('clicked', () => {
recording.delete();
this.emit('deleted');
});
}
setState(rowState) {
......@@ -81,7 +93,15 @@ var Row = GObject.registerClass({
set editMode(state) {
this._infoStack.visible_child_name = state ? 'edit' : 'display';
if (state)
if (state) {
this._entry.grab_focus();
this._editLabelBtn.set_sensitive(false);
}
this._editMode = state;
}
get editMode() {
return this._editMode;
}
});
......@@ -70,6 +70,22 @@ var Window = GObject.registerClass({
this.player.play(recording.uri);
});
row.connect('expand-row', selectedRow => {
let editPending = false;
this._listBox.get_children().forEach(_row => {
if (_row.editMode)
editPending = true;
});
if (!editPending) {
this._listBox.get_children().forEach(_row => {
if (_row !== selectedRow)
_row._revealer.reveal_child = false;
});
selectedRow._revealer.reveal_child = !selectedRow._revealer.reveal_child;
}
});
row.connect('pause', () => this.player.pause());
row.connect('deleted', () => this._recordingList.remove(row.get_index()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment