aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-01-28 18:26:00 +0000
committerConor Curran <conor.curran@canonical.com>2010-01-28 18:26:00 +0000
commit93ae69dcd77bc81c3146c2321eb12226cd7704df (patch)
tree0aacaafacbc063d32b1e04477daa2e3599433de2
parent7ec9f75f2a0cdf13a3728c18a33dca9e327e2bf2 (diff)
downloadayatana-indicator-sound-93ae69dcd77bc81c3146c2321eb12226cd7704df.tar.gz
ayatana-indicator-sound-93ae69dcd77bc81c3146c2321eb12226cd7704df.tar.bz2
ayatana-indicator-sound-93ae69dcd77bc81c3146c2321eb12226cd7704df.zip
slider event detection hooked up, method also defined on server side but there is a compilation problem which for the life of me i cannot see what i'm doing wrong
-rw-r--r--src/Makefile.am14
-rw-r--r--src/common-defs.h1
-rw-r--r--src/indicator-sound.c25
-rw-r--r--src/sound-service-dbus.c19
-rw-r--r--src/sound-service-dbus.h3
-rw-r--r--src/sound-service.c21
-rw-r--r--src/sound-service.h12
-rw-r--r--src/sound-service.list1
-rw-r--r--src/sound-service.xml10
9 files changed, 77 insertions, 29 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8488e50..916e491 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,13 +29,6 @@ sound-service-client.h: $(srcdir)/sound-service.xml
--output=sound-service-client.h \
$(srcdir)/sound-service.xml
-sound-service-server.h: $(srcdir)/sound-service.xml
- dbus-binding-tool \
- --prefix=_sound_service_server \
- --mode=glib-server \
- --output=sound-service-server.h \
- $(srcdir)/sound-service.xml
-
sound-service-marshal.h: $(srcdir)/sound-service.list
glib-genmarshal --header \
--prefix=_sound_service_marshal $(srcdir)/sound-service.list \
@@ -62,6 +55,13 @@ indicator_sound_service_SOURCES = \
indicator_sound_service_CFLAGS = $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror
indicator_sound_service_LDADD = $(SOUNDSERVICE_LIBS) $(GCONF_LIBS)
+sound-service-server.h: $(srcdir)/sound-service.xml
+ dbus-binding-tool \
+ --prefix=_sound_service_server \
+ --mode=glib-server \
+ --output=sound-service-server.h \
+ $(srcdir)/sound-service.xml
+
###############
# Other Stuff
###############
diff --git a/src/common-defs.h b/src/common-defs.h
index 3003bbb..0421bd6 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -1,4 +1,5 @@
/* constants used for signals on the dbus. This file is shared between client and server implementation */
#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
+#define METHOD_SET_SINK_VOLUME "SetSinkVolume"
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 88202c2..0f6cce9 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -95,6 +95,8 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE);
static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata);
static void catch_signal(DBusGProxy * proxy, gint sink_index, gboolean value, gpointer userdata);
+static void slider_event_detected(GtkRange *range, gpointer user_data);
+static gboolean slider_value_changed_event_cb(GtkRange *range, GtkScrollType scroll, double value, gpointer user_data);
static void
indicator_sound_class_init (IndicatorSoundClass *klass)
@@ -164,10 +166,12 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u
static void catch_signal (DBusGProxy * proxy, gint sink_index, gboolean value, gpointer userdata)
{
- g_debug("signal caught - i don't believe it ! with index %i and value %i", sink_index, value);
+ g_debug("signal caught - I don't believe it ! with index %i and value %i", sink_index, value);
}
+
+
static void
indicator_sound_dispose (GObject *object)
{
@@ -215,24 +219,29 @@ get_menu (IndicatorObject * io)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), get_slider());
gtk_widget_show_all(volume_slider);
-/* GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); */
-/* GtkRange* range = (GtkRange*)slider;*/
-/* gdouble value = gtk_range_get_value(range);*/
-/* g_debug("print out the range %d", (int)value);*/
return menu;
}
-static void slider_event_detected( GtkWidget *item,
- GtkUpdateType policy )
+static void slider_event_detected(GtkRange *range, gpointer user_data)
{
g_debug("slider event detected");
}
+static gboolean slider_value_changed_event_cb(GtkRange *range, GtkScrollType scroll, double value, gpointer user_data)
+{
+ g_debug("slider_change_of_value - with value: %f", value);
+ return FALSE;
+}
+
static GtkWidget* get_slider()
{
volume_slider = ido_scale_menu_item_new_with_range ("Volume", 0, 100, 1);
- g_signal_connect(G_OBJECT(volume_slider), "slider-event", G_CALLBACK(slider_event_detected), GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
+ GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
+ GtkRange* range = (GtkRange*)slider;
+ g_signal_connect(G_OBJECT(range), "value-changed", G_CALLBACK(slider_event_detected), NULL);
+ g_signal_connect(G_OBJECT(range), "change-value", G_CALLBACK(slider_value_changed_event_cb), NULL);
+
return volume_slider;
}
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 4c3b3ca..88ddd22 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -25,7 +25,7 @@
#include <dbus/dbus-glib.h>
#include "dbus-shared-names.h"
#include "sound-service-dbus.h"
-#include "sound-service-client.h"
+//#include "sound-service-client.h"
#include "sound-service-server.h"
#include "common-defs.h"
#include "sound-service-marshal.h"
@@ -54,7 +54,7 @@ static void sound_service_dbus_class_init (SoundServiceDbusClass *klass);
static void sound_service_dbus_init (SoundServiceDbus *self);
static void sound_service_dbus_dispose (GObject *object);
static void sound_service_dbus_finalize (GObject *object);
-
+gboolean sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror);
/* GObject Boilerplate */
G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
@@ -82,11 +82,24 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass)
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
}
+//void sound_service_dbus_sink_volume_changed (SoundServiceDbus* obj, gint volume);
+
+gboolean sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror)
+{
+ g_debug("in the set sink volume method in the sound service dbus! Holy Fuck with volume_percent of %i", volume_percent);
+/* if (!IS_SOUND_SERVICE_DBUS(service)) {*/
+/* g_warning("NO BAD EVIL!");*/
+/* return FALSE;*/
+/* }*/
+ return TRUE;
+}
+
/**
Utility methods to emit signals from the service into the ether.
**/
-void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gint sink_index, gboolean value){
+void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gint sink_index, gboolean value)
+{
/* g_assert((num < LAST_SIGNAL) && (num >= 0));*/
g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with sink_index %i and value %i", sink_index, value);
g_signal_emit(obj,
diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h
index 83f9c77..c8a36a7 100644
--- a/src/sound-service-dbus.h
+++ b/src/sound-service-dbus.h
@@ -59,10 +59,9 @@ struct _SoundServiceDbusClass {
GType sound_service_dbus_get_type (void) G_GNUC_CONST;
-// Utility methods to get the messages across the into the static function space of sound-service-dbus
+// Utility methods to get the messages across into the sound-service-dbus
void sound_service_dbus_sink_input_while_muted (SoundServiceDbus* obj, gint sink_index, gboolean value);
-//void sound_service_dbus_sink_volume_changed (SoundServiceDbus* obj, gint volume);
G_END_DECLS
diff --git a/src/sound-service.c b/src/sound-service.c
index cb21e71..27a8248 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -30,6 +30,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
/**********************************************************************************************************************/
static void context_get_sink_info_by_index_callback(pa_context *c, const pa_sink_info *sink, int eol, void *userdata){
if (eol > 0) {
+ // TODO follow this pattern for all other async call-backs involving lists - safest/most accurate approach.
+ if (pa_context_errno(c) == PA_ERR_NOENTITY)
+ return;
+ g_debug(_("Sink info callback failure"));
return;
}
else{
@@ -51,6 +55,7 @@ static void context_success_callback(pa_context *c, int success, void *userdata)
}
// TODO we are not handling multiple sinks appropriately
+// Refactor with Colin and Lennarts' approaches in mind.
static void retrieve_complete_sink_list(pa_context *c, const pa_sink_info *sink, int eol, void *userdata){
if(eol > 0){
// TODO apparently never returns 0 sinks - Tested and it appears this assumption/prediction is correct.
@@ -58,7 +63,7 @@ static void retrieve_complete_sink_list(pa_context *c, const pa_sink_info *sink,
// Some fuzzy reasoning might be needed.
if(sink_list->len == 1){
pa_sink_info* only_sink = (pa_sink_info*)g_ptr_array_index(sink_list, 0);
- //TODO: sink is not null but its module is the null-module-sink!
+ // TODO: sink is not null but its module is the null-module-sink!
// For now taking the easy route string compare on the name and the active port
// needs more testing
int value = g_strcasecmp(only_sink->name, " auto_null ");
@@ -156,6 +161,12 @@ static void context_state_callback(pa_context *c, void *userdata) {
}
}
+/*static void set_volume(gint sink_index, gint volume_percent)*/
+/*{*/
+/* g_debug("set_volume in the sound-service");*/
+/*}*/
+
+
/**********************************************************************************************************************/
// Init functions (GTK and DBUS)
/**********************************************************************************************************************/
@@ -202,10 +213,12 @@ service_shutdown (IndicatorService *service, gpointer user_data)
/* g_debug("Service shutdown");*/
/* if (pulse_context){*/
/* pa_context_unref(pulse_context);*/
+/* pulse_context = NULL;*/
/* }*/
/* g_ptr_array_free(sink_list, TRUE);*/
/* pa_glib_mainloop_free(pa_main_loop);*/
-/* g_main_loop_quit(mainloop);*/
+/* pa_main_loop = NULL;*/
+/* g_main_loop_quit(mainloop);*/
}
return;
}
@@ -239,18 +252,16 @@ main (int argc, char ** argv)
DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT);
dbusmenu_server_set_root(server, root_menuitem);
+ // TODO refactor into separate function
pa_main_loop = pa_glib_mainloop_new(g_main_context_default());
g_assert(pa_main_loop);
pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound");
g_assert(pulse_context);
-
// Establish event callback registration
pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL);
- //rebuild_sound_menu (root_menuitem, dbus_interface);
-
// Run the loop
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
diff --git a/src/sound-service.h b/src/sound-service.h
index 0687ad0..7b8f758 100644
--- a/src/sound-service.h
+++ b/src/sound-service.h
@@ -62,6 +62,18 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
static gboolean all_muted = FALSE;
static void set_global_mute();
+//static void set_volume(gint sink_index, gint volume_percent);
+
+typedef struct {
+ gchar* name;
+ gchar* description;
+ gchar* icon_name;
+ gint index;
+ gint device_index;
+ pa_cvolume volume;
+ pa_channel_map channel_map;
+ gboolean mute;
+} device_info;
// ENTRY AND EXIT POINTS
void service_shutdown(IndicatorService * service, gpointer user_data);
diff --git a/src/sound-service.list b/src/sound-service.list
index 749780f..ee376e9 100644
--- a/src/sound-service.list
+++ b/src/sound-service.list
@@ -1 +1,2 @@
VOID:INT,BOOLEAN
+
diff --git a/src/sound-service.xml b/src/sound-service.xml
index ad1a626..08c6ab5 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -1,13 +1,15 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/ayatana/indicator/sound">
<interface name="org.ayatana.indicator.sound">
-<!-- <method name = "sink_volume">-->
-<!-- <arg type='i' name='index' direction="in"/>-->
-<!-- <arg type='i' name='volume' direction="out"/>-->
+<!-- <method name = "SetSinkVolume">-->
+<!-- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_set_sink_volume"/>-->
+<!-- <arg type='u' name='volume_percent' direction="in"/>-->
<!-- </method>-->
+<!-- Will need to hook up another signal which monitors for volume change
+Our respective UI element should listen to this and therefore will be updated with accurate setting-->
<!-- Triggered when a sink is muted but the input has been sent to that sink -->
<signal name="SinkInputWhileMuted">
- <arg name="sink_index" type="i" direction="out"/>
+ <arg name="sink_index" type="x" direction="out"/>
<arg name="mute_value" type="b" direction="out"/>
</signal>
</interface>