gnome-media r4278 - in trunk/gnome-volume-control: . src
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4278 - in trunk/gnome-volume-control: . src
- Date: Thu, 12 Mar 2009 10:52:03 +0000 (UTC)
Author: hadess
Date: Thu Mar 12 10:52:03 2009
New Revision: 4278
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4278&view=rev
Log:
2009-03-12 Bastien Nocera <hadess hadess net>
* src/gvc-balance-bar.c (_scale_box_new),
(gvc_balance_bar_set_balance_type), (gvc_balance_bar_set_property),
(gvc_balance_bar_class_init), (on_adjustment_value_changed),
(gvc_balance_bar_init), (gvc_balance_bar_new): Fix use of the
zero_adjustment GtkAdjustment in slider callbacks, export
gvc_channel_bar_scroll
* src/gvc-balance-bar.h: Export gvc_channel_bar_scroll
* src/gvc-stream-status-icon.c (on_status_icon_scroll_event):
Use gvc_channel_bar_scroll instead of our own code
(Closes: #564313)
Modified:
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/gvc-channel-bar.c
trunk/gnome-volume-control/src/gvc-channel-bar.h
trunk/gnome-volume-control/src/gvc-stream-status-icon.c
Modified: trunk/gnome-volume-control/src/gvc-channel-bar.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-channel-bar.c (original)
+++ trunk/gnome-volume-control/src/gvc-channel-bar.c Thu Mar 12 10:52:03 2009
@@ -394,6 +394,7 @@
GdkEventButton *event,
GvcChannelBar *bar)
{
+ GtkAdjustment *adj;
gdouble value;
/* HACK: see on_scale_button_press_event() */
@@ -402,13 +403,16 @@
bar->priv->click_lock = FALSE;
- value = gtk_adjustment_get_value (bar->priv->zero_adjustment);
- gtk_adjustment_set_value (bar->priv->adjustment, value);
+ adj = gtk_range_get_adjustment (GTK_RANGE (widget));
+
+ value = gtk_adjustment_get_value (adj);
/* this means the adjustment moved away from zero and
therefore we should unmute and set the volume. */
-
- gvc_channel_bar_set_is_muted (bar, FALSE);
+ if (value > 0)
+ gvc_channel_bar_set_is_muted (bar, FALSE);
+ else
+ gvc_channel_bar_set_is_muted (bar, TRUE);
/* Play a sound! */
ca_gtk_play_for_widget (GTK_WIDGET (bar), 0,
@@ -420,32 +424,55 @@
return FALSE;
}
-static gboolean
-on_scale_scroll_event (GtkWidget *widget,
- GdkEventScroll *event,
- GvcChannelBar *bar)
+gboolean
+gvc_channel_bar_scroll (GvcChannelBar *bar, GdkScrollDirection direction)
{
+ GtkAdjustment *adj;
gdouble value;
- value = gtk_adjustment_get_value (bar->priv->adjustment);
+ g_return_val_if_fail (bar != NULL, FALSE);
+ g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+ /* FIXME we should handle left/right for horizontal bars */
+ if (direction != GDK_SCROLL_UP && direction != GDK_SCROLL_DOWN)
+ return FALSE;
+
+ adj = gtk_range_get_adjustment (GTK_RANGE (bar->priv->scale));
+ if (adj == bar->priv->zero_adjustment) {
+ if (direction == GDK_SCROLL_UP)
+ gvc_channel_bar_set_is_muted (bar, FALSE);
+ return TRUE;
+ }
+
+ value = gtk_adjustment_get_value (adj);
- if (event->direction == GDK_SCROLL_UP) {
+ if (direction == GDK_SCROLL_UP) {
if (value + ADJUSTMENT_MAX/100.0 > ADJUSTMENT_MAX)
value = ADJUSTMENT_MAX;
else
value = value + ADJUSTMENT_MAX/100.0;
- gtk_adjustment_set_value (bar->priv->adjustment, value);
- } else if (event->direction == GDK_SCROLL_DOWN) {
+ } else if (direction == GDK_SCROLL_DOWN) {
if (value - ADJUSTMENT_MAX/100.0 < 0)
value = 0.0;
else
value = value - ADJUSTMENT_MAX/100.0;
- gtk_adjustment_set_value (bar->priv->adjustment, value);
}
+ gvc_channel_bar_set_is_muted (bar, (value == 0.0));
+ adj = gtk_range_get_adjustment (GTK_RANGE (bar->priv->scale));
+ gtk_adjustment_set_value (adj, value);
+
return TRUE;
}
+static gboolean
+on_scale_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event,
+ GvcChannelBar *bar)
+{
+ return gvc_channel_bar_scroll (bar, event->direction);
+}
+
static void
on_zero_adjustment_value_changed (GtkAdjustment *adjustment,
GvcChannelBar *bar)
Modified: trunk/gnome-volume-control/src/gvc-channel-bar.h
==============================================================================
--- trunk/gnome-volume-control/src/gvc-channel-bar.h (original)
+++ trunk/gnome-volume-control/src/gvc-channel-bar.h Thu Mar 12 10:52:03 2009
@@ -76,6 +76,9 @@
void gvc_channel_bar_set_is_amplified (GvcChannelBar *bar,
gboolean amplified);
+gboolean gvc_channel_bar_scroll (GvcChannelBar *bar,
+ GdkScrollDirection direction);
+
G_END_DECLS
#endif /* __GVC_CHANNEL_BAR_H */
Modified: trunk/gnome-volume-control/src/gvc-stream-status-icon.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-stream-status-icon.c (original)
+++ trunk/gnome-volume-control/src/gvc-stream-status-icon.c Thu Mar 12 10:52:03 2009
@@ -267,37 +267,7 @@
GdkEventScroll *event,
GvcStreamStatusIcon *icon)
{
- GtkAdjustment *adj;
-
- adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (icon->priv->bar)));
-
- switch (event->direction) {
- case GDK_SCROLL_UP:
- case GDK_SCROLL_DOWN: {
- gdouble volume;
-
- volume = gtk_adjustment_get_value (adj);
-
- if (event->direction == GDK_SCROLL_UP) {
- volume += adj->step_increment;
- if (volume > adj->upper) {
- volume = adj->upper;
- }
- } else {
- volume -= adj->step_increment;
- if (volume < adj->lower) {
- volume = adj->lower;
- }
- }
-
- gtk_adjustment_set_value (adj, volume);
- return TRUE;
- }
- default:
- break;
- }
-
- return FALSE;
+ return gvc_channel_bar_scroll (GVC_CHANNEL_BAR (icon->priv->bar), event->direction);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]