[rhythmbox] add support for 'comment' tag (bug #560940)



commit ad6f038050522446732e85bf66c56e0586f9b00c
Author: Josh Green <jgreen users sourceforge net>
Date:   Sun May 30 20:21:39 2010 +1000

    add support for 'comment' tag (bug #560940)
    
    The comment tag can now be displayed as an entry view column and in song
    info dialogs, and can also be used in auto playlist criteria.

 backends/gstreamer/rb-encoder-gst.c   |    1 +
 data/ui/general-prefs.ui              |   22 +++++++++++++++++-
 data/ui/song-info.ui                  |   39 ++++++++++++++++++++++++++++++--
 rhythmdb/rhythmdb-private.h           |    1 +
 rhythmdb/rhythmdb-tree.c              |    3 ++
 rhythmdb/rhythmdb.c                   |   21 +++++++++++++++++
 rhythmdb/rhythmdb.h                   |    1 +
 shell/rb-shell-preferences.c          |    8 ++++++
 sources/rb-browser-source.c           |    1 +
 sources/rb-playlist-source.c          |    1 +
 widgets/rb-entry-view.c               |   16 +++++++++++++
 widgets/rb-entry-view.h               |    1 +
 widgets/rb-query-creator-properties.c |    2 +
 widgets/rb-song-info.c                |   33 +++++++++++++++++++++++++++
 14 files changed, 146 insertions(+), 4 deletions(-)
---
diff --git a/backends/gstreamer/rb-encoder-gst.c b/backends/gstreamer/rb-encoder-gst.c
index aa3e967..631aa39 100644
--- a/backends/gstreamer/rb-encoder-gst.c
+++ b/backends/gstreamer/rb-encoder-gst.c
@@ -510,6 +510,7 @@ add_tags_from_entry (RBEncoderGst *encoder,
 	add_string_tag (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, entry, RHYTHMDB_PROP_ARTIST);
 	add_string_tag (tags, GST_TAG_MERGE_APPEND, GST_TAG_ALBUM, entry, RHYTHMDB_PROP_ALBUM);
 	add_string_tag (tags, GST_TAG_MERGE_APPEND, GST_TAG_GENRE, entry, RHYTHMDB_PROP_GENRE);
+	add_string_tag (tags, GST_TAG_MERGE_APPEND, GST_TAG_COMMENT, entry, RHYTHMDB_PROP_COMMENT);
 
 	day = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_DATE);
 
diff --git a/data/ui/general-prefs.ui b/data/ui/general-prefs.ui
index be09f5e..8528236 100644
--- a/data/ui/general-prefs.ui
+++ b/data/ui/general-prefs.ui
@@ -210,7 +210,7 @@
                         <child>
                           <object class="GtkTable" id="table1">
                             <property name="visible">True</property>
-                            <property name="n_rows">6</property>
+                            <property name="n_rows">7</property>
                             <property name="n_columns">2</property>
                             <property name="column_spacing">12</property>
                             <property name="row_spacing">6</property>
@@ -424,6 +424,26 @@
                                 <property name="y_options"></property>
                               </packing>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="comment_check">
+                                <property name="label" translatable="yes">C_omment</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="rb_shell_preferences_column_check_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="top_attach">6</property>
+                                <property name="bottom_attach">7</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options"></property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="position">1</property>
diff --git a/data/ui/song-info.ui b/data/ui/song-info.ui
index 2bde9d0..a774d8e 100644
--- a/data/ui/song-info.ui
+++ b/data/ui/song-info.ui
@@ -15,7 +15,7 @@
           <object class="GtkTable" id="song_info_table">
             <property name="visible">True</property>
             <property name="border_width">12</property>
-            <property name="n_rows">7</property>
+            <property name="n_rows">8</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">12</property>
             <property name="row_spacing">6</property>
@@ -247,10 +247,43 @@
                 <property name="y_options"></property>
               </packing>
             </child>
+            <child>
+              <object class="GtkLabel" id="comment_label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_Comment:</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">song_info_comment</property>
+              </object>
+              <packing>
+                <property name="top_attach">7</property>
+                <property name="bottom_attach">8</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <object class="GtkTextView" id="song_info_comment">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">7</property>
+                <property name="bottom_attach">8</property>
+              </packing>
+            </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
             <property name="position">0</property>
           </packing>
         </child>
diff --git a/rhythmdb/rhythmdb-private.h b/rhythmdb/rhythmdb-private.h
index 5a5b18d..650a392 100644
--- a/rhythmdb/rhythmdb-private.h
+++ b/rhythmdb/rhythmdb-private.h
@@ -77,6 +77,7 @@ struct RhythmDBEntry_ {
 	RBRefString *artist;
 	RBRefString *album;
 	RBRefString *genre;
+	RBRefString *comment;
 	RBRefString *musicbrainz_trackid;
 	RBRefString *musicbrainz_artistid;
 	RBRefString *musicbrainz_albumid;
diff --git a/rhythmdb/rhythmdb-tree.c b/rhythmdb/rhythmdb-tree.c
index e2a18c4..f8655f3 100644
--- a/rhythmdb/rhythmdb-tree.c
+++ b/rhythmdb/rhythmdb-tree.c
@@ -976,6 +976,9 @@ save_entry (RhythmDBTree *db,
 		case RHYTHMDB_PROP_GENRE:
 			save_entry_string(ctx, elt_name, rb_refstring_get (entry->genre));
 			break;
+		case RHYTHMDB_PROP_COMMENT:
+			save_entry_string(ctx, elt_name, rb_refstring_get (entry->comment));
+			break;
 		case RHYTHMDB_PROP_MUSICBRAINZ_TRACKID:
 			save_entry_string_if_set (ctx, elt_name, rb_refstring_get (entry->musicbrainz_trackid));
 			break;
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index 95aa4f7..72caf36 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -576,6 +576,9 @@ metadata_field_from_prop (RhythmDBPropType prop,
 	case RHYTHMDB_PROP_GENRE:
 		*field = RB_METADATA_FIELD_GENRE;
 		return TRUE;
+	case RHYTHMDB_PROP_COMMENT:
+		*field = RB_METADATA_FIELD_COMMENT;
+		return TRUE;
 	case RHYTHMDB_PROP_TRACK_NUMBER:
 		*field = RB_METADATA_FIELD_TRACK_NUMBER;
 		return TRUE;
@@ -1658,6 +1661,7 @@ rhythmdb_entry_allocate (RhythmDB *db,
 	ret->genre = rb_refstring_ref (db->priv->empty_string);
 	ret->artist = rb_refstring_ref (db->priv->empty_string);
 	ret->album = rb_refstring_ref (db->priv->empty_string);
+	ret->comment = rb_refstring_ref (db->priv->empty_string);
 	ret->musicbrainz_trackid = rb_refstring_ref (db->priv->empty_string);
 	ret->musicbrainz_artistid = rb_refstring_ref (db->priv->empty_string);
 	ret->musicbrainz_albumid = rb_refstring_ref (db->priv->empty_string);
@@ -1854,6 +1858,7 @@ rhythmdb_entry_finalize (RhythmDBEntry *entry)
 	rb_refstring_unref (entry->genre);
 	rb_refstring_unref (entry->artist);
 	rb_refstring_unref (entry->album);
+	rb_refstring_unref (entry->comment);
 	rb_refstring_unref (entry->musicbrainz_trackid);
 	rb_refstring_unref (entry->musicbrainz_artistid);
 	rb_refstring_unref (entry->musicbrainz_albumid);
@@ -2074,6 +2079,11 @@ set_props_from_metadata (RhythmDB *db,
 					  RHYTHMDB_PROP_ALBUM_SORTNAME,
 					  "");
 
+	/* comment */
+	set_metadata_string_with_default (db, metadata, entry,
+					  RB_METADATA_FIELD_COMMENT,
+					  RHYTHMDB_PROP_COMMENT,
+					  "");
 }
 
 static gboolean
@@ -3553,6 +3563,12 @@ rhythmdb_entry_set_internal (RhythmDB *db,
 			}
 			entry->genre = rb_refstring_new (g_value_get_string (value));
 			break;
+		case RHYTHMDB_PROP_COMMENT:
+			if (entry->comment != NULL) {
+				rb_refstring_unref (entry->comment);
+			}
+			entry->comment = rb_refstring_new (g_value_get_string (value));
+			break;
 		case RHYTHMDB_PROP_TRACK_NUMBER:
 			entry->tracknum = g_value_get_ulong (value);
 			break;
@@ -4412,6 +4428,7 @@ rhythmdb_prop_type_get_type (void)
 			ENUM_ENTRY (RHYTHMDB_PROP_GENRE, "Genre (gchararray) [genre]"),
 			ENUM_ENTRY (RHYTHMDB_PROP_ARTIST, "Artist (gchararray) [artist]"),
 			ENUM_ENTRY (RHYTHMDB_PROP_ALBUM, "Album (gchararray) [album]"),
+			ENUM_ENTRY (RHYTHMDB_PROP_COMMENT, "Comment (gchararray) [comment]"),
 			ENUM_ENTRY (RHYTHMDB_PROP_TRACK_NUMBER, "Track Number (gulong) [track-number]"),
 			ENUM_ENTRY (RHYTHMDB_PROP_DISC_NUMBER, "Disc Number (gulong) [disc-number]"),
 			ENUM_ENTRY (RHYTHMDB_PROP_MUSICBRAINZ_TRACKID, "Musicbrainz Track ID (gchararray) [mb-trackid]"),
@@ -5244,6 +5261,8 @@ rhythmdb_entry_get_string (RhythmDBEntry *entry,
 		return rb_refstring_get (entry->artist);
 	case RHYTHMDB_PROP_GENRE:
 		return rb_refstring_get (entry->genre);
+	case RHYTHMDB_PROP_COMMENT:
+		return rb_refstring_get (entry->comment);
 	case RHYTHMDB_PROP_MUSICBRAINZ_TRACKID:
 		return rb_refstring_get (entry->musicbrainz_trackid);
 	case RHYTHMDB_PROP_MUSICBRAINZ_ARTISTID:
@@ -5366,6 +5385,8 @@ rhythmdb_entry_get_refstring (RhythmDBEntry *entry,
 		return rb_refstring_ref (entry->artist);
 	case RHYTHMDB_PROP_GENRE:
 		return rb_refstring_ref (entry->genre);
+	case RHYTHMDB_PROP_COMMENT:
+		return rb_refstring_ref (entry->comment);
 	case RHYTHMDB_PROP_MUSICBRAINZ_TRACKID:
 		return rb_refstring_ref (entry->musicbrainz_trackid);
 	case RHYTHMDB_PROP_MUSICBRAINZ_ARTISTID:
diff --git a/rhythmdb/rhythmdb.h b/rhythmdb/rhythmdb.h
index d12657a..051ed39 100644
--- a/rhythmdb/rhythmdb.h
+++ b/rhythmdb/rhythmdb.h
@@ -156,6 +156,7 @@ typedef enum
 	RHYTHMDB_PROP_GENRE,
 	RHYTHMDB_PROP_ARTIST,
 	RHYTHMDB_PROP_ALBUM,
+	RHYTHMDB_PROP_COMMENT,
 	RHYTHMDB_PROP_TRACK_NUMBER,
 	RHYTHMDB_PROP_DISC_NUMBER,
 	RHYTHMDB_PROP_DURATION,
diff --git a/shell/rb-shell-preferences.c b/shell/rb-shell-preferences.c
index 5079864..f261c91 100644
--- a/shell/rb-shell-preferences.c
+++ b/shell/rb-shell-preferences.c
@@ -106,6 +106,7 @@ struct RBShellPreferencesPrivate
 	GtkWidget *artist_check;
 	GtkWidget *album_check;
 	GtkWidget *genre_check;
+	GtkWidget *comment_check;
 	GtkWidget *duration_check;
 	GtkWidget *track_check;
 	GtkWidget *rating_check;
@@ -216,6 +217,8 @@ rb_shell_preferences_init (RBShellPreferences *shell_preferences)
 		GTK_WIDGET (gtk_builder_get_object (builder, "album_check"));
 	shell_preferences->priv->genre_check =
 		GTK_WIDGET (gtk_builder_get_object (builder, "genre_check"));
+	shell_preferences->priv->comment_check =
+		GTK_WIDGET (gtk_builder_get_object (builder, "comment_check"));
 	shell_preferences->priv->duration_check =
 		GTK_WIDGET (gtk_builder_get_object (builder, "duration_check"));
 	shell_preferences->priv->track_check =
@@ -450,6 +453,8 @@ rb_shell_preferences_column_check_changed_cb (GtkCheckButton *butt,
 		colname = "RHYTHMDB_PROP_ALBUM";
 	else if (butt == GTK_CHECK_BUTTON (shell_preferences->priv->genre_check))
 		colname = "RHYTHMDB_PROP_GENRE";
+	else if (butt == GTK_CHECK_BUTTON (shell_preferences->priv->comment_check))
+		colname = "RHYTHMDB_PROP_COMMENT";
 	else if (butt == GTK_CHECK_BUTTON (shell_preferences->priv->duration_check))
 		colname = "RHYTHMDB_PROP_DURATION";
 	else if (butt == GTK_CHECK_BUTTON (shell_preferences->priv->track_check))
@@ -537,6 +542,9 @@ rb_shell_preferences_sync (RBShellPreferences *shell_preferences)
 			       				 shell_preferences->priv->genre_check,
 							 columns, "RHYTHMDB_PROP_GENRE");
 		rb_shell_preferences_sync_column_button (shell_preferences,
+							 shell_preferences->priv->comment_check,
+							 columns, "RHYTHMDB_PROP_COMMENT");
+		rb_shell_preferences_sync_column_button (shell_preferences,
 			       				 shell_preferences->priv->duration_check,
 							 columns, "RHYTHMDB_PROP_DURATION");
 		rb_shell_preferences_sync_column_button (shell_preferences,
diff --git a/sources/rb-browser-source.c b/sources/rb-browser-source.c
index 6c97de1..2cf612d 100644
--- a/sources/rb-browser-source.c
+++ b/sources/rb-browser-source.c
@@ -408,6 +408,7 @@ rb_browser_source_constructed (GObject *object)
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_DURATION, FALSE);
  	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_QUALITY, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);
+	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_COMMENT, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_LOCATION, FALSE);
 
 	g_signal_connect_object (G_OBJECT (source->priv->songs), "show_popup",
diff --git a/sources/rb-playlist-source.c b/sources/rb-playlist-source.c
index 82d0df4..8c59044 100644
--- a/sources/rb-playlist-source.c
+++ b/sources/rb-playlist-source.c
@@ -370,6 +370,7 @@ rb_playlist_source_constructed (GObject *object)
  	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_QUALITY, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_RATING, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);
+	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_COMMENT, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_LOCATION, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_LAST_PLAYED, FALSE);
 	rb_entry_view_append_column (source->priv->songs, RB_ENTRY_VIEW_COL_FIRST_SEEN, FALSE);
diff --git a/widgets/rb-entry-view.c b/widgets/rb-entry-view.c
index aee8d3a..dabbe59 100644
--- a/widgets/rb-entry-view.c
+++ b/widgets/rb-entry-view.c
@@ -1348,6 +1348,9 @@ rb_entry_view_get_column (RBEntryView *view, RBEntryViewColumn coltype)
 	case RB_ENTRY_VIEW_COL_GENRE:
 		propid = RHYTHMDB_PROP_GENRE;
 		break;
+	case RB_ENTRY_VIEW_COL_COMMENT:
+		propid = RHYTHMDB_PROP_COMMENT;
+		break;
 	case RB_ENTRY_VIEW_COL_DURATION:
 		propid = RHYTHMDB_PROP_DURATION;
 		break;
@@ -1406,6 +1409,7 @@ rb_entry_view_cell_edited_cb (GtkCellRendererText *renderer,
 	case RHYTHMDB_PROP_GENRE:
 	case RHYTHMDB_PROP_ARTIST:
 	case RHYTHMDB_PROP_ALBUM:
+	case RHYTHMDB_PROP_COMMENT:
 	case RHYTHMDB_PROP_ARTIST_SORTNAME:
 	case RHYTHMDB_PROP_ALBUM_SORTNAME:
 		break;
@@ -1520,6 +1524,16 @@ rb_entry_view_append_column (RBEntryView *view,
 		key = "Genre";
 		ellipsize = TRUE;
 		break;
+	case RB_ENTRY_VIEW_COL_COMMENT:
+		propid = RHYTHMDB_PROP_COMMENT;
+		cell_data->propid = propid;
+		cell_data_func = (GtkTreeCellDataFunc) rb_entry_view_string_cell_data_func;
+		sort_propid = cell_data->propid;
+		sort_func = (GCompareDataFunc) rhythmdb_query_model_string_sort_func;
+		title = _("Comment");
+		key = "Comment";
+		ellipsize = TRUE;
+		break;
 	case RB_ENTRY_VIEW_COL_DURATION:
 		propid = RHYTHMDB_PROP_DURATION;
 		cell_data->propid = propid;
@@ -1663,6 +1677,7 @@ rb_entry_view_append_column (RBEntryView *view,
 		g_signal_connect_object (renderer, "edited",
 					 G_CALLBACK (rb_entry_view_cell_edited_cb),
 					 view, 0);
+		g_object_set (renderer, "single-paragraph-mode", TRUE, NULL);
 	} else {
 		g_free (cell_data);
 	}
@@ -2667,6 +2682,7 @@ rb_entry_view_column_get_type (void)
 			ENUM_ENTRY (RB_ENTRY_VIEW_COL_ARTIST, "Artist"),
 			ENUM_ENTRY (RB_ENTRY_VIEW_COL_ALBUM, "Album"),
 			ENUM_ENTRY (RB_ENTRY_VIEW_COL_GENRE, "Genre"),
+			ENUM_ENTRY (RB_ENTRY_VIEW_COL_COMMENT, "Comment"),
 			ENUM_ENTRY (RB_ENTRY_VIEW_COL_DURATION, "Duration"),
 			ENUM_ENTRY (RB_ENTRY_VIEW_COL_QUALITY, "Quality"),
 			ENUM_ENTRY (RB_ENTRY_VIEW_COL_RATING, "Rating"),
diff --git a/widgets/rb-entry-view.h b/widgets/rb-entry-view.h
index cd6a2ce..03f5fa6 100644
--- a/widgets/rb-entry-view.h
+++ b/widgets/rb-entry-view.h
@@ -49,6 +49,7 @@ typedef enum {
 	RB_ENTRY_VIEW_COL_ARTIST,
 	RB_ENTRY_VIEW_COL_ALBUM,
 	RB_ENTRY_VIEW_COL_GENRE,
+	RB_ENTRY_VIEW_COL_COMMENT,
 	RB_ENTRY_VIEW_COL_DURATION,
 	RB_ENTRY_VIEW_COL_QUALITY,
 	RB_ENTRY_VIEW_COL_RATING,
diff --git a/widgets/rb-query-creator-properties.c b/widgets/rb-query-creator-properties.c
index 95b8e03..3ad4f84 100644
--- a/widgets/rb-query-creator-properties.c
+++ b/widgets/rb-query-creator-properties.c
@@ -77,6 +77,7 @@ const RBQueryCreatorPropertyOption property_options[] =
 	{ NC_("query-criteria", "Year"), RHYTHMDB_PROP_DATE, RHYTHMDB_PROP_DATE, &year_property_type },
 	{ NC_("query-criteria", "Rating"), RHYTHMDB_PROP_RATING, RHYTHMDB_PROP_RATING, &rating_property_type },
 	{ NC_("query-criteria", "Path"), RHYTHMDB_PROP_LOCATION, RHYTHMDB_PROP_LOCATION, &escaped_string_property_type },
+	{ NC_("query-criteria", "Comment"), RHYTHMDB_PROP_COMMENT, RHYTHMDB_PROP_COMMENT, &string_property_type },
 
 	{ NC_("query-criteria", "Play Count"), RHYTHMDB_PROP_PLAY_COUNT, RHYTHMDB_PROP_PLAY_COUNT, &integer_property_type },
 	{ NC_("query-criteria", "Track Number"), RHYTHMDB_PROP_TRACK_NUMBER, RHYTHMDB_PROP_TRACK_NUMBER, &integer_property_type },
@@ -108,6 +109,7 @@ const RBQueryCreatorSortOption sort_options[] =
 	{ NC_("query-sort", "Track Number"), "Track", N_("_In decreasing order")},
 	{ NC_("query-sort", "Last Played"), "LastPlayed", N_("W_ith more recently played tracks first") },
 	{ NC_("query-sort", "Date Added"), "FirstSeen", N_("W_ith more recently added tracks first") },
+	{ NC_("query-sort", "Comment"), "Comment", N_("_In reverse alphabetical order") },
 };
 
 const int num_sort_options = G_N_ELEMENTS (sort_options);
diff --git a/widgets/rb-song-info.c b/widgets/rb-song-info.c
index e68a595..e0859e4 100644
--- a/widgets/rb-song-info.c
+++ b/widgets/rb-song-info.c
@@ -130,6 +130,8 @@ struct RBSongInfoPrivate
 	GtkWidget   *track_cur;
 	GtkWidget   *disc_cur;
 	GtkWidget   *year;
+	GtkWidget   *comment;
+	GtkTextBuffer *comment_buffer;
 	GtkWidget   *playback_error_box;
 	GtkWidget   *playback_error_label;
 
@@ -489,6 +491,8 @@ rb_song_info_constructed (GObject *object)
 	song_info->priv->album = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_album"));
 	song_info->priv->genre = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_genre"));
 	song_info->priv->year = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_year"));
+	song_info->priv->comment = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_comment"));
+	song_info->priv->comment_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (song_info->priv->comment));
 	song_info->priv->playback_error_box = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_error_box"));
 	song_info->priv->playback_error_label = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_error_label"));
 	song_info->priv->disc_cur = GTK_WIDGET (gtk_builder_get_object (builder, "song_info_disc_cur"));
@@ -504,6 +508,7 @@ rb_song_info_constructed (GObject *object)
 	rb_builder_boldify_label (builder, "artist_label");
 	rb_builder_boldify_label (builder, "genre_label");
 	rb_builder_boldify_label (builder, "year_label");
+	rb_builder_boldify_label (builder, "comment_label");
 	rb_builder_boldify_label (builder, "rating_label");
 	rb_builder_boldify_label (builder, "discn_label");
 	rb_builder_boldify_label (builder, "artist_sortname_label");
@@ -525,6 +530,10 @@ rb_song_info_constructed (GObject *object)
 				 "mnemonic-activate",
 				 G_CALLBACK (rb_song_info_mnemonic_cb),
 				 NULL, 0);
+	g_signal_connect_object (G_OBJECT (song_info->priv->comment),
+				 "mnemonic-activate",
+				 G_CALLBACK (rb_song_info_mnemonic_cb),
+				 NULL, 0);
 	g_signal_connect_object (G_OBJECT (song_info->priv->disc_cur),
 				 "mnemonic-activate",
 				 G_CALLBACK (rb_song_info_mnemonic_cb),
@@ -558,6 +567,7 @@ rb_song_info_constructed (GObject *object)
 	gtk_editable_set_editable (GTK_EDITABLE (song_info->priv->album), editable);
 	gtk_editable_set_editable (GTK_EDITABLE (song_info->priv->genre), editable);
 	gtk_editable_set_editable (GTK_EDITABLE (song_info->priv->year), editable);
+	gtk_text_view_set_editable (GTK_TEXT_VIEW (song_info->priv->comment), editable);
 	gtk_editable_set_editable (GTK_EDITABLE (song_info->priv->disc_cur), editable);
 
 	/* Finish construction */
@@ -1035,6 +1045,9 @@ rb_song_info_populate_dialog (RBSongInfo *song_info)
 	num = rhythmdb_entry_get_ulong (song_info->priv->current_entry, RHYTHMDB_PROP_DISC_NUMBER);
 	rb_song_info_populate_num_field (GTK_ENTRY (song_info->priv->disc_cur), num);
 
+	text = rhythmdb_entry_get_string (song_info->priv->current_entry, RHYTHMDB_PROP_COMMENT);
+	gtk_text_buffer_set_text (song_info->priv->comment_buffer, text, -1);
+
 	rb_song_info_update_duration (song_info);
 	rb_song_info_update_location (song_info);
 	rb_song_info_update_filesize (song_info);
@@ -1615,6 +1628,7 @@ rb_song_info_sync_entry_single (RBSongInfo *dialog)
 	const char *artist_sortname;
 	const char *album_sortname;
 	const char *entry_string;
+	char *comment = NULL;
 	char *endptr;
 	GType type;
 	gulong tracknum;
@@ -1624,6 +1638,7 @@ rb_song_info_sync_entry_single (RBSongInfo *dialog)
 	GValue val = {0,};
 	gboolean changed = FALSE;
 	RhythmDBEntry *entry = dialog->priv->current_entry;
+	GtkTextIter start, end;
 
 	title = gtk_entry_get_text (GTK_ENTRY (dialog->priv->title));
 	genre = gtk_entry_get_text (GTK_ENTRY (dialog->priv->genre));
@@ -1635,6 +1650,10 @@ rb_song_info_sync_entry_single (RBSongInfo *dialog)
 	artist_sortname = gtk_entry_get_text (GTK_ENTRY (dialog->priv->artist_sortname));
 	album_sortname = gtk_entry_get_text (GTK_ENTRY (dialog->priv->album_sortname));
 
+	/* Get comment text (string is allocated) */
+	gtk_text_buffer_get_bounds (dialog->priv->comment_buffer, &start, &end);
+	comment = gtk_text_buffer_get_text (dialog->priv->comment_buffer, &start, &end, FALSE);
+
 	g_signal_emit (dialog, rb_song_info_signals[PRE_METADATA_CHANGE], 0,
 		       entry);
 
@@ -1765,6 +1784,18 @@ rb_song_info_sync_entry_single (RBSongInfo *dialog)
 		changed = TRUE;
 	}
 
+	entry_string = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_COMMENT);
+	if (strcmp (comment, entry_string)) {
+		type = rhythmdb_get_property_type (dialog->priv->db,
+						   RHYTHMDB_PROP_COMMENT);
+		g_value_init (&val, type);
+		g_value_set_string (&val, comment);
+		rhythmdb_entry_set (dialog->priv->db, entry,
+				    RHYTHMDB_PROP_COMMENT, &val);
+		g_value_unset (&val);
+		changed = TRUE;
+	}
+
 	/* FIXME: when an entry is SYNCed, a changed signal is emitted, and
 	 * this signal is also emitted, aren't they redundant?
 	 */
@@ -1773,6 +1804,8 @@ rb_song_info_sync_entry_single (RBSongInfo *dialog)
 
 	if (changed)
 		rhythmdb_commit (dialog->priv->db);
+
+	g_free (comment);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]