[sound-juicer] Add composers to track listview
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] Add composers to track listview
- Date: Thu, 6 Sep 2012 18:41:58 +0000 (UTC)
commit 75ec0e4f02838aaf2634b07ee6f3cc3e56f519b4
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Sun May 13 13:03:53 2012 +0100
Add composers to track listview
Add track composers to the listview and support for editing them in
on_cell_edited.
https://bugzilla.gnome.org/show_bug.cgi?id=661646
src/sj-main.c | 24 ++++++++++++++++++++----
src/sound-juicer.h | 5 +++--
2 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/src/sj-main.c b/src/sj-main.c
index 85bc3df..9d7d84a 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -78,7 +78,7 @@ static GtkWidget *title_entry, *artist_entry, *duration_label, *genre_entry, *ye
static GtkWidget *track_listview, *extract_button, *play_button, *select_button;
static GtkWidget *status_bar;
GtkListStore *track_store;
-GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer;
+GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer, *composer_renderer;
GtkWidget *current_message_area;
@@ -1381,8 +1381,8 @@ static void on_extract_toggled (GtkCellRendererToggle *cellrenderertoggle,
}
/**
- * Callback when the title or artist cells are edited in the list. column_data
- * contains the column number in the model which was modified.
+ * Callback when the title, artist or composer cells are edited in the list.
+ * column_data contains the column number in the model which was modified.
*/
static void on_cell_edited (GtkCellRendererText *renderer,
gchar *path, gchar *string,
@@ -1408,6 +1408,11 @@ static void on_cell_edited (GtkCellRendererText *renderer,
track->artist = g_strdup (string);
gtk_list_store_set (track_store, &iter, COLUMN_ARTIST, track->artist, -1);
break;
+ case COLUMN_COMPOSER:
+ g_free (track->composer);
+ track->composer = g_strdup (string);
+ gtk_list_store_set (track_store, &iter, COLUMN_COMPOSER, track->composer, -1);
+ break;
default:
g_warning (_("Unknown column %d was edited"), column);
}
@@ -1787,7 +1792,7 @@ startup_cb (GApplication *app, gpointer user_data)
setup_genre_entry (genre_entry);
- track_store = gtk_list_store_new (COLUMN_TOTAL, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER);
+ track_store = gtk_list_store_new (COLUMN_TOTAL, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER);
gtk_tree_view_set_model (GTK_TREE_VIEW (track_listview), GTK_TREE_MODEL (track_store));
{
GtkTreeViewColumn *column;
@@ -1837,6 +1842,17 @@ startup_cb (GApplication *app, gpointer user_data)
g_object_set (G_OBJECT (artist_renderer), "editable", TRUE, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (track_listview), column);
+ composer_renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Composer"),
+ composer_renderer,
+ "text", COLUMN_COMPOSER,
+ NULL);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ g_signal_connect (composer_renderer, "edited", G_CALLBACK (on_cell_edited), GUINT_TO_POINTER (COLUMN_COMPOSER));
+ g_object_set (G_OBJECT (composer_renderer), "editable", TRUE, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (track_listview), column);
+
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Duration"),
renderer,
diff --git a/src/sound-juicer.h b/src/sound-juicer.h
index 3560df2..bc45f55 100644
--- a/src/sound-juicer.h
+++ b/src/sound-juicer.h
@@ -65,6 +65,7 @@ typedef enum {
COLUMN_NUMBER,
COLUMN_TITLE,
COLUMN_ARTIST,
+ COLUMN_COMPOSER,
COLUMN_DURATION,
COLUMN_DETAILS,
COLUMN_TOTAL
@@ -130,9 +131,9 @@ extern gboolean open_finished;
extern gboolean autostart;
/**
- * Toggle, Title and Artist Renderers
+ * Toggle, Title, Artist and Composer Renderers
*/
-extern GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer;
+extern GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer, *composer_renderer;
/**
* Debug
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]