[Banshee-List] Genre Support



Hello,

As requested, here is the Genre Support patch in unified format and made against 0.10.6; No browser, and no crazy
performance work (You should have see how the code looked when i was experimenting with cached models ... ), I will now
move my normalized patch and try to get as complete as possible.

regards,

Oscar.



? burn-sharp/.deps
? burn-sharp/.libs
? burn-sharp/glue.lo
? burn-sharp/libnautilusburnglue.la
? libbanshee/.deps
? libbanshee/.libs
? libbanshee/gst-cd-rip-0.8.lo
? libbanshee/gst-misc-0.8.lo
? libbanshee/gst-playback-0.8.lo
? libbanshee/gst-transcode-0.8.lo
? libbanshee/hal-context.lo
? libbanshee/inotify-glue.lo
? libbanshee/libbanshee.la
? libbanshee/xing/.deps
? po/.intltool-merge-cache
? src/.PlayerInterface.cs.swp
Index: data/banshee.glade
===================================================================
RCS file: /cvs/gnome/banshee/data/banshee.glade,v
retrieving revision 1.6
diff -u -r1.6 banshee.glade
--- data/banshee.glade	14 Jan 2006 09:11:02 -0000	1.6
+++ data/banshee.glade	14 Feb 2006 07:51:48 -0000
@@ -17,7 +17,6 @@
   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
   <signal name="delete_event" handler="OnWindowPlayerDeleteEvent" last_modification_time="Sat, 29 Jan 2005 07:50:08 GMT"/>
 
   <child>
@@ -481,7 +480,6 @@
   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
 
   <child>
     <widget class="GtkVBox" id="vbox1">
@@ -839,7 +837,7 @@
 	      <child>
 		<widget class="GtkTable" id="table1">
 		  <property name="visible">True</property>
-		  <property name="n_rows">3</property>
+		  <property name="n_rows">4</property>
 		  <property name="n_columns">2</property>
 		  <property name="homogeneous">False</property>
 		  <property name="row_spacing">8</property>
@@ -1111,6 +1109,91 @@
 		      <property name="y_options">fill</property>
 		    </packing>
 		  </child>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox15">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">5</property>
+
+		      <child>
+			<widget class="GtkButton" id="GenreSync">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+
+			  <child>
+			    <widget class="GtkImage" id="image9">
+			      <property name="visible">True</property>
+			      <property name="stock">gtk-copy</property>
+			      <property name="icon_size">1</property>
+			      <property name="xalign">0.5</property>
+			      <property name="yalign">0.5</property>
+			      <property name="xpad">0</property>
+			      <property name="ypad">0</property>
+			    </widget>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkLabel" id="label63">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">_Genre</property>
+			  <property name="use_underline">True</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="mnemonic_widget">Title</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">3</property>
+		      <property name="bottom_attach">4</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options">fill</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkComboBoxEntry" id="Genre">
+		      <property name="visible">True</property>
+		      <property name="add_tearoffs">False</property>
+		      <property name="has_frame">True</property>
+		      <property name="focus_on_click">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">3</property>
+		      <property name="bottom_attach">4</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options">fill</property>
+		    </packing>
+		  </child>
 		</widget>
 		<packing>
 		  <property name="padding">0</property>
@@ -1414,7 +1497,7 @@
 	<widget class="GtkExpander" id="AdvancedExpander">
 	  <property name="visible">True</property>
 	  <property name="can_focus">True</property>
-	  <property name="expanded">False</property>
+	  <property name="expanded">True</property>
 	  <property name="spacing">0</property>
 
 	  <child>
@@ -1933,7 +2016,6 @@
   <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
 
   <child>
     <widget class="GtkVBox" id="vbox9">
@@ -2231,7 +2313,6 @@
   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
 
   <child>
     <widget class="GtkVBox" id="vbox4">
Index: src/PlayerInterface.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v
retrieving revision 1.147
diff -u -r1.147 PlayerInterface.cs
--- src/PlayerInterface.cs	13 Feb 2006 08:21:33 -0000	1.147
+++ src/PlayerInterface.cs	14 Feb 2006 07:51:49 -0000
@@ -421,6 +421,7 @@
             fields.Add(Catalog.GetString("Song Name"));
             fields.Add(Catalog.GetString("Artist Name"));
             fields.Add(Catalog.GetString("Album Title"));
