aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-01-10 20:25:36 +0000
committerConor Curran <conor.curran@canonical.com>2011-01-10 20:25:36 +0000
commit82425f25064d97b0feb2c0c5cdc839558bf5f51f (patch)
treead51e43395b5abea04a0ffd9a3e9f35200699853
parent5f7a9d979b49674604160ce4baac403c79832470 (diff)
downloadayatana-indicator-sound-82425f25064d97b0feb2c0c5cdc839558bf5f51f.tar.gz
ayatana-indicator-sound-82425f25064d97b0feb2c0c5cdc839558bf5f51f.tar.bz2
ayatana-indicator-sound-82425f25064d97b0feb2c0c5cdc839558bf5f51f.zip
getting there
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/indicator-sound.c213
-rw-r--r--src/title-widget.c11
-rw-r--r--src/transport-widget.c20
-rw-r--r--src/volume-widget.c22
6 files changed, 155 insertions, 115 deletions
diff --git a/configure.ac b/configure.ac
index 9a08077..a6522ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
###########################
GTK_REQUIRED_VERSION=2.12
-INDICATOR_REQUIRED_VERSION=0.3.6
+INDICATOR_REQUIRED_VERSION=0.3.15
DBUSMENUGTK_REQUIRED_VERSION=0.3.9
POLKIT_REQUIRED_VERSION=0.92
PULSE_AUDIO_REQUIRED_VERSION=0.9.19
diff --git a/src/Makefile.am b/src/Makefile.am
index b45da22..0443029 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -126,8 +126,6 @@ EXTRA_DIST = \
#######################
BUILT_SOURCES = \
music_bridge_vala.stamp \
- sound-service-client.h \
- sound-service-server.h \
$(music_bridge_APIFILES) \
gen-sound-service.xml.h \
gen-sound-service.xml.c \
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 53bb366..992dfdd 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -39,7 +39,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dbus-shared-names.h"
-#include "gen-sound-service-xml.h"
+#include "gen-sound-service.xml.h"
#include "common-defs.h"
typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate;
@@ -85,22 +85,35 @@ static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem *
static GDBusNodeInfo *node_info = NULL;
static GDBusInterfaceInfo *interface_info = NULL;
-
+static void create_connection_to_service (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data);
static void connection_changed (IndicatorServiceManager * sm,
gboolean connected,
gpointer userdata);
-
static void g_signal_cb ( GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
- gpointer user_data)
+ gpointer user_data);
+
+static void react_to_signal_sink_input_while_muted (gboolean value,
+ IndicatorSound* self);
+static void react_to_signal_sink_mute_update (gboolean value,
+ IndicatorSound* self);
+static void react_to_signal_sink_availability_update (gboolean value,
+ IndicatorSound* self);
+static void fetch_state ( IndicatorSound* self );
+
+static void get_sink_mute_cb ( GObject *object,
+ GAsyncResult *res,
+ gpointer user_data );
+
+static void get_sink_availability_cb ( GObject *object,
+ GAsyncResult *res,
+ gpointer user_data );
+
-static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata);
-static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata);
-static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata);
-static void fetch_mute_value_from_dbus();
-static void fetch_sink_availability_from_dbus(IndicatorSound* self);
/****Volume States 'members' ***/
static void update_state(const gint state);
@@ -352,8 +365,7 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent,
newitem,
menu_volume_item,
parent);
- fetch_mute_value_from_dbus();
- fetch_sink_availability_from_dbus(INDICATOR_SOUND (io));
+ fetch_state(INDICATOR_SOUND (io));
return TRUE;
}
@@ -365,7 +377,8 @@ connection_changed (IndicatorServiceManager * sm,
{
IndicatorSound* indicator = INDICATOR_SOUND(user_data);
g_return_if_fail ( IS_INDICATOR_SOUND (indicator) );
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE (indicator);
+ GError *error = NULL;
if (connected == FALSE){
return;
@@ -374,9 +387,11 @@ connection_changed (IndicatorServiceManager * sm,
// for 5 seconds and then if no connection message
// is received put the state at 'sink not available'
}
- // If we connection is back on and the proxy is not null
- // we don't need to anything gdbus takes care of the rest - bless.
- if (priv->dbus_proxy!= NULL){
+ // If the proxy is not null and connected is true => its a reconnect,
+ // we don't need to anything, gdbus takes care of the rest - bless.
+ // just fetch the state.
+ if (priv->dbus_proxy != NULL){
+ fetch_state (indicator);
return;
}
@@ -417,7 +432,7 @@ static void create_connection_to_service (GObject *source_object,
IndicatorSound *self = INDICATOR_SOUND(user_data);
GError *error = NULL;
- g_return_if_fail(self != NULL);
+ g_return_if_fail( IS_INDICATOR_SOUND(self) );
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
@@ -428,12 +443,104 @@ static void create_connection_to_service (GObject *source_object,
g_error_free(error);
return;
}
+
+ g_signal_connect(priv->dbus_proxy, "g-signal", G_CALLBACK(g_signal_cb), self);
+ fetch_state (self);
+}
- g_signal_connect(self->dbus_proxy, "g-signal", G_CALLBACK(g_signal), self);
+static void fetch_state (IndicatorSound* self)
+{
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+
+ g_dbus_proxy_call ( priv->dbus_proxy,
+ "GetSinkMute",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)get_sink_mute_cb,
+ self);
+
+ g_dbus_proxy_call ( priv->dbus_proxy,
+ "GetSinkAvailability",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)get_sink_availability_cb,
+ self);
+}
+
+static void get_sink_availability_cb ( GObject *object,
+ GAsyncResult *res,
+ gpointer user_data )
+{
+ IndicatorSound* self = INDICATOR_SOUND(user_data);
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+ GVariant *result, *value;
+ GError *error = NULL;
+ gboolean is_available;
+
+ result = g_dbus_proxy_call_finish ( priv->dbus_proxy,
+ res,
+ &error );
+
+ if (error != NULL) {
+ g_debug("get_sink_availability call failed: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ value = g_variant_get_child_value(result, 0);
+ is_available = g_variant_get_boolean(value);
+
+ if (is_available == FALSE) {
+ update_state(STATE_SINKS_NONE);
+ }
+
+ if(priv->volume_widget != NULL){
+ GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
+ gtk_widget_set_sensitive(slider_widget, is_available);
+ }
+
+ g_variant_unref(value);
+ g_variant_unref(result);
}
+static void get_sink_mute_cb ( GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ IndicatorSound* self = INDICATOR_SOUND(user_data);
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+
+ GVariant *result, *value;
+ GError *error = NULL;
+ gboolean is_muted;
+
+ result = g_dbus_proxy_call_finish ( priv->dbus_proxy,
+ res,
+ &error );
+
+ if (error != NULL) {
+ g_debug("get_sink_mute call failed: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ value = g_variant_get_child_value(result, 0);
+ is_muted = g_variant_get_boolean(value);
+
+ if ( is_muted == TRUE ){
+ update_state(STATE_MUTED);
+ }
+
+ g_variant_unref(value);
+ g_variant_unref(result);
+}
+
/*
Prepare states Array.
*/
@@ -581,66 +688,9 @@ reset_mute_blocking_animation()
}
-/*******************************************************************/
-//DBus method handlers
-/*******************************************************************/
-static void
-fetch_sink_availability_from_dbus(IndicatorSound* self)
-{
- g_return_if_fail(IS_INDICATOR_SOUND(self));
-
- GError * error = NULL;
- gboolean * available_input;
- available_input = g_new0(gboolean, 1);
- com_canonical_indicators_sound_get_sink_availability(sound_dbus_proxy, available_input, &error);
- if (error != NULL) {
- g_warning("Unable to fetch AVAILABILITY at indicator start up: %s", error->message);
- g_error_free(error);
- g_free(available_input);
- return;
- }
-
- device_available = *available_input;
- if (device_available == FALSE) {
- update_state(STATE_SINKS_NONE);
- //g_debug("NO DEVICE AVAILABLE");
- }
-
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
-
- if(priv->volume_widget != NULL){
- GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
- gtk_widget_set_sensitive(slider_widget, device_available);
- }
-
- g_free(available_input);
- //g_debug("IndicatorSound::fetch_sink_availability_from_dbus ->%i", device_available);
-}
-
-
-static void
-fetch_mute_value_from_dbus()
-{
- GError * error = NULL;
- gboolean *mute_input;
- mute_input = g_new0(gboolean, 1);
- com_canonical_indicators_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error);
- if (error != NULL) {
- g_warning("Unable to fetch MUTE at indicator start up: %s", error->message);
- g_error_free(error);
- g_free(mute_input);
- return;
- }
- initial_mute = *mute_input;
- if (initial_mute == TRUE){
- update_state(STATE_MUTED);
- }
- g_free(mute_input);
- //g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute);
-}
/*******************************************************************/
-// Signal reactions
+// DBUS Signal reactions
/*******************************************************************/
static void g_signal_cb ( GDBusProxy *proxy,
const gchar *sender_name,
@@ -654,18 +704,18 @@ static void g_signal_cb ( GDBusProxy *proxy,
g_return_if_fail ( IS_INDICATOR_SOUND(self) );
if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE) == 0){
- react_signal_sink_availability_update ( input, self );
+ react_to_signal_sink_availability_update ( input, self );
}
else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE) == 0){
- react_signal_sink_mute_update ( input, self );
+ react_to_signal_sink_mute_update ( input, self );
}
else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED) == 0){
- react_signal_sink_input_while_muted ( input, self );
+ react_to_signal_sink_input_while_muted ( input, self );
}
}
static void
-react_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self)
+react_to_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self)
{
//g_debug("signal caught - sink input while muted with value %i", block_value);
if (block_value == 1 && blocked_id == 0 && animation_id == 0 && blocked_animation_list != NULL) {
@@ -680,7 +730,7 @@ react_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self)
UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.
*/
static void
-react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self)
+react_to_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self)
{
if (mute_value == TRUE && device_available == TRUE) {
update_state(STATE_MUTED);
@@ -688,7 +738,6 @@ react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self)
reset_mute_blocking_animation();
}
//g_debug("signal caught - sink mute update with mute value: %i", mute_value);
- g_return_if_fail(IS_INDICATOR_SOUND(userdata));
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
if(priv->volume_widget == NULL){
@@ -700,7 +749,7 @@ react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self)
static void
-react_signal_sink_availability_update(gboolean available_value, IndicatorSound* self)
+react_to_signal_sink_availability_update(gboolean available_value, IndicatorSound* self)
{
device_available = available_value;
if (device_available == FALSE) {
diff --git a/src/title-widget.c b/src/title-widget.c
index 08b4b81..1318ce1 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -138,12 +138,11 @@ title_widget_button_press_event (GtkWidget *menuitem,
//g_debug("TitleWidget::menu_press_event");
TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);
- GValue value = {0};
- g_value_init(&value, G_TYPE_BOOLEAN);
-
- g_value_set_boolean(&value, TRUE);
- dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
-
+ GVariant* new_title_event = g_variant_new_boolean(TRUE);
+ dbusmenu_menuitem_handle_event (priv->twin_item,
+ "Title menu event",
+ new_title_event,
+ 0);
return FALSE;
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index d7f4b75..9b45734 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -112,8 +112,8 @@ static gboolean transport_widget_leave_notify_event (GtkWidget *menuitem
GdkEventCrossing *event);
static void transport_widget_property_update ( DbusmenuMenuitem* item,
gchar * property,
- GValue * value,
- gpointer userdata );
+ GVariant * value,
+ gpointer userdata );
static void transport_widget_menu_hidden ( GtkWidget *menu,
TransportWidget *transport);
static void transport_widget_notify ( GObject *item,
@@ -344,13 +344,11 @@ transport_widget_button_release_event (GtkWidget *menuitem,
TransportWidgetEvent result = transport_widget_determine_button_event ( transport,
event );
if(result != TRANSPORT_NADA){
- GValue value = {0};
- g_value_init(&value, G_TYPE_INT);
//g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
- g_value_set_int(&value, (int)result);
+ GVariant* new_transport_state = g_variant_new_int32 ((int)result);
dbusmenu_menuitem_handle_event ( priv->twin_item,
"Transport state change",
- &value,
+ new_transport_state,
0 );
}
transport_widget_react_to_button_release ( transport,
@@ -402,13 +400,11 @@ transport_widget_react_to_key_release_event ( TransportWidget* transport,
{
if(transport_event != TRANSPORT_NADA){
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
- GValue value = {0};
- g_value_init(&value, G_TYPE_INT);
//g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
- g_value_set_int(&value, (int)transport_event);
+ GVariant* new_transport_event = g_variant_new_int32((int)transport_event);
dbusmenu_menuitem_handle_event ( priv->twin_item,
"Transport state change",
- &value,
+ new_transport_event,
0 );
}
transport_widget_react_to_button_release ( transport,
@@ -1700,7 +1696,7 @@ transport_widget_set_twin_item(TransportWidget* self,
**/
static void
transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
- GValue* value, gpointer userdata)
+ GVariant* value, gpointer userdata)
{
//g_debug("transport_widget_update_state - with property %s", property);
TransportWidget* bar = (TransportWidget*)userdata;
@@ -1708,7 +1704,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0)
{
- int update_value = g_value_get_int(value);
+ int update_value = g_variant_get_int32(value);
//g_debug("transport_widget_update_state - with value %i", update_value);
transport_widget_toggle_play_pause(bar, (TransportWidgetState)update_value);
}
diff --git a/src/volume-widget.c b/src/volume-widget.c
index c37f9c7..6fd4632 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -48,7 +48,7 @@ static void volume_widget_finalize (GObject *object);
static void volume_widget_set_twin_item( VolumeWidget* self,
DbusmenuMenuitem* twin_item);
static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
- GValue* value, gpointer userdata);
+ GVariant* value, gpointer userdata );
static gboolean volume_widget_change_value_cb (GtkRange *range,
GtkScrollType scroll,
@@ -122,8 +122,8 @@ volume_widget_finalize (GObject *object)
}
static void
-volume_widget_property_update(DbusmenuMenuitem* item, gchar* property,
- GValue* value, gpointer userdata)
+volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
+ GVariant* value, gpointer userdata)
{
g_return_if_fail (IS_VOLUME_WIDGET (userdata));
VolumeWidget* mitem = VOLUME_WIDGET(userdata);
@@ -133,7 +133,7 @@ volume_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(priv->grabbed == FALSE){
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
- gdouble update = g_value_get_double (value);
+ gdouble update = g_variant_get_double (value);
//g_debug("volume-widget - update level with value %f", update);
gtk_range_set_value(range, update);
determine_state_from_volume(update);
@@ -150,8 +150,8 @@ volume_widget_set_twin_item(VolumeWidget* self,
g_object_ref(priv->twin_item);
g_signal_connect(G_OBJECT(twin_item), "property-changed",
G_CALLBACK(volume_widget_property_update), self);
- gdouble initial_level = g_value_get_double (dbusmenu_menuitem_property_get_value(twin_item,
- DBUSMENU_VOLUME_MENUITEM_LEVEL));
+ gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item,
+ DBUSMENU_VOLUME_MENUITEM_LEVEL));
//g_debug("volume_widget_set_twin_item initial level = %f", initial_level);
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
@@ -195,11 +195,9 @@ void
volume_widget_update(VolumeWidget* self, gdouble update)
{
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self);
- GValue value = {0};
- g_value_init(&value, G_TYPE_DOUBLE);
gdouble clamped = CLAMP(update, 0, 100);
- g_value_set_double(&value, clamped);
- dbusmenu_menuitem_handle_event (priv->twin_item, "update", &value, 0);
+ GVariant* new_volume = g_variant_new_double(clamped);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "update", new_volume, 0);
}
GtkWidget*
@@ -246,8 +244,8 @@ volume_widget_get_current_volume ( GtkWidget *widget )
{
VolumeWidget* mitem = VOLUME_WIDGET(widget);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
- gdouble vol = g_value_get_double ( dbusmenu_menuitem_property_get_value( priv->twin_item,
- DBUSMENU_VOLUME_MENUITEM_LEVEL));
+ gdouble vol = g_variant_get_double( dbusmenu_menuitem_property_get_variant( priv->twin_item,
+ DBUSMENU_VOLUME_MENUITEM_LEVEL));
return vol;
}