about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@openmailbox.org>2015-10-09 11:50:21 +0200
committerMichael Vetter <jubalh@openmailbox.org>2015-10-12 09:29:04 +0200
commite434b1bbf8bd84b8478f4264bf1ced66b64f4df9 (patch)
tree0fedac7ec422f81437effda72b8caca9709f934b
parent4730dca546a6242b71cb9fcef1dc7d5adb1fe0a5 (diff)
downloadprofani-tty-e434b1bbf8bd84b8478f4264bf1ced66b64f4df9.tar.gz
Create is_notify_enabled function
The same code was used on two different occasions. I put it into a
function.
-rw-r--r--src/common.c18
-rw-r--r--src/common.h1
-rw-r--r--src/main.c14
-rw-r--r--src/ui/console.c13
4 files changed, 22 insertions, 24 deletions
diff --git a/src/common.c b/src/common.c
index 0a314c91..c77c45c8 100644
--- a/src/common.c
+++ b/src/common.c
@@ -644,3 +644,21 @@ strip_arg_quotes(const char * const input)
 
     return unquoted;
 }
+
+gboolean
+is_notify_enabled(void)
+{
+    gboolean notify_enabled = FALSE;
+
+#ifdef HAVE_OSXNOTIFY
+    notify_enabled = TRUE;
+#endif
+#ifdef HAVE_LIBNOTIFY
+    notify_enabled = TRUE;
+#endif
+#ifdef PLATFORM_CYGWIN
+    notify_enabled = TRUE;
+#endif
+
+    return notify_enabled;
+}
diff --git a/src/common.h b/src/common.h
index a1e0226e..71977aaf 100644
--- a/src/common.h
+++ b/src/common.h
@@ -128,5 +128,6 @@ int get_next_available_win_num(GList *used);
 
 char* get_file_or_linked(char *loc, char *basedir);
 char * strip_arg_quotes(const char * const input);
+gboolean is_notify_enabled(void);
 
 #endif
diff --git a/src/main.c b/src/main.c
index 49e1defc..32d6dd2c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,6 +40,7 @@
 #endif
 
 #include "profanity.h"
+#include "common.h"
 #include "command/command.h"
 
 static gboolean disable_tls = FALSE;
@@ -105,18 +106,7 @@ main(int argc, char **argv)
         g_print("XMPP library: libstrophe\n");
 #endif
 
-        gboolean notify_enabled = FALSE;
-
-#ifdef HAVE_OSXNOTIFY
-        notify_enabled = TRUE;
-#endif
-#ifdef HAVE_LIBNOTIFY
-        notify_enabled = TRUE;
-#endif
-#ifdef PLATFORM_CYGWIN
-        notify_enabled = TRUE;
-#endif
-        if (notify_enabled) {
+        if (is_notify_enabled()) {
             g_print("Desktop notification support: Enabled\n");
         } else {
             g_print("Desktop notification support: Disabled\n");
diff --git a/src/ui/console.c b/src/ui/console.c
index 5445a503..64b8e5a1 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1151,18 +1151,7 @@ cons_show_ui_prefs(void)
 void
 cons_notify_setting(void)
 {
-    gboolean notify_enabled = FALSE;
-#ifdef HAVE_OSXNOTIFY
-    notify_enabled = TRUE;
-#endif
-#ifdef HAVE_LIBNOTIFY
-    notify_enabled = TRUE;
-#endif
-#ifdef PLATFORM_CYGWIN
-    notify_enabled = TRUE;
-#endif
-
-    if (notify_enabled) {
+    if (is_notify_enabled()) {
         if (prefs_get_boolean(PREF_NOTIFY_MESSAGE))
             cons_show("Messages (/notify message)          : ON");
         else