sound: Show a mute switch instead of a checkbox
The switch use here matches exactly the usage guidelines.
This commit is contained in:
parent
64ffedd618
commit
a58bb45cba
1 changed files with 20 additions and 19 deletions
|
@ -54,7 +54,7 @@ struct GvcChannelBarPrivate
|
|||
GtkWidget *scale;
|
||||
GtkWidget *high_image;
|
||||
GtkWidget *mute_box;
|
||||
GtkWidget *mute_button;
|
||||
GtkWidget *mute_switch;
|
||||
GtkAdjustment *adjustment;
|
||||
GtkAdjustment *zero_adjustment;
|
||||
gboolean show_mute;
|
||||
|
@ -512,14 +512,14 @@ on_zero_adjustment_value_changed (GtkAdjustment *adjustment,
|
|||
}
|
||||
|
||||
static void
|
||||
update_mute_button (GvcChannelBar *bar)
|
||||
update_mute_switch (GvcChannelBar *bar)
|
||||
{
|
||||
if (bar->priv->show_mute) {
|
||||
gtk_widget_show (bar->priv->mute_button);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->priv->mute_button),
|
||||
bar->priv->is_muted);
|
||||
gtk_widget_show (bar->priv->mute_switch);
|
||||
gtk_switch_set_active (GTK_SWITCH (bar->priv->mute_switch),
|
||||
!bar->priv->is_muted);
|
||||
} else {
|
||||
gtk_widget_hide (bar->priv->mute_button);
|
||||
gtk_widget_hide (bar->priv->mute_switch);
|
||||
|
||||
if (bar->priv->is_muted) {
|
||||
/* If we aren't showing the mute button then
|
||||
|
@ -554,7 +554,7 @@ gvc_channel_bar_set_is_muted (GvcChannelBar *bar,
|
|||
/* Update our internal state before telling the
|
||||
* front-end about our changes */
|
||||
bar->priv->is_muted = is_muted;
|
||||
update_mute_button (bar);
|
||||
update_mute_switch (bar);
|
||||
g_object_notify (G_OBJECT (bar), "is-muted");
|
||||
}
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ gvc_channel_bar_set_show_mute (GvcChannelBar *bar,
|
|||
if (show_mute != bar->priv->show_mute) {
|
||||
bar->priv->show_mute = show_mute;
|
||||
g_object_notify (G_OBJECT (bar), "show-mute");
|
||||
update_mute_button (bar);
|
||||
update_mute_switch (bar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ gvc_channel_bar_constructor (GType type,
|
|||
|
||||
self = GVC_CHANNEL_BAR (object);
|
||||
|
||||
update_mute_button (self);
|
||||
update_mute_switch (self);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -857,12 +857,13 @@ gvc_channel_bar_class_init (GvcChannelBarClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
on_mute_button_toggled (GtkToggleButton *button,
|
||||
GvcChannelBar *bar)
|
||||
on_mute_switch_toggled (GtkSwitch *sw,
|
||||
GParamSpec *pspec,
|
||||
GvcChannelBar *bar)
|
||||
{
|
||||
gboolean is_muted;
|
||||
is_muted = gtk_toggle_button_get_active (button);
|
||||
gvc_channel_bar_set_is_muted (bar, is_muted);
|
||||
is_muted = gtk_switch_get_active (sw);
|
||||
gvc_channel_bar_set_is_muted (bar, !is_muted);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -898,14 +899,14 @@ gvc_channel_bar_init (GvcChannelBar *bar)
|
|||
G_CALLBACK (on_zero_adjustment_value_changed),
|
||||
bar);
|
||||
|
||||
bar->priv->mute_button = gtk_check_button_new_with_label (_("Mute"));
|
||||
gtk_widget_set_no_show_all (bar->priv->mute_button, TRUE);
|
||||
g_signal_connect (bar->priv->mute_button,
|
||||
"toggled",
|
||||
G_CALLBACK (on_mute_button_toggled),
|
||||
bar->priv->mute_switch = gtk_switch_new ();
|
||||
gtk_widget_set_no_show_all (bar->priv->mute_switch, TRUE);
|
||||
g_signal_connect (bar->priv->mute_switch,
|
||||
"notify::active",
|
||||
G_CALLBACK (on_mute_switch_toggled),
|
||||
bar);
|
||||
bar->priv->mute_box = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_container_add (GTK_CONTAINER (bar->priv->mute_box), bar->priv->mute_button);
|
||||
gtk_container_add (GTK_CONTAINER (bar->priv->mute_box), bar->priv->mute_switch);
|
||||
|
||||
bar->priv->low_image = gtk_image_new_from_icon_name ("audio-volume-low-symbolic",
|
||||
GTK_ICON_SIZE_MENU);
|
||||
|
|
Loading…
Add table
Reference in a new issue