aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-08-02 19:13:58 +0100
committerConor Curran <conor.curran@canonical.com>2010-08-02 19:13:58 +0100
commit9f7e55264deaaad68280ae33daad95fca604df8b (patch)
tree60a7fbb7bb9eee411eb0ce60a72a191376cc8108 /src
parent496ac14d4e3b4e5b9284083cf4ce277cfe5ef343 (diff)
downloadayatana-indicator-sound-9f7e55264deaaad68280ae33daad95fca604df8b.tar.gz
ayatana-indicator-sound-9f7e55264deaaad68280ae33daad95fca604df8b.tar.bz2
ayatana-indicator-sound-9f7e55264deaaad68280ae33daad95fca604df8b.zip
replaced now needs tweaking
Diffstat (limited to 'src')
-rw-r--r--src/common-defs.h3
-rw-r--r--src/dbus-menu-manager.c14
-rw-r--r--src/dbus-menu-manager.h1
-rw-r--r--src/indicator-sound.c9
-rw-r--r--src/play-button.c21
-rw-r--r--src/pulse-manager.c10
-rw-r--r--src/slider-menu-item.c6
-rw-r--r--src/sound-service.c4
-rw-r--r--src/volume-widget.c61
-rw-r--r--src/volume-widget.h2
10 files changed, 60 insertions, 71 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index 46ff520..e3b4552 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -27,7 +27,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_PROPERTY_EMPTY -1
/* DBUS Custom Items */
-#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-type"
+#define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type"
+#define DBUSMENU_VOLUME_MENUITEM_LEVEL "x-canonical-ido-volume-level"
#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"
#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c
index 4cd4a6b..076b177 100644
--- a/src/dbus-menu-manager.c
+++ b/src/dbus-menu-manager.c
@@ -31,6 +31,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sound-service-dbus.h"
#include "pulse-manager.h"
#include "slider-menu-item.h"
+#include "common-defs.h"
#include "dbus-shared-names.h"
@@ -74,13 +75,15 @@ DbusmenuMenuitem* dbus_menu_manager_setup()
return root_menuitem;
}
-/**
-teardown:
-**/
-void dbus_menu_manager_teardown()
+
+void dbus_menu_manager_update_volume(gdouble volume)
{
- //TODO tidy up dbus_interface and items!
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_DOUBLE);
+ g_value_set_double(&value, volume);
+ dbusmenu_menuitem_property_set_value(volume_slider_menuitem, DBUSMENU_VOLUME_MENUITEM_LEVEL, &value);
}
+
/**
update_pa_state:
@@ -123,7 +126,6 @@ void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value)
/*-------------------------------------------------------------------------*/
// Private Methods
/*-------------------------------------------------------------------------*/
-
static void refresh_menu()
{
g_debug("in the refresh menu method");
diff --git a/src/dbus-menu-manager.h b/src/dbus-menu-manager.h
index 926e292..ec2b2e2 100644
--- a/src/dbus-menu-manager.h
+++ b/src/dbus-menu-manager.h
@@ -25,6 +25,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
DbusmenuMenuitem* dbus_menu_manager_setup();
void dbus_menu_manager_teardown();
+void dbus_menu_manager_update_volume(gdouble volume);
void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble current_vol);
// TODO update pa_state should incorporate the method below !
void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value);
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index fee87c8..bf44d15 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -247,7 +247,7 @@ get_menu (IndicatorObject * io)
DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT);
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_VOLUME_MENUITEM_TYPE, new_volume_slider_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);
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TITLE_MENUITEM_TYPE, new_title_widget);
@@ -814,7 +814,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
{
gboolean digested = FALSE;
- g_return_val_if_fail(IS_INDICATOR_SOUND(data));
+ g_return_val_if_fail(IS_INDICATOR_SOUND(data), FALSE);
IndicatorSound *sound = INDICATOR_SOUND (data);
@@ -882,9 +882,10 @@ 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;
+ g_debug("Scroll detected");
+ 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));
diff --git a/src/play-button.c b/src/play-button.c
index e4382c1..94e6f98 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -454,29 +454,8 @@ void
play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update)
{
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
- gboolean changed = priv->current_state != update;
priv->current_state = update;
g_debug("PlayButton::toggle play state : %i", priv->current_state);
-
- if(changed == TRUE){
- g_debug("Toggle play pause - changed of state detected - redraw button");
- cairo_t *cr;
-
- cr = gdk_cairo_create (button->window);
-
- GList* list = g_hash_table_lookup(priv->command_coordinates,
- GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE));
-
- cairo_rectangle(cr,
- GPOINTER_TO_INT(g_list_nth_data(list, 0)),
- GPOINTER_TO_INT(g_list_nth_data(list, 1)),
- GPOINTER_TO_INT(g_list_nth_data(list, 2)),
- GPOINTER_TO_INT(g_list_nth_data(list, 3)));
-
- cairo_clip(cr);
- draw (button, cr);
- cairo_destroy (cr);
- }
}
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index a9a47e4..4ff9e1d 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -211,7 +211,8 @@ static void mute_each_sink(gpointer key, gpointer value, gpointer user_data)
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());
+ //sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume());
+ dbus_menu_manager_update_volume(get_default_sink_volume());
}
/* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/
@@ -288,7 +289,7 @@ static void context_success_callback(pa_context *c, int success, void *userdata)
/**
On Service startup this callback will be called multiple times resulting our sinks_hash container to be filled with the
available sinks.
-For now this callback it assumes it only used at startup. It may be necessary to use if sinks become available after startup.
+For now this callback assumes it only used at startup. It may be necessary to use if sinks become available after startup.
Major candidate for refactoring.
**/
static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, int eol, void *userdata)
@@ -399,7 +400,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
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);
+ dbus_menu_manager_update_volume(volume_percent);
}
if (mute_changed == TRUE) {
@@ -410,7 +411,8 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
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);
+ //sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
+ dbus_menu_manager_update_volume(volume_percent);
}
}
}
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index d56422a..9536ff8 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -90,9 +90,11 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g
SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume)
{
+
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(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_VOLUME_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;
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 8768cd3..16fa87c 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -42,8 +42,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown !");
// TODO: uncomment for release !!
- close_pulse_activites();
- g_main_loop_quit(mainloop);
+ //close_pulse_activites();
+ //g_main_loop_quit(mainloop);
}
return;
}
diff --git a/src/volume-widget.c b/src/volume-widget.c
index 8b54a32..9b6e5f7 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -22,6 +22,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#include <glib/gi18n.h>
+#include <math.h>
+#include <glib.h>
#include "volume-widget.h"
#include "common-defs.h"
#include <libido/idoscalemenuitem.h>
@@ -45,8 +47,7 @@ static void volume_widget_finalize (GObject *object);
static void volume_widget_set_twin_item( VolumeWidget* self,
DbusmenuMenuitem* twin_item);
static void volume_widget_set_ido_position(VolumeWidget* self,
- gint position,
- gint duration);
+ gdouble new_volume);
//callbacks
static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata);
@@ -54,6 +55,9 @@ static gboolean volume_widget_change_value_cb (GtkRange *range,
GtkScrollType scroll,
gdouble value,
gpointer user_data);
+static gboolean volume_widget_value_changed_cb(GtkRange *range,
+ gpointer user_data);
+
static void volume_widget_slider_grabbed(GtkWidget *widget, gpointer user_data);
static void volume_widget_slider_released(GtkWidget *widget, gpointer user_data);
static void volume_widget_parent_changed (GtkWidget *widget, gpointer user_data);
@@ -82,14 +86,14 @@ volume_widget_init (VolumeWidget *self)
ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (priv->ido_volume_slider), IDO_SCALE_MENU_ITEM_STYLE_IMAGE);
g_object_set(priv->ido_volume_slider, "reverse-scroll-events", TRUE, NULL);
- g_signal_connect (volume_slider,
- "notify::parent", G_CALLBACK (slider_parent_changed),
+ g_signal_connect (priv->ido_volume_slider,
+ "notify::parent", G_CALLBACK (volume_widget_parent_changed),
NULL);
GtkWidget* volume_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
// register slider changes listening on the range
- g_signal_connect(volume_widget, "change-value", G_CALLBACK(volume_widget_change_value_cb), self);
+ //g_signal_connect(volume_widget, "change-value", G_CALLBACK(volume_widget_change_value_cb), self);
g_signal_connect(volume_widget, "value-changed", G_CALLBACK(volume_widget_value_changed_cb), self);
g_signal_connect(priv->ido_volume_slider, "slider-grabbed", G_CALLBACK(volume_widget_slider_grabbed), self);
g_signal_connect(priv->ido_volume_slider, "slider-released", G_CALLBACK(volume_widget_slider_released), self);
@@ -107,8 +111,6 @@ volume_widget_init (VolumeWidget *self)
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (volume_widget));
gtk_adjustment_set_step_increment(adj, 3);
-
- gtk_widget_show_all(volume_widget);
}
static void
@@ -126,13 +128,18 @@ volume_widget_finalize (GObject *object)
static void
volume_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata)
-{
- g_debug("scrub-widget::property_update");
-
+{
g_return_if_fail (IS_VOLUME_WIDGET (userdata));
VolumeWidget* mitem = VOLUME_WIDGET(userdata);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
-
+ g_debug("scrub-widget::property_update for prop %s", property);
+ if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){
+ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
+ GtkRange *range = (GtkRange*)slider;
+ gdouble update = g_value_get_double (value);
+ g_debug("volume-widget - update level with value %f", update);
+ gtk_range_set_value(range, update);
+ }
}
static void
@@ -174,20 +181,18 @@ volume_widget_change_value_cb (GtkRange *range,
}
static gboolean
-volume_widget_value_changed(GtkRange *range, gpointer user_data)
+volume_widget_value_changed_cb(GtkRange *range, gpointer user_data)
{
g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
VolumeWidget* mitem = VOLUME_WIDGET(user_data);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
-
- gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(priv->ido_volume_slider), 0, 100);
- // Replace with dbus properties inspection
- /*if (current_value == exterior_vol_update) {
- g_debug("ignore the value changed event - its come from the outside");
- return FALSE;
- }*/
-
+ if(priv->grabbed == TRUE){
+ return TRUE;
+ }
+
+ gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(priv->ido_volume_slider)), 0, 100);
+
GValue value = {0};
g_value_init(&value, G_TYPE_DOUBLE);
g_value_set_double(&value, current_value);
@@ -195,13 +200,13 @@ volume_widget_value_changed(GtkRange *range, gpointer user_data)
dbusmenu_menuitem_handle_event (priv->twin_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);
+ //determine_state_from_volume(current_value);
return FALSE;
}
GtkWidget*
-volume_widget_get_ido_bar(VolumeWidget* self)
+volume_widget_get_ido_slider(VolumeWidget* self)
{
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self);
return priv->ido_volume_slider;
@@ -215,20 +220,16 @@ volume_widget_parent_changed (GtkWidget *widget,
g_debug("volume_widget_parent_changed");
}
-
+
+//TODO: are we using this as convenience function
static void
volume_widget_set_ido_position(VolumeWidget* self,
- gint position,
- gint duration)
+ gdouble new_volume)
{
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self);
- gdouble ido_position = position/(gdouble)duration * 100.0;
- g_debug("volume_widget_set_ido_position - pos: %i, duration: %i, ido_pos: %f", position, duration, ido_position);
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
- if(duration == 0)
- ido_position = 0.0;
- gtk_range_set_value(range, ido_position);
+ gtk_range_set_value(range, new_volume);
}
static void
diff --git a/src/volume-widget.h b/src/volume-widget.h
index 8e3e895..7e6ab84 100644
--- a/src/volume-widget.h
+++ b/src/volume-widget.h
@@ -45,7 +45,7 @@ struct _VolumeWidget {
GType volume_widget_get_type (void) G_GNUC_CONST;
GtkWidget* volume_widget_new(DbusmenuMenuitem* twin_item);
-GtkWidget* volume_widget_get_ido_bar(VolumeWidget* self);
+GtkWidget* volume_widget_get_ido_slider(VolumeWidget* self);
G_END_DECLS