On Mon, May 09, 2005 at 11:03:11PM +0200, Oliver Lemke wrote:
> Hi all,
> 
> The subject is mostly speaking for itself. In patch 76 of the merge
> branch the artist is displayed below the album name in the browser
> view. 

The attached patch adds a couple of things I thought of:
 - if more than one artist name is found for an album, display "various
   artists" rather than whichever one happened to come first
 - display the number of songs in the album (if we're going to add a
   second line to the album display, why not?)

thanks,
-jonathan


* looking for [EMAIL PROTECTED]/rhythmbox--merge--0.9--patch-76 to compare with
* comparing to [EMAIL PROTECTED]/rhythmbox--merge--0.9--patch-76
M  rhythmdb/rhythmdb-property-model.h
M  rhythmdb/rhythmdb-property-model.c
M  widgets/rb-property-view.c

* modified files

--- orig/rhythmdb/rhythmdb-property-model.c
+++ mod/rhythmdb/rhythmdb-property-model.c
@@ -110,6 +110,8 @@
        RhythmDBPropType sort_propid;
        gboolean use_nat_sort;
 
+       gchar *various_artists;
+
        guint stamp;
 
        GPtrArray *query;
@@ -360,6 +362,8 @@
        model->priv->all->name = g_strdup (_("All"));
        model->priv->all->sort_key = NULL;
        model->priv->all->artist = NULL;
+
+       model->priv->various_artists = _("Various Artists");
 }
 
 static void
@@ -384,7 +388,8 @@
                RhythmDBPropertyModelEntry *prop = g_sequence_ptr_get_data 
(ptr);
                g_free (prop->name);
                g_free (prop->sort_key);
-               g_free (prop->artist);
+               if (prop->artist != model->priv->various_artists)
+                       g_free (prop->artist);
        }
 
        g_mem_chunk_destroy (model->priv->property_memchunk);
@@ -486,9 +491,22 @@
        GSequencePtr ptr;
        GCompareDataFunc compare;
 
+       iter.stamp = model->priv->stamp;
+
        if ((ptr = g_hash_table_lookup (model->priv->reverse_map, propstr))) {
                prop = g_sequence_ptr_get_data (ptr);
                prop->refcount++;
+
+               /* if we have multiple artists for the same album, just say 
"Various Artists" */
+               if (strcmp (prop->artist, artist) != 0) {
+                       g_free (prop->artist);
+                       prop->artist = model->priv->various_artists;
+               }
+
+               iter.user_data = ptr;
+               path = rhythmdb_property_model_get_path (GTK_TREE_MODEL 
(model), &iter);
+               gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, 
&iter);
+               gtk_tree_path_free (path);
                return;
        }
 
@@ -498,7 +516,6 @@
        prop->artist = g_strdup (artist);
        prop->refcount = 1;
 
-       iter.stamp = model->priv->stamp;
        compare = (GCompareDataFunc) (model->priv->use_nat_sort ?
                rhythmdb_property_model_compare_nat : 
rhythmdb_property_model_compare);
        ptr = g_sequence_insert_sorted (model->priv->properties, prop,
@@ -534,16 +551,19 @@
 
        g_assert ((ptr = g_hash_table_lookup (model->priv->reverse_map, 
propstr)));
 
+       iter.stamp = model->priv->stamp;
+       iter.user_data = ptr;
+       path = rhythmdb_property_model_get_path (GTK_TREE_MODEL (model), &iter);
        prop = g_sequence_ptr_get_data (ptr);
+
        rb_debug ("deleting \"%s\": refcount: %d", propstr, prop->refcount);
        prop->refcount--;
-       if (prop->refcount > 0)
+       if (prop->refcount > 0) {
+               gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, 
&iter);
+               gtk_tree_path_free (path);
                return;
+       }
 
-       iter.stamp = model->priv->stamp;
-       iter.user_data = ptr;
-
-       path = rhythmdb_property_model_get_path (GTK_TREE_MODEL (model), &iter);
        g_signal_emit (G_OBJECT (model), 
rhythmdb_property_model_signals[PRE_ROW_DELETION], 0);
        gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
        gtk_tree_path_free (path);
@@ -551,7 +571,8 @@
        g_hash_table_remove (model->priv->reverse_map, prop->name);
        g_free (prop->name);
        g_free (prop->sort_key);
-       g_free (prop->artist);
+       if (prop->artist != model->priv->various_artists)
+               g_free (prop->artist);
        g_mem_chunk_free (model->priv->property_memchunk, prop);
        return;
 }
@@ -596,6 +617,8 @@
                return G_TYPE_BOOLEAN;
        case 2:
                return G_TYPE_STRING;
+       case 4:
+               return G_TYPE_INT;
        default:
                g_assert_not_reached ();
                return G_TYPE_INVALID;
@@ -682,6 +705,10 @@
                        g_value_init (value, GDK_TYPE_PIXBUF);
                        g_value_set_object (value, NULL);
                        break;
+               case 4:
+                       g_value_init (value, G_TYPE_INT);
+                       g_value_set_int (value, 0);
+                       break;
                default:
                        g_assert_not_reached ();
                }
@@ -717,6 +744,10 @@
                        g_value_set_object (value, cover);
                        g_object_unref (G_OBJECT (cover));
                        break;
+               case 4:
+                       g_value_init (value, G_TYPE_INT);
+                       g_value_set_int (value, prop->refcount);
+                       break;
                default:
                        g_assert_not_reached ();
                }


--- orig/rhythmdb/rhythmdb-property-model.h
+++ mod/rhythmdb/rhythmdb-property-model.h
@@ -43,6 +43,8 @@
        RHYTHMDB_PROPERTY_MODEL_COLUMN_TITLE,
        RHYTHMDB_PROPERTY_MODEL_COLUMN_PRIORITY,
        RHYTHMDB_PROPERTY_MODEL_COLUMN_ARTIST,
+       RHYTHMDB_PROPERTY_MODEL_COLUMN_PIXBUF,
+       RHYTHMDB_PROPERTY_MODEL_COLUMN_COUNT,
        RHYTHMDB_PROPERTY_MODEL_COLUMN_LAST,
 } RhythmDBPropertyModelColumn;
 


--- orig/widgets/rb-property-view.c
+++ mod/widgets/rb-property-view.c
@@ -503,18 +503,21 @@
        if (view->priv->propid == RHYTHMDB_PROP_ALBUM)
        {
                char *name, *artist;
+               int songs;
 
                gtk_tree_model_get (GTK_TREE_MODEL (tree_model), iter,
-                                   0, &name, 1, &bold, 2, &artist, -1);
+                                   0, &name, 1, &bold, 2, &artist, 4, &songs, 
-1);
 
                if (!bold)
                {
                        char *markup;
-                       markup = g_markup_printf_escaped ("%s\n<span 
size=\"smaller\">%s <u>%s</u></span>",
-                                                         name, _("by"), 
artist);
+                       char *songs_text = g_strdup_printf (ngettext ("%d 
song", "%d songs", songs), songs);
+                       markup = g_markup_printf_escaped ("%s\n<span 
size=\"smaller\">%s <u>%s</u> (%s)</span>",
+                                                         name, _("by"), 
artist, songs_text);
                        g_object_set (G_OBJECT (renderer), "markup", markup,
                                      "weight", PANGO_WEIGHT_NORMAL, NULL);
                        g_free (markup);
+                       g_free (songs_text);
                }
                else
                {



_______________________________________________
rhythmbox-devel mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/rhythmbox-devel

Reply via email to