[easytag/wip/application-window: 106/112] Move picture details dialog to GtkBuilder
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 106/112] Move picture details dialog to GtkBuilder
- Date: Wed, 27 Aug 2014 21:06:25 +0000 (UTC)
commit 303997d6364caabcbd8865c7ab657ab7299ed544
Author: David King <amigadave amigadave com>
Date: Wed Aug 20 16:02:06 2014 +0100
Move picture details dialog to GtkBuilder
data/org.gnome.EasyTAG.gresource.xml | 1 +
data/tag_area.ui | 84 ++++++++++++++++++
po/POTFILES.in | 1 +
src/tag_area.c | 161 ++++++++++++++++-----------------
4 files changed, 164 insertions(+), 83 deletions(-)
---
diff --git a/data/org.gnome.EasyTAG.gresource.xml b/data/org.gnome.EasyTAG.gresource.xml
index e4a503f..af477d4 100644
--- a/data/org.gnome.EasyTAG.gresource.xml
+++ b/data/org.gnome.EasyTAG.gresource.xml
@@ -5,6 +5,7 @@
<file preprocess='xml-stripblanks'>menus.ui</file>
<file preprocess='xml-stripblanks'>playlist_dialog.ui</file>
<file preprocess='xml-stripblanks'>preferences_dialog.ui</file>
+ <file preprocess='xml-stripblanks'>tag_area.ui</file>
<file preprocess='xml-stripblanks'>toolbar.ui</file>
<file preprocess='to-pixdata'>images/all-lowercase.png</file>
<file preprocess='to-pixdata'>images/all-uppercase.png</file>
diff --git a/data/tag_area.ui b/data/tag_area.ui
new file mode 100644
index 0000000..e7af316
--- /dev/null
+++ b/data/tag_area.ui
@@ -0,0 +1,84 @@
+<interface domain="easytag">
+ <requires lib="gtk+" version="3.4"/>
+ <object class="GtkDialog" id="image_properties_dialog">
+ <property name="border-width">12</property>
+ <property name="destroy-with-parent">True</property>
+ <property name="modal">True</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkGrid" id="properties_grid">
+ <property name="column-spacing">12</property>
+ <property name="orientation">vertical</property>
+ <property name="row-spacing">6</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="types_scrolled">
+ <property name="min-content-height">300</property>
+ <property name="min-content-width">400</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeView" id="types_view">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="types_column">
+ <property name="title" translatable="yes">Image
Type</property>
+ <child>
+ <object class="GtkCellRendererText" id="types_renderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="description_label">
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Description</property>
+ <property name="margin-top">12</property>
+ <property name="visible">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="description_entry">
+ <property name="margin-left">12</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="button_box">
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="use-underline">True</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="accept_button">
+ <property name="can-default">True</property>
+ <property name="label" translatable="yes">_Accept</property>
+ <property name="use-underline">True</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-3">accept_button</action-widget>
+ <action-widget response="-2">cancel_button</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0861842..c7d0949 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/easytag.desktop.in
[type: gettext/glade]data/menus.ui
[type: gettext/glade]data/playlist_dialog.ui
[type: gettext/glade]data/preferences_dialog.ui
+[type: gettext/glade]data/tag_area.ui
[type: gettext/glade]data/toolbar.ui
data/org.gnome.EasyTAG.gschema.xml
nautilus-extension/nautilus-easytag.c
diff --git a/src/tag_area.c b/src/tag_area.c
index 7c659d1..cf6de04 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -1489,10 +1489,7 @@ on_picture_properties_button_clicked (GObject *object,
{
EtTagArea *self;
EtTagAreaPrivate *priv;
- GtkWidget *ScrollWindowPictureTypes, *PictureTypesWindow;
- GtkWidget *type, *label, *desc;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
+ GtkWidget *type, *desc;
GtkTreeSelection *selection;
GtkListStore *store;
GtkTreeIter type_iter_to_select, iter;
@@ -1507,10 +1504,11 @@ on_picture_properties_button_clicked (GObject *object,
self = ET_TAG_AREA (user_data);
priv = et_tag_area_get_instance_private (self);
- parent_window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object)));
- if (!gtk_widget_is_toplevel(GTK_WIDGET(parent_window)))
+ parent_window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (object)));
+
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (parent_window)))
{
- g_warning("Could not get parent window\n");
+ g_warning ("Could not get parent window");
return;
}
@@ -1521,14 +1519,17 @@ on_picture_properties_button_clicked (GObject *object,
for (l = selection_list; l != NULL; l = g_list_next (l))
{
+ GtkWidget *PictureTypesWindow;
GtkTreePath *path = l->data;
Picture *pic = NULL;
GtkTreeSelection *selectiontype;
gchar *title;
GtkTreePath *rowPath;
gboolean valid;
+ GtkBuilder *builder;
+ GError *error = NULL;
- // Get corresponding picture
+ /* Get corresponding picture. */
valid = gtk_tree_model_get_iter (model, &iter, path);
if (valid)
@@ -1541,42 +1542,36 @@ on_picture_properties_button_clicked (GObject *object,
break;
}
- title = g_strdup_printf (_("Image Properties %d/%d"), selection_i++,
- selection_nbr);
- PictureTypesWindow = gtk_dialog_new_with_buttons (title,
- parent_window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_Cancel"),
- GTK_RESPONSE_REJECT,
- _("_OK"),
- GTK_RESPONSE_OK,
- NULL);
- g_free(title);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/EasyTAG/tag_area.ui",
+ &error);
- gtk_window_set_default_size (GTK_WINDOW (PictureTypesWindow), 400,
- 400);
- gtk_dialog_set_default_response(GTK_DIALOG(PictureTypesWindow), GTK_RESPONSE_OK);
+ if (error != NULL)
+ {
+ g_error ("Unable to get image properties dialog from resource: %s",
+ error->message);
+ }
- ScrollWindowPictureTypes = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ScrollWindowPictureTypes),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- store = gtk_list_store_new(PICTURE_TYPE_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_INT);
- type = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ title = g_strdup_printf (_("Image Properties %d/%d"), selection_i++,
+ selection_nbr);
+ PictureTypesWindow = GTK_WIDGET (gtk_builder_get_object (builder,
+ "image_properties_dialog"));
+ gtk_window_set_title (GTK_WINDOW (PictureTypesWindow), title);
+ g_free (title);
+ gtk_window_set_transient_for (GTK_WINDOW (PictureTypesWindow),
+ parent_window);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (PictureTypesWindow),
+ GTK_RESPONSE_ACCEPT);
+
+ store = gtk_list_store_new (PICTURE_TYPE_COLUMN_COUNT, G_TYPE_STRING,
+ G_TYPE_INT);
+ type = GTK_WIDGET (gtk_builder_get_object (builder, "types_view"));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (type), GTK_TREE_MODEL (store));
g_object_unref (store);
- gtk_container_add(GTK_CONTAINER(ScrollWindowPictureTypes), type);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_title (column, _("Image Type"));
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", PICTURE_TYPE_COLUMN_TEXT,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(type), column);
-
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(PictureTypesWindow))),ScrollWindowPictureTypes,TRUE,TRUE,0);
- // Behaviour following the tag type...
+ /* Behaviour following the tag type. */
switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
{
case MP4_TAG:
@@ -1595,10 +1590,10 @@ on_picture_properties_button_clicked (GObject *object,
break;
}
- // Other tag types
+ /* Other tag types. */
default:
{
- // Load pictures types
+ /* Load pictures types. */
for (pic_type = ET_PICTURE_TYPE_OTHER; pic_type < ET_PICTURE_TYPE_UNDEFINED; pic_type++)
{
GtkTreeIter itertype;
@@ -1611,75 +1606,75 @@ on_picture_properties_button_clicked (GObject *object,
pic_type, -1);
/* Line to select by default. */
if (pic->type == pic_type)
+ {
type_iter_to_select = itertype;
+ }
}
break;
}
}
- // Select the line by default
- selectiontype = gtk_tree_view_get_selection(GTK_TREE_VIEW(type));
- gtk_tree_selection_select_iter(selectiontype, &type_iter_to_select);
+ /* Select the line by default. */
+ selectiontype = gtk_tree_view_get_selection (GTK_TREE_VIEW (type));
+ gtk_tree_selection_select_iter (selectiontype, &type_iter_to_select);
+
+ /* Set visible the current selected line. */
+ rowPath = gtk_tree_model_get_path (GTK_TREE_MODEL (store),
+ &type_iter_to_select);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (type), rowPath, NULL,
+ FALSE, 0, 0);
+ gtk_tree_path_free (rowPath);
- // Set visible the current selected line
- rowPath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &type_iter_to_select);
- gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(type), rowPath, NULL, FALSE, 0, 0);
- gtk_tree_path_free(rowPath);
+ /* Entry for the description. */
+ desc = GTK_WIDGET (gtk_builder_get_object (builder,
+ "description_entry"));
- // Description of the picture
- label = gtk_label_new (_("Image Description:"));
-
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(PictureTypesWindow))),label,FALSE,FALSE,4);
+ g_object_unref (builder);
- // Entry for the description
- desc = gtk_entry_new();
-
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(PictureTypesWindow))),desc,FALSE,FALSE,0);
if (pic->description)
{
- gchar *tmp = Try_To_Validate_Utf8_String(pic->description);
- gtk_entry_set_text(GTK_ENTRY(desc), tmp);
- g_free(tmp);
+ gchar *tmp = Try_To_Validate_Utf8_String (pic->description);
+ gtk_entry_set_text (GTK_ENTRY (desc), tmp);
+ g_free (tmp);
}
// Behaviour following the tag type...
switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
{
case MP4_TAG:
- {
- gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(desc), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (desc), FALSE);
break;
- }
-
- // Other tag types
+ /* Other tag types. */
default:
- {
break;
- }
}
- gtk_widget_show_all(PictureTypesWindow);
+ gtk_widget_show_all (PictureTypesWindow);
- response = gtk_dialog_run(GTK_DIALOG(PictureTypesWindow));
- if (response == GTK_RESPONSE_OK)
+ response = gtk_dialog_run (GTK_DIALOG (PictureTypesWindow));
+
+ if (response == GTK_RESPONSE_ACCEPT)
{
GtkTreeModel *modeltype;
GtkTreeIter itertype;
- modeltype = gtk_tree_view_get_model(GTK_TREE_VIEW(type));
- selectiontype = gtk_tree_view_get_selection(GTK_TREE_VIEW(type));
- if (gtk_tree_selection_get_selected(selectiontype, &modeltype, &itertype))
+ modeltype = gtk_tree_view_get_model (GTK_TREE_VIEW (type));
+ selectiontype = gtk_tree_view_get_selection (GTK_TREE_VIEW (type));
+
+ if (gtk_tree_selection_get_selected (selectiontype, &modeltype,
+ &itertype))
{
gchar *buffer, *pic_info;
gint t;
- gtk_tree_model_get(modeltype, &itertype,
+ gtk_tree_model_get (modeltype, &itertype,
PICTURE_TYPE_COLUMN_TYPE_CODE, &t, -1);
pic->type = t;
- buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(desc)));
+ buffer = g_strdup (gtk_entry_get_text (GTK_ENTRY (desc)));
g_strstrip (buffer);
- if (pic->description)
- g_free(pic->description);
+
+ g_free (pic->description);
/* If the entry was empty, buffer will be the empty string "".
* This can be safely passed to the underlying
@@ -1689,15 +1684,15 @@ on_picture_properties_button_clicked (GObject *object,
* downstream bugs when 0 was passed instead. */
pic->description = buffer;
- // Update value in the PictureEntryView
- pic_info = Picture_Info(pic);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter,
- PICTURE_COLUMN_TEXT, pic_info,
- -1);
- g_free(pic_info);
+ /* Update value in the PictureEntryView. */
+ pic_info = Picture_Info (pic);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ PICTURE_COLUMN_TEXT, pic_info, -1);
+ g_free (pic_info);
}
}
- gtk_widget_destroy(PictureTypesWindow);
+
+ gtk_widget_destroy (PictureTypesWindow);
}
g_list_free_full (selection_list, (GDestroyNotify)gtk_tree_path_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]