aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dbus-menu-manager.c220
-rw-r--r--src/dbus-menu-manager.h12
-rw-r--r--[-rwxr-xr-x]src/indicator-sound.c600
-rw-r--r--src/indicator-sound.h12
-rw-r--r--src/pulse-manager.c761
-rw-r--r--src/pulse-manager.h14
-rw-r--r--src/slider-menu-item.c49
-rw-r--r--src/slider-menu-item.h16
-rw-r--r--src/sound-service-dbus.c201
-rw-r--r--src/sound-service-dbus.h5
-rw-r--r--src/sound-service.c54
-rw-r--r--src/sound-service.h12
12 files changed, 950 insertions, 1006 deletions
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c
index 9d62adb..d19bfbb 100644
--- a/src/dbus-menu-manager.c
+++ b/src/dbus-menu-manager.c
@@ -5,16 +5,16 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -27,8 +27,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-glib/client.h>
-#include "dbus-menu-manager.h"
-#include "sound-service-dbus.h"
+#include "dbus-menu-manager.h"
+#include "sound-service-dbus.h"
#include "pulse-manager.h"
#include "slider-menu-item.h"
@@ -53,7 +53,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
static void refresh_menu();
/*-------------------------------------------------------------------------*/
-// Public Methods
+// Public Methods
/*-------------------------------------------------------------------------*/
/**
@@ -61,17 +61,17 @@ setup:
**/
DbusmenuMenuitem* dbus_menu_manager_setup()
{
- root_menuitem = dbusmenu_menuitem_new();
- g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem));
-
- g_idle_add(idle_routine, root_menuitem);
+ root_menuitem = dbusmenu_menuitem_new();
+ g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem));
- dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
+ g_idle_add(idle_routine, root_menuitem);
- DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT);
- dbusmenu_server_set_root(server, root_menuitem);
- establish_pulse_activities(dbus_interface);
- return root_menuitem;
+ dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
+
+ DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT);
+ dbusmenu_server_set_root(server, root_menuitem);
+ establish_pulse_activities(dbus_interface);
+ return root_menuitem;
}
/**
@@ -79,7 +79,7 @@ teardown:
**/
void dbus_menu_manager_teardown()
{
- //TODO tidy up dbus_interface and items!
+ //TODO tidy up dbus_interface and items!
}
/**
@@ -87,25 +87,24 @@ update_pa_state:
**/
void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble percent)
{
- b_sink_available = sink_available;
- b_all_muted = sink_muted;
- b_pulse_ready = pa_state;
- volume_percent = percent;
- g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent);
- // Only rebuild the menu on start up...
- if(b_startup == TRUE){
- rebuild_sound_menu(root_menuitem, dbus_interface);
- b_startup = FALSE;
- }
- else{
- refresh_menu();
- }
- // Emit the signals after the menus are setup/torn down
- // preserve ordering !
- sound_service_dbus_update_sink_availability(dbus_interface, sink_available);
- sound_service_dbus_update_sink_volume(dbus_interface, percent);
- sound_service_dbus_update_sink_mute(dbus_interface, sink_muted);
- dbus_menu_manager_update_mute_ui(b_all_muted);
+ b_sink_available = sink_available;
+ b_all_muted = sink_muted;
+ b_pulse_ready = pa_state;
+ volume_percent = percent;
+ g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent);
+ // Only rebuild the menu on start up...
+ if (b_startup == TRUE) {
+ rebuild_sound_menu(root_menuitem, dbus_interface);
+ b_startup = FALSE;
+ } else {
+ refresh_menu();
+ }
+ // Emit the signals after the menus are setup/torn down
+ // preserve ordering !
+ sound_service_dbus_update_sink_availability(dbus_interface, sink_available);
+ sound_service_dbus_update_sink_volume(dbus_interface, percent);
+ sound_service_dbus_update_sink_mute(dbus_interface, sink_muted);
+ dbus_menu_manager_update_mute_ui(b_all_muted);
}
/**
@@ -114,46 +113,44 @@ update_mute_ui:
**/
void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value)
{
- b_all_muted = incoming_mute_value;
- dbusmenu_menuitem_property_set(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- b_all_muted == FALSE ? _("Mute All") : _("Unmute"));
+ b_all_muted = incoming_mute_value;
+ dbusmenu_menuitem_property_set(mute_all_menuitem,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ b_all_muted == FALSE ? _("Mute All") : _("Unmute"));
}
/*-------------------------------------------------------------------------*/
-// Private Methods
+// Private Methods
/*-------------------------------------------------------------------------*/
static void refresh_menu()
{
- g_debug("in the refresh menu method");
- if(b_sink_available == FALSE || b_pulse_ready == FALSE)
- {
-
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED,
- FALSE);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- FALSE);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- FALSE);
-
- }
- else if(b_sink_available == TRUE && b_pulse_ready == TRUE){
-
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED,
- TRUE);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- TRUE);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- TRUE);
- }
+ g_debug("in the refresh menu method");
+ if (b_sink_available == FALSE || b_pulse_ready == FALSE) {
+
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ FALSE);
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_VISIBLE,
+ FALSE);
+ dbusmenu_menuitem_property_set_bool(mute_all_menuitem,
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ FALSE);
+
+ } else if (b_sink_available == TRUE && b_pulse_ready == TRUE) {
+
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ TRUE);
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_VISIBLE,
+ TRUE);
+ dbusmenu_menuitem_property_set_bool(mute_all_menuitem,
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ TRUE);
+ }
}
@@ -163,23 +160,22 @@ Something for glip mainloop to do when idle
**/
static gboolean idle_routine (gpointer data)
{
- return FALSE;
+ return FALSE;
}
-
+
/**
show_sound_settings_dialog:
Bring up the gnome volume preferences dialog
**/
-static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data)
+static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data)
{
- GError * error = NULL;
- if (!g_spawn_command_line_async("gnome-volume-control", &error))
- {
- g_warning("Unable to show dialog: %s", error->message);
- g_error_free(error);
- }
+ GError * error = NULL;
+ if (!g_spawn_command_line_async("gnome-volume-control", &error)) {
+ g_warning("Unable to show dialog: %s", error->message);
+ g_error_free(error);
+ }
}
/**
@@ -188,35 +184,35 @@ Build the DBus menu items, mute/unmute, slider, separator and sound preferences
**/
static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service)
{
- // Mute button
- mute_all_menuitem = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute All") : _("Unmute"));
- g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available);
-
- // Slider
- volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent);
- dbusmenu_menuitem_child_append(root, mute_all_menuitem);
- dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem));
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED,
- b_sink_available && !b_all_muted);
- g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- b_sink_available);
- // Separator
- DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_append(root, separator);
-
- // Sound preferences dialog
- DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences..."));
+ // Mute button
+ mute_all_menuitem = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute All") : _("Unmute"));
+ g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL);
+ dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available);
+
+ // Slider
+ volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent);
+ dbusmenu_menuitem_child_append(root, mute_all_menuitem);
+ dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem));
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ b_sink_available && !b_all_muted);
+ g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted);
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_VISIBLE,
+ b_sink_available);
+ // Separator
+ DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_child_append(root, separator);
+
+ // Sound preferences dialog
+ DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences..."));
//_("Sound Preferences..."));
- dbusmenu_menuitem_child_append(root, settings_mi);
- g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(show_sound_settings_dialog), NULL);
+ dbusmenu_menuitem_child_append(root, settings_mi);
+ g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK(show_sound_settings_dialog), NULL);
}
/**
@@ -225,11 +221,11 @@ Callback for the dbusmenuitem button
**/
static void set_global_mute_from_ui()
{
- b_all_muted = !b_all_muted;
- toggle_global_mute(b_all_muted);
- dbusmenu_menuitem_property_set(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- b_all_muted == FALSE ? _("Mute All") : _("Unmute"));
+ b_all_muted = !b_all_muted;
+ toggle_global_mute(b_all_muted);
+ dbusmenu_menuitem_property_set(mute_all_menuitem,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ b_all_muted == FALSE ? _("Mute All") : _("Unmute"));
}
diff --git a/src/dbus-menu-manager.h b/src/dbus-menu-manager.h
index a5286ca..926e292 100644
--- a/src/dbus-menu-manager.h
+++ b/src/dbus-menu-manager.h
@@ -10,16 +10,16 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 9f7e136..3f0d2d3 100755..100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -57,14 +57,14 @@ typedef struct _IndicatorSoundClass IndicatorSoundClass;
//GObject class struct
struct _IndicatorSoundClass {
- IndicatorObjectClass parent_class;
+ IndicatorObjectClass parent_class;
};
//GObject instance struct
struct _IndicatorSound {
- IndicatorObject parent;
+ IndicatorObject parent;
GtkWidget *slider;
- IndicatorServiceManager *service;
+ IndicatorServiceManager *service;
};
// GObject Boiler plate
GType indicator_sound_get_type (void);
@@ -147,27 +147,27 @@ static void free_the_animation_list();
static void
indicator_sound_class_init (IndicatorSoundClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = indicator_sound_dispose;
- object_class->finalize = indicator_sound_finalize;
+ object_class->dispose = indicator_sound_dispose;
+ object_class->finalize = indicator_sound_finalize;
- IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass);
- io_class->get_label = get_label;
- io_class->get_image = get_icon;
- io_class->get_menu = get_menu;
+ IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass);
+ io_class->get_label = get_label;
+ io_class->get_image = get_icon;
+ io_class->get_menu = get_menu;
io_class->scroll = scroll;
design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
- return;
+ return;
}
static void
indicator_sound_init (IndicatorSound *self)
{
- self->service = NULL;
- self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION);
+ self->service = NULL;
+ self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION);
prepare_state_machine();
prepare_blocked_animation();
animation_id = 0;
@@ -177,31 +177,31 @@ indicator_sound_init (IndicatorSound *self)
slider_in_direct_use = FALSE;
exterior_vol_update = OUT_OF_RANGE;
- g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self);
+ g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self);
return;
}
static void
indicator_sound_dispose (GObject *object)
{
- IndicatorSound * self = INDICATOR_SOUND(object);
+ IndicatorSound * self = INDICATOR_SOUND(object);
- if (self->service != NULL) {
- g_object_unref(G_OBJECT(self->service));
- self->service = NULL;
- }
+ if (self->service != NULL) {
+ g_object_unref(G_OBJECT(self->service));
+ self->service = NULL;
+ }
g_hash_table_destroy(volume_states);
free_the_animation_list();
- G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object);
- return;
+ G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object);
+ return;
}
-static void
+static void
free_the_animation_list()
{
- if(blocked_animation_list != NULL){
+ if (blocked_animation_list != NULL) {
g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL);
g_list_free(blocked_animation_list);
blocked_animation_list = NULL;
@@ -211,24 +211,24 @@ free_the_animation_list()
static void
indicator_sound_finalize (GObject *object)
{
- G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object);
- return;
+ G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object);
+ return;
}
static GtkLabel *
get_label (IndicatorObject * io)
{
- return NULL;
+ return NULL;
}
static GtkImage *
get_icon (IndicatorObject * io)
-{
+{
gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
g_debug("At start-up attempting to set the image to %s", current_name);
- speaker_image = indicator_image_helper(current_name);
- gtk_widget_show(GTK_WIDGET(speaker_image));
- return speaker_image;
+ speaker_image = indicator_image_helper(current_name);
+ gtk_widget_show(GTK_WIDGET(speaker_image));
+ return speaker_image;
}
/* Indicator based function to get the menu for the whole
@@ -241,8 +241,8 @@ get_menu (IndicatorObject * io)
DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu);
g_object_set_data (G_OBJECT (client), "indicator", io);
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item);
- dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget);
- dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget);
+ dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget);
+ dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget);
// register Key-press listening on the menu widget as the slider does not allow this.
g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL);
@@ -253,8 +253,8 @@ static void
slider_parent_changed (GtkWidget *widget,
gpointer user_data)
{
- gtk_widget_set_size_request (widget, 200, -1);
- g_debug("slider parent changed");
+ gtk_widget_set_size_request (widget, 200, -1);
+ g_debug("slider parent changed");
}
/**
@@ -264,93 +264,93 @@ Create a new dBusMenu Slider item.
static gboolean
new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- IndicatorObject *io = NULL;
+ IndicatorObject *io = NULL;
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
- g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- io = g_object_get_data (G_OBJECT (client), "indicator");
+ io = g_object_get_data (G_OBJECT (client), "indicator");
- volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 1);
- g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL);
+ volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 1);
+ g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL);
- g_signal_connect (volume_slider,
- "notify::parent", G_CALLBACK (slider_parent_changed),
- NULL);
+ g_signal_connect (volume_slider,
+ "notify::parent", G_CALLBACK (slider_parent_changed),
+ NULL);
- GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider);
+ GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider);
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent);
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent);
- // register slider changes listening on the range
- GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
+ // register slider changes listening on the range
+ GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
- INDICATOR_SOUND (io)->slider = slider;
+ INDICATOR_SOUND (io)->slider = slider;
- g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem);
- g_signal_connect(volume_slider, "slider-grabbed", G_CALLBACK(slider_grabbed), NULL);
- g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL);
- g_signal_connect(slider, "style-set", G_CALLBACK(style_changed_cb), NULL);
+ g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem);
+ g_signal_connect(volume_slider, "slider-grabbed", G_CALLBACK(slider_grabbed), NULL);
+ g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL);
+ g_signal_connect(slider, "style-set", G_CALLBACK(style_changed_cb), NULL);
- // Set images on the ido
- GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider);
- GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)));
- gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU);
- g_object_unref(primary_gicon);
+ // Set images on the ido
+ GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider);
+ GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)));
+ gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU);
+ g_object_unref(primary_gicon);
- GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider);
- GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)));
- gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU);
- g_object_unref(secondary_gicon);
+ GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider);
+ GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)));
+ gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU);
+ g_object_unref(secondary_gicon);
- gtk_widget_set_sensitive(volume_slider, !initial_mute);
+ gtk_widget_set_sensitive(volume_slider, !initial_mute);
- GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider));
- gtk_adjustment_set_step_increment(adj, 3);
+ GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider));
+ gtk_adjustment_set_step_increment(adj, 3);
- gtk_widget_show_all(volume_slider);
+ gtk_widget_show_all(volume_slider);
- return TRUE;
+ return TRUE;
}
static gboolean
new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- g_debug("indicator-sound: new_transport_bar() called ");
+ g_debug("indicator-sound: new_transport_bar() called ");
+
+ GtkWidget* bar = NULL;
- GtkWidget* bar = NULL;
-
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- bar = transport_widget_new(newitem);
+ bar = transport_widget_new(newitem);
GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent);
-
- gtk_widget_show_all(bar);
-
- return TRUE;
+
+ gtk_widget_show_all(bar);
+
+ return TRUE;
}
static gboolean
new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
- g_debug("indicator-sound: new_metadata_widget");
+ g_debug("indicator-sound: new_metadata_widget");
- GtkWidget* metadata = NULL;
+ GtkWidget* metadata = NULL;
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- metadata = metadata_widget_new (newitem);
- GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata);
-
+ metadata = metadata_widget_new (newitem);
+ GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata);
+
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_metadata_widget, parent);
- gtk_widget_show_all(metadata);
+ gtk_widget_show_all(metadata);
- return TRUE;
+ return TRUE;
}
//const gchar* path = dbusmenu_menuitem_property_get(new_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH);
@@ -361,62 +361,62 @@ new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
static void
connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata)
{
- if (connected) {
- if (sound_dbus_proxy == NULL) {
- GError * error = NULL;
-
- DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-
- sound_dbus_proxy = dbus_g_proxy_new_for_name_owner(sbus,
- INDICATOR_SOUND_DBUS_NAME,
- INDICATOR_SOUND_SERVICE_DBUS_OBJECT,
- INDICATOR_SOUND_SERVICE_DBUS_INTERFACE,
- &error);
+ if (connected) {
+ if (sound_dbus_proxy == NULL) {
+ GError * error = NULL;
- if (error != NULL) {
- g_warning("Unable to get status proxy: %s", error->message);
- g_error_free(error);
- }
- g_debug("about to connect to the signals");
- dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+ DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL);
- dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL);
- dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), NULL, NULL);
- dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL);
+ sound_dbus_proxy = dbus_g_proxy_new_for_name_owner(sbus,
+ INDICATOR_SOUND_DBUS_NAME,
+ INDICATOR_SOUND_SERVICE_DBUS_OBJECT,
+ INDICATOR_SOUND_SERVICE_DBUS_INTERFACE,
+ &error);
- // Ensure we are in a coherent state with the service at start up.
- // Preserve ordering!
- fetch_volume_percent_from_dbus();
- fetch_mute_value_from_dbus();
- fetch_sink_availability_from_dbus();
- }
+ if (error != NULL) {
+ g_warning("Unable to get status proxy: %s", error->message);
+ g_error_free(error);
+ }
+ g_debug("about to connect to the signals");
+ dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL);
+ dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL);
+ dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), NULL, NULL);
+ dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL);
+
+ // Ensure we are in a coherent state with the service at start up.
+ // Preserve ordering!
+ fetch_volume_percent_from_dbus();
+ fetch_mute_value_from_dbus();
+ fetch_sink_availability_from_dbus();
+ }
- } else {
- //TODO : will need to handle this scenario
- // Not much can we do here really, if there is no dbus connection tis goosed.
- }
+ } else {
+ //TODO : will need to handle this scenario
+ // Not much can we do here really, if there is no dbus connection tis goosed.
+ }
- return;
+ return;
}
/*
Prepare states Array.
*/
-void
+void
prepare_state_machine()
{
- volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-low-zero-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel"));
+ volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel"));
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-low-zero-panel"));
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel"));
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel"));
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel"));
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel"));
+ g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel"));
}
/*
@@ -436,7 +436,7 @@ prepare_blocked_animation()
temp_image = indicator_image_helper(blocked_name);
GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image);
- if(mute_buf == NULL || blocked_buf == NULL){
+ if (mute_buf == NULL || blocked_buf == NULL) {
g_debug("Don bother with the animation, the theme aint got the goods !");
return;
}
@@ -444,8 +444,7 @@ prepare_blocked_animation()
int i;
// sample 51 snapshots - range : 0-256
- for(i = 0; i < 51; i++)
- {
+ for (i = 0; i < 51; i++) {
gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0,
gdk_pixbuf_get_width(mute_buf),
gdk_pixbuf_get_height(mute_buf),
@@ -453,9 +452,9 @@ prepare_blocked_animation()
blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf));
}
g_object_ref_sink(mute_buf);
- g_object_unref(mute_buf);
+ g_object_unref(mute_buf);
g_object_ref_sink(blocked_buf);
- g_object_unref(blocked_buf);
+ g_object_unref(blocked_buf);
}
@@ -487,11 +486,11 @@ tidy_up_hash()
static void
update_state(const gint state)
{
-/* g_debug("update state beginning - previous_state = %i", previous_state);*/
+ /* g_debug("update state beginning - previous_state = %i", previous_state);*/
previous_state = current_state;
-/* g_debug("update state 3rd line - previous_state = %i", previous_state);*/
+ /* g_debug("update state 3rd line - previous_state = %i", previous_state);*/
current_state = state;
gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
@@ -502,51 +501,46 @@ update_state(const gint state)
void
determine_state_from_volume(gdouble volume_percent)
{
-/* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/
- if (device_available == FALSE)
- return;
- gint state = previous_state;
- if (volume_percent < 30.0 && volume_percent > 0){
- state = STATE_LOW;
- }
- else if(volume_percent < 70.0 && volume_percent >= 30.0){
- state = STATE_MEDIUM;
- }
- else if(volume_percent >= 70.0){
- state = STATE_HIGH;
- }
- else if(volume_percent == 0.0){
- state = STATE_ZERO;
- }
- update_state(state);
+ /* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/
+ if (device_available == FALSE)
+ return;
+ gint state = previous_state;
+ if (volume_percent < 30.0 && volume_percent > 0) {
+ state = STATE_LOW;
+ } else if (volume_percent < 70.0 && volume_percent >= 30.0) {
+ state = STATE_MEDIUM;
+ } else if (volume_percent >= 70.0) {
+ state = STATE_HIGH;
+ } else if (volume_percent == 0.0) {
+ state = STATE_ZERO;
+ }
+ update_state(state);
}
static gboolean
start_animation()
{
- blocked_iter = blocked_animation_list;
- blocked_id = 0;
- g_debug("exit from blocked hold start the animation\n");
- animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL);
- return FALSE;
+ blocked_iter = blocked_animation_list;
+ blocked_id = 0;
+ g_debug("exit from blocked hold start the animation\n");
+ animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL);
+ return FALSE;
}
static gboolean
fade_back_to_mute_image()
{
- if(blocked_iter != NULL)
- {
- g_debug("in animation 'loop'\n");
- gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data);
- blocked_iter = blocked_iter->next;
- return TRUE;
- }
- else{
- animation_id = 0;
- g_debug("exit from animation now\n");
- return FALSE;
- }
+ if (blocked_iter != NULL) {
+ g_debug("in animation 'loop'\n");
+ gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data);
+ blocked_iter = blocked_iter->next;
+ return TRUE;
+ } else {
+ animation_id = 0;
+ g_debug("exit from animation now\n");
+ return FALSE;
+ }
}
/*******************************************************************/
@@ -555,67 +549,67 @@ fade_back_to_mute_image()
static void
fetch_sink_availability_from_dbus()
{
- GError * error = NULL;
- gboolean * available_input;
- available_input = g_new0(gboolean, 1);
- org_ayatana_indicator_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");
- }
-
- if (GTK_IS_WIDGET (volume_slider))
- gtk_widget_set_sensitive(volume_slider, device_available);
-
+ GError * error = NULL;
+ gboolean * available_input;
+ available_input = g_new0(gboolean, 1);
+ org_ayatana_indicator_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);
- g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available);
+ return;
+ }
+ device_available = *available_input;
+ if (device_available == FALSE) {
+ update_state(STATE_SINKS_NONE);
+ g_debug("NO DEVICE AVAILABLE");
+ }
+
+ if (GTK_IS_WIDGET (volume_slider))
+ gtk_widget_set_sensitive(volume_slider, device_available);
+
+ g_free(available_input);
+ g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available);
}
-static void
+static void
fetch_volume_percent_from_dbus()
{
- GError * error = NULL;
- gdouble *volume_percent_input;
- volume_percent_input = g_new0(gdouble, 1);
- org_ayatana_indicator_sound_get_sink_volume(sound_dbus_proxy, volume_percent_input, &error);
- if (error != NULL) {
- g_warning("Unable to fetch VOLUME at indicator start up: %s", error->message);
- g_error_free(error);
- g_free(volume_percent_input);
- return;
- }
- initial_volume_percent = *volume_percent_input;
- determine_state_from_volume(initial_volume_percent);
+ GError * error = NULL;
+ gdouble *volume_percent_input;
+ volume_percent_input = g_new0(gdouble, 1);
+ org_ayatana_indicator_sound_get_sink_volume(sound_dbus_proxy, volume_percent_input, &error);
+ if (error != NULL) {
+ g_warning("Unable to fetch VOLUME at indicator start up: %s", error->message);
+ g_error_free(error);
g_free(volume_percent_input);
- g_debug("at the indicator start up and the volume percent returned from dbus method is %f", initial_volume_percent);
+ return;
+ }
+ initial_volume_percent = *volume_percent_input;
+ determine_state_from_volume(initial_volume_percent);
+ g_free(volume_percent_input);
+ g_debug("at the indicator start up and the volume percent returned from dbus method is %f", initial_volume_percent);
}
-static void
+static void
fetch_mute_value_from_dbus()
{
- GError * error = NULL;
- gboolean *mute_input;
- mute_input = g_new0(gboolean, 1);
- org_ayatana_indicator_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);
+ GError * error = NULL;
+ gboolean *mute_input;
+ mute_input = g_new0(gboolean, 1);
+ org_ayatana_indicator_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);
- g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute);
+ 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);
}
/*******************************************************************/
@@ -624,70 +618,68 @@ fetch_mute_value_from_dbus()
static void
catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata)
{
- 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) {
- gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
- indicator_image_helper_update(speaker_image, image_name);
- blocked_id = g_timeout_add_seconds(5, start_animation, NULL);
- }
+ 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) {
+ gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
+ indicator_image_helper_update(speaker_image, image_name);
+ blocked_id = g_timeout_add_seconds(5, start_animation, NULL);
+ }
}
static void
catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata)
{
- if (slider_in_direct_use == FALSE){
- GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
- GtkRange *range = (GtkRange*)slider;
+ if (slider_in_direct_use == FALSE) {
+ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
+ GtkRange *range = (GtkRange*)slider;
- // DEBUG
- gdouble current_value = gtk_range_get_value(range);
- g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent);
- exterior_vol_update = volume_percent;
- gtk_range_set_value(range, volume_percent);
- determine_state_from_volume(volume_percent);
- }
+ // DEBUG
+ gdouble current_value = gtk_range_get_value(range);
+ g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent);
+ exterior_vol_update = volume_percent;
+ gtk_range_set_value(range, volume_percent);
+ determine_state_from_volume(volume_percent);
+ }
}
static void
catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata)
{
- //We can be sure the service won't send a mute signal unless it has changed !
- //UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.
- if(mute_value == TRUE && device_available == TRUE)
- {
- update_state(STATE_MUTED);
- }
- else{
- reset_mute_blocking_animation();
- }
- g_debug("signal caught - sink mute update with mute value: %i", mute_value);
- gtk_widget_set_sensitive(volume_slider, !mute_value);
+ //We can be sure the service won't send a mute signal unless it has changed !
+ //UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.
+ if (mute_value == TRUE && device_available == TRUE) {
+ update_state(STATE_MUTED);
+ } else {
+ reset_mute_blocking_animation();
+ }
+ g_debug("signal caught - sink mute update with mute value: %i", mute_value);
+ gtk_widget_set_sensitive(volume_slider, !mute_value);
}
static void
reset_mute_blocking_animation()
{
- if(animation_id != 0){
- g_debug("about to remove the animation_id callback from the mainloop!!**");
- g_source_remove(animation_id);
- animation_id = 0;
- }
- if(blocked_id != 0){
- g_debug("about to remove the blocked_id callback from the mainloop!!**");
- g_source_remove(blocked_id);
- blocked_id = 0;
- }
+ if (animation_id != 0) {
+ g_debug("about to remove the animation_id callback from the mainloop!!**");
+ g_source_remove(animation_id);
+ animation_id = 0;
+ }
+ if (blocked_id != 0) {
+ g_debug("about to remove the blocked_id callback from the mainloop!!**");
+ g_source_remove(blocked_id);
+ blocked_id = 0;
+ }
}
static void
catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata)
{
- device_available = available_value;
- if (device_available == FALSE){
- update_state(STATE_SINKS_NONE);
- }
- g_debug("signal caught - sink availability update with value: %i", available_value);
+ device_available = available_value;
+ if (device_available == FALSE) {
+ update_state(STATE_SINKS_NONE);
+ }
+ g_debug("signal caught - sink availability update with value: %i", available_value);
}
@@ -703,36 +695,36 @@ This callback will get triggered irregardless of whether its a user change or a
static gboolean
value_changed_event_cb(GtkRange *range, gpointer user_data)
{
- gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100);
- if(current_value == exterior_vol_update){
- g_debug("ignore the value changed event - its come from the outside");
- return FALSE;
- }
- DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data;
- GValue value = {0};
- g_value_init(&value, G_TYPE_DOUBLE);
- g_value_set_double(&value, current_value);
- g_debug("Value changed callback - = %f", current_value);
- dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0);
- // This is not ideal in that the icon ui will update on ui actions and not on actual service feedback.
- // but necessary for now as the server does not send volume update information if the source of change was this ui.
- determine_state_from_volume(current_value);
+ gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100);
+ if (current_value == exterior_vol_update) {
+ g_debug("ignore the value changed event - its come from the outside");
return FALSE;
+ }
+ DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data;
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_DOUBLE);
+ g_value_set_double(&value, current_value);
+ g_debug("Value changed callback - = %f", current_value);
+ dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0);
+ // This is not ideal in that the icon ui will update on ui actions and not on actual service feedback.
+ // but necessary for now as the server does not send volume update information if the source of change was this ui.
+ determine_state_from_volume(current_value);
+ return FALSE;
}
static void
slider_grabbed (GtkWidget *widget, gpointer user_data)
{
- slider_in_direct_use = TRUE;
- g_debug ("!!!!!! grabbed\n");
+ slider_in_direct_use = TRUE;
+ g_debug ("!!!!!! grabbed\n");
}
static void
slider_released (GtkWidget *widget, gpointer user_data)
{
- slider_in_direct_use = FALSE;
- g_debug ("!!!!!! released\n");
+ slider_in_direct_use = FALSE;
+ g_debug ("!!!!!! released\n");
}
@@ -752,30 +744,22 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
GtkWidget *menuitem;
menuitem = GTK_MENU_SHELL (widget)->active_menu_item;
- if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE)
- {
- switch(event->keyval)
- {
+ if (IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) {
+ switch (event->keyval) {
case GDK_Right:
- digested = TRUE;
- if(event->state & GDK_CONTROL_MASK)
- {
- new_value = 100;
- }
- else
- {
+ digested = TRUE;
+ if (event->state & GDK_CONTROL_MASK) {
+ new_value = 100;
+ } else {
new_value = current_value + five_percent;
- }
- break;
- case GDK_Left:
- digested = TRUE;
- if(event->state & GDK_CONTROL_MASK)
- {
- new_value = 0;
}
- else
- {
- new_value = current_value - five_percent;
+ break;
+ case GDK_Left:
+ digested = TRUE;
+ if (event->state & GDK_CONTROL_MASK) {
+ new_value = 0;
+ } else {
+ new_value = current_value - five_percent;
}
break;
case GDK_plus:
@@ -791,11 +775,10 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
}
new_value = CLAMP(new_value, 0, 100);
- if(new_value != current_value && current_state != STATE_MUTED)
- {
+ if (new_value != current_value && current_state != STATE_MUTED) {
g_debug("Attempting to set the range from the key listener to %f", new_value);
// In order to ensure that the exterior filtering does not catch this, reset the exterior_vol_update
- // to ensure these updates.
+ // to ensure these updates.
exterior_vol_update = OUT_OF_RANGE;
gtk_range_set_value(range, new_value);
}
@@ -817,18 +800,17 @@ style_changed_cb(GtkWidget *widget, gpointer user_data)
static void
scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
{
- if (device_available == FALSE || current_state == STATE_MUTED)
- return;
+ if (device_available == FALSE || current_state == STATE_MUTED)
+ return;
IndicatorSound *sound = INDICATOR_SOUND (io);
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (sound->slider));
gdouble value = gtk_range_get_value (GTK_RANGE (sound->slider));
-
- if (direction == INDICATOR_OBJECT_SCROLL_UP){
- value += adj->step_increment;
- }
- else{
- value -= adj->step_increment;
+
+ if (direction == INDICATOR_OBJECT_SCROLL_UP) {
+ value += adj->step_increment;
+ } else {
+ value -= adj->step_increment;
}
gtk_range_set_value (GTK_RANGE (sound->slider), value);
}
diff --git a/src/indicator-sound.h b/src/indicator-sound.h
index e508390..386ad2a 100644
--- a/src/indicator-sound.h
+++ b/src/indicator-sound.h
@@ -11,16 +11,16 @@ Authors:
Conor Curran <conor.curra@canonical.com>
Ted Gould <ted@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 7323797..a9a47e4 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -50,7 +50,7 @@ static pa_cvolume construct_mono_volume(const pa_cvolume* vol);
/**
Future Refactoring notes
- - Push all UI updates out through update PA state in the service.
+ - Push all UI updates out through update PA state in the service.
- Collapse 3 update_sink_info into one. The essentially do the same thing from different contexts.
**/
@@ -59,18 +59,18 @@ Entry point
**/
void establish_pulse_activities(SoundServiceDbus *service)
{
- dbus_service = service;
- 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);
-
- sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info);
-
- // Establish event callback registration
- pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
- dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
- pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
+ dbus_service = service;
+ 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);
+
+ sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info);
+
+ // Establish event callback registration
+ pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
+ dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
+ pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
}
/**
@@ -79,7 +79,7 @@ Needed for testing - bah!
**/
pa_context* get_context()
{
- return pulse_context;
+ return pulse_context;
}
/**
@@ -88,44 +88,44 @@ Gracefully close our connection with the Pulse async library.
**/
void close_pulse_activites()
{
- if (pulse_context != NULL){
-/* g_debug("freeing the pulse context");*/
- pa_context_unref(pulse_context);
- pulse_context = NULL;
- }
- g_hash_table_destroy(sink_hash);
- pa_glib_mainloop_free(pa_main_loop);
- pa_main_loop = NULL;
-/* g_debug("I just closed communication with Pulse");*/
+ if (pulse_context != NULL) {
+ /* g_debug("freeing the pulse context");*/
+ pa_context_unref(pulse_context);
+ pulse_context = NULL;
+ }
+ g_hash_table_destroy(sink_hash);
+ pa_glib_mainloop_free(pa_main_loop);
+ pa_main_loop = NULL;
+ /* g_debug("I just closed communication with Pulse");*/
}
-/**
+/**
reconnect_to_pulse()
In the event of Pulseaudio flapping in the wind handle gracefully without
memory leaks !
*/
static void reconnect_to_pulse()
{
- // reset
- if (pulse_context != NULL){
- g_debug("freeing the pulse context");
- pa_context_unref(pulse_context);
- pulse_context = NULL;
- }
-
- if(sink_hash != NULL){
- g_hash_table_destroy(sink_hash);
- sink_hash = NULL;
- }
-
- // reconnect
- pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound");
- g_assert(pulse_context);
- sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info);
- // Establish event callback registration
- pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
- dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
- pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
+ // reset
+ if (pulse_context != NULL) {
+ g_debug("freeing the pulse context");
+ pa_context_unref(pulse_context);
+ pulse_context = NULL;
+ }
+
+ if (sink_hash != NULL) {
+ g_hash_table_destroy(sink_hash);
+ sink_hash = NULL;
+ }
+
+ // reconnect
+ pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound");
+ g_assert(pulse_context);
+ sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info);
+ // Establish event callback registration
+ pa_context_set_state_callback(pulse_context, context_state_callback, NULL);
+ dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0);
+ pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
}
/**
@@ -134,9 +134,9 @@ item destructor method for the sink_info hash
**/
static void destroy_sink_info(void *value)
{
- sink_info *sink = (sink_info*)value;
- g_free(sink->name);
- g_free(sink);
+ sink_info *sink = (sink_info*)value;
+ g_free(sink->name);
+ g_free(sink);
}
/*
@@ -144,125 +144,122 @@ Controllers & Utilities
*/
static gboolean determine_sink_availability()
{
- // Firstly check to see if we have any sinks
- // if not get the hell out of here !
- if (g_hash_table_size(sink_hash) < 1){
-/* g_debug("Sink_available returning false because sinks_hash is empty !!!"); */
- DEFAULT_SINK_INDEX = -1;
- return FALSE;
- }
- // Secondly, make sure the default sink index is set
- // If the default sink index has not been set
- // (via the server or has been reset because default sink has been removed),
- // it will attempt to set it to the value of the first
- // index in the array of keys from the sink_hash.
- GList* keys = g_hash_table_get_keys(sink_hash);
- GList* key = g_list_first(keys);
-
- DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? GPOINTER_TO_INT(key->data) : DEFAULT_SINK_INDEX;
-
- // Thirdly ensure the default sink index does not have the name "auto_null"
- sink_info* s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- // Up until now the most rebust method to test this is to manually remove the available sink device
- // kernel module and then reload (rmmod & modprobe).
- // TODO: Edge case of dynamic loading and unloading of sinks should be handled also.
-/* g_debug("About to test for to see if the available sink is null - s->name = %s", s->name);*/
- gboolean available = g_ascii_strncasecmp("auto_null", s->name, 9) != 0;
-/* g_debug("PA_Manager -> determine_sink_availability: %i", available);*/
- return available;
+ // Firstly check to see if we have any sinks
+ // if not get the hell out of here !
+ if (g_hash_table_size(sink_hash) < 1) {
+ /* g_debug("Sink_available returning false because sinks_hash is empty !!!"); */
+ DEFAULT_SINK_INDEX = -1;
+ return FALSE;
+ }
+ // Secondly, make sure the default sink index is set
+ // If the default sink index has not been set
+ // (via the server or has been reset because default sink has been removed),
+ // it will attempt to set it to the value of the first
+ // index in the array of keys from the sink_hash.
+ GList* keys = g_hash_table_get_keys(sink_hash);
+ GList* key = g_list_first(keys);
+
+ DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? GPOINTER_TO_INT(key->data) : DEFAULT_SINK_INDEX;
+
+ // Thirdly ensure the default sink index does not have the name "auto_null"
+ sink_info* s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
+ // Up until now the most rebust method to test this is to manually remove the available sink device
+ // kernel module and then reload (rmmod & modprobe).
+ // TODO: Edge case of dynamic loading and unloading of sinks should be handled also.
+ /* g_debug("About to test for to see if the available sink is null - s->name = %s", s->name);*/
+ gboolean available = g_ascii_strncasecmp("auto_null", s->name, 9) != 0;
+ /* g_debug("PA_Manager -> determine_sink_availability: %i", available);*/
+ return available;
}
static gboolean default_sink_is_muted()
{
- if(DEFAULT_SINK_INDEX < 0)
- return FALSE;
- if (g_hash_table_size(sink_hash) < 1)
- return FALSE;
- sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- return s->mute;
+ if (DEFAULT_SINK_INDEX < 0)
+ return FALSE;
+ if (g_hash_table_size(sink_hash) < 1)
+ return FALSE;
+ sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
+ return s->mute;
}
static void check_sink_input_while_muted_event(gint sink_index)
{
-/* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/
+ /* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/
- if (default_sink_is_muted(sink_index) == TRUE){
- sound_service_dbus_sink_input_while_muted (dbus_service, TRUE);
- }
- else{
- sound_service_dbus_sink_input_while_muted(dbus_service, FALSE);
- }
+ if (default_sink_is_muted(sink_index) == TRUE) {
+ sound_service_dbus_sink_input_while_muted (dbus_service, TRUE);
+ } else {
+ sound_service_dbus_sink_input_while_muted(dbus_service, FALSE);
+ }
}
static gdouble get_default_sink_volume()
{
- if (DEFAULT_SINK_INDEX < 0)
- return 0;
- sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- pa_volume_t vol = pa_cvolume_avg(&s->volume);
- gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
-/* g_debug("software volume = %f", volume_percent);*/
- return volume_percent;
+ if (DEFAULT_SINK_INDEX < 0)
+ return 0;
+ sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
+ pa_volume_t vol = pa_cvolume_avg(&s->volume);
+ gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
+ /* g_debug("software volume = %f", volume_percent);*/
+ return volume_percent;
}
static void mute_each_sink(gpointer key, gpointer value, gpointer user_data)
{
- sink_info *info = (sink_info*)value;
- pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL));
- if(GPOINTER_TO_INT(user_data) == 1){
- sound_service_dbus_update_sink_mute(dbus_service, TRUE);
- }
- else{
- sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume());
- }
-
-/* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/
+ sink_info *info = (sink_info*)value;
+ pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL));
+ if (GPOINTER_TO_INT(user_data) == 1) {
+ sound_service_dbus_update_sink_mute(dbus_service, TRUE);
+ } else {
+ sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume());
+ }
+
+ /* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/
}
void toggle_global_mute(gboolean mute_value)
{
- g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value));
-/* g_debug("in the pulse manager: toggle global mute value %i", mute_value);*/
+ g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value));
+ /* g_debug("in the pulse manager: toggle global mute value %i", mute_value);*/
}
/*
-Refine the resolution of the slider or binary scale it to achieve a more subtle volume control.
-Use the base volume stored in the sink struct to calculate actual linear volumes.
+Refine the resolution of the slider or binary scale it to achieve a more subtle volume control.
+Use the base volume stored in the sink struct to calculate actual linear volumes.
*/
void set_sink_volume(gdouble percent)
{
- if(pa_server_available == FALSE)
- return;
-/* g_debug("in the pulse manager:set_sink_volume with percent %f", percent);*/
-
- if(DEFAULT_SINK_INDEX < 0)
- {
- g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink");
- return;
- }
+ if (pa_server_available == FALSE)
+ return;
+ /* g_debug("in the pulse manager:set_sink_volume with percent %f", percent);*/
+
+ if (DEFAULT_SINK_INDEX < 0) {
+ g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink");
+ return;
+ }
- sink_info *cached_sink = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
+ sink_info *cached_sink = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- pa_cvolume new_volume;
- pa_cvolume_init(&new_volume);
- new_volume.channels = 1;
- pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100);
- pa_cvolume_set(&new_volume, 1, new_volume_value);
- pa_cvolume_set(&cached_sink->volume, cached_sink->channel_map.channels, new_volume_value);
- pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &new_volume, NULL, NULL));
+ pa_cvolume new_volume;
+ pa_cvolume_init(&new_volume);
+ new_volume.channels = 1;
+ pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100);
+ pa_cvolume_set(&new_volume, 1, new_volume_value);
+ pa_cvolume_set(&cached_sink->volume, cached_sink->channel_map.channels, new_volume_value);
+ pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &new_volume, NULL, NULL));
}
static pa_cvolume construct_mono_volume(const pa_cvolume* vol)
{
- pa_cvolume new_volume;
- pa_cvolume_init(&new_volume);
- new_volume.channels = 1;
- pa_volume_t max_vol = pa_cvolume_max(vol);
- pa_cvolume_set(&new_volume, 1, max_vol);
- return new_volume;
-}
+ pa_cvolume new_volume;
+ pa_cvolume_init(&new_volume);
+ new_volume.channels = 1;
+ pa_volume_t max_vol = pa_cvolume_max(vol);
+ pa_cvolume_set(&new_volume, 1, max_vol);
+ return new_volume;
+}
/**********************************************************************************************************************/
// Pulse-Audio asychronous call-backs
@@ -270,24 +267,22 @@ static pa_cvolume construct_mono_volume(const pa_cvolume* vol)
static void gather_pulse_information(pa_context *c, void *userdata)
{
- pa_operation *operation;
- if(!(operation = pa_context_get_server_info(c, pulse_server_info_callback, userdata)))
- {
- g_warning("pa_context_get_server_info failed");
- if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL)))
- {
- g_warning("pa_context_get_sink_info_list() failed - cannot fetch server or sink info - leaving . . .");
- return;
- }
+ pa_operation *operation;
+ if (!(operation = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) {
+ g_warning("pa_context_get_server_info failed");
+ if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL))) {
+ g_warning("pa_context_get_sink_info_list() failed - cannot fetch server or sink info - leaving . . .");
+ return;
}
- pa_operation_unref(operation);
- return;
+ }
+ pa_operation_unref(operation);
+ return;
}
static void context_success_callback(pa_context *c, int success, void *userdata)
{
-/* g_debug("Context Success Callback - result = %i", success);*/
+ /* g_debug("Context Success Callback - result = %i", success);*/
}
/**
@@ -298,296 +293,270 @@ Major candidate for refactoring.
**/
static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, int eol, void *userdata)
{
- if (eol > 0) {
-
- gboolean device_available = determine_sink_availability();
- if(device_available == TRUE)
- {
- dbus_menu_manager_update_pa_state(TRUE,
- device_available,
- default_sink_is_muted(),
- get_default_sink_volume());
- }
- else{
- //Update the indicator to show PA either is not ready or has no available sink
- g_warning("Cannot find a suitable default sink ...");
- dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume());
- }
- }
- else{
-/* g_debug("About to add an item to our hash");*/
- sink_info *value;
- value = g_new0(sink_info, 1);
- value->index = sink->index;
- value->name = g_strdup(sink->name);
- value->mute = !!sink->mute;
- value->volume = construct_mono_volume(&sink->volume);
- value->base_volume = sink->base_volume;
- value->channel_map = sink->channel_map;
- g_hash_table_insert(sink_hash, GINT_TO_POINTER(sink->index), value);
-/* g_debug("After adding an item to our hash");*/
+ if (eol > 0) {
+
+ gboolean device_available = determine_sink_availability();
+ if (device_available == TRUE) {
+ dbus_menu_manager_update_pa_state(TRUE,
+ device_available,
+ default_sink_is_muted(),
+ get_default_sink_volume());
+ } else {
+ //Update the indicator to show PA either is not ready or has no available sink
+ g_warning("Cannot find a suitable default sink ...");
+ dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume());
}
+ } else {
+ /* g_debug("About to add an item to our hash");*/
+ sink_info *value;
+ value = g_new0(sink_info, 1);
+ value->index = sink->index;
+ value->name = g_strdup(sink->name);
+ value->mute = !!sink->mute;
+ value->volume = construct_mono_volume(&sink->volume);
+ value->base_volume = sink->base_volume;
+ value->channel_map = sink->channel_map;
+ g_hash_table_insert(sink_hash, GINT_TO_POINTER(sink->index), value);
+ /* g_debug("After adding an item to our hash");*/
+ }
}
static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info *info, int eol, void *userdata)
{
- if (eol > 0) {
- if (pa_context_errno(c) == PA_ERR_NOENTITY)
- return;
- g_warning("Default Sink info callback failure");
- return;
- }
- else{
- DEFAULT_SINK_INDEX = info->index;
-/* g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); */
- GList *keys = g_hash_table_get_keys(sink_hash);
- gint position = g_list_index(keys, GINT_TO_POINTER(info->index));
- // Only update sink-list if the index is not in our already fetched list.
- if(position < 0)
- {
- pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL));
- }
- else
- {
- dbus_menu_manager_update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume());
- }
+ if (eol > 0) {
+ if (pa_context_errno(c) == PA_ERR_NOENTITY)
+ return;
+ g_warning("Default Sink info callback failure");
+ return;
+ } else {
+ DEFAULT_SINK_INDEX = info->index;
+ /* g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); */
+ GList *keys = g_hash_table_get_keys(sink_hash);
+ gint position = g_list_index(keys, GINT_TO_POINTER(info->index));
+ // Only update sink-list if the index is not in our already fetched list.
+ if (position < 0) {
+ pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL));
+ } else {
+ dbus_menu_manager_update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume());
}
+ }
}
-static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_info *info, int eol, void *userdata){
- if (eol > 0) {
- if (pa_context_errno(c) == PA_ERR_NOENTITY)
- return;
-/* g_warning("Sink INPUT info callback failure");*/
- return;
+static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_info *info, int eol, void *userdata)
+{
+ if (eol > 0) {
+ if (pa_context_errno(c) == PA_ERR_NOENTITY)
+ return;
+ /* g_warning("Sink INPUT info callback failure");*/
+ return;
+ } else {
+ if (info == NULL) {
+ // TODO: watch this carefully - PA async api should not be doing this . . .
+ /* g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");*/
+ return;
}
- else{
- if (info == NULL)
- {
- // TODO: watch this carefully - PA async api should not be doing this . . .
-/* g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");*/
- return;
- }
-/* g_debug("\n SINK INPUT INFO sink index : %d \n", info->sink);*/
- check_sink_input_while_muted_event(info->sink);
- }
+ /* g_debug("\n SINK INPUT INFO sink index : %d \n", info->sink);*/
+ check_sink_input_while_muted_event(info->sink);
+ }
}
static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, void *userdata)
{
- if (eol > 0) {
- if (pa_context_errno(c) == PA_ERR_NOENTITY)
- return;
-/* g_warning("Sink INPUT info callback failure");*/
- return;
- }
- gint position = -1;
- GList *keys = g_hash_table_get_keys(sink_hash);
+ if (eol > 0) {
+ if (pa_context_errno(c) == PA_ERR_NOENTITY)
+ return;
+ /* g_warning("Sink INPUT info callback failure");*/
+ return;
+ }
+ gint position = -1;
+ GList *keys = g_hash_table_get_keys(sink_hash);
+
+ if (info == NULL)
+ return;
- if(info == NULL)
- return;
-
- position = g_list_index(keys, GINT_TO_POINTER(info->index));
-
- if(position >= 0) // => index is within the keys of the hash.
- {
- sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index));
- s->name = g_strdup(info->name);
- gboolean mute_changed = s->mute != !!info->mute;
- s->mute = !!info->mute;
- gboolean volume_changed = has_volume_changed(info, s);
-
-/* g_debug("new balance : %i", (int)(pa_cvolume_get_balance(&info->volume, &info->channel_map) * 100));*/
-/* g_debug("cached balance : %i", (int)(pa_cvolume_get_balance(&s->volume, &s->channel_map) * 100));*/
-/* g_debug("update_sink_info: new_volume input : %f", (gdouble)(pa_cvolume_max(&info->volume)));*/
-/* g_debug("update sink info: cached volume is at: %f", (gdouble)(pa_cvolume_max(&s->volume)));*/
-/* g_debug("update sink info : volume changed = %i", volume_changed);*/
-/* g_debug("update sink info : compatibility = %i", pa_cvolume_compatible_with_channel_map(&info->volume, &s->channel_map));*/
-
- s->volume = construct_mono_volume(&info->volume);
- s->channel_map = info->channel_map;
-
- if(DEFAULT_SINK_INDEX == s->index)
- {
- //update the UI
- if (volume_changed == TRUE && s->mute == FALSE)
- {
- pa_volume_t vol = pa_cvolume_max(&s->volume);
- gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
-/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
- sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
- }
-
- if (mute_changed == TRUE)
- {
-/* g_debug("Updating Mute from PA manager with mute = %i", s->mute);*/
- sound_service_dbus_update_sink_mute(dbus_service, s->mute);
- dbus_menu_manager_update_mute_ui(s->mute);
- if(s->mute == FALSE){
- pa_volume_t vol = pa_cvolume_max(&s->volume);
- gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
-/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
- sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
- }
- }
+ position = g_list_index(keys, GINT_TO_POINTER(info->index));
+
+ if (position >= 0) { // => index is within the keys of the hash.
+ sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index));
+ s->name = g_strdup(info->name);
+ gboolean mute_changed = s->mute != !!info->mute;
+ s->mute = !!info->mute;
+ gboolean volume_changed = has_volume_changed(info, s);
+
+ /* g_debug("new balance : %i", (int)(pa_cvolume_get_balance(&info->volume, &info->channel_map) * 100));*/
+ /* g_debug("cached balance : %i", (int)(pa_cvolume_get_balance(&s->volume, &s->channel_map) * 100));*/
+ /* g_debug("update_sink_info: new_volume input : %f", (gdouble)(pa_cvolume_max(&info->volume)));*/
+ /* g_debug("update sink info: cached volume is at: %f", (gdouble)(pa_cvolume_max(&s->volume)));*/
+ /* g_debug("update sink info : volume changed = %i", volume_changed);*/
+ /* g_debug("update sink info : compatibility = %i", pa_cvolume_compatible_with_channel_map(&info->volume, &s->channel_map));*/
+
+ s->volume = construct_mono_volume(&info->volume);
+ s->channel_map = info->channel_map;
+
+ if (DEFAULT_SINK_INDEX == s->index) {
+ //update the UI
+ if (volume_changed == TRUE && s->mute == FALSE) {
+ pa_volume_t vol = pa_cvolume_max(&s->volume);
+ gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
+ /* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
+ sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
+ }
+
+ if (mute_changed == TRUE) {
+ /* g_debug("Updating Mute from PA manager with mute = %i", s->mute);*/
+ sound_service_dbus_update_sink_mute(dbus_service, s->mute);
+ dbus_menu_manager_update_mute_ui(s->mute);
+ if (s->mute == FALSE) {
+ pa_volume_t vol = pa_cvolume_max(&s->volume);
+ gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
+ /* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
+ sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
}
+ }
}
- else
- {
- sink_info *value;
- value = g_new0(sink_info, 1);
- value->index = info->index;
- value->name = g_strdup(info->name);
- value->mute = !!info->mute;
- value->volume = construct_mono_volume(&info->volume);
- value->channel_map = info->channel_map;
- value->base_volume = info->base_volume;
- g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value);
-/* g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");*/
- sound_service_dbus_update_sink_availability(dbus_service, TRUE);
- }
+ } else {
+ sink_info *value;
+ value = g_new0(sink_info, 1);
+ value->index = info->index;
+ value->name = g_strdup(info->name);
+ value->mute = !!info->mute;
+ value->volume = construct_mono_volume(&info->volume);
+ value->channel_map = info->channel_map;
+ value->base_volume = info->base_volume;
+ g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value);
+ /* g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");*/
+ sound_service_dbus_update_sink_availability(dbus_service, TRUE);
+ }
}
static gboolean has_volume_changed(const pa_sink_info* new_sink, sink_info* cached_sink)
{
- if(pa_cvolume_compatible_with_channel_map(&new_sink->volume, &cached_sink->channel_map) == FALSE)
- return FALSE;
+ if (pa_cvolume_compatible_with_channel_map(&new_sink->volume, &cached_sink->channel_map) == FALSE)
+ return FALSE;
- pa_cvolume new_vol = construct_mono_volume(&new_sink->volume);
+ pa_cvolume new_vol = construct_mono_volume(&new_sink->volume);
- if(pa_cvolume_equal(&new_vol, &(cached_sink->volume)) == TRUE){
-/* g_debug("has_volume_changed: volumes appear to be equal? no change triggered!"); */
- return FALSE;
- }
-
- return TRUE;
+ if (pa_cvolume_equal(&new_vol, &(cached_sink->volume)) == TRUE) {
+ /* g_debug("has_volume_changed: volumes appear to be equal? no change triggered!"); */
+ return FALSE;
+ }
+
+ return TRUE;
}
static void pulse_server_info_callback(pa_context *c, const pa_server_info *info, void *userdata)
{
-/* g_debug("server info callback");*/
- pa_operation *operation;
- if (info == NULL)
- {
- g_warning("No server - get the hell out of here");
- dbus_menu_manager_update_pa_state(FALSE, FALSE, TRUE, 0);
- pa_server_available = FALSE;
- return;
- }
- pa_server_available = TRUE;
- if(info->default_sink_name != NULL)
- {
- if (!(operation = pa_context_get_sink_info_by_name(c, info->default_sink_name, pulse_default_sink_info_callback, userdata)))
- {
- g_warning("pa_context_get_sink_info_by_name() failed");
- }
- else{
- pa_operation_unref(operation);
- return;
- }
+ /* g_debug("server info callback");*/
+ pa_operation *operation;
+ if (info == NULL) {
+ g_warning("No server - get the hell out of here");
+ dbus_menu_manager_update_pa_state(FALSE, FALSE, TRUE, 0);
+ pa_server_available = FALSE;
+ return;
+ }
+ pa_server_available = TRUE;
+ if (info->default_sink_name != NULL) {
+ if (!(operation = pa_context_get_sink_info_by_name(c, info->default_sink_name, pulse_default_sink_info_callback, userdata))) {
+ g_warning("pa_context_get_sink_info_by_name() failed");
+ } else {
+ pa_operation_unref(operation);
+ return;
}
- if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL)))
- {
- g_warning("pa_context_get_sink_info_list() failed");
- return;
- }
- pa_operation_unref(operation);
+ }
+ if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL))) {
+ g_warning("pa_context_get_sink_info_list() failed");
+ return;
+ }
+ pa_operation_unref(operation);
}
static void subscribed_events_callback(pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata)
{
- switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK)
- {
- case PA_SUBSCRIPTION_EVENT_SINK:
- if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
- {
- if(index == DEFAULT_SINK_INDEX)
- sound_service_dbus_update_sink_availability(dbus_service, FALSE);
-
-/* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/
- g_hash_table_remove(sink_hash, GINT_TO_POINTER(index));
-
- if(index == DEFAULT_SINK_INDEX){
-/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK REMOVAL: default sink %i has been removed.", DEFAULT_SINK_INDEX); */
- DEFAULT_SINK_INDEX = -1;
- determine_sink_availability();
- }
-/* g_debug("subscribed_events_callback - Now what is our default sink : %i", DEFAULT_SINK_INDEX); */
- }
- else
- {
-/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK: a generic sink event - will trigger an update"); */
- pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata));
- }
- break;
- case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
-/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!");*/
- if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
- {
- //handle the sink input remove event - not relevant for current design
- }
- else
- {
- pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata));
- }
- break;
- case PA_SUBSCRIPTION_EVENT_SERVER:
- g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SERVER change of some description ???");
- pa_operation *o;
- if(!(o = pa_context_get_server_info(c, pulse_server_info_callback, userdata)))
- {
- g_warning("subscribed_events_callback - pa_context_get_server_info() failed");
- return;
- }
- pa_operation_unref(o);
- break;
- }
+ switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
+ case PA_SUBSCRIPTION_EVENT_SINK:
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
+ if (index == DEFAULT_SINK_INDEX)
+ sound_service_dbus_update_sink_availability(dbus_service, FALSE);
+
+ /* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/
+ g_hash_table_remove(sink_hash, GINT_TO_POINTER(index));
+
+ if (index == DEFAULT_SINK_INDEX) {
+ /* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK REMOVAL: default sink %i has been removed.", DEFAULT_SINK_INDEX); */
+ DEFAULT_SINK_INDEX = -1;
+ determine_sink_availability();
+ }
+ /* g_debug("subscribed_events_callback - Now what is our default sink : %i", DEFAULT_SINK_INDEX); */
+ } else {
+ /* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK: a generic sink event - will trigger an update"); */
+ pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata));
+ }
+ break;
+ case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
+ /* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!");*/
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
+ //handle the sink input remove event - not relevant for current design
+ } else {
+ pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata));
+ }
+ break;
+ case PA_SUBSCRIPTION_EVENT_SERVER:
+ g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SERVER change of some description ???");
+ pa_operation *o;
+ if (!(o = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) {
+ g_warning("subscribed_events_callback - pa_context_get_server_info() failed");
+ return;
+ }
+ pa_operation_unref(o);
+ break;
+ }
}
-static void context_state_callback(pa_context *c, void *userdata) {
- switch (pa_context_get_state(c)) {
- case PA_CONTEXT_UNCONNECTED:
-/* g_debug("unconnected");*/
- break;
- case PA_CONTEXT_CONNECTING:
-/* g_debug("connecting - waiting for the server to become available");*/
- break;
- case PA_CONTEXT_AUTHORIZING:
-/* g_debug("authorizing");*/
- break;
- case PA_CONTEXT_SETTING_NAME:
-/* g_debug("context setting name");*/
- break;
- case PA_CONTEXT_FAILED:
- g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?");
- pa_server_available = FALSE;
- reconnect_to_pulse();
- break;
- case PA_CONTEXT_TERMINATED:
-/* g_debug("context terminated");*/
- break;
- case PA_CONTEXT_READY:
- g_debug("PA daemon is ready");
- pa_operation *o;
-
- pa_context_set_subscribe_callback(c, subscribed_events_callback, userdata);
-
- if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t)
- (PA_SUBSCRIPTION_MASK_SINK|
- PA_SUBSCRIPTION_MASK_SINK_INPUT|
- PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) {
- g_warning("pa_context_subscribe() failed");
- return;
- }
- pa_operation_unref(o);
-
- gather_pulse_information(c, userdata);
-
- break;
+static void context_state_callback(pa_context *c, void *userdata)
+{
+ switch (pa_context_get_state(c)) {
+ case PA_CONTEXT_UNCONNECTED:
+ /* g_debug("unconnected");*/
+ break;
+ case PA_CONTEXT_CONNECTING:
+ /* g_debug("connecting - waiting for the server to become available");*/
+ break;
+ case PA_CONTEXT_AUTHORIZING:
+ /* g_debug("authorizing");*/
+ break;
+ case PA_CONTEXT_SETTING_NAME:
+ /* g_debug("context setting name");*/
+ break;
+ case PA_CONTEXT_FAILED:
+ g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?");
+ pa_server_available = FALSE;
+ reconnect_to_pulse();
+ break;
+ case PA_CONTEXT_TERMINATED:
+ /* g_debug("context terminated");*/
+ break;
+ case PA_CONTEXT_READY:
+ g_debug("PA daemon is ready");
+ pa_operation *o;
+
+ pa_context_set_subscribe_callback(c, subscribed_events_callback, userdata);
+
+ if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t)
+ (PA_SUBSCRIPTION_MASK_SINK|
+ PA_SUBSCRIPTION_MASK_SINK_INPUT|
+ PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) {
+ g_warning("pa_context_subscribe() failed");
+ return;
}
+ pa_operation_unref(o);
+
+ gather_pulse_information(c, userdata);
+
+ break;
+ }
}
diff --git a/src/pulse-manager.h b/src/pulse-manager.h
index 54978bb..fc01f1c 100644
--- a/src/pulse-manager.h
+++ b/src/pulse-manager.h
@@ -29,19 +29,19 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct {
- gchar* name;
- gint index;
- pa_cvolume volume;
- pa_channel_map channel_map;
- gboolean mute;
- pa_volume_t base_volume;
+ gchar* name;
+ gint index;
+ pa_cvolume volume;
+ pa_channel_map channel_map;
+ gboolean mute;
+ pa_volume_t base_volume;
} sink_info;
pa_context* get_context(void);
void establish_pulse_activities(SoundServiceDbus *service);
void set_sink_volume(gdouble percent);
-void toggle_global_mute(gboolean mute_value);
+void toggle_global_mute(gboolean mute_value);
void close_pulse_activites();
#endif
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 8a21fcf..d56422a 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -4,16 +4,16 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -28,9 +28,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate;
-struct _SliderMenuItemPrivate
-{
- gdouble slider_value;
+struct _SliderMenuItemPrivate {
+ gdouble slider_value;
};
#define SLIDER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SLIDER_MENU_ITEM_TYPE, SliderMenuItemPrivate))
@@ -46,58 +45,58 @@ G_DEFINE_TYPE (SliderMenuItem, slider_menu_item, DBUSMENU_TYPE_MENUITEM);
static void slider_menu_item_class_init (SliderMenuItemClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (SliderMenuItemPrivate));
+ g_type_class_add_private (klass, sizeof (SliderMenuItemPrivate));
- object_class->dispose = slider_menu_item_dispose;
- object_class->finalize = slider_menu_item_finalize;
+ object_class->dispose = slider_menu_item_dispose;
+ object_class->finalize = slider_menu_item_finalize;
DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass);
mclass->handle_event = handle_event;
- return;
+ return;
}
static void slider_menu_item_init (SliderMenuItem *self)
{
- g_debug("Building new Slider Menu Item");
- return;
+ g_debug("Building new Slider Menu Item");
+ return;
}
static void slider_menu_item_dispose (GObject *object)
{
- G_OBJECT_CLASS (slider_menu_item_parent_class)->dispose (object);
- return;
+ G_OBJECT_CLASS (slider_menu_item_parent_class)->dispose (object);
+ return;
}
static void
slider_menu_item_finalize (GObject *object)
{
- G_OBJECT_CLASS (slider_menu_item_parent_class)->finalize (object);
+ G_OBJECT_CLASS (slider_menu_item_parent_class)->finalize (object);
}
static void
handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
{
- g_debug("in the handle event method of slider_menu_item");
+ g_debug("in the handle event method of slider_menu_item");
gdouble volume_input = 0;
volume_input = g_value_get_double(value);
- if(value != NULL)
- set_sink_volume(volume_input);
+ if (value != NULL)
+ set_sink_volume(volume_input);
}
SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume)
{
- SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL);
+ SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_SLIDER_MENUITEM_TYPE);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available);
- return self;
+ return self;
}
-
+
diff --git a/src/slider-menu-item.h b/src/slider-menu-item.h
index c2acf63..763944f 100644
--- a/src/slider-menu-item.h
+++ b/src/slider-menu-item.h
@@ -4,16 +4,16 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SLIDER_MENU_ITEM_H__
@@ -37,11 +37,11 @@ typedef struct _SliderMenuItem SliderMenuItem;
typedef struct _SliderMenuItemClass SliderMenuItemClass;
struct _SliderMenuItemClass {
- DbusmenuMenuitemClass parent_class;
+ DbusmenuMenuitemClass parent_class;
};
struct _SliderMenuItem {
- DbusmenuMenuitem parent;
+ DbusmenuMenuitem parent;
};
GType slider_menu_item_get_type (void);
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index d1ddfc4..85945d0 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -28,7 +28,7 @@
#include "common-defs.h"
#include "pulse-manager.h"
-// DBUS methods
+// DBUS methods
static gboolean sound_service_dbus_get_sink_volume(SoundServiceDbus* service, gdouble* volume_percent_input, GError** gerror);
static gboolean sound_service_dbus_get_sink_mute(SoundServiceDbus* service, gboolean* mute_input, GError** gerror);
static gboolean sound_service_dbus_get_sink_availability(SoundServiceDbus* service, gboolean* availability_input, GError** gerror);
@@ -38,12 +38,11 @@ static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const
typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate;
-struct _SoundServiceDbusPrivate
-{
- DBusGConnection *connection;
- gdouble volume_percent;
- gboolean mute;
- gboolean sink_availability;
+struct _SoundServiceDbusPrivate {
+ DBusGConnection *connection;
+ gdouble volume_percent;
+ gboolean mute;
+ gboolean sink_availability;
};
@@ -73,47 +72,47 @@ G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
static void
sound_service_dbus_class_init (SoundServiceDbusClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof(SoundServiceDbusPrivate));
-
- object_class->dispose = sound_service_dbus_dispose;
- object_class->finalize = sound_service_dbus_finalize;
-
- g_assert(klass != NULL);
- dbus_g_object_type_install_info(SOUND_SERVICE_DBUS_TYPE,
- &dbus_glib__sound_service_server_object_info);
-
- signals[SINK_INPUT_WHILE_MUTED] = g_signal_new("sink-input-while-muted",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
- signals[SINK_VOLUME_UPDATE] = g_signal_new("sink-volume-update",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__DOUBLE,
- G_TYPE_NONE, 1, G_TYPE_DOUBLE);
-
- signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
- signals[SINK_AVAILABLE_UPDATE] = g_signal_new("sink-available-update",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof(SoundServiceDbusPrivate));
+
+ object_class->dispose = sound_service_dbus_dispose;
+ object_class->finalize = sound_service_dbus_finalize;
+
+ g_assert(klass != NULL);
+ dbus_g_object_type_install_info(SOUND_SERVICE_DBUS_TYPE,
+ &dbus_glib__sound_service_server_object_info);
+
+ signals[SINK_INPUT_WHILE_MUTED] = g_signal_new("sink-input-while-muted",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+ signals[SINK_VOLUME_UPDATE] = g_signal_new("sink-volume-update",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE, 1, G_TYPE_DOUBLE);
+
+ signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals[SINK_AVAILABLE_UPDATE] = g_signal_new("sink-available-update",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
@@ -122,41 +121,41 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass)
static void
sound_service_dbus_init (SoundServiceDbus *self)
{
- GError *error = NULL;
- SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
-
- priv->connection = NULL;
- priv->volume_percent = 0;
- priv->mute = FALSE;
- priv->sink_availability = FALSE;
-
- /* Fetch the session bus */
- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-
- if (error != NULL) {
- g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message);
- g_error_free(error);
- return;
- }
- /* register the service on it */
- dbus_g_connection_register_g_object(priv->connection,
- INDICATOR_SOUND_SERVICE_DBUS_OBJECT,
- G_OBJECT(self));
+ GError *error = NULL;
+ SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
+
+ priv->connection = NULL;
+ priv->volume_percent = 0;
+ priv->mute = FALSE;
+ priv->sink_availability = FALSE;
+
+ /* Fetch the session bus */
+ priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+ if (error != NULL) {
+ g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message);
+ g_error_free(error);
+ return;
+ }
+ /* register the service on it */
+ dbus_g_connection_register_g_object(priv->connection,
+ INDICATOR_SOUND_SERVICE_DBUS_OBJECT,
+ G_OBJECT(self));
}
static void
sound_service_dbus_dispose (GObject *object)
{
- G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object);
- return;
+ G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object);
+ return;
}
static void
sound_service_dbus_finalize (GObject *object)
{
- G_OBJECT_CLASS (sound_service_dbus_parent_class)->finalize (object);
- return;
+ G_OBJECT_CLASS (sound_service_dbus_parent_class)->finalize (object);
+ return;
}
@@ -165,32 +164,32 @@ DBUS Method Callbacks
**/
static void 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!, with volume_percent of %i", volume_percent);
- set_sink_volume(volume_percent);
+ g_debug("in the set sink volume method in the sound service dbus!, with volume_percent of %i", volume_percent);
+ set_sink_volume(volume_percent);
}
static gboolean sound_service_dbus_get_sink_volume (SoundServiceDbus *self, gdouble *volume_percent_input, GError** gerror)
{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
- g_debug("Get sink volume method in the sound service dbus!, about to send over volume percent of %f", priv->volume_percent);
- *volume_percent_input = priv->volume_percent;
- return TRUE;
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ g_debug("Get sink volume method in the sound service dbus!, about to send over volume percent of %f", priv->volume_percent);
+ *volume_percent_input = priv->volume_percent;
+ return TRUE;
}
static gboolean sound_service_dbus_get_sink_mute (SoundServiceDbus *self, gboolean *mute_input, GError** gerror)
{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
- g_debug("Get sink mute - sound service dbus!, about to send over mute_value of %i", priv->mute);
- *mute_input = priv->mute;
- return TRUE;
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ g_debug("Get sink mute - sound service dbus!, about to send over mute_value of %i", priv->mute);
+ *mute_input = priv->mute;
+ return TRUE;
}
static gboolean sound_service_dbus_get_sink_availability (SoundServiceDbus *self, gboolean *availability_input, GError** gerror)
{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
- g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability);
- *availability_input = priv->sink_availability;
- return TRUE;
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability);
+ *availability_input = priv->sink_availability;
+ return TRUE;
}
/**
@@ -199,8 +198,8 @@ Utility methods to emit signals from the service into the ether.
**/
void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean block_value)
{
-/* g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value);*/
- g_signal_emit(obj,
+ /* g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value);*/
+ g_signal_emit(obj,
signals[SINK_INPUT_WHILE_MUTED],
0,
block_value);
@@ -208,11 +207,11 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean
void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume)
{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
- priv->volume_percent = sink_volume;
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
+ priv->volume_percent = sink_volume;
-/* g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent);*/
- g_signal_emit(obj,
+ /* g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent);*/
+ g_signal_emit(obj,
signals[SINK_VOLUME_UPDATE],
0,
priv->volume_percent);
@@ -220,12 +219,12 @@ void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_v
void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute)
{
-/* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/
+ /* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
- priv->mute = sink_mute;
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
+ priv->mute = sink_mute;
- g_signal_emit(obj,
+ g_signal_emit(obj,
signals[SINK_MUTE_UPDATE],
0,
priv->mute);
@@ -233,16 +232,16 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mu
void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availability)
{
-/* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/
+ /* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
- priv->sink_availability = sink_availability;
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj);
+ priv->sink_availability = sink_availability;
- g_signal_emit(obj,
+ g_signal_emit(obj,
signals[SINK_AVAILABLE_UPDATE],
0,
priv->sink_availability);
}
-
+
diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h
index ae4953e..258b610 100644
--- a/src/sound-service-dbus.h
+++ b/src/sound-service-dbus.h
@@ -38,8 +38,7 @@ typedef struct _SoundServiceDbus SoundServiceDbus;
typedef struct _SoundServiceDbusClass SoundServiceDbusClass;
typedef struct _SoundData SoundData;
-struct _SoundData
-{
+struct _SoundData {
SoundServiceDbus *service;
};
@@ -49,7 +48,7 @@ struct _SoundServiceDbus {
struct _SoundServiceDbusClass {
GObjectClass parent_class;
-};
+};
GType sound_service_dbus_get_type (void) G_GNUC_CONST;
// Utility methods to get the SIGNAL messages across into the sound-service-dbus
diff --git a/src/sound-service.c b/src/sound-service.c
index 38e5fba..ea04e4b 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -7,16 +7,16 @@ Authors:
Ted Gould <ted@canonical.com>
Cody Russell <crussell@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -35,49 +35,49 @@ static GMainLoop *mainloop = NULL;
/**
service_shutdown:
When the service interface starts to shutdown, we
-should follow it.
+should follow it.
**/
void
service_shutdown (IndicatorService *service, gpointer user_data)
{
- if (mainloop != NULL) {
- g_debug("Service shutdown !");
+ if (mainloop != NULL) {
+ g_debug("Service shutdown !");
// TODO: uncomment for release !!
- close_pulse_activites();
- g_main_loop_quit(mainloop);
- }
- return;
+ //close_pulse_activites();
+ //g_main_loop_quit(mainloop);
+ }
+ return;
}
/**
-main:
+main:
**/
int
main (int argc, char ** argv)
{
g_type_init();
- setlocale (LC_ALL, "");
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
- IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME,
- INDICATOR_SOUND_DBUS_VERSION);
- g_signal_connect(G_OBJECT(service),
- INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
- G_CALLBACK(service_shutdown), NULL);
+ IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME,
+ INDICATOR_SOUND_DBUS_VERSION);
+ g_signal_connect(G_OBJECT(service),
+ INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
+ G_CALLBACK(service_shutdown), NULL);
- DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup();
- MusicPlayerBridge* server = music_player_bridge_new();
- music_player_bridge_set_root_menu_item(server, root_menuitem);
+ DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup();
+ MusicPlayerBridge* server = music_player_bridge_new();
+ music_player_bridge_set_root_menu_item(server, root_menuitem);
- // Run the loop
+ // Run the loop
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
-
+
return 0;
}
diff --git a/src/sound-service.h b/src/sound-service.h
index cefbf45..e95d4c7 100644
--- a/src/sound-service.h
+++ b/src/sound-service.h
@@ -10,16 +10,16 @@ Authors:
Ted Gould <ted@canonical.com>
Cody Russell <crussell@canonical.com>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/