Commit 133e47d1 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

Include sample D-Bus controller

parent 12225395
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.0.2 on Mon Nov 20 00:07:47 2006 by fun@zod-->
<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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Previous</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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Play/Pause</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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Next</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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Stop</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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Quit vlc</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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Close controller</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="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="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="width_request">185</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Select Da Directory !</property>
<property name="tooltip" translatable="yes">Choose a 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="relief">GTK_RELIEF_NONE</property>
<property name="tooltip" translatable="yes">Add MRL, or directory if empty</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="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>
</child>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="item">
<property name="width_request">185</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="xpad">8</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_name">vlc</property>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</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>
<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>
#!/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.
#
import dbus
import dbus.glib
import gtk
import gtk.glade
import egg.trayicon
import os
global position
def itemchange_handler(item):
l_item.set_text(item)
bus = dbus.SessionBus()
remote_object = bus.get_object("org.videolan.vlc", "/org/videolan/vlc")
interface = dbus.Interface(remote_object, "org.videolan.vlc")
try:
remote_object.connect_to_signal("ItemChange", itemchange_handler, dbus_interface="org.videolan.vlc")
except:
True
def AddMRL(widget):
mrl = e_mrl.get_text()
if mrl != None and mrl != "":
interface.AddMRL(mrl, True)
else:
mrl = bt_file.get_filename()
if mrl != None and mrl != "":
interface.AddMRL("directory://" + mrl, True)
def Next(widget):
interface.Next()
update(0)
def Prev(widget):
interface.Prev()
update(0)
def Stop(widget):
interface.Stop()
update(0)
def update(widget):
itemchange_handler(str(interface.GetPlayingItem()))
GetPlayStatus(0)
def GetPlayStatus(widget):
status = str(interface.GetPlayStatus())
if status == "playing":
img_bt_toggle.set_from_stock("gtk-media-pause", gtk.ICON_SIZE_SMALL_TOOLBAR)
else:
img_bt_toggle.set_from_stock("gtk-media-play", gtk.ICON_SIZE_SMALL_TOOLBAR)
def Quit(widget):
interface.Quit()
l_item.set_text("")
def TogglePause(widget):
if interface.TogglePause() == True:
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
else:
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR)
update(0)
def expander(widget):
if exp.get_label() == "More":
exp.set_label("Less")
else:
exp.set_label("More")
def delete_event(self, widget):
widget.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()
def tray_button(widget,event):
global position
if event.button == 1:
if window.get_property('visible'):
position = window.get_position()
window.hide()
else:
window.move(position[0], position[1])
window.show()
if event.button == 3:
menu.popup(None,None,None,event.button,event.time)
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_mrl = xml.get_widget('AddMRL')
bt_next = xml.get_widget('next')
bt_prev = xml.get_widget('prev')
bt_stop = xml.get_widget('stop')
bt_toggle = xml.get_widget('toggle')
l_item = xml.get_widget('item')
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')
menu = xml.get_widget('menu1')
menuitem = xml.get_widget('menuquit')
vlcicon = xml.get_widget('eventicon')
window.connect('delete_event', delete_event)
window.connect('destroy', destroy)
window.connect('key_release_event', key_release)
tray = egg.trayicon.TrayIcon("VLC")
eventbox = gtk.EventBox()
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 fuck():
return
def icon_clicked(widget, event):
update(0)
menu.attach_to_widget(eventbox, fuck)
bt_close.connect('clicked', destroy)
bt_quit.connect('clicked', Quit)
bt_mrl.connect('clicked', AddMRL)
bt_toggle.connect('clicked', TogglePause)
bt_next.connect('clicked', Next)
bt_prev.connect('clicked', Prev)
bt_stop.connect('clicked', Stop)
exp.connect('activate', expander)
menuitem.connect('activate', destroy)
vlcicon.set_events(gtk.gdk.BUTTON_PRESS_MASK)
vlcicon.connect('button_press_event', icon_clicked)
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
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