diff options
Diffstat (limited to 'mate-volume-control/gvc-stream-status-icon.c')
-rw-r--r-- | mate-volume-control/gvc-stream-status-icon.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/mate-volume-control/gvc-stream-status-icon.c b/mate-volume-control/gvc-stream-status-icon.c index 8ca2849..dccd20d 100644 --- a/mate-volume-control/gvc-stream-status-icon.c +++ b/mate-volume-control/gvc-stream-status-icon.c @@ -29,12 +29,14 @@ #define MATE_DESKTOP_USE_UNSTABLE_API #include <libmate-desktop/mate-desktop-utils.h> +#include <libmate-desktop/mate-image-menu-item.h> #include "gvc-channel-bar.h" #include "gvc-stream-status-icon.h" struct _GvcStreamStatusIconPrivate { + GSettings *sound_settings; gchar **icon_names; GtkWidget *dock; GtkWidget *bar; @@ -243,8 +245,8 @@ on_status_icon_popup_menu (GtkStatusIcon *status_icon, /* Set icon to muted*/ image = gtk_image_new_from_icon_name(icon->priv->icon_names[0], GTK_ICON_SIZE_MENU); } - item = gtk_image_menu_item_new_with_mnemonic(label); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + item = mate_image_menu_item_new_with_mnemonic(label); + mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_menu_mute_toggled), @@ -252,10 +254,10 @@ on_status_icon_popup_menu (GtkStatusIcon *status_icon, gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - item = gtk_image_menu_item_new_with_mnemonic (_("_Sound Preferences")); + item = mate_image_menu_item_new_with_mnemonic (_("_Sound Preferences")); image = gtk_image_new_from_icon_name ("multimedia-volume-control", GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image); g_signal_connect (G_OBJECT (item), "activate", @@ -380,6 +382,7 @@ static void update_icon (GvcStreamStatusIcon *icon) { guint volume = 0; + guint volume_percent = 0; gdouble decibel = 0; guint normal = 0; gboolean muted = FALSE; @@ -407,7 +410,7 @@ update_icon (GvcStreamStatusIcon *icon) /* Select an icon, they are expected to be sorted, the lowest index being * the mute icon and the rest being volume increments */ - if (volume <= 0 || muted) + if (volume == 0 || muted) n = 0; else n = CLAMP (3 * volume / normal + 1, 1, 3); @@ -424,7 +427,9 @@ update_icon (GvcStreamStatusIcon *icon) description = mate_mixer_stream_control_get_label (icon->priv->control); - guint volume_percent = (guint) round (100.0 * volume / normal); + if (normal != 0) + volume_percent = (guint) (100.0 * ((double) volume) / ((double) normal)); + if (muted) { markup = g_strdup_printf ("<b>%s: %s %u%%</b>\n<small>%s</small>", icon->priv->display_name, @@ -508,7 +513,7 @@ void gvc_stream_status_icon_set_display_name (GvcStreamStatusIcon *icon, const gchar *name) { - g_return_if_fail (GVC_STREAM_STATUS_ICON (icon)); + g_return_if_fail (GVC_IS_STREAM_STATUS_ICON (icon)); g_free (icon->priv->display_name); @@ -522,7 +527,7 @@ void gvc_stream_status_icon_set_control (GvcStreamStatusIcon *icon, MateMixerStreamControl *control) { - g_return_if_fail (GVC_STREAM_STATUS_ICON (icon)); + g_return_if_fail (GVC_IS_STREAM_STATUS_ICON (icon)); if (icon->priv->control == control) return; @@ -689,6 +694,8 @@ gvc_stream_status_icon_init (GvcStreamStatusIcon *icon) icon->priv = gvc_stream_status_icon_get_instance_private (icon); + icon->priv->sound_settings = g_settings_new ("org.mate.sound"); + g_signal_connect (G_OBJECT (icon), "activate", G_CALLBACK (on_status_icon_activate), @@ -745,6 +752,17 @@ gvc_stream_status_icon_init (GvcStreamStatusIcon *icon) gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar), GTK_ORIENTATION_VERTICAL); + gvc_channel_bar_set_show_mark_text (GVC_CHANNEL_BAR (icon->priv->bar), + FALSE); + + g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable", + icon->priv->bar, "show-marks", + G_SETTINGS_BIND_GET); + + g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable", + icon->priv->bar, "extended", + G_SETTINGS_BIND_GET); + /* Set volume control frame, slider and toplevel window to follow panel theme */ GtkWidget *toplevel = gtk_widget_get_toplevel (icon->priv->dock); GtkStyleContext *context; @@ -781,6 +799,8 @@ gvc_stream_status_icon_finalize (GObject *object) on_icon_theme_change, icon); + g_clear_object (&icon->priv->sound_settings); + G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->finalize (object); } |