[easytag] Move browser to GtkBuilder
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Move browser to GtkBuilder
- Date: Thu, 18 Sep 2014 18:16:47 +0000 (UTC)
commit 498bf51ad4d1d7bd39b52a88fd7c0bace6f35598
Author: David King <amigadave amigadave com>
Date: Wed Sep 17 22:48:56 2014 +0100
Move browser to GtkBuilder
data/browser.ui | 542 ++++++++++++++++++++++++++++++++++++++++++++++
src/application_window.c | 25 +--
src/browser.c | 383 ++++++---------------------------
src/browser.h | 4 +-
4 files changed, 614 insertions(+), 340 deletions(-)
---
diff --git a/data/browser.ui b/data/browser.ui
index b2856a4..6d422b8 100644
--- a/data/browser.ui
+++ b/data/browser.ui
@@ -1,5 +1,68 @@
<interface domain="easytag">
<requires lib="gtk+" version="3.4"/>
+ <object class="GtkListStore" id="directory_model">
+ <columns>
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="files_model">
+ <columns>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gpointer"/>
+ <column type="gint"/>
+ <column type="gboolean"/>
+ <column type="gint"/>
+ <column type="GdkRGBA"/>
+ <column type="GdkRGBA"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="tree_model">
+ <columns>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gboolean"/>
+ <column type="gboolean"/>
+ <column type="GIcon"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="artist_model">
+ <columns>
+ <column type="GdkPixbuf"/>
+ <column type="gchararray"/>
+ <column type="guint"/>
+ <column type="guint"/>
+ <column type="gpointer"/>
+ <column type="PangoStyle"/>
+ <column type="gint"/>
+ <column type="GdkRGBA"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="album_model">
+ <columns>
+ <column type="GIcon"/>
+ <column type="gchararray"/>
+ <column type="guint"/>
+ <column type="gpointer"/>
+ <column type="PangoStyle"/>
+ <column type="gint"/>
+ <column type="GdkRGBA"/>
+ <column type="gboolean"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="open_directory_dialog">
<property name="border-width">12</property>
<property name="destroy-with-parent">True</property>
@@ -264,4 +327,483 @@
<action-widget response="-6">cancel_button</action-widget>
</action-widgets>
</object>
+ <object class="GtkGrid" id="browser_grid">
+ <property name="column-spacing">6</property>
+ <property name="row-spacing">6</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkComboBox" id="browser_combo">
+ <property name="has-entry">True</property>
+ <property name="model">directory_model</property>
+ <property name="entry-text-column">0</property>
+ <property name="hexpand">True</property>
+ <property name="tooltip-text" translatable="yes">Choose a directory to show in the
browser</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="GtkButton" id="open_button">
+ <property name="label" translatable="yes">_Open</property>
+ <property name="tooltip-text" translatable="yes">Select a directory to browse</property>
+ <property name="use-underline">True</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="files_label">
+ <property name="label" translatable="yes">No files</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">2</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkPaned" id="browser_paned">
+ <property name="orientation">horizontal</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkNotebook" id="directory_album_artist_notebook">
+ <property name="show-border">False</property>
+ <property name="show-tabs">False</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="directory_scrolled">
+ <property name="expand">True</property>
+ <property name="min-content-height">225</property>
+ <property name="min-content-width">225</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeView" id="directory_view">
+ <property name="model">tree_model</property>
+ <property name="headers-visible">False</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="directory_column">
+ <property name="sizing">autosize</property>
+ <child>
+ <object class="GtkCellRendererPixbuf"
id="directory_icon_renderer"/>
+ <attributes>
+ <attribute name="gicon">4</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText"
id="directory_text_renderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPaned" id="artist_album_paned">
+ <property name="orientation">vertical</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="artist_scrolled">
+ <property name="expand">True</property>
+ <property name="min-content-height">225</property>
+ <property name="min-content-width">225</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeView" id="artist_view">
+ <property name="model">artist_model</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeViewColumn"
id="artist_view_column">
+ <property name="sizing">autosize</property>
+ <property name="title"
translatable="yes">Artist</property>
+ <child>
+ <object class="GtkCellRendererPixbuf"
id="artist_icon_renderer"/>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText"
id="artist_text_renderer"/>
+ <attributes>
+ <attribute
name="foreground-rgba">7</attribute>
+ <attribute name="style">5</attribute>
+ <attribute name="text">1</attribute>
+ <attribute name="weight">6</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="artist_n_albums_column">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">#
Albums</property>
+ <child>
+ <object class="GtkCellRendererText"
id="artist_n_albums_text_renderer"/>
+ <attributes>
+ <attribute
name="foreground-rgba">7</attribute>
+ <attribute name="style">5</attribute>
+ <attribute name="text">2</attribute>
+ <attribute name="weight">6</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="artist_n_files_column">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">#
Files</property>
+ <child>
+ <object class="GtkCellRendererText"
id="artist_n_files_text_renderer"/>
+ <attributes>
+ <attribute
name="foreground-rgba">7</attribute>
+ <attribute name="style">5</attribute>
+ <attribute name="text">3</attribute>
+ <attribute name="weight">6</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="album_scrolled">
+ <property name="expand">True</property>
+ <property name="min-content-height">225</property>
+ <property name="min-content-width">225</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeView" id="album_view">
+ <property name="model">album_model</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="album_view_column">
+ <property name="sizing">autosize</property>
+ <property name="title"
translatable="yes">Album</property>
+ <child>
+ <object class="GtkCellRendererPixbuf"
id="album_icon_renderer"/>
+ <attributes>
+ <attribute name="gicon">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText"
id="album_text_renderer"/>
+ <attributes>
+ <attribute
name="foreground-rgba">6</attribute>
+ <attribute name="style">4</attribute>
+ <attribute name="text">1</attribute>
+ <attribute name="weight">5</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="album_n_files_column">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">#
Files</property>
+ <child>
+ <object class="GtkCellRendererText"
id="album_n_files_text_renderer"/>
+ <attributes>
+ <attribute
name="foreground-rgba">6</attribute>
+ <attribute name="style">4</attribute>
+ <attribute name="text">2</attribute>
+ <attribute name="weight">5</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="files_scrolled">
+ <property name="expand">True</property>
+ <property name="min-content-height">225</property>
+ <property name="min-content-width">225</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeView" id="files_view">
+ <property name="model">files_model</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="filename_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Filename</property>
+ <child>
+ <object class="GtkCellRendererText" id="filename_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">0</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="title_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Title</property>
+ <child>
+ <object class="GtkCellRendererText" id="title_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">1</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="artist_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Artist</property>
+ <child>
+ <object class="GtkCellRendererText" id="artist_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">2</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="album_artist_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Album Artist</property>
+ <child>
+ <object class="GtkCellRendererText" id="album_artist_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">3</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="album_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Album</property>
+ <child>
+ <object class="GtkCellRendererText" id="album_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">4</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="year_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Year</property>
+ <child>
+ <object class="GtkCellRendererText" id="year_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">5</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="disc_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Disc</property>
+ <child>
+ <object class="GtkCellRendererText" id="disc_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">6</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="track_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Track</property>
+ <child>
+ <object class="GtkCellRendererText" id="track_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">7</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="genre_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Genre</property>
+ <child>
+ <object class="GtkCellRendererText" id="genre_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">8</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="comment_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Comment</property>
+ <child>
+ <object class="GtkCellRendererText" id="comment_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">9</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="composer_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Composer</property>
+ <child>
+ <object class="GtkCellRendererText" id="composer_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">10</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="orig_artist_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Original Artist</property>
+ <child>
+ <object class="GtkCellRendererText" id="orig_artist_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">11</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="copyright_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Copyright</property>
+ <child>
+ <object class="GtkCellRendererText" id="copyright_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">12</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="url_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">URL</property>
+ <child>
+ <object class="GtkCellRendererText" id="url_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">13</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="encoded_by_column">
+ <property name="clickable">True</property>
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes">Encoded By</property>
+ <child>
+ <object class="GtkCellRendererText" id="encoded_by_renderer"/>
+ <attributes>
+ <attribute name="background-rgba">19</attribute>
+ <attribute name="foreground-rgba">20</attribute>
+ <attribute name="text">14</attribute>
+ <attribute name="weight">18</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="files_selection">
+ <property name="mode">multiple</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ <property name="width">3</property>
+ </packing>
+ </child>
+ </object>
</interface>
diff --git a/src/application_window.c b/src/application_window.c
index 29771c1..6347366 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -260,26 +260,6 @@ et_application_window_tag_area_clear (EtApplicationWindow *self)
et_tag_area_clear (ET_TAG_AREA (priv->tag_area));
}
-static GtkWidget *
-create_browser_area (EtApplicationWindow *self)
-{
- EtApplicationWindowPrivate *priv;
- GtkWidget *frame;
-
- priv = et_application_window_get_instance_private (self);
-
- frame = gtk_frame_new (_("Browser"));
- gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
-
- priv->browser = GTK_WIDGET (et_browser_new ());
- gtk_container_add (GTK_CONTAINER (frame), priv->browser);
-
- /* Don't load init dir here because Tag area hasn't been yet created!.
- * It will be load at the end of the main function */
-
- return frame;
-}
-
static void
et_application_window_show_cddb_dialog (EtApplicationWindow *self)
{
@@ -1629,7 +1609,6 @@ et_application_window_init (EtApplicationWindow *self)
GtkWindow *window;
GtkWidget *main_vbox;
GtkWidget *hbox, *vbox;
- GtkWidget *widget;
priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
ET_TYPE_APPLICATION_WINDOW,
@@ -1712,8 +1691,8 @@ et_application_window_init (EtApplicationWindow *self)
priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
/* Browser (Tree + File list + Entry) */
- widget = create_browser_area (self);
- gtk_paned_pack1 (GTK_PANED (priv->hpaned), widget, TRUE, TRUE);
+ priv->browser = GTK_WIDGET (et_browser_new ());
+ gtk_paned_pack1 (GTK_PANED (priv->hpaned), priv->browser, TRUE, TRUE);
/* Vertical box for FileArea + TagArea */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
diff --git a/src/browser.c b/src/browser.c
index b77a8e3..9fe9c08 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -51,7 +51,7 @@
#include "win32/win32dep.h"
/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
-G_DEFINE_TYPE (EtBrowser, et_browser, GTK_TYPE_BOX)
+G_DEFINE_TYPE (EtBrowser, et_browser, GTK_TYPE_BIN)
#define et_browser_get_instance_private(browser) (browser->priv)
@@ -3777,133 +3777,75 @@ static void
create_browser (EtBrowser *self)
{
EtBrowserPrivate *priv;
- GtkWidget *HBox;
- GtkWidget *ScrollWindowDirectoryTree;
- GtkWidget *ScrollWindowFileList;
- GtkWidget *ScrollWindowArtistList;
- GtkWidget *ScrollWindowAlbumList;
- GtkWidget *Label;
- GtkWidget *ArtistAlbumVPaned;
- GtkWidget *BrowserHPaned;
+ GtkWidget *grid;
gsize i;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
GtkBuilder *builder;
GError *error = NULL;
GMenuModel *menu_model;
- const gchar *BrowserTree_Titles[] = { N_("Tree") };
- const gchar *BrowserList_Titles[] = { N_("Filename"), N_("Title"),
- N_("Artist"), N_("Album Artist"),
- N_("Album"), N_("Year"), N_("Disc"),
- N_("Track"), N_("Genre"),
- N_("Comment"), N_("Composer"),
- N_("Original Artist"),
- N_("Copyright"), N_("URL"),
- N_("Encoded By") };
- const gchar *ArtistList_Titles[] = { N_("Artist"), N_("# Albums"),
- N_("# Files") };
- const gchar *AlbumList_Titles[] = { N_("Album"), N_("# Files") };
+ const gchar * const ids[] = { "filename_column", "title_column",
+ "artist_column", "album_artist_column",
+ "album_column", "year_column", "disc_column",
+ "track_column", "genre_column",
+ "comment_column", "composer_column",
+ "orig_artist_column", "copyright_column",
+ "url_column", "encoded_by_column" };
priv = et_browser_get_instance_private (self);
gtk_container_set_border_width (GTK_CONTAINER (self), 2);
- // HBox for BrowserEntry + priv->label
- HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
- gtk_box_pack_start (GTK_BOX (self), HBox, FALSE, TRUE, 0);
+ /* The entry box for displaying path. */
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder, "/org/gnome/EasyTAG/browser.ui",
+ &error);
- /*
- * The entry box for displaying path
- */
- priv->entry_model = gtk_list_store_new (MISC_COMBO_COUNT, G_TYPE_STRING);
+ if (error != NULL)
+ {
+ g_error ("Unable to get browser from resource: %s",
+ error->message);
+ }
- priv->entry_combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->entry_model));
- /* The model would normally be unreffed here, but the browser owns a ref so
- * that the model is not finalized before the destroy() vfunc runs. */
- gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(priv->entry_combo), MISC_COMBO_TEXT);
+ grid = GTK_WIDGET (gtk_builder_get_object (builder, "browser_grid"));
+ gtk_container_add (GTK_CONTAINER (self), grid);
+
+ priv->entry_model = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "directory_model"));
+
+ priv->entry_combo = GTK_WIDGET (gtk_builder_get_object (builder,
+ "browser_combo"));
/* History list */
- Load_Path_Entry_List(priv->entry_model, MISC_COMBO_TEXT);
- //gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(priv->entry_combo),2); // Two columns to display paths
+ Load_Path_Entry_List (priv->entry_model, MISC_COMBO_TEXT);
g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->entry_combo)),
"activate", G_CALLBACK (Browser_Entry_Activated),
- self);
- gtk_box_pack_start(GTK_BOX(HBox),priv->entry_combo,TRUE,TRUE,1);
- gtk_widget_set_tooltip_text (GTK_WIDGET (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->entry_combo)))),
- _("Choose a directory to show in the browser"));
+ self);
- /*
- * The button to select a directory to browse
- */
- priv->button = gtk_button_new_with_mnemonic (_("_Open"));
- gtk_box_pack_start (GTK_BOX (HBox), priv->button, FALSE, FALSE, 1);
+ /* The button to select a directory to browse. */
+ priv->button = GTK_WIDGET (gtk_builder_get_object (builder,
+ "open_button"));
g_signal_connect_swapped (priv->button, "clicked",
G_CALLBACK (File_Selection_Window_For_Directory),
gtk_bin_get_child (GTK_BIN (priv->entry_combo)));
- gtk_widget_set_tooltip_text (priv->button,
- _("Select a directory to browse"));
-
- /*
- * The label for displaying number of files in path (without subdirs)
- */
+ /* The label for displaying number of files in path (without subdirs). */
/* Translators: No files, as in "0 files". */
- priv->label = gtk_label_new(_("No files"));
- gtk_box_pack_start (GTK_BOX (HBox), priv->label, FALSE, FALSE, 2);
-
- /* Browser NoteBook :
- * - one tab for the priv->tree
- * - one tab for the priv->artist_list and the priv->album_list
- */
- priv->notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
+ priv->label = GTK_WIDGET (gtk_builder_get_object (builder, "files_label"));
+ /* Browser notebook: one tab for the priv->tree, one tab for the
+ * priv->artist_list and the priv->album_list. */
+ priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder,
+ "directory_album_artist_notebook"));
- /*
- * The ScrollWindow and the Directory-Tree
- */
- ScrollWindowDirectoryTree = gtk_scrolled_window_new(NULL,NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ScrollWindowDirectoryTree),
- GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
- priv->directory_model = gtk_tree_store_new(TREE_COLUMN_COUNT,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_ICON);
-
- Label = gtk_label_new(_("Tree"));
- gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook),ScrollWindowDirectoryTree,Label);
+ /* The ScrollWindow and the Directory-Tree. */
+ priv->directory_model = GTK_TREE_STORE (gtk_builder_get_object (builder,
+ "tree_model"));
/* The tree view */
- priv->tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->directory_model));
- g_object_unref (priv->directory_model);
- gtk_container_add(GTK_CONTAINER(ScrollWindowDirectoryTree),priv->tree);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->tree), TRUE);
-
- // Column for the pixbuf + text
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _(BrowserTree_Titles[0]));
-
- // Cell of the column for the pixbuf
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "gicon", TREE_COLUMN_ICON,
- NULL);
- // Cell of the column for the text
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", TREE_COLUMN_DIR_NAME,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->tree), column);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ priv->tree = GTK_WIDGET (gtk_builder_get_object (builder,
+ "directory_view"));
Browser_Tree_Initialize (self);
-
/* Signals */
g_signal_connect_swapped (priv->tree, "row-expanded",
G_CALLBACK (expand_cb), self);
@@ -3917,7 +3859,6 @@ create_browser (EtBrowser *self)
G_CALLBACK (Browser_Tree_Key_Press), NULL);
/* Create popup menu on browser tree view. */
- builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/org/gnome/EasyTAG/menus.ui",
&error);
@@ -3936,93 +3877,19 @@ create_browser (EtBrowser *self)
g_signal_connect (priv->tree, "popup-menu",
G_CALLBACK (on_directory_tree_popup_menu), self);
- /*
- * The ScrollWindows with the Artist and Album Lists
- */
-
- ArtistAlbumVPaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
-
- Label = gtk_label_new(_("Artist & Album"));
- gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook),ArtistAlbumVPaned,Label);
+ /* The ScrollWindows with the Artist and Album Lists. */
+ priv->artist_model = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "artist_model"));
- ScrollWindowArtistList = gtk_scrolled_window_new(NULL,NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ScrollWindowArtistList),
- GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
-
- priv->artist_model = gtk_list_store_new (ARTIST_COLUMN_COUNT,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING,
- G_TYPE_UINT,
- G_TYPE_UINT,
- G_TYPE_POINTER,
- PANGO_TYPE_STYLE,
- G_TYPE_INT,
- GDK_TYPE_RGBA);
-
- priv->artist_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->artist_model));
- g_object_unref (priv->artist_model);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->artist_list), TRUE);
+ priv->artist_list = GTK_WIDGET (gtk_builder_get_object (builder,
+ "artist_view"));
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->artist_list)),
GTK_SELECTION_SINGLE);
-
-
- // Artist column
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _(ArtistList_Titles[0]));
-
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "pixbuf", ARTIST_PIXBUF,
- NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", ARTIST_NAME,
- "weight", ARTIST_FONT_WEIGHT,
- "style", ARTIST_FONT_STYLE,
- "foreground-rgba", ARTIST_ROW_FOREGROUND,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->artist_list), column);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
- // # Albums of Artist column
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _(ArtistList_Titles[1]));
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", ARTIST_NUM_ALBUMS,
- "weight", ARTIST_FONT_WEIGHT,
- "style", ARTIST_FONT_STYLE,
- "foreground-rgba", ARTIST_ROW_FOREGROUND,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->artist_list), column);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
- // # Files of Artist column
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _(ArtistList_Titles[2]));
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", ARTIST_NUM_FILES,
- "weight", ARTIST_FONT_WEIGHT,
- "style", ARTIST_FONT_STYLE,
- "foreground-rgba", ARTIST_ROW_FOREGROUND,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->artist_list), column);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
priv->artist_selected_handler = g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW
(priv->artist_list)),
"changed",
G_CALLBACK (Browser_Artist_List_Row_Selected),
self);
- gtk_container_add(GTK_CONTAINER(ScrollWindowArtistList),priv->artist_list);
-
/* Create popup menu on browser artist list. */
menu_model = G_MENU_MODEL (gtk_builder_get_object (builder,
"directory-artist-menu"));
@@ -4033,68 +3900,18 @@ create_browser (EtBrowser *self)
G_CALLBACK (on_artist_tree_button_press_event), self);
g_signal_connect (priv->artist_list, "popup-menu",
G_CALLBACK (on_artist_tree_popup_menu), self);
- // Not available yet!
- //ui_widget_set_sensitive(MENU_FILE, AM_ARTIST_OPEN_FILE_WITH, FALSE);
-
- ScrollWindowAlbumList = gtk_scrolled_window_new(NULL,NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ScrollWindowAlbumList),
- GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
-
- priv->album_model = gtk_list_store_new (ALBUM_COLUMN_COUNT,
- G_TYPE_ICON,
- G_TYPE_STRING,
- G_TYPE_UINT,
- G_TYPE_POINTER,
- PANGO_TYPE_STYLE,
- G_TYPE_INT,
- GDK_TYPE_RGBA,
- G_TYPE_BOOLEAN);
-
- priv->album_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->album_model));
- g_object_unref (priv->album_model);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->album_list), TRUE);
- gtk_tree_view_set_reorderable(GTK_TREE_VIEW(priv->album_list), FALSE);
- gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->album_list)),
GTK_SELECTION_SINGLE);
-
- // Album column
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _(AlbumList_Titles[0]));
-
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer, "gicon",
- ALBUM_GICON, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", ALBUM_NAME,
- "weight", ALBUM_FONT_WEIGHT,
- "style", ALBUM_FONT_STYLE,
- "foreground-rgba", ALBUM_ROW_FOREGROUND,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->album_list), column);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
- // # files column
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _(AlbumList_Titles[1]));
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer,
- "text", ALBUM_NUM_FILES,
- "weight", ALBUM_FONT_WEIGHT,
- "style", ALBUM_FONT_STYLE,
- "foreground-rgba", ALBUM_ROW_FOREGROUND,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(priv->album_list), column);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+
+ priv->album_model = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "album_model"));
+ priv->album_list = GTK_WIDGET (gtk_builder_get_object (builder,
+ "album_view"));
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->album_list)),
+ GTK_SELECTION_SINGLE);
priv->album_selected_handler = g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW
(priv->album_list)),
"changed",
G_CALLBACK (Browser_Album_List_Row_Selected),
self);
- gtk_container_add(GTK_CONTAINER(ScrollWindowAlbumList),priv->album_list);
/* Create Popup Menu on browser album list. */
menu_model = G_MENU_MODEL (gtk_builder_get_object (builder,
@@ -4107,68 +3924,18 @@ create_browser (EtBrowser *self)
g_signal_connect (priv->album_list, "popup-menu",
G_CALLBACK (on_album_tree_popup_menu), self);
- // Not available yet!
- //ui_widget_set_sensitive(MENU_FILE, AM_ALBUM_OPEN_FILE_WITH, FALSE);
-
-
- gtk_paned_pack1(GTK_PANED(ArtistAlbumVPaned),ScrollWindowArtistList,TRUE,TRUE); // Top side
- gtk_paned_pack2(GTK_PANED(ArtistAlbumVPaned),ScrollWindowAlbumList,TRUE,TRUE); // Bottom side
-
-
- /*
- * The ScrollWindow and the List
- */
- ScrollWindowFileList = gtk_scrolled_window_new(NULL,NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ScrollWindowFileList),
- GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
-
/* The file list */
- priv->file_model = gtk_list_store_new (LIST_COLUMN_COUNT,
- G_TYPE_STRING, /* Filename. */
- G_TYPE_STRING, /* Title tag. */
- G_TYPE_STRING, /* Artist tag. */
- G_TYPE_STRING, /* Album artist tag. */
- G_TYPE_STRING, /* Album tag. */
- G_TYPE_STRING, /* Year tag. */
- G_TYPE_STRING, /* Disc/CD number tag. */
- G_TYPE_STRING, /* Track tag. */
- G_TYPE_STRING, /* Genre tag. */
- G_TYPE_STRING, /* Comment tag. */
- G_TYPE_STRING, /* Composer tag. */
- G_TYPE_STRING, /* Orig. artist tag. */
- G_TYPE_STRING, /* Copyright tag. */
- G_TYPE_STRING, /* URL tag. */
- G_TYPE_STRING, /* Encoded by tag. */
- G_TYPE_POINTER, /* File pointer. */
- G_TYPE_INT, /* File key. */
- G_TYPE_BOOLEAN, /* File OtherDir. */
- G_TYPE_INT, /* Font weight. */
- GDK_TYPE_RGBA, /* Row background. */
- GDK_TYPE_RGBA); /* Row foreground. */
-
- priv->file_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->file_model));
- g_object_unref (priv->file_model);
- gtk_container_add(GTK_CONTAINER(ScrollWindowFileList), priv->file_view);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->file_view), TRUE);
+ priv->file_model = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "files_model"));
+ priv->file_view = GTK_WIDGET (gtk_builder_get_object (builder,
+ "files_view"));
/* Add columns to tree view. See ET_FILE_LIST_COLUMN. */
for (i = 0; i <= LIST_FILE_ENCODED_BY; i++)
{
- guint ascending_sort = 2 * i;
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_text_new ();
-
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_title (column, _(BrowserList_Titles[i]));
- gtk_tree_view_column_set_attributes(column, renderer, "text", i,
- "weight", LIST_FONT_WEIGHT,
- "background-rgba",
- LIST_ROW_BACKGROUND,
- "foreground-rgba",
- LIST_ROW_FOREGROUND, NULL);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->file_view), column);
- gtk_tree_view_column_set_clickable (column, TRUE);
+ const guint ascending_sort = 2 * i;
+ GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder, ids[i]));
+
g_object_set_data (G_OBJECT (column), "browser", self);
g_signal_connect (column, "clicked",
G_CALLBACK (et_browser_on_column_clicked),
@@ -4177,8 +3944,8 @@ create_browser (EtBrowser *self)
g_signal_connect_swapped (MainSettings, "changed::sort-mode",
G_CALLBACK (on_sort_mode_changed), self);
- gtk_tree_view_set_reorderable(GTK_TREE_VIEW(priv->file_view), FALSE);
-
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->file_view)),GTK_SELECTION_MULTIPLE);
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_view)),
+ GTK_SELECTION_MULTIPLE);
/* When selecting a line. */
gtk_tree_selection_set_select_function (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_view)),
Browser_List_Select_Func, self,
@@ -4187,7 +3954,8 @@ create_browser (EtBrowser *self)
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->file_model), 0,
Browser_List_Sort_Func, NULL, NULL);
et_browser_refresh_sort (self);
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(priv->file_model), 0, GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->file_model),
+ 0, GTK_SORT_ASCENDING);
priv->file_selected_handler = g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW
(priv->file_view)),
"changed",
@@ -4208,24 +3976,10 @@ create_browser (EtBrowser *self)
g_object_unref (builder);
- /*
- * The list store for run program combos
- */
+ /* The list store for run program combos. */
priv->run_program_model = gtk_list_store_new(MISC_COMBO_COUNT, G_TYPE_STRING);
- /*
- * The pane for the tree and list
- */
- BrowserHPaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start (GTK_BOX (self), BrowserHPaned, TRUE, TRUE, 0);
- /* Left side. */
- gtk_paned_pack1 (GTK_PANED (BrowserHPaned), priv->notebook, TRUE, TRUE);
- /* Right side. */
- gtk_paned_pack2 (GTK_PANED (BrowserHPaned), ScrollWindowFileList, TRUE,
- TRUE);
-
/* TODO: Give the browser area a sensible default size. */
- gtk_paned_set_position (GTK_PANED (BrowserHPaned), 250);
gtk_widget_show_all (GTK_WIDGET (self));
/* Set home variable as current path */
@@ -5194,8 +4948,8 @@ et_browser_destroy (GtkWidget *widget)
if (priv->entry_model)
{
Save_Path_Entry_List (priv->entry_model, MISC_COMBO_TEXT);
- g_object_unref (priv->entry_model);
priv->entry_model = NULL;
+ /* The model is disposed when the combo box is disposed. */
}
GTK_WIDGET_CLASS (et_browser_parent_class)->destroy (widget);
@@ -5251,6 +5005,5 @@ et_browser_class_init (EtBrowserClass *klass)
EtBrowser *
et_browser_new (void)
{
- return g_object_new (ET_TYPE_BROWSER, "orientation",
- GTK_ORIENTATION_VERTICAL, NULL);
+ return g_object_new (ET_TYPE_BROWSER, NULL);
}
diff --git a/src/browser.h b/src/browser.h
index 201fdfb..b149f8f 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -37,14 +37,14 @@ typedef struct _EtBrowserPrivate EtBrowserPrivate;
struct _EtBrowser
{
/*< private >*/
- GtkBox parent_instance;
+ GtkBin parent_instance;
EtBrowserPrivate *priv;
};
struct _EtBrowserClass
{
/*< private >*/
- GtkBoxClass parent_class;
+ GtkBinClass parent_class;
};
GType et_browser_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]