[gnome-sound-recorder] row: add export btn & ensure they fit in small sizes
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] row: add export btn & ensure they fit in small sizes
- Date: Sat, 8 Aug 2020 19:57:13 +0000 (UTC)
commit c8effe07a9d6b0428f63eb2e0deeacb140d058b6
Author: Kavan Mevada <kavanmevada gmail com>
Date: Wed Jul 29 21:50:14 2020 +0530
row: add export btn & ensure they fit in small sizes
data/ui/row.ui | 174 +++++++++++++++++++++++++++++++++++++++++++------------
src/recording.js | 8 +++
src/row.js | 40 ++++++++++---
3 files changed, 176 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/row.ui b/data/ui/row.ui
index c9a61c5a..c87720d9 100644
--- a/data/ui/row.ui
+++ b/data/ui/row.ui
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
+ <requires lib="libhandy" version="0.0"/>
<template class="Gjs_Row" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -139,56 +140,102 @@
<property name="margin_right">12</property>
<property name="margin_bottom">12</property>
<child>
- <object class="GtkButton" id="deleteBtn">
+ <object class="GtkStack" id="rightStack">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Delete</property>
- <property name="halign">center</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
<property name="valign">center</property>
<child>
- <object class="GtkImage">
+ <object class="HdySqueezer" id="squeezer">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">user-trash-symbolic</property>
- </object>
- </child>
- <style>
- <class name="pill-button"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkStack" id="renameStack">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hhomogeneous">False</property>
- <child>
- <object class="GtkButton" id="renameBtn">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Rename</property>
- <property name="halign">center</property>
+ <property name="halign">end</property>
<property name="valign">center</property>
+ <property name="homogeneous">True</property>
<child>
- <object class="GtkImage">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">document-edit-symbolic</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkButton" id="exportBtn">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Export</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="action_name">recording.export</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">document-save-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="pill-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="renameBtn">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Rename</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin_left">8</property>
+ <property name="action_name">recording.rename</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>
+ <style>
+ <class name="pill-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="optionBtn">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="menu_model">optionMenu</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">view-more-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="pill-button"/>
+ </style>
</object>
</child>
- <style>
- <class name="pill-button"/>
- </style>
</object>
<packing>
- <property name="name">rename</property>
+ <property name="name">options</property>
</packing>
</child>
<child>
@@ -198,6 +245,7 @@
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Save</property>
+ <property name="halign">end</property>
<property name="valign">center</property>
<signal name="clicked" handler="onSaveRecording" swapped="no"/>
<child>
@@ -222,11 +270,42 @@
<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="GtkBox" id="deleteBtnBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkButton" id="deleteBtn">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Delete</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">user-trash-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="pill-button"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="playbackControls">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
@@ -383,4 +462,23 @@
</object>
</child>
</template>
+ <menu id="optionMenu">
+ <section>
+ <item>
+ <attribute name="action">recording.rename</attribute>
+ <attribute name="label" translatable="yes">Rename</attribute>
+ </item>
+ <item>
+ <attribute name="action">recording.export</attribute>
+ <attribute name="label" translatable="yes">Export</attribute>
+ </item>
+ </section>
+ </menu>
+ <object class="GtkSizeGroup">
+ <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
+ <widgets>
+ <widget name="rightStack"/>
+ <widget name="deleteBtnBox"/>
+ </widgets>
+</object>
</interface>
diff --git a/src/recording.js b/src/recording.js
index d490bde4..8b5dbd24 100644
--- a/src/recording.js
+++ b/src/recording.js
@@ -100,6 +100,14 @@ var Recording = new GObject.registerClass({
this.waveformCache.trash_async(GLib.PRIORITY_DEFAULT, null, null);
}
+ save(dest) {
+ this.file.copy_async(dest,
+ Gio.FileCreateFlags.NONE, GLib.PRIORITY_DEFAULT, null, null, (obj, res) => {
+ if (obj.copy_finish(res))
+ log('Exporting file: done');
+ });
+ }
+
get waveformCache() {
return CacheDir.get_child(`${this.name}_data`);
}
diff --git a/src/row.js b/src/row.js
index c7c9dd52..28f96fff 100644
--- a/src/row.js
+++ b/src/row.js
@@ -1,5 +1,5 @@
/* exported Row */
-const { Gdk, GObject, Gst, Gtk } = imports.gi;
+const { Gdk, Gio, GObject, Gst, Gtk } = imports.gi;
const { displayDateTime, formatTime } = imports.utils;
const { WaveForm, WaveType } = imports.waveform;
@@ -10,7 +10,7 @@ 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', 'optionBox', 'seekBackward', 'seekForward', 'renameStack', 'renameBtn',
'deleteBtn'],
+ InternalChildren: ['playbackStack', 'mainStack', 'playButton', 'pauseButton', 'name', 'entry', 'date',
'duration', 'revealer', 'playbackControls', 'rightStack', 'squeezer', 'saveBtn', 'renameBtn', 'exportBtn',
'saveBtn', 'rightStack', 'optionBox', 'seekBackward', 'seekForward', 'optionBtn', 'deleteBtn'],
Signals: {
'play': { param_types: [GObject.TYPE_STRING] },
'pause': {},
@@ -49,6 +49,34 @@ var Row = GObject.registerClass({
this._editMode = false;
+ let actionGroup = new Gio.SimpleActionGroup();
+
+ let renameAction = new Gio.SimpleAction({ name: 'rename' });
+ let exportAction = new Gio.SimpleAction({ name: 'export' });
+
+ exportAction.connect('activate', () => {
+ const dialog = Gtk.FileChooserNative.new(_('Export Recording'), null,
Gtk.FileChooserAction.SAVE, _('_Export'), _('_Cancel'));
+ dialog.set_current_name(this._recording.name);
+ dialog.connect('response', (_dialog, _response) => {
+ if (_response === Gtk.ResponseType.ACCEPT) {
+ const dest = dialog.get_file();
+ this._recording.save(dest);
+ }
+ _dialog.destroy();
+ });
+
+ dialog.run();
+ });
+
+ renameAction.connect('activate', () => {
+ this.editMode = true;
+ });
+
+ actionGroup.add_action(renameAction);
+ actionGroup.add_action(exportAction);
+ this.insert_action_group('recording', actionGroup);
+
+
this._entry.connect('key-press-event', (_, event) => {
const key = event.get_keyval()[1];
this._entry.get_style_context().remove_class('error');
@@ -89,10 +117,6 @@ var Row = GObject.registerClass({
this._seekBackward.connect('clicked', _ => this.emit('seek-backward'));
this._seekForward.connect('clicked', _ => this.emit('seek-forward'));
- this._renameBtn.connect('clicked', () => {
- this.editMode = true;
- });
-
this._deleteBtn.connect('clicked', () => {
recording.delete();
this.emit('deleted');
@@ -121,9 +145,9 @@ var Row = GObject.registerClass({
this._entry.grab_focus();
this._saveBtn.grab_default();
- this._renameStack.visible_child_name = 'save';
+ this._rightStack.visible_child_name = 'save';
} else {
- this._renameStack.visible_child_name = 'rename';
+ this._rightStack.visible_child_name = 'options';
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]