[libnotify] notify-send: Move server capabilities check to a separate function
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnotify] notify-send: Move server capabilities check to a separate function
- Date: Wed, 27 Apr 2022 19:38:48 +0000 (UTC)
commit c99aacdb91fa6b22b25efd7c09ad2601eaf92f03
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Apr 27 21:32:30 2022 +0200
notify-send: Move server capabilities check to a separate function
tools/notify-send.c | 25 +++++++++++++++++--------
1 file 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. "
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]