Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csd-media-keys: Show device description on volume OSD #399

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions plugins/media-keys/csd-media-keys-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ cinnamon_proxy_complete (GObject *source,
static void
show_osd (CsdMediaKeysManager *manager,
const char *icon,
const char *label,
int level,
int outx,
int outy)
Expand All @@ -407,6 +408,9 @@ show_osd (CsdMediaKeysManager *manager,
if (icon)
g_variant_builder_add (&builder, "{sv}",
"icon", g_variant_new_string (icon));
if (label)
g_variant_builder_add (&builder, "{sv}",
"label", g_variant_new_string (label));
if (level >= 0)
g_variant_builder_add (&builder, "{sv}",
"level", g_variant_new_int32 (level));
Expand Down Expand Up @@ -633,7 +637,7 @@ do_eject_action (CsdMediaKeysManager *manager)
}

/* Show the dialogue */
show_osd (manager, "media-eject-symbolic", -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
show_osd (manager, "media-eject-symbolic", NULL, -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);

/* Clean up the drive selection and exit if no suitable
* drives are found */
Expand Down Expand Up @@ -687,7 +691,7 @@ do_touchpad_osd_action (CsdMediaKeysManager *manager, gboolean state)
{
show_osd (manager,
state ? "input-touchpad-symbolic" : "touchpad-disabled-symbolic",
-1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
NULL, -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
}

static void
Expand Down Expand Up @@ -723,11 +727,23 @@ show_sound_osd (CsdMediaKeysManager *manager,
gboolean sound_changed,
gboolean quiet)
{
GvcMixerUIDevice *device;
const GvcMixerStreamPort *port;
const char *icon;

icon = get_icon_name_for_volume (muted, vol, is_mic);

show_osd (manager, icon, vol, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
port = gvc_mixer_stream_get_port (stream);
if (g_strcmp0 (gvc_mixer_stream_get_form_factor (stream), "internal") != 0 ||
(port != NULL &&
g_strcmp0 (port->port, "analog-output-speaker") != 0 &&
g_strcmp0 (port->port, "analog-output") != 0)) {
device = gvc_mixer_control_lookup_device_from_stream (manager->priv->volume, stream);
show_osd (manager, icon,
gvc_mixer_ui_device_get_description (device),
vol, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
} else {
show_osd (manager, icon, NULL, vol, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
}

if (quiet == FALSE && sound_changed != FALSE && muted == FALSE) {
gboolean enabled = g_settings_get_boolean (manager->priv->sound_settings, "volume-sound-enabled");
Expand Down Expand Up @@ -1221,7 +1237,7 @@ csd_media_player_key_pressed (CsdMediaKeysManager *manager,
if (!have_listeners) {
if (!mpris_controller_key (manager->priv->mpris_controller, key)) {
/* Popup a dialog with an (/) icon */
show_osd (manager, "action-unavailable-symbolic", -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
show_osd (manager, "action-unavailable-symbolic", NULL, -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
}
return TRUE;
}
Expand Down Expand Up @@ -1315,7 +1331,7 @@ do_video_rotate_lock_action (CsdMediaKeysManager *manager,
g_object_unref (settings);

show_osd (manager, locked ? "rotation-locked-symbolic"
: "rotation-allowed-symbolic", -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
: "rotation-allowed-symbolic", NULL, -1, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
}

static void
Expand Down Expand Up @@ -1476,7 +1492,7 @@ update_screen_cb (GObject *source_object,

/* update the dialog with the new value */
g_variant_get (variant, "(uii)", &percentage, &outx, &outy);
show_osd (manager, "display-brightness-symbolic", percentage, outx, outy);
show_osd (manager, "display-brightness-symbolic", NULL, percentage, outx, outy);
g_variant_unref (variant);
}

Expand Down Expand Up @@ -1558,7 +1574,7 @@ update_keyboard_cb (GObject *source_object,

/* update the dialog with the new value */
g_variant_get (new_percentage, "(u)", &percentage);
show_osd (manager, "keyboard-brightness-symbolic", percentage, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
show_osd (manager, "keyboard-brightness-symbolic", NULL, percentage, OSD_ALL_OUTPUTS_X, OSD_ALL_OUTPUTS_Y);
g_variant_unref (new_percentage);
}

Expand Down
Loading