[gnome-sound-recorder] infodialog: migrate to use glade Part of #65
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] infodialog: migrate to use glade Part of #65
- Date: Tue, 31 Mar 2020 12:22:29 +0000 (UTC)
commit 1dfc6c18b056a4deaf3d50a34c4453e1e3f5a86c
Author: Kavan Mevada <kavanmevada gmail com>
Date: Tue Mar 31 12:43:49 2020 +0530
infodialog: migrate to use glade
Part of #65
data/org.gnome.SoundRecorder.data.gresource.xml | 1 +
data/ui/infodialog.ui | 200 +++++++++++++++++++++++
po/POTFILES.in | 3 +-
src/info.js | 153 +++--------------
src/mainWindow.js | 14 +-
src/org.gnome.SoundRecorder.src.gresource.xml.in | 2 +-
src/{fileUtil.js => utils.js} | 0
7 files changed, 233 insertions(+), 140 deletions(-)
---
diff --git a/data/org.gnome.SoundRecorder.data.gresource.xml b/data/org.gnome.SoundRecorder.data.gresource.xml
index 490ea27..6700b5d 100644
--- a/data/org.gnome.SoundRecorder.data.gresource.xml
+++ b/data/org.gnome.SoundRecorder.data.gresource.xml
@@ -4,6 +4,7 @@
<file>application.css</file>
<file>ui/window.ui</file>
<file>ui/preferences.ui</file>
+ <file>ui/infodialog.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/infodialog.ui b/data/ui/infodialog.ui
new file mode 100644
index 0000000..e94f1c4
--- /dev/null
+++ b/data/ui/infodialog.ui
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.0 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="Gjs_InfoDialog" parent="GtkWindow">
+ <property name="can_focus">False</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="default_width">400</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="deletable">False</property>
+ <child>
+ <object class="GtkBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">0</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">16</property>
+ <property name="margin_end">16</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">16</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">File Name</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Source</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="dateModifiedLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Date Modified</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Date Created</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Media Type</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="fileNameEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">start</property>
+ <property name="width_chars">30</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="sourceLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="dateModifiedValueLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="dateCreatedLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="mediaTypeLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <style>
+ <class name="dialog-vbox"/>
+ </style>
+ </object>
+ </child>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Info</property>
+ <child>
+ <object class="GtkButton" id="cancelBtn">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="doneBtn">
+ <property name="label" translatable="yes">Done</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 439556f..14f39a4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,9 +3,10 @@ data/org.gnome.SoundRecorder.gschema.xml.in
data/org.gnome.SoundRecorder.desktop.in.in
data/ui/window.ui
data/ui/preferences.ui
+data/ui/infodialog.ui
src/audioProfile.js
src/application.js
-src/fileUtil.js
+src/utils.js
src/info.js
src/listview.js
src/main.js
diff --git a/src/info.js b/src/info.js
index f4bbe65..025a0ad 100644
--- a/src/info.js
+++ b/src/info.js
@@ -22,142 +22,41 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
+const GObject = imports.gi.GObject;
-var InfoDialog = class InfoDialog {
- constructor(fileNav) {
- let fileName = fileNav;
+var InfoDialog = GObject.registerClass({ // eslint-disable-line no-unused-vars
+ Template: 'resource:///org/gnome/SoundRecorder/ui/infodialog.ui',
+ InternalChildren: ['cancelBtn', 'doneBtn', 'fileNameEntry', 'sourceLabel', 'dateModifiedLabel',
'dateModifiedValueLabel', 'dateCreatedLabel', 'mediaTypeLabel'],
+}, class InfoDialog extends Gtk.Window {
+ _init(file) {
+ this._file = Gio.File.new_for_uri(file.uri);
- this._file = Gio.File.new_for_uri(fileNav.uri);
+ super._init({ transient_for: Gio.Application.get_default().get_active_window() });
- this.widget = new Gtk.Dialog({ resizable: false,
- modal: true,
- destroy_with_parent: true,
- default_width: 400 });
- this.widget.set_transient_for(Gio.Application.get_default().get_active_window());
- let header = new Gtk.HeaderBar({ title: _('Info') });
- header.set_show_close_button(false);
- this.widget.set_titlebar(header);
-
-
- let cancelButton = new Gtk.Button({ label: _('Cancel') });
- cancelButton.connect('clicked', () => this.onCancelClicked());
-
- header.pack_start(cancelButton);
-
- let doneButton = new Gtk.Button({ label: _('Done') });
- doneButton.connect('clicked', () => this.onDoneClicked());
-
- header.pack_end(doneButton);
-
- let headerBarSizeGroup = new Gtk.SizeGroup({ mode: Gtk.SizeGroupMode.HORIZONTAL });
-
- headerBarSizeGroup.add_widget(cancelButton);
- headerBarSizeGroup.add_widget(doneButton);
-
- let grid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
- row_homogeneous: true,
- column_homogeneous: true,
- halign: Gtk.Align.CENTER,
- row_spacing: 6,
- column_spacing: 12,
- margin_bottom: 18,
- margin_end: 18,
- margin_start: 18,
- margin_top: 18 });
-
- let contentArea = this.widget.get_content_area();
- contentArea.pack_start(grid, true, true, 2);
-
- // File Name item
- // Translators: "File Name" is the label next to the file name
- // in the info dialog
- this._name = new Gtk.Label({ label: C_('File Name', 'Name'),
- halign: Gtk.Align.END });
- this._name.get_style_context().add_class('dim-label');
- grid.add(this._name);
-
-
- // Source item
- this._source = new Gtk.Label({ label: _('Source'),
- halign: Gtk.Align.END });
- this._source.get_style_context().add_class('dim-label');
-
- if (fileName.appName !== null)
- grid.add(this._source);
-
-
- // Date Modified item
- this._dateModifiedLabel = new Gtk.Label({ label: _('Date Modified'),
- halign: Gtk.Align.END });
- this._dateModifiedLabel.get_style_context().add_class('dim-label');
- grid.add(this._dateModifiedLabel);
-
- // Date Created item
- this._dateCreatedLabel = new Gtk.Label({ label: _('Date Created'),
- halign: Gtk.Align.END });
- this._dateCreatedLabel.get_style_context().add_class('dim-label');
-
- if (fileName.dateCreated !== null)
- grid.add(this._dateCreatedLabel);
-
-
- // Media type item
- // Translators: "Type" is the label next to the media type
- // (Ogg Vorbis, AAC, ...) in the info dialog
- this._mediaType = new Gtk.Label({ label: C_('Media Type', 'Type'),
- halign: Gtk.Align.END });
- this._mediaType.get_style_context().add_class('dim-label');
- grid.add(this._mediaType);
-
- // File name value
- this._fileNameEntry = new Gtk.Entry({ activates_default: true,
- text: fileName.fileName,
- editable: true,
- hexpand: true,
- width_chars: 40,
- halign: Gtk.Align.START });
- grid.attach_next_to(this._fileNameEntry, this._name, Gtk.PositionType.RIGHT, 2, 1);
+ this._fileNameEntry.text = file.fileName;
// Source value
- let sourceLink = this._file.get_parent();
- let sourcePath = sourceLink.get_path();
+ this._sourceLabel.label = this._file.get_parent().get_path();
- this._sourceData = new Gtk.LinkButton({ label: sourcePath,
- uri: sourceLink.get_uri(),
- halign: Gtk.Align.START });
- if (fileName.appName !== null)
- grid.attach_next_to(this._sourceData, this._source, Gtk.PositionType.RIGHT, 2, 1);
-
- // Date Modified value
- if (fileName.dateModified !== null) {
- this._dateModifiedData = new Gtk.Label({ label: fileName.dateModified,
- halign: Gtk.Align.START });
- grid.attach_next_to(this._dateModifiedData, this._dateModifiedLabel, Gtk.PositionType.RIGHT, 2,
1);
- }
-
- // Date Created value
- if (fileName.dateCreated) {
- this._dateCreatedData = new Gtk.Label({ label: fileName.dateCreated,
- halign: Gtk.Align.START });
- grid.attach_next_to(this._dateCreatedData, this._dateCreatedLabel, Gtk.PositionType.RIGHT, 2, 1);
+ if (file.dateModified !== null) {
+ this._dateModifiedValueLabel.label = file.dateModified;
+ } else {
+ this._dateModifiedValueLabel.destroy();
+ this._dateModifiedLabel.destroy();
}
- // Media type data
- this._mediaTypeData = new Gtk.Label({ label: fileName.mediaType || _('Unknown'),
- halign: Gtk.Align.START });
- grid.attach_next_to(this._mediaTypeData, this._mediaType, Gtk.PositionType.RIGHT, 2, 1);
+ this._dateCreatedLabel.label = file.dateCreated;
+ this._mediaTypeLabel.label = file.mediaType || _('Unknown');
- this.widget.show_all();
- }
-
- onDoneClicked() {
- let newFileName = this._fileNameEntry.get_text();
- this._file.set_display_name_async(newFileName, GLib.PRIORITY_DEFAULT, null, null);
- this.widget.destroy();
- }
+ this._cancelBtn.connect('clicked', () => {
+ this.destroy();
+ });
- onCancelClicked() {
- this.widget.destroy();
+ this._doneBtn.connect('clicked', () => {
+ let newFileName = this._fileNameEntry.get_text();
+ this._file.set_display_name_async(newFileName, GLib.PRIORITY_DEFAULT, null, null);
+ this.destroy();
+ });
}
-};
+});
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 388df2b..e5bd612 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -30,7 +30,7 @@ const Pango = imports.gi.Pango;
const Settings = imports.preferences.settings;
const AudioProfile = imports.audioProfile;
-const FileUtil = imports.fileUtil;
+const Utils = imports.utils;
const Info = imports.info;
const Listview = imports.listview;
const Play = imports.play;
@@ -76,7 +76,7 @@ var MainWindow = GObject.registerClass({
_init(params) {
audioProfile = new AudioProfile.AudioProfile();
- displayTime = new FileUtil.DisplayTime();
+ displayTime = new Utils.DisplayTime();
view = this;
this._addListviewPage();
this.labelID = null;
@@ -410,7 +410,7 @@ var MainWindow = GObject.registerClass({
this._info.connect('clicked', button => {
let row = button.get_parent().get_parent();
this.listBox.select_row(row);
- this._onInfoButton(file);
+ (new Info.InfoDialog(file)).show();
});
this._info.set_tooltip_text(_('Info'));
this.rowGrid.attach(this._info, 27, 0, 1, 2);
@@ -543,14 +543,6 @@ var MainWindow = GObject.registerClass({
return fileToPlay;
}
- _onInfoButton(selected) {
- let infoDialog = new Info.InfoDialog(selected);
-
- infoDialog.widget.connect('response', () => {
- infoDialog.widget.destroy();
- });
- }
-
setLabel(time) {
this.time = time;
diff --git a/src/org.gnome.SoundRecorder.src.gresource.xml.in
b/src/org.gnome.SoundRecorder.src.gresource.xml.in
index 7fb1ff4..91c3f40 100644
--- a/src/org.gnome.SoundRecorder.src.gresource.xml.in
+++ b/src/org.gnome.SoundRecorder.src.gresource.xml.in
@@ -3,7 +3,7 @@
<gresource prefix="/org/gnome/SoundRecorder@profile@/js">
<file>application.js</file>
<file>audioProfile.js</file>
- <file>fileUtil.js</file>
+ <file>utils.js</file>
<file>info.js</file>
<file>listview.js</file>
<file>main.js</file>
diff --git a/src/fileUtil.js b/src/utils.js
similarity index 100%
rename from src/fileUtil.js
rename to src/utils.js
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]