+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.3.3 on Wed Aug 22 03:00:39 2007 -->
-<glade-interface>
- <widget class="GtkWindow" id="window1">
- <property name="resizable">False</property>
- <property name="window_position">GTK_WIN_POS_CENTER</property>
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="homogeneous">True</property>
- <child>
- <widget class="GtkButton" id="prev">
- <property name="width_request">37</property>
- <property name="height_request">37</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Previous</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image8">
- <property name="visible">True</property>
- <property name="stock">gtk-media-previous</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="toggle">
- <property name="width_request">37</property>
- <property name="height_request">37</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Play/Pause</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image6">
- <property name="visible">True</property>
- <property name="stock">gtk-media-play</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="next">
- <property name="width_request">37</property>
- <property name="height_request">37</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Next</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="stock">gtk-media-next</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="stop">
- <property name="width_request">37</property>
- <property name="height_request">37</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Stop</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image9">
- <property name="visible">True</property>
- <property name="stock">gtk-media-stop</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="quit">
- <property name="width_request">37</property>
- <property name="height_request">37</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Quit vlc</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image5">
- <property name="width_request">26</property>
- <property name="height_request">26</property>
- <property name="visible">True</property>
- <property name="stock">gtk-quit</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="close">
- <property name="width_request">37</property>
- <property name="height_request">37</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Close controller</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="stock">gtk-close</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="position">5</property>
- </packing>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkExpander" id="expander2">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show more options</property>
- <child>
- <widget class="GtkVBox" id="vbox2">
- <property name="visible">True</property>
- <child>
- <widget class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <child>
- <widget class="GtkHScale" id="time_s">
- <property name="width_request">180</property>
- <property name="height_request">20</property>
- <property name="visible">True</property>
- <property name="adjustment">0 0 1000 10 100 0</property>
- <property name="digits">-1</property>
- <property name="draw_value">False</property>
- <property name="value_pos">GTK_POS_RIGHT</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkSpinButton" id="vol">
- <property name="width_request">42</property>
- <property name="height_request">20</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip" translatable="yes">Volume in %</property>
- <property name="editable">False</property>
- <property name="adjustment">100 0 100 1 10 10</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <property name="update_policy">GTK_UPDATE_IF_VALID</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <child>
- <widget class="GtkVBox" id="expandvbox">
- <property name="visible">True</property>
- <child>
- <widget class="GtkFileChooserButton" id="ChooseFile">
- <property name="width_request">185</property>
- <property name="height_request">35</property>
- <property name="visible">True</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>
- </child>
- <child>
- <widget class="GtkEntry" id="mrl">
- <property name="width_request">185</property>
- <property name="height_request">20</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Enter a full MRL</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkFixed" id="fixed1">
- <property name="visible">True</property>
- <child>
- <widget class="GtkButton" id="AddMRL">
- <property name="width_request">35</property>
- <property name="height_request">35</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Add MRL, or directory if empty</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkImage" id="image4">
- <property name="width_request">100</property>
- <property name="height_request">80</property>
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Add to playlist</property>
- <property name="stock">gtk-add</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="y">10</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="l_artist">
- <property name="width_request">180</property>
- <property name="height_request">20</property>
- <property name="visible">True</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">True</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
- <property name="single_line_mode">True</property>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <child>
- <widget class="GtkLabel" id="l_title">
- <property name="width_request">180</property>
- <property name="height_request">20</property>
- <property name="visible">True</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">True</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
- <property name="single_line_mode">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkEventBox" id="eventicon">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImage" id="vlcicon">
- <property name="visible">True</property>
- <property name="events"></property>
- <property name="tooltip" translatable="yes">Update meta info</property>
- <property name="xpad">8</property>
- <property name="icon_name">vlc</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">3</property>
- </packing>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">More</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
-</glade-interface>
+++ /dev/null
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-#
-# Copyright (C) 2006 Rafaël Carré <funman at videolanorg>
-#
-# $Id$
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
-#
-
-#
-# NOTE: this controller is a SAMPLE, and thus doesn't implement all the D-Bus Media Player specification. http://wiki.videolan.org/index.php/DBus-spec
-# This is an unfinished document (on the 12/06/2006) and has been designed to be as general as possible.
-# So don't expect that much from this, but basic capabilities should work out of the box (Play/Pause/Next/Add)
-#
-# 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.glib
-import gtk
-import gtk.glade
-import gobject
-import os
-
-global position
-global timer
-global playing
-playing = False
-
-def itemchange_handler(item):
- gobject.timeout_add( 2000, timeset)
- try:
- a = item["artist"]
- except:
- a = ""
- try:
- t = item["title"]
- except:
- t = ""
- if t == "":
- t = item["URI"]
- l_artist.set_text(a)
- l_title.set_text(t)
-
-#connect to the bus
-bus = dbus.SessionBus()
-player_o = bus.get_object("org.mpris.vlc", "/Player")
-tracklist_o = bus.get_object("org.mpris.vlc", "/TrackList")
-
-tracklist = dbus.Interface(tracklist_o, "org.freedesktop.MediaPlayer")
-player = dbus.Interface(player_o, "org.freedesktop.MediaPlayer")
-try:
- player_o.connect_to_signal("TrackChange", itemchange_handler, dbus_interface="org.freedesktop.MediaPlayer")
-except:
- True
-
-#plays an element
-def AddTrack(widget):
- mrl = e_mrl.get_text()
- if mrl != None and mrl != "":
- tracklist.AddTrack(mrl, True)
- e_mrl.set_text('')
- else:
- mrl = bt_file.get_filename()
- if mrl != None and mrl != "":
- tracklist.AddTrack("directory://" + mrl, True)
- update(0)
-
-#basic control
-def Next(widget):
- player.Next(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
- update(0)
-
-def Prev(widget):
- player.Prev(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
- update(0)
-
-def Stop(widget):
- player.Stop(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
- update(0)
-
-#update status display
-def update(widget):
- item = tracklist.GetMetadata(tracklist.GetCurrentTrack())
- vol.set_value(player.VolumeGet())
- try:
- a = item["artist"]
- except: a = ""
- try:
- t = item["title"]
- except: t = ""
- if t == "":
- t = item["URI"]
- l_artist.set_text(a)
- l_title.set_text(t)
- GetPlayStatus(0)
-
-#get playing status from remote vlc
-def GetPlayStatus(widget):
- global playing
- status = player.GetStatus()
- if status == 0:
- img_bt_toggle.set_from_stock("gtk-media-pause", gtk.ICON_SIZE_SMALL_TOOLBAR)
- playing = True
- else:
- img_bt_toggle.set_from_stock("gtk-media-play", gtk.ICON_SIZE_SMALL_TOOLBAR)
- playing = False
-
-def Quit(widget):
- player.Quit(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
- l_title.set_text("")
-
-def Pause(widget):
- player.Pause()
- status = player.GetStatus()
- 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)
-
-#callback for volume
-def volchange(widget, data):
- 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):
- player.PositionSet(int(time_s.get_value()), reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
-
-#refresh position
-def timeset():
- global playing
- time_s.set_value(player.PositionGet())
- return playing
-
-#simple/full display
-def expander(widget):
- if exp.get_expanded() == False:
- exp.set_label("Less")
- else:
- exp.set_label("More")
-
-#close event
-def delete_event(self, widget):
- self.hide()
- return True
-
-def destroy(widget):
- gtk.main_quit()
-
-def key_release(widget, event):
- global position
- if event.keyval == gtk.keysyms.Escape:
- position = window.get_position()
- widget.hide()
-
-#click on the tray icon
-def tray_button(widget):
- global position
- if window.get_property('visible'):
- position = window.get_position()
- window.hide()
- else:
- window.move(position[0], position[1])
- window.show()
-
-xml = gtk.glade.XML('dbus-vlc.glade')
-
-bt_close = xml.get_widget('close')
-bt_quit = xml.get_widget('quit')
-bt_file = xml.get_widget('ChooseFile')
-bt_next = xml.get_widget('next')
-bt_prev = xml.get_widget('prev')
-bt_stop = xml.get_widget('stop')
-bt_toggle = xml.get_widget('toggle')
-bt_mrl = xml.get_widget('AddMRL')
-l_artist = xml.get_widget('l_artist')
-l_title = xml.get_widget('l_title')
-e_mrl = xml.get_widget('mrl')
-window = xml.get_widget('window1')
-img_bt_toggle=xml.get_widget('image6')
-exp = xml.get_widget('expander2')
-expvbox = xml.get_widget('expandvbox')
-vlcicon = xml.get_widget('eventicon')
-vol = xml.get_widget('vol')
-time_s = xml.get_widget('time_s')
-time_l = xml.get_widget('time_l')
-
-window.connect('delete_event', delete_event)
-window.connect('destroy', destroy)
-window.connect('key_release_event', key_release)
-
-tray = gtk.status_icon_new_from_icon_name("vlc")
-tray.connect('activate', tray_button)
-
-def icon_clicked(widget, event):
- update(0)
-
-bt_close.connect('clicked', destroy)
-bt_quit.connect('clicked', Quit)
-bt_mrl.connect('clicked', AddTrack)
-bt_toggle.connect('clicked', Pause)
-bt_next.connect('clicked', Next)
-bt_prev.connect('clicked', Prev)
-bt_stop.connect('clicked', Stop)
-exp.connect('activate', expander)
-vol.connect('change-value', volchange)
-vol.connect('scroll-event', volchange)
-time_s.connect('adjust-bounds', timechange)
-vlcicon.set_events(gtk.gdk.BUTTON_PRESS_MASK)
-vlcicon.connect('button_press_event', icon_clicked)
-time_s.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
-gobject.timeout_add( 2000, timeset)
-
-library = "/media/mp3"
-
-try:
- os.chdir(library)
- bt_file.set_current_folder(library)
-except:
- print "edit this file to point to your media library"
-
-window.set_icon_name('vlc')
-window.set_title("VLC - D-Bus ctrl")
-window.show()
-
-try:
- update(0)
-except:
- 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()
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.3.3 on Wed Aug 22 03:00:39 2007 -->
+<glade-interface>
+ <widget class="GtkWindow" id="window1">
+ <property name="resizable">False</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <widget class="GtkButton" id="prev">
+ <property name="width_request">37</property>
+ <property name="height_request">37</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Previous</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image8">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-previous</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="toggle">
+ <property name="width_request">37</property>
+ <property name="height_request">37</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Play/Pause</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image6">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-play</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="next">
+ <property name="width_request">37</property>
+ <property name="height_request">37</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Next</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-next</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="stop">
+ <property name="width_request">37</property>
+ <property name="height_request">37</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Stop</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image9">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-stop</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="quit">
+ <property name="width_request">37</property>
+ <property name="height_request">37</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Quit vlc</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image5">
+ <property name="width_request">26</property>
+ <property name="height_request">26</property>
+ <property name="visible">True</property>
+ <property name="stock">gtk-quit</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="close">
+ <property name="width_request">37</property>
+ <property name="height_request">37</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Close controller</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-close</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkExpander" id="expander2">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show more options</property>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHScale" id="time_s">
+ <property name="width_request">180</property>
+ <property name="height_request">20</property>
+ <property name="visible">True</property>
+ <property name="adjustment">0 0 1000 10 100 0</property>
+ <property name="digits">-1</property>
+ <property name="draw_value">False</property>
+ <property name="value_pos">GTK_POS_RIGHT</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="vol">
+ <property name="width_request">42</property>
+ <property name="height_request">20</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip" translatable="yes">Volume in %</property>
+ <property name="editable">False</property>
+ <property name="adjustment">100 0 100 1 10 10</property>
+ <property name="snap_to_ticks">True</property>
+ <property name="numeric">True</property>
+ <property name="update_policy">GTK_UPDATE_IF_VALID</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkVBox" id="expandvbox">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkFileChooserButton" id="ChooseFile">
+ <property name="width_request">185</property>
+ <property name="height_request">35</property>
+ <property name="visible">True</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>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="mrl">
+ <property name="width_request">185</property>
+ <property name="height_request">20</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Enter a full MRL</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkFixed" id="fixed1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkButton" id="AddMRL">
+ <property name="width_request">35</property>
+ <property name="height_request">35</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Add MRL, or directory if empty</property>
+ <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkImage" id="image4">
+ <property name="width_request">100</property>
+ <property name="height_request">80</property>
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Add to playlist</property>
+ <property name="stock">gtk-add</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="y">10</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="l_artist">
+ <property name="width_request">180</property>
+ <property name="height_request">20</property>
+ <property name="visible">True</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">True</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
+ <property name="single_line_mode">True</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="l_title">
+ <property name="width_request">180</property>
+ <property name="height_request">20</property>
+ <property name="visible">True</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">True</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
+ <property name="single_line_mode">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkEventBox" id="eventicon">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="vlcicon">
+ <property name="visible">True</property>
+ <property name="events"></property>
+ <property name="tooltip" translatable="yes">Update meta info</property>
+ <property name="xpad">8</property>
+ <property name="icon_name">vlc</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">More</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
--- /dev/null
+#!/usr/bin/python
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2006 Rafaël Carré <funman at videolanorg>
+#
+# $Id$
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+#
+
+#
+# NOTE: this controller is a SAMPLE, and thus doesn't implement all the D-Bus Media Player specification. http://wiki.videolan.org/index.php/DBus-spec
+# This is an unfinished document (on the 12/06/2006) and has been designed to be as general as possible.
+# So don't expect that much from this, but basic capabilities should work out of the box (Play/Pause/Next/Add)
+#
+# 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.glib
+import gtk
+import gtk.glade
+import gobject
+import os
+
+global position
+global timer
+global playing
+playing = False
+
+def itemchange_handler(item):
+ gobject.timeout_add( 2000, timeset)
+ try:
+ a = item["artist"]
+ except:
+ a = ""
+ try:
+ t = item["title"]
+ except:
+ t = ""
+ if t == "":
+ t = item["URI"]
+ l_artist.set_text(a)
+ l_title.set_text(t)
+
+#connect to the bus
+bus = dbus.SessionBus()
+player_o = bus.get_object("org.mpris.vlc", "/Player")
+tracklist_o = bus.get_object("org.mpris.vlc", "/TrackList")
+
+tracklist = dbus.Interface(tracklist_o, "org.freedesktop.MediaPlayer")
+player = dbus.Interface(player_o, "org.freedesktop.MediaPlayer")
+try:
+ player_o.connect_to_signal("TrackChange", itemchange_handler, dbus_interface="org.freedesktop.MediaPlayer")
+except:
+ True
+
+#plays an element
+def AddTrack(widget):
+ mrl = e_mrl.get_text()
+ if mrl != None and mrl != "":
+ tracklist.AddTrack(mrl, True)
+ e_mrl.set_text('')
+ else:
+ mrl = bt_file.get_filename()
+ if mrl != None and mrl != "":
+ tracklist.AddTrack("directory://" + mrl, True)
+ update(0)
+
+#basic control
+def Next(widget):
+ player.Next(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
+ update(0)
+
+def Prev(widget):
+ player.Prev(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
+ update(0)
+
+def Stop(widget):
+ player.Stop(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
+ update(0)
+
+#update status display
+def update(widget):
+ item = tracklist.GetMetadata(tracklist.GetCurrentTrack())
+ vol.set_value(player.VolumeGet())
+ try:
+ a = item["artist"]
+ except: a = ""
+ try:
+ t = item["title"]
+ except: t = ""
+ if t == "":
+ t = item["URI"]
+ l_artist.set_text(a)
+ l_title.set_text(t)
+ GetPlayStatus(0)
+
+#get playing status from remote vlc
+def GetPlayStatus(widget):
+ global playing
+ status = player.GetStatus()
+ if status == 0:
+ img_bt_toggle.set_from_stock("gtk-media-pause", gtk.ICON_SIZE_SMALL_TOOLBAR)
+ playing = True
+ else:
+ img_bt_toggle.set_from_stock("gtk-media-play", gtk.ICON_SIZE_SMALL_TOOLBAR)
+ playing = False
+
+def Quit(widget):
+ player.Quit(reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
+ l_title.set_text("")
+
+def Pause(widget):
+ player.Pause()
+ status = player.GetStatus()
+ 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)
+
+#callback for volume
+def volchange(widget, data):
+ 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):
+ player.PositionSet(int(time_s.get_value()), reply_handler=(lambda *args: None), error_handler=(lambda *args: None))
+
+#refresh position
+def timeset():
+ global playing
+ time_s.set_value(player.PositionGet())
+ return playing
+
+#simple/full display
+def expander(widget):
+ if exp.get_expanded() == False:
+ exp.set_label("Less")
+ else:
+ exp.set_label("More")
+
+#close event
+def delete_event(self, widget):
+ self.hide()
+ return True
+
+def destroy(widget):
+ gtk.main_quit()
+
+def key_release(widget, event):
+ global position
+ if event.keyval == gtk.keysyms.Escape:
+ position = window.get_position()
+ widget.hide()
+
+#click on the tray icon
+def tray_button(widget):
+ global position
+ if window.get_property('visible'):
+ position = window.get_position()
+ window.hide()
+ else:
+ window.move(position[0], position[1])
+ window.show()
+
+xml = gtk.glade.XML('dbus-vlc.glade')
+
+bt_close = xml.get_widget('close')
+bt_quit = xml.get_widget('quit')
+bt_file = xml.get_widget('ChooseFile')
+bt_next = xml.get_widget('next')
+bt_prev = xml.get_widget('prev')
+bt_stop = xml.get_widget('stop')
+bt_toggle = xml.get_widget('toggle')
+bt_mrl = xml.get_widget('AddMRL')
+l_artist = xml.get_widget('l_artist')
+l_title = xml.get_widget('l_title')
+e_mrl = xml.get_widget('mrl')
+window = xml.get_widget('window1')
+img_bt_toggle=xml.get_widget('image6')
+exp = xml.get_widget('expander2')
+expvbox = xml.get_widget('expandvbox')
+vlcicon = xml.get_widget('eventicon')
+vol = xml.get_widget('vol')
+time_s = xml.get_widget('time_s')
+time_l = xml.get_widget('time_l')
+
+window.connect('delete_event', delete_event)
+window.connect('destroy', destroy)
+window.connect('key_release_event', key_release)
+
+tray = gtk.status_icon_new_from_icon_name("vlc")
+tray.connect('activate', tray_button)
+
+def icon_clicked(widget, event):
+ update(0)
+
+bt_close.connect('clicked', destroy)
+bt_quit.connect('clicked', Quit)
+bt_mrl.connect('clicked', AddTrack)
+bt_toggle.connect('clicked', Pause)
+bt_next.connect('clicked', Next)
+bt_prev.connect('clicked', Prev)
+bt_stop.connect('clicked', Stop)
+exp.connect('activate', expander)
+vol.connect('change-value', volchange)
+vol.connect('scroll-event', volchange)
+time_s.connect('adjust-bounds', timechange)
+vlcicon.set_events(gtk.gdk.BUTTON_PRESS_MASK)
+vlcicon.connect('button_press_event', icon_clicked)
+time_s.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
+gobject.timeout_add( 2000, timeset)
+
+library = "/media/mp3"
+
+try:
+ os.chdir(library)
+ bt_file.set_current_folder(library)
+except:
+ print "edit this file to point to your media library"
+
+window.set_icon_name('vlc')
+window.set_title("VLC - D-Bus ctrl")
+window.show()
+
+try:
+ update(0)
+except:
+ 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()