+            fields.Add(Catalog.GetString("Genre"));
             
             searchEntry = new SearchEntry(fields);
             searchEntry.EnterPress += delegate(object o, EventArgs args) {
@@ -1488,11 +1489,14 @@
                 match = ti.Title;
             } else if(field == Catalog.GetString("Album Title")) {
                 match = ti.Album;
+            } else if(field == Catalog.GetString("Genre")) {
+                match = ti.Genre;
             } else {
                 string [] matches = {
                     ti.Artist,
                     ti.Album,
-                    ti.Title
+                    ti.Title,
+					ti.Genre
                 };
 
                 foreach(string m in matches) {
Index: src/PlaylistView.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlaylistView.cs,v
retrieving revision 1.39
diff -u -r1.39 PlaylistView.cs
--- src/PlaylistView.cs	8 Feb 2006 07:39:25 -0000	1.39
+++ src/PlaylistView.cs	14 Feb 2006 07:51:49 -0000
@@ -55,6 +55,7 @@
             Track,
             Artist,
             Title,
+			Genre,
             Album,
             Time,
             Rating,
@@ -89,31 +90,34 @@
             columns.Add(new PlaylistColumn(this, Catalog.GetString("Title"), "Title", 
                 new TreeCellDataFunc(TrackCellTitle), new CellRendererText(),
                 2, (int)ColumnId.Title));
+            columns.Add(new PlaylistColumn(this, Catalog.GetString("Genre"), "Genre",
+                new TreeCellDataFunc(TrackCellGenre), new CellRendererText(),
+                3, (int)ColumnId.Genre));
             columns.Add(new PlaylistColumn(this, Catalog.GetString("Album"), "Album", 
                 new TreeCellDataFunc(TrackCellAlbum), new CellRendererText(),
-                3, (int)ColumnId.Album));
+                4, (int)ColumnId.Album));
             columns.Add(new PlaylistColumn(this, Catalog.GetString("Time"), "Time", 
                 new TreeCellDataFunc(TrackCellTime), new CellRendererText(),
-                4, (int)ColumnId.Time));
+                5, (int)ColumnId.Time));
             
             RatingColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Rating"), "Rating",
                 new TreeCellDataFunc(TrackCellRating), new RatingRenderer(),
-                5, (int)ColumnId.Rating);
+                6, (int)ColumnId.Rating);
             columns.Add(RatingColumn);
             
             PlaysColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Plays"), "Plays",
                 new TreeCellDataFunc(TrackCellPlayCount), 
                 new CellRendererText(),
-                6, (int)ColumnId.PlayCount);
+                7, (int)ColumnId.PlayCount);
             columns.Add(PlaysColumn);
             
             LastPlayedColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Last Played"), "Last-Played",
                 new TreeCellDataFunc(TrackCellLastPlayed), 
                 new CellRendererText(),
-                7, (int)ColumnId.LastPlayed);
+                8, (int)ColumnId.LastPlayed);
             columns.Add(LastPlayedColumn);
             
             foreach(PlaylistColumn plcol in columns) {
@@ -175,6 +179,8 @@
                 new TreeIterCompareFunc(ArtistTreeIterCompareFunc));
             model.SetSortFunc((int)ColumnId.Title, 
                 new TreeIterCompareFunc(TitleTreeIterCompareFunc));
+            model.SetSortFunc((int)ColumnId.Genre,
+                new TreeIterCompareFunc(GenreTreeIterCompareFunc));
             model.SetSortFunc((int)ColumnId.Album, 
                 new TreeIterCompareFunc(AlbumTreeIterCompareFunc));
             model.SetSortFunc((int)ColumnId.Time, 
@@ -243,6 +249,13 @@
                 model.IterTrackInfo(b).Title);
         }
         
+        public int GenreTreeIterCompareFunc(TreeModel _model, TreeIter a, 
+            TreeIter b)
+        {
+            return StringFieldCompare(model.IterTrackInfo(a).Genre, 
+                model.IterTrackInfo(b).Genre);
+        }
+        
         public int AlbumTreeIterCompareFunc(TreeModel _model, TreeIter a, 
             TreeIter b)
         {
@@ -393,7 +406,18 @@
             SetRendererAttributes((CellRendererText)cell, ti.Title, iter);
         }
         
