summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2022-04-27 21:32:30 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2022-04-27 21:32:30 +0200
commitc99aacdb91fa6b22b25efd7c09ad2601eaf92f03 (patch)
treef317b2c10e5f380f10f6808adbed1ca7ff2cba2e
parent997115b45953c90eb64860629f826daa494625a5 (diff)
downloadlibnotify-c99aacdb91fa6b22b25efd7c09ad2601eaf92f03.tar.gz
notify-send: Move server capabilities check to a separate function
-rw-r--r--tools/notify-send.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/notify-send.c b/tools/notify-send.c
index c992180..a72dc94 100644
--- a/tools/notify-send.c
+++ b/tools/notify-send.c
@@ -176,6 +176,22 @@ on_wait_timeout (gpointer data)
return FALSE;
}
+static gboolean
+server_has_capability (const gchar *capability)
+{
+ GList *server_caps = notify_get_server_caps ();
+ gboolean supported;
+
+ supported = !!g_list_find_custom (server_caps,
+ capability,
+ (GCompareFunc) g_ascii_strcasecmp);
+
+ g_list_foreach (server_caps, (GFunc) g_free, NULL);
+ g_list_free (server_caps);
+
+ return supported;
+}
+
int
main (int argc, char *argv[])
{
@@ -350,19 +366,12 @@ main (int argc, char *argv[])
}
if (actions != NULL) {
- GList *server_caps = notify_get_server_caps ();
gint i = 0;
char *action = NULL;
gchar **spl = NULL;
gboolean have_actions;
- have_actions =
- !!g_list_find_custom (server_caps,
- "actions",
- (GCompareFunc) g_ascii_strcasecmp);
- g_list_foreach (server_caps, (GFunc) g_free, NULL);
- g_list_free (server_caps);
-
+ have_actions = server_has_capability ("actions");
if (!have_actions) {
g_printerr (N_("Actions are not supported by this "
"notifications server. "