Commit 7fe7324d authored by Rafaël Carré's avatar Rafaël Carré

Updates D-Bus controller to new D-Bus methods.

parent 0e252d3a
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.0.2 on Tue Nov 21 18:02:27 2006 by fun@zod--> <!--Generated with glade3 3.2.0 on Sat Apr 7 01:02:24 2007 by fun@ubuntu-->
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="window1"> <widget class="GtkWindow" id="window1">
<property name="resizable">False</property> <property name="resizable">False</property>
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
<property name="width_request">37</property> <property name="width_request">37</property>
<property name="height_request">37</property> <property name="height_request">37</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Previous</property> <property name="tooltip" translatable="yes">Previous</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image8"> <widget class="GtkImage" id="image8">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
<property name="width_request">37</property> <property name="width_request">37</property>
<property name="height_request">37</property> <property name="height_request">37</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Play/Pause</property> <property name="tooltip" translatable="yes">Play/Pause</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image6"> <widget class="GtkImage" id="image6">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
<property name="width_request">37</property> <property name="width_request">37</property>
<property name="height_request">37</property> <property name="height_request">37</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Next</property> <property name="tooltip" translatable="yes">Next</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image1"> <widget class="GtkImage" id="image1">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -73,8 +73,8 @@ ...@@ -73,8 +73,8 @@
<property name="width_request">37</property> <property name="width_request">37</property>
<property name="height_request">37</property> <property name="height_request">37</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Stop</property> <property name="tooltip" translatable="yes">Stop</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image9"> <widget class="GtkImage" id="image9">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -93,8 +93,8 @@ ...@@ -93,8 +93,8 @@
<property name="width_request">37</property> <property name="width_request">37</property>
<property name="height_request">37</property> <property name="height_request">37</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Quit vlc</property> <property name="tooltip" translatable="yes">Quit vlc</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image5"> <widget class="GtkImage" id="image5">
<property name="width_request">26</property> <property name="width_request">26</property>
...@@ -114,8 +114,8 @@ ...@@ -114,8 +114,8 @@
<property name="width_request">37</property> <property name="width_request">37</property>
<property name="height_request">37</property> <property name="height_request">37</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Close controller</property> <property name="tooltip" translatable="yes">Close controller</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image2"> <widget class="GtkImage" id="image2">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -160,12 +160,12 @@ ...@@ -160,12 +160,12 @@
<property name="height_request">20</property> <property name="height_request">20</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Volume in %</property>
<property name="editable">False</property> <property name="editable">False</property>
<property name="adjustment">100 0 100 1 10 10</property> <property name="adjustment">100 0 100 1 10 10</property>
<property name="snap_to_ticks">True</property> <property name="snap_to_ticks">True</property>
<property name="numeric">True</property> <property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property> <property name="update_policy">GTK_UPDATE_IF_VALID</property>
<property name="tooltip" translatable="yes">Volume in %</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -187,12 +187,12 @@ ...@@ -187,12 +187,12 @@
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkFileChooserButton" id="ChooseFile"> <widget class="GtkFileChooserButton" id="ChooseFile">
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="width_request">185</property> <property name="width_request">185</property>
<property name="height_request">35</property> <property name="height_request">35</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Select Da Directory !</property>
<property name="tooltip" translatable="yes">Choose a directory</property> <property name="tooltip" translatable="yes">Choose a directory</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="title" translatable="yes">Select Da Directory !</property>
</widget> </widget>
</child> </child>
<child> <child>
...@@ -218,8 +218,8 @@ ...@@ -218,8 +218,8 @@
<property name="width_request">35</property> <property name="width_request">35</property>
<property name="height_request">35</property> <property name="height_request">35</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Add MRL, or directory if empty</property> <property name="tooltip" translatable="yes">Add MRL, or directory if empty</property>
<property name="relief">GTK_RELIEF_NONE</property>
<child> <child>
<widget class="GtkImage" id="image4"> <widget class="GtkImage" id="image4">
<property name="width_request">100</property> <property name="width_request">100</property>
...@@ -265,7 +265,6 @@ ...@@ -265,7 +265,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="events"></property> <property name="events"></property>
<property name="xpad">8</property> <property name="xpad">8</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_name">vlc</property> <property name="icon_name">vlc</property>
</widget> </widget>
</child> </child>
...@@ -298,15 +297,4 @@ ...@@ -298,15 +297,4 @@
</widget> </widget>
</child> </child>
</widget> </widget>
<widget class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
<widget class="GtkImageMenuItem" id="menuquit">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-quit</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>
...@@ -27,22 +27,31 @@ ...@@ -27,22 +27,31 @@
# #
# Also notice it has been designed first for a previous specificaiton, and thus some code may not work/be disabled # Also notice it has been designed first for a previous specificaiton, and thus some code may not work/be disabled
# #
# You'll need pygtk >= 2.10 to use gtk.StatusIcon
#
import dbus import dbus
import dbus.glib import dbus.glib
import gtk import gtk
import gtk.glade import gtk.glade
import egg.trayicon
import gobject import gobject
import os import os
global position global position
global timer global timer
#global playing global playing
playing = False
def itemchange_handler(item): def itemchange_handler(item):
gobject.timeout_add( 2000, timeset) gobject.timeout_add( 2000, timeset)
l_item.set_text(item) try:
a = item["artist"]
except:
a = ""
if a == "":
a = item["URI"]
l_item.set_text(a)
#connect to the bus
bus = dbus.SessionBus() bus = dbus.SessionBus()
player_o = bus.get_object("org.freedesktop.MediaPlayer", "/Player") player_o = bus.get_object("org.freedesktop.MediaPlayer", "/Player")
tracklist_o = bus.get_object("org.freedesktop.MediaPlayer", "/TrackList") tracklist_o = bus.get_object("org.freedesktop.MediaPlayer", "/TrackList")
...@@ -54,6 +63,7 @@ try: ...@@ -54,6 +63,7 @@ try:
except: except:
True True
#plays an element
def AddTrack(widget): def AddTrack(widget):
mrl = e_mrl.get_text() mrl = e_mrl.get_text()
if mrl != None and mrl != "": if mrl != None and mrl != "":
...@@ -62,7 +72,9 @@ def AddTrack(widget): ...@@ -62,7 +72,9 @@ def AddTrack(widget):
mrl = bt_file.get_filename() mrl = bt_file.get_filename()
if mrl != None and mrl != "": if mrl != None and mrl != "":
tracklist.AddTrack("directory://" + mrl, True) tracklist.AddTrack("directory://" + mrl, True)
update(0)
#basic control
def Next(widget): def Next(widget):
player.Next(reply_handler=(lambda *args: None), error_handler=(lambda *args: None)) player.Next(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
update(0) update(0)
...@@ -75,14 +87,15 @@ def Stop(widget): ...@@ -75,14 +87,15 @@ def Stop(widget):
player.Stop(reply_handler=(lambda *args: None), error_handler=(lambda *args: None)) player.Stop(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
update(0) update(0)
#update status display
def update(widget): def update(widget):
# itemchange_handler(str(player.GetPlayingItem()))
vol.set_value(player.VolumeGet()) vol.set_value(player.VolumeGet())
GetPlayStatus(0) GetPlayStatus(0)
#get playing status from remote vlc
def GetPlayStatus(widget): def GetPlayStatus(widget):
global playing global playing
status = str(player.GetStatus()) status = player.GetStatus()
if status == 0: if status == 0:
img_bt_toggle.set_from_stock("gtk-media-pause", gtk.ICON_SIZE_SMALL_TOOLBAR) img_bt_toggle.set_from_stock("gtk-media-pause", gtk.ICON_SIZE_SMALL_TOOLBAR)
playing = True playing = True
...@@ -96,29 +109,38 @@ def Quit(widget): ...@@ -96,29 +109,38 @@ def Quit(widget):
def Pause(widget): def Pause(widget):
player.Pause() player.Pause()
# img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_SMALL_TOOLBAR) status = player.GetStatus()
# img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR) if status == 0:
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
gobject.timeout_add( 2000, timeset)
else:
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR)
update(0) update(0)
#callback for volume
def volchange(widget, data): def volchange(widget, data):
player.VolumeSet(vol.get_value_as_int(), reply_handler=(lambda *args: None), error_handler=(lambda *args: None)) player.VolumeSet(vol.get_value_as_int(), reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
#callback for position change
def timechange(widget, x=None, y=None): def timechange(widget, x=None, y=None):
player.PositionSet(time_s.get_value(), reply_handler=(lambda *args: None), error_handler=(lambda *args: None)) player.PositionSet(int(time_s.get_value()), reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
#refresh position
def timeset(): def timeset():
# global playing global playing
time_s.set_value(player.PositionGet()) time_s.set_value(player.PositionGet())
# return playing return playing
#simple/full display
def expander(widget): def expander(widget):
if exp.get_expanded() == False: if exp.get_expanded() == False:
exp.set_label("Less") exp.set_label("Less")
else: else:
exp.set_label("More") exp.set_label("More")
#close event
def delete_event(self, widget): def delete_event(self, widget):
widget.hide() self.hide()
return True return True
def destroy(widget): def destroy(widget):
...@@ -130,17 +152,15 @@ def key_release(widget, event): ...@@ -130,17 +152,15 @@ def key_release(widget, event):
position = window.get_position() position = window.get_position()
widget.hide() widget.hide()
def tray_button(widget,event): #click on the tray icon
def tray_button(widget):
global position global position
if event.button == 1: if window.get_property('visible'):
if window.get_property('visible'): position = window.get_position()
position = window.get_position() window.hide()
window.hide() else:
else: window.move(position[0], position[1])
window.move(position[0], position[1]) window.show()
window.show()
if event.button == 3:
menu.popup(None,None,None,event.button,event.time)
xml = gtk.glade.XML('dbus-vlc.glade') xml = gtk.glade.XML('dbus-vlc.glade')
...@@ -158,8 +178,6 @@ window = xml.get_widget('window1') ...@@ -158,8 +178,6 @@ window = xml.get_widget('window1')
img_bt_toggle=xml.get_widget('image6') img_bt_toggle=xml.get_widget('image6')
exp = xml.get_widget('expander2') exp = xml.get_widget('expander2')
expvbox = xml.get_widget('expandvbox') expvbox = xml.get_widget('expandvbox')
menu = xml.get_widget('menu1')
menuitem = xml.get_widget('menuquit')
vlcicon = xml.get_widget('eventicon') vlcicon = xml.get_widget('eventicon')
vol = xml.get_widget('vol') vol = xml.get_widget('vol')
time_s = xml.get_widget('time_s') time_s = xml.get_widget('time_s')
...@@ -169,21 +187,12 @@ window.connect('delete_event', delete_event) ...@@ -169,21 +187,12 @@ window.connect('delete_event', delete_event)
window.connect('destroy', destroy) window.connect('destroy', destroy)
window.connect('key_release_event', key_release) window.connect('key_release_event', key_release)
tray = egg.trayicon.TrayIcon("VLC") tray = gtk.status_icon_new_from_icon_name("vlc")
eventbox = gtk.EventBox() tray.connect('activate', tray_button)
tray.add(eventbox)
eventbox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
eventbox.connect('button_press_event', tray_button)
image = gtk.Image()
eventbox.add(image)
image.set_from_icon_name("vlc", gtk.ICON_SIZE_MENU)
tray.show_all()
def icon_clicked(widget, event): def icon_clicked(widget, event):
update(0) update(0)
menu.attach_to_widget(eventbox,None)
bt_close.connect('clicked', destroy) bt_close.connect('clicked', destroy)
bt_quit.connect('clicked', Quit) bt_quit.connect('clicked', Quit)
bt_mrl.connect('clicked', AddTrack) bt_mrl.connect('clicked', AddTrack)
...@@ -192,9 +201,6 @@ bt_next.connect('clicked', Next) ...@@ -192,9 +201,6 @@ bt_next.connect('clicked', Next)
bt_prev.connect('clicked', Prev) bt_prev.connect('clicked', Prev)
bt_stop.connect('clicked', Stop) bt_stop.connect('clicked', Stop)
exp.connect('activate', expander) exp.connect('activate', expander)
menuitem.connect('activate', destroy)
vlcicon.set_events(gtk.gdk.BUTTON_PRESS_MASK)
vlcicon.connect('button_press_event', icon_clicked)
vol.connect('change-value', volchange) vol.connect('change-value', volchange)
vol.connect('scroll-event', volchange) vol.connect('scroll-event', volchange)
time_s.connect('adjust-bounds', timechange) time_s.connect('adjust-bounds', timechange)
...@@ -219,4 +225,13 @@ try: ...@@ -219,4 +225,13 @@ try:
except: except:
True True
icon_theme = gtk.icon_theme_get_default()
try:
pix = icon_theme.load_icon("vlc",24,0)
window.set_icon(pix)
except:
True
position = window.get_position()
vol.set_value(player.VolumeGet())
gtk.main() gtk.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment