diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-03-04 18:02:45 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-03-04 18:02:45 +0000 |
commit | 6b706a64c5bdcc4b33adfa94b5fa71dbda928399 (patch) | |
tree | 3589261458b296c7a280fb9ec6218f9f7b785049 /src | |
parent | 633b514efeaf1c4086e1b2e5fbef185b199517c8 (diff) | |
download | ayatana-indicator-sound-6b706a64c5bdcc4b33adfa94b5fa71dbda928399.tar.gz ayatana-indicator-sound-6b706a64c5bdcc4b33adfa94b5fa71dbda928399.tar.bz2 ayatana-indicator-sound-6b706a64c5bdcc4b33adfa94b5fa71dbda928399.zip |
slider stretching in place
Diffstat (limited to 'src')
-rw-r--r-- | src/dbus-menu-manager.c | 5 | ||||
-rw-r--r-- | src/indicator-sound.c | 47 | ||||
-rw-r--r-- | src/slider-menu-item.c | 1 | ||||
-rw-r--r-- | src/sound-service.c | 4 |
4 files changed, 26 insertions, 31 deletions
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 17003df..d2102ef 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <unistd.h> #include <glib/gi18n.h> @@ -210,8 +209,8 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service // Sound preferences dialog DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, - _("Sound Preferences...")); + 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); diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 3a6ae30..098b24f 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -78,14 +78,14 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE); static GtkLabel * get_label (IndicatorObject * io); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); + //Slider related static GtkWidget *volume_slider = NULL; static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); -// Alternative callback mechanism, may use this again once ido is updated. -/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data);*/ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); +static void slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data); // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; @@ -96,6 +96,7 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value static void fetch_volume_percent_from_dbus(); static void fetch_mute_value_from_dbus(); + /****Volume States 'members' ***/ static void update_state(const gint state); @@ -201,6 +202,7 @@ get_menu (IndicatorObject * io) return GTK_MENU(menu); } + /** new_slider_item: Create a new dBusMenu Slider item. @@ -220,10 +222,9 @@ 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); + g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); - // alternative callback mechanism which i could use again at some point. -/* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */ - + g_signal_connect(slider, "size-allocate", G_CALLBACK(slider_size_allocate), NULL); // Set images on the ido primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); @@ -277,9 +278,6 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u return; } - - - /* Prepare states Array. */ @@ -452,6 +450,21 @@ static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) } /** +slider_size_allocate: +Callback on the size-allocate event on the slider item. +**/ +static void slider_size_allocate(GtkWidget *widget, + GtkAllocation *allocation, + gpointer user_data) +{ + g_print("size allocate on slider (%dx%d)\n", allocation->width, allocation->height); + if(allocation->width < 200) + { + gtk_widget_set_size_request(widget, 200, -1); + } +} + +/** key_press_cb: **/ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) @@ -514,22 +527,4 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat return digested; } -/** -This callback should only be called when the user actually drags the slider. -Turned off for now in favour of the non descriminating value-changed call back. -Once the grabbing listener is implemented on the slider may revert to using this. -Its another tool for filtering unwanted volume change updates. -**/ -/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data)*/ -/*{*/ -/* DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data;*/ -/* gdouble clamped_input = CLAMP(input_value, 0, 100);*/ -/* GValue value = {0};*/ -/* g_debug("User input on SLIDER - = %f", clamped_input);*/ -/* g_value_init(&value, G_TYPE_DOUBLE);*/ -/* g_value_set_double(&value, clamped_input);*/ -/* dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0);*/ -/* return FALSE; */ -/*} */ - diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index ef3b1fa..a14f4f9 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -92,6 +92,7 @@ SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_vol 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; } diff --git a/src/sound-service.c b/src/sound-service.c index 403b2b0..9e967c2 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -44,8 +44,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; } |