mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Create is_notify_enabled function
The same code was used on two different occasions. I put it into a function.
This commit is contained in:
parent
4730dca546
commit
e434b1bbf8
18
src/common.c
18
src/common.c
@ -644,3 +644,21 @@ strip_arg_quotes(const char * const input)
|
|||||||
|
|
||||||
return unquoted;
|
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;
|
||||||
|
}
|
||||||
|
@ -128,5 +128,6 @@ int get_next_available_win_num(GList *used);
|
|||||||
|
|
||||||
char* get_file_or_linked(char *loc, char *basedir);
|
char* get_file_or_linked(char *loc, char *basedir);
|
||||||
char * strip_arg_quotes(const char * const input);
|
char * strip_arg_quotes(const char * const input);
|
||||||
|
gboolean is_notify_enabled(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
14
src/main.c
14
src/main.c
@ -40,6 +40,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "profanity.h"
|
#include "profanity.h"
|
||||||
|
#include "common.h"
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
|
|
||||||
static gboolean disable_tls = FALSE;
|
static gboolean disable_tls = FALSE;
|
||||||
@ -105,18 +106,7 @@ main(int argc, char **argv)
|
|||||||
g_print("XMPP library: libstrophe\n");
|
g_print("XMPP library: libstrophe\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gboolean notify_enabled = FALSE;
|
if (is_notify_enabled()) {
|
||||||
|
|
||||||
#ifdef HAVE_OSXNOTIFY
|
|
||||||
notify_enabled = TRUE;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LIBNOTIFY
|
|
||||||
notify_enabled = TRUE;
|
|
||||||
#endif
|
|
||||||
#ifdef PLATFORM_CYGWIN
|
|
||||||
notify_enabled = TRUE;
|
|
||||||
#endif
|
|
||||||
if (notify_enabled) {
|
|
||||||
g_print("Desktop notification support: Enabled\n");
|
g_print("Desktop notification support: Enabled\n");
|
||||||
} else {
|
} else {
|
||||||
g_print("Desktop notification support: Disabled\n");
|
g_print("Desktop notification support: Disabled\n");
|
||||||
|
@ -1151,18 +1151,7 @@ cons_show_ui_prefs(void)
|
|||||||
void
|
void
|
||||||
cons_notify_setting(void)
|
cons_notify_setting(void)
|
||||||
{
|
{
|
||||||
gboolean notify_enabled = FALSE;
|
if (is_notify_enabled()) {
|
||||||
#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 (prefs_get_boolean(PREF_NOTIFY_MESSAGE))
|
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE))
|
||||||
cons_show("Messages (/notify message) : ON");
|
cons_show("Messages (/notify message) : ON");
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user