From e434b1bbf8bd84b8478f4264bf1ced66b64f4df9 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 9 Oct 2015 11:50:21 +0200 Subject: Create is_notify_enabled function The same code was used on two different occasions. I put it into a function. --- src/common.c | 18 ++++++++++++++++++ src/common.h | 1 + src/main.c | 14 ++------------ src/ui/console.c | 13 +------------ 4 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src') 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 -- cgit 1.4.1-2-gfad0