[Banshee-List] Changing the Entry for a ComboBox for the Genre in the TrakInfo Editor



Hello Aaron,

I change the Genre Entry for a ComboBoxEntry and fetched the existing Genres of the Database, I do not know if you will
have anther idea from where to get the Genres list.

regards,

Oscar.
? aclocal.m4
? autom4te.cache
? config.guess
? config.sub
? configure
? intltool-extract.in
? intltool-merge.in
? intltool-update.in
? ltmain.sh
? mkinstalldirs
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	30 Jan 2006 16:57:00 -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.134
diff -u -r1.134 PlayerInterface.cs
--- src/PlayerInterface.cs	17 Jan 2006 16:51:14 -0000	1.134
+++ src/PlayerInterface.cs	30 Jan 2006 16:57:01 -0000
@@ -438,6 +438,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) {
@@ -1536,11 +1537,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.37
diff -u -r1.37 PlaylistView.cs
--- src/PlaylistView.cs	17 Jan 2006 16:51:14 -0000	1.37
+++ src/PlaylistView.cs	30 Jan 2006 16:57:01 -0000
@@ -55,6 +55,7 @@
             Track,
             Artist,
             Title,
+			Genre,
             Album,
             Time,
             Rating,
@@ -89,17 +90,20 @@
             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));
             
-            PlaylistColumn _RatingColumn = new PlaylistColumn(this, 
+			PlaylistColumn _RatingColumn = new PlaylistColumn(this, 
                 Catalog.GetString("Rating"), "Rating",
                 new TreeCellDataFunc(TrackCellRating), new RatingRenderer(),
-                5, (int)ColumnId.Rating);
+                6, (int)ColumnId.Rating);
             columns.Add(_RatingColumn);
             RatingColumn = _RatingColumn.Column;
             
@@ -107,7 +111,7 @@
                 Catalog.GetString("Plays"), "Plays",
                 new TreeCellDataFunc(TrackCellPlayCount), 
                 new CellRendererText(),
-                6, (int)ColumnId.PlayCount);
+                7, (int)ColumnId.PlayCount);
             columns.Add(_PlaysColumn);
             PlaysColumn = _PlaysColumn.Column;
             
@@ -115,7 +119,7 @@
                 Catalog.GetString("Last Played"), "Last-Played",
                 new TreeCellDataFunc(TrackCellLastPlayed), 
                 new CellRendererText(),
-                7, (int)ColumnId.LastPlayed);
+                8, (int)ColumnId.LastPlayed);
             columns.Add(_LastPlayedColumn);
             LastPlayedColumn = _LastPlayedColumn.Column;
             
@@ -395,7 +399,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	30 Jan 2006 16:57:01 -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.5
diff -u -r1.5 Library.cs
--- src/Banshee.Base/Library.cs	6 Jan 2006 03:56:26 -0000	1.5
+++ src/Banshee.Base/Library.cs	30 Jan 2006 16:57:01 -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]