Commit 7930c1b3 authored by Rafaël Carré's avatar Rafaël Carré

Implement input position control

parent e7bcc680
<?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 12:55:24 2006 by fun@zod--> <!--Generated with glade3 3.0.2 on Tue Nov 21 15:28:41 2006 by fun@zod-->
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="window1"> <widget class="GtkWindow" id="window1">
<property name="resizable">False</property> <property name="resizable">False</property>
...@@ -132,7 +132,6 @@ ...@@ -132,7 +132,6 @@
<child> <child>
<widget class="GtkExpander" id="expander2"> <widget class="GtkExpander" id="expander2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="expanded">True</property>
<property name="tooltip" translatable="yes">Show more options</property> <property name="tooltip" translatable="yes">Show more options</property>
<child> <child>
<widget class="GtkVBox" id="vbox2"> <widget class="GtkVBox" id="vbox2">
...@@ -141,7 +140,7 @@ ...@@ -141,7 +140,7 @@
<widget class="GtkHBox" id="hbox2"> <widget class="GtkHBox" id="hbox2">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkHScale" id="times"> <widget class="GtkHScale" id="time_s">
<property name="width_request">107</property> <property name="width_request">107</property>
<property name="height_request">20</property> <property name="height_request">20</property>
<property name="visible">True</property> <property name="visible">True</property>
...@@ -151,31 +150,21 @@ ...@@ -151,31 +150,21 @@
<property name="value_pos">GTK_POS_RIGHT</property> <property name="value_pos">GTK_POS_RIGHT</property>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkLabel" id="timel">
<property name="width_request">30</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="label" translatable="yes">time</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<widget class="GtkSpinButton" id="vol"> <widget class="GtkSpinButton" id="vol">
<property name="width_request">42</property> <property name="width_request">42</property>
<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="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="wrap">True</property> <property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</widget> </widget>
......
...@@ -25,9 +25,11 @@ import dbus.glib ...@@ -25,9 +25,11 @@ import dbus.glib
import gtk import gtk
import gtk.glade import gtk.glade
import egg.trayicon import egg.trayicon
import gobject
import os import os
global position global position
global timer
def itemchange_handler(item): def itemchange_handler(item):
l_item.set_text(item) l_item.set_text(item)
...@@ -67,11 +69,14 @@ def update(widget): ...@@ -67,11 +69,14 @@ def update(widget):
GetPlayStatus(0) GetPlayStatus(0)
def GetPlayStatus(widget): def GetPlayStatus(widget):
global timer
status = str(interface.GetPlayStatus()) status = str(interface.GetPlayStatus())
if status == "playing": if status == "playing":
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)
timer = gobject.timeout_add( 2000, timeset)
else: else:
img_bt_toggle.set_from_stock("gtk-media-play", gtk.ICON_SIZE_SMALL_TOOLBAR) img_bt_toggle.set_from_stock("gtk-media-play", gtk.ICON_SIZE_SMALL_TOOLBAR)
gobject.timeout_remove(timer)
def Quit(widget): def Quit(widget):
interface.Quit() interface.Quit()
...@@ -84,8 +89,15 @@ def TogglePause(widget): ...@@ -84,8 +89,15 @@ def TogglePause(widget):
img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR) img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR)
update(0) update(0)
def volchange(widget): def volchange(widget, data):
interface.VolumeSet(vol.get_value_as_int()) interface.VolumeSet(vol.get_value_as_int(), reply_handler=(lambda: None), error_handler=(lambda: None))
def timechange(widget, x=None, y=None):
interface.PositionSet(time_s.get_value() * 10, reply_handler=(lambda: None), error_handler=(lambda: None))
def timeset():
time_s.set_value(interface.PositionGet() / 10)
return True
def expander(widget): def expander(widget):
if exp.get_expanded() == False: if exp.get_expanded() == False:
...@@ -138,6 +150,8 @@ menu = xml.get_widget('menu1') ...@@ -138,6 +150,8 @@ menu = xml.get_widget('menu1')
menuitem = xml.get_widget('menuquit') 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_l = xml.get_widget('time_l')
window.connect('delete_event', delete_event) window.connect('delete_event', delete_event)
window.connect('destroy', destroy) window.connect('destroy', destroy)
...@@ -153,13 +167,10 @@ eventbox.add(image) ...@@ -153,13 +167,10 @@ eventbox.add(image)
image.set_from_icon_name("vlc", gtk.ICON_SIZE_MENU) image.set_from_icon_name("vlc", gtk.ICON_SIZE_MENU)
tray.show_all() tray.show_all()
def fuck():
return
def icon_clicked(widget, event): def icon_clicked(widget, event):
update(0) update(0)
menu.attach_to_widget(eventbox, fuck) 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)
...@@ -172,7 +183,11 @@ exp.connect('activate', expander) ...@@ -172,7 +183,11 @@ exp.connect('activate', expander)
menuitem.connect('activate', destroy) menuitem.connect('activate', destroy)
vlcicon.set_events(gtk.gdk.BUTTON_PRESS_MASK) vlcicon.set_events(gtk.gdk.BUTTON_PRESS_MASK)
vlcicon.connect('button_press_event', icon_clicked) vlcicon.connect('button_press_event', icon_clicked)
vol.connect('value-changed', volchange) vol.connect('change-value', volchange)
vol.connect('scroll-event', volchange)
time_s.connect('adjust-bounds', timechange)
time_s.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
library = "/media/mp3" library = "/media/mp3"
......
...@@ -110,8 +110,63 @@ DBUS_METHOD( Quit ) ...@@ -110,8 +110,63 @@ DBUS_METHOD( Quit )
REPLY_SEND; REPLY_SEND;
} }
DBUS_METHOD( PositionGet )
{ /* returns position as an int in the range [0;1000] */
REPLY_INIT;
OUT_ARGUMENTS;
vlc_value_t position;
dbus_uint16_t i_pos;
playlist_t *p_playlist = pl_Yield( ((vlc_object_t*) p_this) );
input_thread_t *p_input = p_playlist->p_input;
if( !p_input )
i_pos = 0;
else
{
var_Get( p_input, "position", &position );
i_pos = position.f_float * 1000 ;
}
ADD_UINT16( &i_pos );
pl_Release( ((vlc_object_t*) p_this) );
REPLY_SEND;
}
DBUS_METHOD( PositionSet )
{ /* set position from an int in the range [0;1000] */
REPLY_INIT;
vlc_value_t position;
dbus_uint16_t i_pos;
DBusError error;
dbus_error_init( &error );
dbus_message_get_args( p_from, &error,
DBUS_TYPE_UINT16, &i_pos,
DBUS_TYPE_INVALID );
if( dbus_error_is_set( &error ) )
{
msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s\n",
error.message );
dbus_error_free( &error );
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
playlist_t *p_playlist = pl_Yield( ((vlc_object_t*) p_this) );
input_thread_t *p_input = p_playlist->p_input;
if( p_input )
{
position.f_float = ((float)i_pos) / 1000;
var_Set( p_input, "position", position );
}
pl_Release( ((vlc_object_t*) p_this) );
REPLY_SEND;
}
DBUS_METHOD( VolumeGet ) DBUS_METHOD( VolumeGet )
{ /* get volume in percentage */ { /* returns volume in percentage */
REPLY_INIT; REPLY_INIT;
OUT_ARGUMENTS; OUT_ARGUMENTS;
dbus_uint16_t i_vol; dbus_uint16_t i_vol;
...@@ -332,6 +387,8 @@ DBUS_METHOD( handle_messages ) ...@@ -332,6 +387,8 @@ DBUS_METHOD( handle_messages )
METHOD_FUNC( "Stop", Stop ); METHOD_FUNC( "Stop", Stop );
METHOD_FUNC( "VolumeSet", VolumeSet ); METHOD_FUNC( "VolumeSet", VolumeSet );
METHOD_FUNC( "VolumeGet", VolumeGet ); METHOD_FUNC( "VolumeGet", VolumeGet );
METHOD_FUNC( "PositionSet", PositionSet );
METHOD_FUNC( "PositionGet", PositionGet );
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
#define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b ) #define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b )
#define ADD_UINT32( i ) DBUS_ADD( DBUS_TYPE_UINT32, i ) #define ADD_UINT32( i ) DBUS_ADD( DBUS_TYPE_UINT32, i )
#define ADD_UINT16( i ) DBUS_ADD( DBUS_TYPE_UINT16, i ) #define ADD_UINT16( i ) DBUS_ADD( DBUS_TYPE_UINT16, i )
#define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b )
/* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */ /* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */
...@@ -110,6 +111,12 @@ const char* psz_introspection_xml_data = ...@@ -110,6 +111,12 @@ const char* psz_introspection_xml_data =
" <method name=\"VolumeGet\">\n" " <method name=\"VolumeGet\">\n"
" <arg type=\"q\" direction=\"out\" />\n" " <arg type=\"q\" direction=\"out\" />\n"
" </method>\n" " </method>\n"
" <method name=\"PositionSet\">\n"
" <arg type=\"q\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"PositionGet\">\n"
" <arg type=\"q\" direction=\"out\" />\n"
" </method>\n"
" </interface>\n" " </interface>\n"
"</node>\n" "</node>\n"
; ;
......
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