aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-03-18 12:17:04 +0000
committerConor Curran <conor.curran@canonical.com>2010-03-18 12:17:04 +0000
commit87011fc598699215a9268af59b9426176a5038ff (patch)
treeb97d9185d06eb8b8b6b207080dcb383da63a35ac
parentc865edaf8a55627fec5cb85dbb77296e193ad342 (diff)
parent6e407358a9f48bcf24c6224b35cd2845fdf56004 (diff)
downloadayatana-indicator-sound-87011fc598699215a9268af59b9426176a5038ff.tar.gz
ayatana-indicator-sound-87011fc598699215a9268af59b9426176a5038ff.tar.bz2
ayatana-indicator-sound-87011fc598699215a9268af59b9426176a5038ff.zip
Merged Cody's scrolling work and updated version to overcome ppa problem
-rw-r--r--configure.ac4
-rw-r--r--src/indicator-sound.c50
2 files changed, 41 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac
index 770245a..2a465ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,10 @@
-AC_INIT(indicator-sound, 0.1.3.1, conor.curran@canonical.com)
+AC_INIT(indicator-sound, 0.2.1, conor.curran@canonical.com)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-sound, 0.1.3.1)
+AM_INIT_AUTOMAKE(indicator-sound, 0.2.1)
AM_MAINTAINER_MODE
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 3b2b426..e9a8e73 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -7,6 +7,7 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
Ted Gould <ted@canonical.com>
+ Cody Russell <cody.russell@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
@@ -60,6 +61,7 @@ struct _IndicatorSoundClass {
//GObject instance struct
struct _IndicatorSound {
IndicatorObject parent;
+ GtkWidget *slider;
IndicatorServiceManager *service;
};
// GObject Boiler plate
@@ -77,7 +79,8 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE);
//GTK+ items
static GtkLabel * get_label (IndicatorObject * io);
static GtkImage * get_icon (IndicatorObject * io);
-static GtkMenu * get_menu (IndicatorObject * io);
+static GtkMenu * get_menu (IndicatorObject * io);
+static void scroll (IndicatorObject*io, gint delta, IndicatorScrollDirection direction);
//Slider related
static GtkWidget *volume_slider = NULL;
@@ -140,9 +143,10 @@ indicator_sound_class_init (IndicatorSoundClass *klass)
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->get_menu = get_menu;
+ io_class->scroll = scroll;
- design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
+ design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
return;
}
@@ -172,7 +176,7 @@ indicator_sound_dispose (GObject *object)
self->service = NULL;
}
g_hash_table_destroy(volume_states);
-
+
if(blocked_animation_list != NULL){
g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL);
g_list_free(blocked_animation_list);
@@ -212,7 +216,10 @@ static GtkMenu *
get_menu (IndicatorObject * io)
{
DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT);
- DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu);
+ 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);
// register Key-press listening on the menu widget as the slider does not allow this.
@@ -235,9 +242,13 @@ Create a new dBusMenu Slider item.
**/
static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
+ IndicatorObject *io = NULL;
+
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");
+
volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 0.5);
g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL);
@@ -252,6 +263,8 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p
// register slider changes listening on the range
GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_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);
@@ -343,18 +356,18 @@ static void prepare_blocked_animation()
{
gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED));
-
- GtkImage* temp_image = indicator_image_helper(muted_name);
- GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image);
- temp_image = indicator_image_helper(blocked_name);
+ GtkImage* temp_image = indicator_image_helper(muted_name);
+ GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image);
+
+ temp_image = indicator_image_helper(blocked_name);
GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image);
int i;
if(mute_buf == NULL || blocked_buf == NULL){
g_debug("Don bother with the animation, the theme aint got the goods");
- return;
+ return;
}
// sample 22 snapshots - range : 0-256
@@ -495,7 +508,7 @@ static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean blo
blocked_iter = blocked_animation_list;
animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL);
- }
+ }
}
static gboolean fade_back_to_mute_image()
@@ -655,3 +668,18 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat
}
+static void
+scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
+{
+ 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;
+
+ gtk_range_set_value (GTK_RANGE (sound->slider),
+ value);
+}