aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-12-19 17:05:21 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-12-19 17:05:21 +0100
commit635be6aa470e050d21ddfe54f27dd00d753f2dd1 (patch)
treeac34cc8a86c9da8da8f6bf6dbd1cbdc882c5b9c8 /src
parent51d61854f2b90eb21b00fa2d84284bc3b77862b6 (diff)
parentc96d7eda53f5eb73cf4d3c850de2f444035ae8f3 (diff)
downloadayatana-indicator-power-635be6aa470e050d21ddfe54f27dd00d753f2dd1.tar.gz
ayatana-indicator-power-635be6aa470e050d21ddfe54f27dd00d753f2dd1.tar.bz2
ayatana-indicator-power-635be6aa470e050d21ddfe54f27dd00d753f2dd1.zip
Merge branch 'personal/peat-psuwit/bring-back-lomiri-hints'
Attributes GH PR #90: https://github.com/AyatanaIndicators/ayatana-indicator-power/pull/90
Diffstat (limited to 'src')
-rw-r--r--src/notifier.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/notifier.c b/src/notifier.c
index 07c5efa..5f0562e 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -88,6 +88,9 @@ typedef struct
gboolean caps_queried;
gboolean actions_supported;
+ #ifdef LOMIRI_FEATURES_ENABLED
+ gboolean lomiri_snap_decisions_supported;
+ #endif
GCancellable * cancellable;
#ifdef LOMIRI_FEATURES_ENABLED
@@ -265,8 +268,8 @@ on_dismiss_clicked(NotifyNotification * nn G_GNUC_UNUSED,
/* no-op; libnotify warns if we have a NULL action callback */
}
-static gboolean
-are_actions_supported(IndicatorPowerNotifier * self)
+static void
+ensure_caps_queried(IndicatorPowerNotifier * self)
{
priv_t * const p = get_priv(self);
@@ -276,22 +279,54 @@ are_actions_supported(IndicatorPowerNotifier * self)
GList * caps;
GList * l;
- /* see if actions are supported */
+ #ifdef LOMIRI_FEATURES_ENABLED
+ gboolean lomiri_snap_decisions_supported = FALSE;
+ #endif
+
+ /* see if actions and snap decisions are supported */
actions_supported = FALSE;
caps = notify_get_server_caps();
- for (l=caps; l!=NULL && !actions_supported; l=l->next)
+ for (l=caps; l!=NULL; l=l->next) {
if (!g_strcmp0(l->data, "actions"))
actions_supported = TRUE;
+ #ifdef LOMIRI_FEATURES_ENABLED
+ else if (!g_strcmp0(l->data, "x-lomiri-snap-decisions"))
+ lomiri_snap_decisions_supported = TRUE;
+ #endif
+ }
p->actions_supported = actions_supported;
+ #ifdef LOMIRI_FEATURES_ENABLED
+ p->lomiri_snap_decisions_supported = lomiri_snap_decisions_supported;
+ #endif
p->caps_queried = TRUE;
g_list_free_full(caps, g_free);
}
+}
+
+static gboolean
+are_actions_supported(IndicatorPowerNotifier * self)
+{
+ priv_t * const p = get_priv(self);
+
+ ensure_caps_queried(self);
return p->actions_supported;
}
+#ifdef LOMIRI_FEATURES_ENABLED
+static gboolean
+are_lomiri_snap_decisions_supported(IndicatorPowerNotifier * self)
+{
+ priv_t * const p = get_priv(self);
+
+ ensure_caps_queried(self);
+
+ return p->lomiri_snap_decisions_supported;
+}
+#endif
+
static void
notification_show(IndicatorPowerNotifier * self)
{
@@ -342,7 +377,15 @@ notification_show(IndicatorPowerNotifier * self)
notify_notification_set_hint(nn, "sound-file", g_variant_new_string("file://" LOMIRI_SOUNDSDIR "/notifications/" LOW_BATTERY_SOUND));
}
}
-
+ #ifdef LOMIRI_FEATURES_ENABLED
+ if (are_lomiri_snap_decisions_supported(self)) {
+ /* Yes, all supposedly boolean values take strings... */
+ notify_notification_set_hint(nn, "x-lomiri-snap-decisions", g_variant_new_string("true"));
+ notify_notification_set_hint(nn, "x-lomiri-non-shaped-icon", g_variant_new_string("true"));
+ notify_notification_set_hint(nn, "x-lomiri-private-affirmative-tint", g_variant_new_string("true"));
+ notify_notification_set_hint(nn, "x-lomiri-snap-decisions-timeout", g_variant_new_int32(INT32_MAX));
+ }
+ #endif
notify_notification_set_timeout(nn, NOTIFY_EXPIRES_NEVER);
notify_notification_add_action(nn, "dismiss", _("OK"), on_dismiss_clicked, NULL, NULL);
notify_notification_add_action(nn, "settings", _("Battery settings"), on_battery_settings_clicked, NULL, NULL);