[easytag] Move file area to GtkBuilder
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Move file area to GtkBuilder
- Date: Fri, 19 Sep 2014 15:49:48 +0000 (UTC)
commit 596a179593d895e123aecc616218b6a0875bce74
Author: David King <amigadave amigadave com>
Date: Fri Sep 19 16:47:40 2014 +0100
Move file area to GtkBuilder
data/file_area.ui | 194 ++++++++++++++++++++++++++++++++++
data/org.gnome.EasyTAG.gresource.xml | 1 +
po/POTFILES.in | 1 +
src/file_area.c | 140 ++++++++++---------------
4 files changed, 252 insertions(+), 84 deletions(-)
---
diff --git a/data/file_area.ui b/data/file_area.ui
new file mode 100644
index 0000000..e60ce50
--- /dev/null
+++ b/data/file_area.ui
@@ -0,0 +1,194 @@
+<interface domain="easytag">
+ <requires lib="gtk+" version="3.4"/>
+ <object class="GtkGrid" id="file_grid">
+ <property name="border-width">6</property>
+ <property name="column-spacing">6</property>
+ <property name="row-spacing">6</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="file_label">
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">File</property>
+ <property name="visible">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="index_label">
+ <property name="label" translatable="yes">0/0:</property>
+ <property name="margin-left">12</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="filename_entry">
+ <property name="hexpand">True</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="header_grid">
+ <property name="column-spacing">6</property>
+ <property name="margin-left">12</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkLabel" id="version_label">
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Encoder:</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="version_value_label">
+ <property name="halign">start</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="bitrate_label">
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Bitrate:</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="bitrate_value_label">
+ <property name="halign">start</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="samplerate_label">
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Sample rate:</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="samplerate_value_label">
+ <property name="halign">start</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="field_separator">
+ <property name="orientation">vertical</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="height">3</property>
+ <property name="left-attach">2</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="mode_label">
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Mode:</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">3</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="mode_value_label">
+ <property name="halign">start</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">4</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="size_label">
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Size:</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">3</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="size_value_label">
+ <property name="halign">start</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">4</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="duration_label">
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Duration:</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">3</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="duration_value_label">
+ <property name="halign">start</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">4</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">3</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/data/org.gnome.EasyTAG.gresource.xml b/data/org.gnome.EasyTAG.gresource.xml
index 2e5395d..1fad756 100644
--- a/data/org.gnome.EasyTAG.gresource.xml
+++ b/data/org.gnome.EasyTAG.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix='/org/gnome/EasyTAG'>
<file preprocess='xml-stripblanks'>browser.ui</file>
<file preprocess='xml-stripblanks'>cddb_dialog.ui</file>
+ <file preprocess='xml-stripblanks'>file_area.ui</file>
<file preprocess='xml-stripblanks'>load_files_dialog.ui</file>
<file preprocess='xml-stripblanks'>menus.ui</file>
<file preprocess='xml-stripblanks'>playlist_dialog.ui</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a3b8e42..d4589f2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@ data/easytag.appdata.xml.in
data/easytag.desktop.in
[type: gettext/glade]data/browser.ui
[type: gettext/glade]data/cddb_dialog.ui
+[type: gettext/glade]data/file_area.ui
[type: gettext/glade]data/load_files_dialog.ui
[type: gettext/glade]data/menus.ui
[type: gettext/glade]data/playlist_dialog.ui
diff --git a/src/file_area.c b/src/file_area.c
index 80ca5c1..eedb715 100644
--- a/src/file_area.c
+++ b/src/file_area.c
@@ -34,7 +34,7 @@ G_DEFINE_TYPE (EtFileArea, et_file_area, GTK_TYPE_BIN)
struct _EtFileAreaPrivate
{
- GtkWidget *frame;
+ GtkWidget *file_label;
GtkWidget *index_label;
GtkWidget *name_entry;
@@ -78,99 +78,73 @@ static void
create_file_area (EtFileArea *self)
{
EtFileAreaPrivate *priv;
- GtkWidget *vbox, *hbox;
- GtkWidget *separator;
+ GtkBuilder *builder;
+ GError *error = NULL;
+ GtkWidget *grid;
priv = et_file_area_get_instance_private (self);
- priv->frame = gtk_frame_new (_("File"));
- gtk_container_add (GTK_CONTAINER (self), priv->frame);
- gtk_container_set_border_width (GTK_CONTAINER (priv->frame), 2);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/EasyTAG/file_area.ui",
+ &error);
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (priv->frame), vbox);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
+ if (error != NULL)
+ {
+ g_error ("Unable to get file area from resource: %s",
+ error->message);
+ }
- /* HBox for FileEntry and IconBox */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+ grid = GTK_WIDGET (gtk_builder_get_object (builder, "file_grid"));
+ gtk_container_add (GTK_CONTAINER (self), grid);
- /* File index (position in list + list length) */
- priv->index_label = gtk_label_new ("0/0:");
- gtk_box_pack_start (GTK_BOX (hbox), priv->index_label, FALSE, FALSE, 0);
+ priv->file_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "file_label"));
+
+ priv->index_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "index_label"));
/* Filename. */
- priv->name_entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), priv->name_entry, TRUE, TRUE, 2);
+ priv->name_entry = GTK_WIDGET (gtk_builder_get_object (builder,
+ "filename_entry"));
g_signal_connect (priv->name_entry, "populate-popup",
G_CALLBACK (on_entry_populate_popup), NULL);
/* File information. */
- priv->header_grid = gtk_grid_new ();
- gtk_container_add (GTK_CONTAINER (vbox), priv->header_grid);
- gtk_container_set_border_width (GTK_CONTAINER (priv->header_grid), 2);
- gtk_grid_set_row_spacing (GTK_GRID (priv->header_grid), 1);
- gtk_grid_set_column_spacing (GTK_GRID (priv->header_grid), 2);
-
- priv->version_label = gtk_label_new (_("Encoder:"));
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->version_label, 0, 0,
- 1, 1);
- priv->version_value_label = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->version_value_label,
- 1, 0, 1, 1);
- gtk_widget_set_halign (priv->version_label, GTK_ALIGN_END);
- gtk_widget_set_halign (priv->version_value_label, GTK_ALIGN_START);
-
- priv->bitrate_label = gtk_label_new (_("Bitrate:"));
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->bitrate_label, 0, 1,
- 1, 1);
- priv->bitrate_value_label = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->bitrate_value_label,
- 1, 1, 1, 1);
- gtk_widget_set_halign (priv->bitrate_label, GTK_ALIGN_END);
- gtk_widget_set_halign (priv->bitrate_value_label, GTK_ALIGN_START);
-
- /* Translators: Please try to keep this string as short as possible as it
- * is shown in a narrow column. */
- priv->samplerate_label = gtk_label_new (_("Sample rate:"));
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->samplerate_label, 0,
- 2, 1, 1);
- priv->samplerate_value_label = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (priv->header_grid),
- priv->samplerate_value_label, 1, 2, 1, 1);
- gtk_widget_set_halign (priv->samplerate_label, GTK_ALIGN_END);
- gtk_widget_set_halign (priv->samplerate_value_label, GTK_ALIGN_START);
-
- separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
- gtk_grid_attach (GTK_GRID (priv->header_grid), separator, 2, 0, 1, 4);
-
- priv->mode_label = gtk_label_new(_("Mode:"));
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->mode_label, 3, 0, 1,
- 1);
- priv->mode_value_label = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->mode_value_label, 4,
- 0, 1, 1);
- gtk_widget_set_halign (priv->mode_label, GTK_ALIGN_END);
- gtk_widget_set_halign (priv->mode_value_label, GTK_ALIGN_START);
-
- priv->size_label = gtk_label_new (_("Size:"));
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->size_label, 3, 1, 1,
- 1);
- priv->size_value_label = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->size_value_label, 4,
- 1, 1, 1);
- gtk_widget_set_halign (priv->size_label, GTK_ALIGN_END);
- gtk_widget_set_halign (priv->size_value_label, GTK_ALIGN_START);
-
- priv->duration_label = gtk_label_new (_("Duration:"));
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->duration_label, 3, 2,
- 1, 1);
- priv->duration_value_label = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (priv->header_grid), priv->duration_value_label,
- 4, 2, 1, 1);
- gtk_widget_set_halign (priv->duration_label, GTK_ALIGN_END);
- gtk_widget_set_halign (priv->duration_value_label, GTK_ALIGN_START);
+ priv->header_grid = GTK_WIDGET (gtk_builder_get_object (builder,
+ "header_grid"));
+ priv->version_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "version_label"));
+ priv->version_value_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "version_value_label"));
+
+ priv->bitrate_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "bitrate_label"));
+ priv->bitrate_value_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "bitrate_value_label"));
+
+ priv->samplerate_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "samplerate_label"));
+ priv->samplerate_value_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "samplerate_value_label"));
+
+ priv->mode_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "mode_label"));
+ priv->mode_value_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "mode_value_label"));
+
+ priv->size_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "size_label"));
+ priv->size_value_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "size_value_label"));
+
+ priv->duration_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "duration_label"));
+ priv->duration_value_label = GTK_WIDGET (gtk_builder_get_object (builder,
+ "duration_value_label"));
+
+ g_object_unref (builder);
g_signal_connect_swapped (MainSettings, "changed::file-show-header",
G_CALLBACK (on_file_show_header_changed), self);
@@ -183,8 +157,6 @@ et_file_area_init (EtFileArea *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_FILE_AREA,
EtFileAreaPrivate);
create_file_area (self);
-
- gtk_widget_show_all (GTK_WIDGET (self));
}
static void
@@ -244,7 +216,7 @@ et_file_area_set_header_fields (EtFileArea *self,
priv = et_file_area_get_instance_private (self);
- gtk_frame_set_label (GTK_FRAME (priv->frame), fields->description);
+ gtk_label_set_text (GTK_LABEL (priv->file_label), fields->description);
gtk_label_set_text (GTK_LABEL (priv->version_label),
fields->version_label);
gtk_label_set_text (GTK_LABEL (priv->version_value_label),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]