Changeset 529
- Timestamp:
- 01/11/07 18:59:03 (2 years ago)
- Files:
-
- trunk/src/control.py (modified) (1 diff)
- trunk/src/dbus_service.py (modified) (3 diffs)
- trunk/src/main.py (modified) (4 diffs)
- trunk/src/main_window.py (modified) (1 diff)
- trunk/src/playlist_control.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/control.py
r515 r529 43 43 gobject.SIGNAL_RUN_LAST, 44 44 gobject.TYPE_NONE, []) 45 self._is_active = False 45 46 46 47 def shutdown(self): 47 48 pass 48 49 49 def set_active(self, state = True, audio_ctrl = None): 50 pass 51 def set_focused(self, state = True): 50 def set_active(self, state=True, audio_ctrl=None): 51 self._is_active = state 52 def is_active(self): 53 return self._is_active 54 55 def set_focused(self, state=True): 52 56 pass 53 57 trunk/src/dbus_service.py
r527 r529 21 21 import dbus, dbus.service, dbus.glib 22 22 import mesk 23 import config, playlist_control 23 24 24 OBJ_PATH = '/net/nicfit/mesk/MeskApp'25 25 INTERFACE = 'net.nicfit.mesk.MeskAppInterface' 26 SERVICE = 'net.nicfit.mesk.MeskApp' 26 27 def get_service_name(profile): 28 return _append_profile('net.nicfit.mesk.MeskApp.', profile) 29 def get_object_path(profile): 30 return _append_profile('/net/nicfit/mesk/MeskApp/', profile) 31 32 def _append_profile(prefix, profile): 33 if not profile: 34 profile = 'default' 35 return prefix + profile 27 36 28 37 class MeskDbusService(dbus.service.Object): … … 30 39 31 40 def __init__(self, bus_name, profile, main_win): 32 dbus.service.Object.__init__(self, bus_name, OBJ_PATH)33 41 self._main_win = main_win 34 42 self._profile = profile 43 obj_path = get_object_path(self._profile) 44 dbus.service.Object.__init__(self, bus_name, obj_path) 35 45 36 46 self._audio_control = self._main_win._audio_control … … 132 142 133 143 @dbus.service.method(INTERFACE) 134 def get_current_playlist(self): 135 pass 144 def list_playlists(self): 145 return config.get_all_playlist_names() 146 147 @dbus.service.method(INTERFACE) 148 def get_active_playlist(self): 149 for ctrl in self._main_win._controls: 150 if ((type(ctrl) is playlist_control.PlaylistControl) and 151 ctrl.is_active()): 152 return ctrl.name 153 return '' 154 155 ## FIXME 156 # @dbus.service.method(INTERFACE) 157 # def enqueue_uri(self, uri, pl): 158 # first_c = None 159 # for ctrl in self._main_win._controls: 160 # if type(ctrl) is playlist_control.PlaylistControl: 161 # if first_pl is None: 162 # first_pl = ctrl 163 # print ctrl.name 164 # uri = mesk.uri.make_uri(uri) 165 # print "enqueue_uri:", uri, pl 136 166 137 167 def _on_audio_source_changed(self, ctrl, old, new): trunk/src/main.py
r519 r529 72 72 remote_status |= self._remote_control(arg) 73 73 except Exception, ex: 74 mesk.log.error('Dbus error: %s' % str(ex))74 sys.stderr.write('Dbus error: %s\n' % str(ex)) 75 75 return 2 76 76 … … 210 210 import dbus 211 211 import dbus_service # This is a local module 212 obj_path = dbus_service.get_object_path(self.profile) 213 service = dbus_service.get_service_name(self.profile) 212 214 session_bus = dbus.SessionBus() 213 self.remote_control = \ 214 dbus.Interface(session_bus.get_object(dbus_service.SERVICE, 215 dbus_service.OBJ_PATH), 216 dbus_service.INTERFACE) 215 obj = session_bus.get_object(service, obj_path) 216 self.remote_control = dbus.Interface(obj, dbus_service.INTERFACE) 217 217 218 218 if cmd in ['--stop']: … … 241 241 '--get-current-length']: 242 242 metadata = cmd[cmd.rfind('-') + 1:] 243 method = getattr(self.remote_control, 'get_current_%s' % metadata) 243 method = getattr(self.remote_control, 244 'get_current_%s' % metadata) 244 245 data = method() 245 sys.stdout.write(data.encode(locale.getpreferredencoding()) + '\n') 246 sys.stdout.write(data.encode(locale.getpreferredencoding()) + 247 '\n') 248 elif cmd in ['--list-playlists']: 249 playlists = self.remote_control.list_playlists() 250 for pl in playlists: 251 sys.stdout.write('%s\n' % 252 pl.encode(locale.getpreferredencoding())) 253 elif cmd in ['--get-active-playlist']: 254 pl = self.remote_control.get_active_playlist() 255 if pl: 256 sys.stdout.write('%s\n' % 257 pl.encode(locale.getpreferredencoding())) 258 ## FIXME 259 # elif cmd in ['--enqueue-uri']: 260 # uri, pl = self.opts.enqueue_uri 261 # self.remote_control.enqueue_uri(uri, pl) 246 262 else: 247 263 assert(False) # This should not happen … … 313 329 help=_('Returns the length (in seconds) of the ' 314 330 'current audio source.')) 331 rc_opts.add_option('--list-playlists', action='store_true', 332 help=_('List all playlists.')) 333 rc_opts.add_option('--get-active-playlist', action='store_true', 334 help=_('List the name of the active ' 335 'PlaylistControl. This value may be empty.')) 336 ## FIXME 337 # rc_opts.add_option('--enqueue-uri', type='string', action='store', 338 # nargs=2, metavar='URI PLAYLIST', 339 # help=_('Enqueue a URI to PLAYLIST. The playlist ' 340 # 'is opened if not already.')) 315 341 self.add_option_group(rc_opts) 316 342 trunk/src/main_window.py
r528 r529 135 135 self.DBUS_SUPPORT = True 136 136 session_bus = dbus.SessionBus() 137 name = dbus.service.BusName(dbus_service.SERVICE, bus=session_bus) 137 service_id = dbus_service.get_service_name(self.profile) 138 name = dbus.service.BusName(service_id, bus=session_bus) 138 139 self.mesk_dbus = dbus_service.MeskDbusService(name, self.profile, 139 140 self) trunk/src/playlist_control.py
r527 r529 70 70 self._playlist = None 71 71 self._playlist_save_id = None 72 self._i s_active = self._initial_active = False72 self._initial_active = False 73 73 self._audio_control = None 74 74 self._row_activated_awaiting_active = None … … 288 288 289 289 def set_active(self, active=True, audio_ctrl=None): 290 control.Control.set_active(self, active, audio_ctrl) 290 291 291 292 if not active: … … 295 296 else: 296 297 self._audio_control = audio_ctrl 297 self._is_active = active298 298 299 299 # Connect events for audio_control on first activation
