mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Made periodic message reminders a user option
This commit is contained in:
parent
294ea2d1be
commit
f488200408
@ -73,6 +73,7 @@ static gboolean _cmd_set_typing(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_set_flash(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_set_showsplash(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_set_chlog(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_set_remind(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_away(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_online(const char * const inp, struct cmd_help_t help);
|
||||
static gboolean _cmd_dnd(const char * const inp, struct cmd_help_t help);
|
||||
@ -204,10 +205,10 @@ static struct cmd_t setting_commands[] =
|
||||
|
||||
{ "/notify",
|
||||
_cmd_set_notify,
|
||||
{ "/notify on|off", "Enable/disable desktop notifications.",
|
||||
{ "/notify on|off", "Enable/disable message notifications.",
|
||||
{ "/notify on|off",
|
||||
"--------------",
|
||||
"Switch the desktop notifications on or off.",
|
||||
"Switch the message notifications on or off.",
|
||||
"The notification will appear for all incoming messages.",
|
||||
"The desktop environment must support desktop notifications.",
|
||||
"",
|
||||
@ -228,6 +229,19 @@ static struct cmd_t setting_commands[] =
|
||||
"Config file value : typing=true|false",
|
||||
NULL } } },
|
||||
|
||||
{ "/remind",
|
||||
_cmd_set_remind,
|
||||
{ "/remind seconds", "Set message reminder period in seconds.",
|
||||
{ "/remind seconds",
|
||||
"--------------",
|
||||
"Set the period for new message reminders as desktop notifications.",
|
||||
"The value is in seconds, a setting of 0 will disable the feature.",
|
||||
"The desktop environment must support desktop notifications.",
|
||||
"",
|
||||
"Config file section : [ui]",
|
||||
"Config file value : remind=seconds",
|
||||
NULL } } },
|
||||
|
||||
{ "/flash",
|
||||
_cmd_set_flash,
|
||||
{ "/flash on|off", "Enable/disable screen flash notifications.",
|
||||
@ -701,6 +715,29 @@ _cmd_set_chlog(const char * const inp, struct cmd_help_t help)
|
||||
"Chat logging", prefs_set_chlog);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cmd_set_remind(const char * const inp, struct cmd_help_t help)
|
||||
{
|
||||
if ((strncmp(inp, "/remind ", 8) != 0) || (strlen(inp) < 9)) {
|
||||
char usage[strlen(help.usage + 8)];
|
||||
sprintf(usage, "Usage: %s", help.usage);
|
||||
cons_show(usage);
|
||||
} else {
|
||||
// copy input
|
||||
char inp_cpy[strlen(inp) + 1];
|
||||
strcpy(inp_cpy, inp);
|
||||
|
||||
// get period
|
||||
strtok(inp_cpy, " ");
|
||||
char *period_str = strtok(NULL, " ");
|
||||
gint period = atoi(period_str);
|
||||
|
||||
prefs_set_remind(period);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cmd_away(const char * const inp, struct cmd_help_t help)
|
||||
{
|
||||
|
@ -269,6 +269,19 @@ prefs_set_chlog(gboolean value)
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
gint
|
||||
prefs_get_remind(void)
|
||||
{
|
||||
return g_key_file_get_integer(prefs, "ui", "remind", NULL);
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_remind(gint value)
|
||||
{
|
||||
g_key_file_set_integer(prefs, "ui", "remind", value);
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
void
|
||||
prefs_add_login(const char *jid)
|
||||
{
|
||||
|
@ -52,6 +52,8 @@ gboolean prefs_get_chlog(void);
|
||||
void prefs_set_chlog(gboolean value);
|
||||
gboolean prefs_get_showsplash(void);
|
||||
void prefs_set_showsplash(gboolean value);
|
||||
gint prefs_get_remind(void);
|
||||
void prefs_set_remind(gint value);
|
||||
|
||||
void prefs_add_login(const char *jid);
|
||||
|
||||
|
@ -41,8 +41,6 @@ static log_level_t _get_log_level(char *log_level);
|
||||
gboolean _process_input(char *inp);
|
||||
static void _create_config_directory();
|
||||
|
||||
static gdouble remind_period = 10;
|
||||
|
||||
void
|
||||
profanity_run(void)
|
||||
{
|
||||
@ -62,6 +60,8 @@ profanity_run(void)
|
||||
while(ch != '\n') {
|
||||
|
||||
gdouble elapsed = g_timer_elapsed(timer, NULL);
|
||||
|
||||
gint remind_period = prefs_get_remind();
|
||||
|
||||
// 0 means to not remind
|
||||
if (remind_period > 0 && elapsed >= remind_period) {
|
||||
|
@ -472,34 +472,40 @@ cons_prefs(void)
|
||||
cons_show("");
|
||||
|
||||
if (prefs_get_beep())
|
||||
cons_show("Terminal beep : ON");
|
||||
cons_show("Terminal beep : ON");
|
||||
else
|
||||
cons_show("Terminal beep : OFF");
|
||||
cons_show("Terminal beep : OFF");
|
||||
|
||||
if (prefs_get_flash())
|
||||
cons_show("Terminal flash : ON");
|
||||
cons_show("Terminal flash : ON");
|
||||
else
|
||||
cons_show("Terminal flash : OFF");
|
||||
cons_show("Terminal flash : OFF");
|
||||
|
||||
if (prefs_get_notify())
|
||||
cons_show("Desktop notifications : ON");
|
||||
cons_show("Message notifications : ON");
|
||||
else
|
||||
cons_show("Desktop notifications : OFF");
|
||||
cons_show("Message notifications : OFF");
|
||||
|
||||
if (prefs_get_typing())
|
||||
cons_show("Typing notifications : ON");
|
||||
cons_show("Typing notifications : ON");
|
||||
else
|
||||
cons_show("Typing notifications : OFF");
|
||||
cons_show("Typing notifications : OFF");
|
||||
|
||||
if (prefs_get_showsplash())
|
||||
cons_show("Splash screen : ON");
|
||||
cons_show("Splash screen : ON");
|
||||
else
|
||||
cons_show("Splash screen : OFF");
|
||||
cons_show("Splash screen : OFF");
|
||||
|
||||
if (prefs_get_chlog())
|
||||
cons_show("Chat logging : ON");
|
||||
cons_show("Chat logging : ON");
|
||||
else
|
||||
cons_show("Chat logging : OFF");
|
||||
cons_show("Chat logging : OFF");
|
||||
|
||||
char remind_period[50];
|
||||
sprintf(remind_period,
|
||||
"Message reminder period : %d seconds", prefs_get_remind());
|
||||
|
||||
cons_show(remind_period);
|
||||
|
||||
cons_show("");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user