aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2023-03-08 20:30:52 +0100
committerRobert Tari <robert@tari.in>2023-03-08 22:51:59 +0100
commit6b17e30fdca2a6aa772b2af1c8b648970f1ae362 (patch)
tree0a7d6c1fa5c2bffa5760efa28f82c5e1ebff0666
parent13d89c6789855f96cf5e0465c1fe894d63fec8ea (diff)
downloadayatana-indicator-display-6b17e30fdca2a6aa772b2af1c8b648970f1ae362.tar.gz
ayatana-indicator-display-6b17e30fdca2a6aa772b2af1c8b648970f1ae362.tar.bz2
ayatana-indicator-display-6b17e30fdca2a6aa772b2af1c8b648970f1ae362.zip
src/rotation-lock.cpp: Add brightness action, slider and handlers
fixes https://github.com/AyatanaIndicators/ayatana-indicator-display/issues/72
-rw-r--r--src/rotation-lock.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/rotation-lock.cpp b/src/rotation-lock.cpp
index 1a8c98d..9523358 100644
--- a/src/rotation-lock.cpp
+++ b/src/rotation-lock.cpp
@@ -172,6 +172,8 @@ private:
guint nTemperature = 6500;
GVariant *pProfile = g_settings_get_value (pImpl->m_settings, "color-temp-profile");
guint nProfile = g_variant_get_uint16 (pProfile);
+ GVariant *pBrightness = g_settings_get_value (pImpl->m_settings, "brightness");
+ gdouble fBrightness = g_variant_get_double (pBrightness);
if (nProfile == 0)
{
@@ -206,7 +208,7 @@ private:
g_action_change_state (pAction, pTemperature);
GError *pError = NULL;
- gchar *sCommand = g_strdup_printf ("xsct %u", nTemperature);
+ gchar *sCommand = g_strdup_printf ("xsct %u %f", nTemperature, fBrightness);
gboolean bSuccess = g_spawn_command_line_sync (sCommand, NULL, NULL, NULL, &pError);
if (!bSuccess)
@@ -248,6 +250,11 @@ private:
updateColorTemp (pData);
}
+ static void onBrightnessSettings (GSettings *pSettings, const gchar *sKey, gpointer pData)
+ {
+ updateColorTemp (pData);
+ }
+
static void onColorTempProfile (GSettings *pSettings, const gchar *sKey, gpointer pData)
{
RotationLockIndicator::Impl *pImpl = (RotationLockIndicator::Impl*) pData;
@@ -374,6 +381,14 @@ private:
g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
g_object_unref(G_OBJECT(action));
g_signal_connect (m_settings, "changed::color-temp-profile", G_CALLBACK (onColorTempProfile), this);
+
+ pVariantType = g_variant_type_new("d");
+ action = g_simple_action_new_stateful ("brightness", pVariantType, g_variant_new_double (0));
+ g_variant_type_free(pVariantType);
+ g_settings_bind_with_mapping (m_settings, "brightness", action, "state", G_SETTINGS_BIND_DEFAULT, settings_to_action_state, action_state_to_settings, NULL, NULL);
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+ g_object_unref (G_OBJECT (action));
+ g_signal_connect (m_settings, "changed::brightness", G_CALLBACK (onBrightnessSettings), this);
}
#endif
@@ -450,10 +465,25 @@ private:
{
#ifdef COLOR_TEMP_ENABLED
section = g_menu_new ();
- GIcon *pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-on");
- GIcon *pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-off");
+
+ GIcon *pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-brightness-low");
+ GIcon *pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-brightness-high");
GVariant *pIconMinSerialised = g_icon_serialize (pIconMin);
GVariant *pIconMaxSerialised = g_icon_serialize (pIconMax);
+ menu_item = g_menu_item_new (_("Brightness"), "indicator.brightness");
+ g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
+ g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
+ g_menu_item_set_attribute_value (menu_item, "min-icon", pIconMinSerialised);
+ g_menu_item_set_attribute_value (menu_item, "max-icon", pIconMaxSerialised);
+ g_menu_item_set_attribute (menu_item, "min-value", "d", 0.5);
+ g_menu_item_set_attribute (menu_item, "max-value", "d", 1.0);
+ g_menu_item_set_attribute (menu_item, "step", "d", 0.005);
+ g_menu_append_item (section, menu_item);
+
+ pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-on");
+ pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-off");
+ pIconMinSerialised = g_icon_serialize (pIconMin);
+ pIconMaxSerialised = g_icon_serialize (pIconMax);
menu_item = g_menu_item_new (_("Color temperature"), "indicator.color-temp");
g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");