Changeset 474
- Timestamp:
- 10/16/06 20:14:41 (2 years ago)
- Files:
-
- trunk/src/config.py (modified) (1 diff)
- trunk/src/data/glade/version_migration.glade (added)
- trunk/src/main.py (modified) (2 diffs)
- trunk/src/main_window.py (modified) (2 diffs)
- trunk/src/mesk/gtk_utils.py (modified) (2 diffs)
- trunk/src/mmkeys (deleted)
- trunk/src/playlist_control.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/config.py
r471 r474 36 36 name = section.split('.', 1)[1] 37 37 playlists.append(name) 38 return playlists39 40 def get_all_playlists():41 playlists = {}42 for section in mesk.config.sections():43 if section.startswith(mesk.CONFIG_PLAYLIST + '.'):44 name = section.split('.', 1)[1]45 playlists[name] = PlaylistConfig(name)46 38 return playlists 47 39 trunk/src/main.py
r473 r474 64 64 self.main_window.show_tips_window() 65 65 66 # FIXME: 67 self.tray_icon = \ 68 gtk.status_icon_new_from_file('data/images/mesk-22.png') 69 self.tray_icon.set_visible(True) 70 self.tray_icon.set_tooltip("This is a test") 71 self.tray_icon.connect('activate', self._on_trayicon_activate) 72 self.tray_icon.connect('popup-menu', self._on_trayicon_menu) 73 66 74 try: 67 75 gtk.main() … … 194 202 195 203 if minor == 2: # 0.2.x --> 0.3.x 196 # Update m3u playlists to xspf 197 #import dialogs 198 #md = dialogs.MessageDialog(None, modal=True) 199 #md.run() 204 self._migrate_m3u_to_xspf() 200 205 # FIXME 201 206 #sys.exit(1) 202 return 203 import config 204 for name in config.get_all_playlist_names(): 205 sect = mesk.CONFIG_PLAYLIST + '.' + name 206 uri_str = mesk.config.get(sect, 'uri') 207 pl = mesk.playlist.load(mesk.uri.make_uri(uri_str), name) 208 print sect, pl 209 207 208 def _on_trayicon_activate(self, status_icon): 209 print "activate" 210 def _on_trayicon_menu(self, status_icon, button, time): 211 print "menu" 212 213 def _migrate_m3u_to_xspf(self): 214 # Update m3u playlists to xspf 215 import mesk, config 216 m3u_playlists = [] 217 for name in config.get_all_playlist_names(): 218 sect = mesk.CONFIG_PLAYLIST + '.' + name 219 uri_str = mesk.config.get(sect, 'uri') 220 if os.path.splitext(uri_str)[1] == '.m3u': 221 m3u_playlists.append(sect) 222 223 if len(m3u_playlists): 224 import mesk.gtk_utils; 225 from mesk.gtk_utils import get_glade, update_pending_events 226 glade_xml = get_glade('mesk_0_3_0_upgrade_window', 227 'version_migration.glade') 228 win = glade_xml.get_widget('mesk_0_3_0_upgrade_window') 229 win.show_now() 230 update_pending_events() 231 status_label = glade_xml.get_widget('status_label') 232 progressbar = glade_xml.get_widget('progressbar') 233 count = 0 234 for sect in m3u_playlists: 235 name = sect.split('.')[1] 236 status_label.set_markup("<small>%s</small>" % 237 (_("Converting playlist '%s' to XSPF") % 238 name)) 239 update_pending_events() 240 uri = mesk.uri.make_uri(mesk.config.get(sect, 'uri')) 241 # Load each playlist 242 pl = mesk.playlist.load(uri, name) 243 pl.set_shuffle(mesk.config.getboolean(sect, 'shuffle')) 244 pl.set_repeat(mesk.config.getboolean(sect, 'repeat')) 245 try: 246 pl.set_curr_index(mesk.config.getint(sect, 'current')) 247 except IndexError: 248 pass 249 # FIXME: Stash more 250 # Convert to XSPF 251 path = mesk.uri.unescape(uri.path) 252 path = "%s.xspf" % \ 253 mesk.uri.escape_path(os.path.splitext(uri.path)[0]) 254 mesk.playlist.xspf.save(path, pl) 255 # Update config, removed options are now stored in the 256 # XSPF playlist 257 mesk.config.set(sect, "uri", str(mesk.uri.make_uri(path))) 258 mesk.config.remove_option(sect, "current") 259 mesk.config.remove_option(sect, "repeat") 260 mesk.config.remove_option(sect, "shuffle") 261 # FIXME: Remove more 262 # Update progress 263 count += 1 264 progressbar.set_fraction(float(count) / 265 float(len(m3u_playlists))) 266 update_pending_events() 267 progressbar.set_fraction(1.0) 268 update_pending_events() 269 win.destroy() 210 270 211 271 import optparse trunk/src/main_window.py
r473 r474 378 378 if self._pref_window is None: 379 379 self._pref_window = PreferenceWindow() 380 self._pref_window. show()380 self._pref_window.present() 381 381 382 382 def _on_compact_menuitem_activate(self, widget): … … 478 478 479 479 # Add new playlist entries 480 playlists = set(config.get_all_playlist s().keys())480 playlists = set(config.get_all_playlist_names()) 481 481 playlists = list(playlists.difference(shown_playlists)) 482 482 if playlists: trunk/src/mesk/gtk_utils.py
r473 r474 19 19 ################################################################################ 20 20 import os, sys 21 import gobject, gtk, pango21 import gobject, gtk, gtk.glade, pango 22 22 import xml.sax.saxutils 23 23 … … 106 106 glade_file = '%s.glade' % symbol 107 107 return gtk.glade.XML(os.path.join(glade_dir, glade_file), symbol, 'mesk') 108 109 def update_pending_events(): 110 while gtk.events_pending(): 111 gtk.main_iteration(False) trunk/src/playlist_control.py
r473 r474 182 182 183 183 # Load playlist 184 # FIXME 184 # FIXME: remove timing code? 185 185 import time 186 186 t1 = time.time() … … 188 188 t2 = time.time() 189 189 print "Playlist load time: %fs" % (t2 - t1) 190 pl.set_shuffle(self._pl_config.shuffle)191 pl.set_repeat(self._pl_config.repeat)192 190 pl.set_curr_index(-1) 193 if not pl.is_shuffled() and not self._pl_config.queue:194 try:195 pl.set_curr_index(self._pl_config.current)196 except IndexError:197 pass198 191 pl._queue = self._pl_config.queue 199 192 … … 226 219 mesk.playlist.xspf.save(mesk.uri.unescape(self._pl_config.uri.path), 227 220 self._playlist) 228 # FIXME229 #mesk.playlist.xspf.save('../pl.xspf', self._playlist)230 221 231 222 self._debug_show_playlist() … … 1029 1020 # For every N inserts update UI 1030 1021 if count % MAX_ROWS_PENDING == 0: 1031 while gtk.events_pending():1032 gtk.main_iteration(False) 1022 mesk.gtk_utils.update_pending_events() 1023 1033 1024 except (UnsupportedScheme, Exception), ex: 1034 1025 msg = _('Error dropping source: %s\n\n%s') % \
