Commit 8808f2f0 authored by Rafaël Carré's avatar Rafaël Carré

Implement Volume control

parent 4d243c1d
<?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 Mon Nov 20 00:07:47 2006 by fun@zod--> <!--Generated with glade3 3.0.2 on Tue Nov 21 12:55:24 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,10 +132,54 @@ ...@@ -132,10 +132,54 @@
<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">
<property name="visible">True</property> <property name="visible">True</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<widget class="GtkHScale" id="times">
<property name="width_request">107</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
<property name="digits">-1</property>
<property name="draw_value">False</property>
<property name="value_pos">GTK_POS_RIGHT</property>
</widget>
</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>
<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="adjustment">100 0 100 1 10 10</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
<child> <child>
<widget class="GtkHBox" id="hbox4"> <widget class="GtkHBox" id="hbox4">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -196,6 +240,9 @@ ...@@ -196,6 +240,9 @@
</packing> </packing>
</child> </child>
</widget> </widget>
<packing>
<property name="position">1</property>
</packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox3"> <widget class="GtkHBox" id="hbox3">
...@@ -230,7 +277,7 @@ ...@@ -230,7 +277,7 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</widget> </widget>
......
...@@ -63,6 +63,7 @@ def Stop(widget): ...@@ -63,6 +63,7 @@ def Stop(widget):
def update(widget): def update(widget):
itemchange_handler(str(interface.GetPlayingItem())) itemchange_handler(str(interface.GetPlayingItem()))
vol.set_value(interface.VolumeGet())
GetPlayStatus(0) GetPlayStatus(0)
def GetPlayStatus(widget): def GetPlayStatus(widget):
...@@ -83,8 +84,11 @@ def TogglePause(widget): ...@@ -83,8 +84,11 @@ 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):
interface.VolumeSet(vol.get_value_as_int())
def expander(widget): def expander(widget):
if exp.get_label() == "More": if exp.get_expanded() == False:
exp.set_label("Less") exp.set_label("Less")
else: else:
exp.set_label("More") exp.set_label("More")
...@@ -133,7 +137,7 @@ expvbox = xml.get_widget('expandvbox') ...@@ -133,7 +137,7 @@ expvbox = xml.get_widget('expandvbox')
menu = xml.get_widget('menu1') 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')
window.connect('delete_event', delete_event) window.connect('delete_event', delete_event)
window.connect('destroy', destroy) window.connect('destroy', destroy)
...@@ -168,6 +172,7 @@ exp.connect('activate', expander) ...@@ -168,6 +172,7 @@ 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)
library = "/media/mp3" library = "/media/mp3"
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "dbus.h" #include "dbus.h"
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include <vlc_meta.h> #include <vlc_meta.h>
#include <vlc_input.h> #include <vlc_input.h>
...@@ -109,6 +110,44 @@ DBUS_METHOD( Quit ) ...@@ -109,6 +110,44 @@ DBUS_METHOD( Quit )
REPLY_SEND; REPLY_SEND;
} }
DBUS_METHOD( VolumeGet )
{ /* get volume in percentage */
REPLY_INIT;
OUT_ARGUMENTS;
dbus_uint16_t i_vol;
/* 2nd argument of aout_VolumeGet is uint16 */
aout_VolumeGet( (vlc_object_t*) p_this, &i_vol );
i_vol = ( 100 * i_vol ) / AOUT_VOLUME_MAX;
ADD_UINT16( &i_vol );
REPLY_SEND;
}
DBUS_METHOD( VolumeSet )
{ /* set volume in percentage */
REPLY_INIT;
DBusError error;
dbus_error_init( &error );
dbus_uint16_t i_vol;
dbus_message_get_args( p_from, &error,
DBUS_TYPE_UINT16, &i_vol,
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;
}
aout_VolumeSet( (vlc_object_t*) p_this, ( AOUT_VOLUME_MAX / 100 ) * i_vol );
REPLY_SEND;
}
DBUS_METHOD( Next ) DBUS_METHOD( Next )
{ /* next playlist item */ { /* next playlist item */
REPLY_INIT; REPLY_INIT;
...@@ -291,6 +330,8 @@ DBUS_METHOD( handle_messages ) ...@@ -291,6 +330,8 @@ DBUS_METHOD( handle_messages )
METHOD_FUNC( "Next", Next ); METHOD_FUNC( "Next", Next );
METHOD_FUNC( "Quit", Quit ); METHOD_FUNC( "Quit", Quit );
METHOD_FUNC( "Stop", Stop ); METHOD_FUNC( "Stop", Stop );
METHOD_FUNC( "VolumeSet", VolumeSet );
METHOD_FUNC( "VolumeGet", VolumeGet );
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s ) #define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s )
#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 )
/* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */ /* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */
...@@ -103,6 +104,12 @@ const char* psz_introspection_xml_data = ...@@ -103,6 +104,12 @@ const char* psz_introspection_xml_data =
" </method>\n" " </method>\n"
" <method name=\"Stop\">\n" " <method name=\"Stop\">\n"
" </method>\n" " </method>\n"
" <method name=\"VolumeSet\">\n"
" <arg type=\"q\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"VolumeGet\">\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