1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added notify preference

This commit is contained in:
James Booth 2012-06-28 23:45:37 +01:00
parent 18494c3701
commit 54ef09bfbd
4 changed files with 33 additions and 1 deletions

View File

@ -44,6 +44,7 @@ static gboolean _cmd_connect(const char * const inp);
static gboolean _cmd_msg(const char * const inp);
static gboolean _cmd_close(const char * const inp);
static gboolean _cmd_set_beep(const char * const inp);
static gboolean _cmd_set_notify(const char * const inp);
static gboolean _cmd_set_flash(const char * const inp);
static gboolean _cmd_set_showsplash(const char * const inp);
static gboolean _cmd_away(const char * const inp);
@ -65,6 +66,7 @@ static PAutocomplete commands_ac;
static struct cmd_t commands[] = {
{ "/away", _cmd_away },
{ "/beep", _cmd_set_beep },
{ "/notify", _cmd_set_notify },
{ "/chat", _cmd_chat },
{ "/close", _cmd_close },
{ "/connect", _cmd_connect },
@ -273,6 +275,21 @@ static gboolean _cmd_set_beep(const char * const inp)
return TRUE;
}
static gboolean _cmd_set_notify(const char * const inp)
{
if (strcmp(inp, "/notify on") == 0) {
cons_show("Desktop notifications enabled.");
prefs_set_notify(TRUE);
} else if (strcmp(inp, "/notify off") == 0) {
cons_show("Desktop notifications disabled.");
prefs_set_notify(FALSE);
} else {
cons_show("Usage: /notify <on/off>");
}
return TRUE;
}
static gboolean _cmd_set_flash(const char * const inp)
{
if (strcmp(inp, "/flash on") == 0) {

View File

@ -173,6 +173,17 @@ void prefs_set_beep(gboolean value)
_save_prefs();
}
gboolean prefs_get_notify(void)
{
return g_key_file_get_boolean(prefs, "ui", "notify", NULL);
}
void prefs_set_notify(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "notify", value);
_save_prefs();
}
gboolean prefs_get_flash(void)
{
return g_key_file_get_boolean(prefs, "ui", "flash", NULL);

View File

@ -32,6 +32,8 @@ void reset_login_search(void);
gboolean prefs_get_beep(void);
void prefs_set_beep(gboolean value);
gboolean prefs_get_notify(void);
void prefs_set_notify(gboolean value);
gboolean prefs_get_flash(void);
void prefs_set_flash(gboolean value);
void prefs_add_login(const char *jid);

View File

@ -189,11 +189,12 @@ void win_show_incomming_msg(const char * const from, const char * const message)
if (prefs_get_flash())
flash();
_win_notify(short_from);
}
if (prefs_get_beep())
beep();
if (prefs_get_notify())
_win_notify(short_from);
}
static void _win_notify(char * short_from)
@ -305,6 +306,7 @@ void cons_help(void)
cons_show("Settings:");
cons_show("");
cons_show("/beep <on/off> : Enable/disable sound notification");
cons_show("/notify <on/off> : Enable/disable desktop notifications");
cons_show("/flash <on/off> : Enable/disable screen flash notification");
cons_show("/showsplash <on/off> : Enable/disable splash logo on startup");
cons_show("");