-        protected void TrackCellAlbum(TreeViewColumn tree_column,
+        protected void TrackCellGenre(TreeViewColumn tree_column,
+            CellRenderer cell, TreeModel tree_model, TreeIter iter)
+        {
+            TrackInfo ti = model.IterTrackInfo(iter);
+            if(ti == null) {
+                return;
+            }
+            
+            SetRendererAttributes((CellRendererText)cell, ti.Genre, iter);
+        }
+        
+		protected void TrackCellAlbum(TreeViewColumn tree_column,
             CellRenderer cell, TreeModel tree_model, TreeIter iter)
         {
             TrackInfo ti = model.IterTrackInfo(iter);
Index: src/TrackProperties.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/TrackProperties.cs,v
retrieving revision 1.21
diff -u -r1.21 TrackProperties.cs
--- src/TrackProperties.cs	14 Jan 2006 20:27:11 -0000	1.21
+++ src/TrackProperties.cs	14 Feb 2006 07:51:49 -0000
@@ -44,6 +44,7 @@
         public string Artist;
         public string Album;
         public string Title;
+		public string Genre;
         public Uri Uri;
     
         public uint TrackNumber;
@@ -60,6 +61,7 @@
             Artist = track.Artist;
             Album = track.Album;
             Title = track.Title;
+			Genre = track.Genre;
             TrackNumber = track.TrackNumber;
             TrackCount = track.TrackCount;
             Uri = track.Uri;
@@ -70,6 +72,7 @@
             track.Artist = Artist;
             track.Album = Album;
             track.Title = Title;
+			track.Genre = Genre;
             track.TrackNumber = TrackNumber;
             track.TrackCount = TrackCount;
             track.Uri = Uri;
@@ -97,11 +100,14 @@
         [Widget] private Button AlbumSync;
         [Widget] private Button TitleSync;
         [Widget] private Label TitleLabel;
+        [Widget] private Button GenreSync;
+        [Widget] private Label GenreLabel;
         [Widget] private SpinButton TrackCount;
         [Widget] private SpinButton TrackNumber;
         [Widget] private Entry Artist;
         [Widget] private Entry Album;
         [Widget] private Entry Title;
+        [Widget] private ComboBoxEntry Genre;
         [Widget] private Container EditorContainer;
         [Widget] private Expander AdvancedExpander;
         [Widget] private Label Uri;
@@ -149,12 +155,27 @@
             ArtistSync.Clicked += OnArtistSyncClicked;
             AlbumSync.Clicked += OnAlbumSyncClicked;
             TitleSync.Clicked += OnTitleSyncClicked;
+            GenreSync.Clicked += OnGenreSyncClicked;
             
             Artist.Changed += OnValueEdited;
             Album.Changed += OnValueEdited;
             Title.Changed += OnValueEdited;
-                
-            Next.Visible = TrackSet.Count > 1;
+			Genre.Entry.Changed += OnValueEdited;
+			ListStore genre_model = new ListStore(typeof(string));
+			//genre_model.SetValue("Blues");
+			//CellRendererText text = new CellRendererText ();
+			//text.Xalign=0;
+			//Genre.PackStart (text, true);
+			//Genre.AddAttribute(text, "Entry.Text", 0);
+			Genre.Model = genre_model;
+			Genre.TextColumn = 0;
+            
+			foreach(string genre in Globals.Library.GetGenreList()) {
+				genre_model.AppendValues(genre);
+            	//genre_model.SetValue(genre_model.Append(), 0, "item " + i);			
+			}
+            
+			Next.Visible = TrackSet.Count > 1;
             Previous.Visible = TrackSet.Count > 1;
                 
             glade["MultiTrackHeader"].Visible = TrackSet.Count > 1;
@@ -164,6 +185,7 @@
             ArtistSync.Visible = TrackSet.Count > 1;
             AlbumSync.Visible = TrackSet.Count > 1;
             TitleSync.Visible = TrackSet.Count > 1;
+            GenreSync.Visible = TrackSet.Count > 1;
             
             tips.SetTip(TrackNumberSync, Catalog.GetString("Set all Track Numbers to this value"), "track numbers");
             tips.SetTip(TrackNumberIterator, Catalog.GetString("Automatically Set All Track Numbers"), "track iterator");
@@ -171,6 +193,7 @@
             tips.SetTip(ArtistSync, Catalog.GetString("Set all Artists to this value"), "artists");
             tips.SetTip(AlbumSync, Catalog.GetString("Set all Albums to this value"), "albums");
             tips.SetTip(TitleSync, Catalog.GetString("Set all Titles to this value"), "titles");
+            tips.SetTip(GenreSync, Catalog.GetString("Set all Genres to this value"), "genres");
                 
             LoadTrack(0);
             
@@ -208,6 +231,7 @@
             (glade["Artist"] as Entry).Text = track.Artist;
             (glade["Album"] as Entry).Text = track.Album;
             (glade["Title"] as Entry).Text = track.Title;
+            (glade["Genre"] as ComboBoxEntry).Entry.Text = track.Genre;
             
             (glade["DurationLabel"] as Label).Markup = PrepareStatistic(String.Format("{0}:{1}", 
                 track.Track.Duration.Minutes, (track.Track.Duration.Seconds).ToString("00")));
@@ -321,6 +345,13 @@
             }
         }
         
+        private void OnGenreSyncClicked(object o, EventArgs args)
+        {
+            foreach(EditorTrack track in TrackSet) {
+                track.Genre = Genre.Entry.Text;
+            }
+        }
+        
         private EditorTrack UpdateCurrent()
         {
             if(currentIndex < 0 || currentIndex >= TrackSet.Count) {
@@ -334,6 +365,7 @@
             track.Artist = Artist.Text;
             track.Album = Album.Text;
             track.Title = Title.Text;
+			track.Genre = Genre.Entry.Text;
             
             return track;
         }
Index: src/Banshee.Base/Library.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/Banshee.Base/Library.cs,v
retrieving revision 1.6
diff -u -r1.6 Library.cs
--- src/Banshee.Base/Library.cs	24 Jan 2006 04:38:53 -0000	1.6
+++ src/Banshee.Base/Library.cs	14 Feb 2006 07:51:49 -0000
@@ -105,6 +105,16 @@
             ThreadAssist.Spawn(ReloadLibraryThread);
         }
         
+		public ArrayList GetGenreList() 
+		{
+			ArrayList genres = new ArrayList();
+            IDataReader reader = Db.Query("SELECT DISTINCT Genre FROM Tracks Order by Genre");
+            while(reader.Read()) {
+				genres.Add(reader["Genre"] as string);
+			}
+			return genres;
+		}
+
         private void ReloadLibraryThread()
         {
             Tracks.Clear();


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