Changeset 474

Show
Ignore:
Timestamp:
10/16/06 20:14:41 (2 years ago)
Author:
nicfit
Message:

Removed mmkeys (for the time being, not sure how I want to do keybindings) and xspf work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/config.py

    r471 r474  
    3636            name = section.split('.', 1)[1] 
    3737            playlists.append(name) 
    38     return playlists 
    39  
    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) 
    4638    return playlists 
    4739 
  • trunk/src/main.py

    r473 r474  
    6464            self.main_window.show_tips_window() 
    6565 
     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 
    6674        try: 
    6775            gtk.main() 
     
    194202 
    195203            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() 
    200205                # FIXME 
    201206                #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() 
    210270 
    211271import optparse 
  • trunk/src/main_window.py

    r473 r474  
    378378        if self._pref_window is None: 
    379379            self._pref_window = PreferenceWindow() 
    380         self._pref_window.show() 
     380        self._pref_window.present() 
    381381 
    382382    def _on_compact_menuitem_activate(self, widget): 
     
    478478 
    479479        # Add new playlist entries 
    480         playlists = set(config.get_all_playlists().keys()) 
     480        playlists = set(config.get_all_playlist_names()) 
    481481        playlists = list(playlists.difference(shown_playlists)) 
    482482        if playlists: 
  • trunk/src/mesk/gtk_utils.py

    r473 r474  
    1919################################################################################ 
    2020import os, sys 
    21 import gobject, gtk, pango 
     21import gobject, gtk, gtk.glade, pango 
    2222import xml.sax.saxutils 
    2323 
     
    106106        glade_file = '%s.glade' % symbol 
    107107    return gtk.glade.XML(os.path.join(glade_dir, glade_file), symbol, 'mesk') 
     108 
     109def update_pending_events(): 
     110    while gtk.events_pending(): 
     111        gtk.main_iteration(False) 
  • trunk/src/playlist_control.py

    r473 r474  
    182182 
    183183        # Load playlist 
    184         # FIXME 
     184        # FIXME: remove timing code? 
    185185        import time 
    186186        t1 = time.time() 
     
    188188        t2 = time.time() 
    189189        print "Playlist load time: %fs" % (t2 - t1) 
    190         pl.set_shuffle(self._pl_config.shuffle) 
    191         pl.set_repeat(self._pl_config.repeat) 
    192190        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                 pass 
    198191        pl._queue = self._pl_config.queue 
    199192 
     
    226219            mesk.playlist.xspf.save(mesk.uri.unescape(self._pl_config.uri.path), 
    227220                                    self._playlist) 
    228             # FIXME 
    229             #mesk.playlist.xspf.save('../pl.xspf', self._playlist) 
    230221 
    231222            self._debug_show_playlist() 
     
    10291020                        # For every N inserts update UI 
    10301021                        if count % MAX_ROWS_PENDING == 0: 
    1031                             while gtk.events_pending(): 
    1032                                 gtk.main_iteration(False) 
     1022                            mesk.gtk_utils.update_pending_events() 
     1023 
    10331024            except (UnsupportedScheme, Exception), ex: 
    10341025                msg = _('Error dropping source: %s\n\n%s') % \