aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRatchanan Srirattanamet <ratchanan@ubports.com>2023-12-08 16:55:29 +0700
committerRatchanan Srirattanamet <ratchanan@ubports.com>2023-12-08 16:55:29 +0700
commit28b0b55e98b9e955209e5a26f28acc9b1b6e43ad (patch)
treec78f504eb8202262b62f225961df8be57a2c0b0b /src
parentf494eae6a5d5acd7b84437e5e251c6e3ff6f83a8 (diff)
downloadayatana-indicator-power-28b0b55e98b9e955209e5a26f28acc9b1b6e43ad.tar.gz
ayatana-indicator-power-28b0b55e98b9e955209e5a26f28acc9b1b6e43ad.tar.bz2
ayatana-indicator-power-28b0b55e98b9e955209e5a26f28acc9b1b6e43ad.zip
Guard Lomiri-specific notification hints under conditionals
Diffstat (limited to 'src')
-rw-r--r--src/notifier.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/notifier.c b/src/notifier.c
index cef8a3c..73f62b4 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,11 +377,14 @@ notification_show(IndicatorPowerNotifier * self)
notify_notification_set_hint(nn, "sound-file", g_variant_new_string("file://" LOMIRI_SOUNDSDIR "/notifications/" LOW_BATTERY_SOUND));
}
}
-
- 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));
+ #ifdef LOMIRI_FEATURES_ENABLED
+ if (are_lomiri_snap_decisions_supported(self)) {
+ 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);