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

Added /intype setting

Seperate settings for showing contact typing in UI (/intype), and
as desktop notifications (/notify typing).
This commit is contained in:
James Booth 2012-10-28 00:33:20 +01:00
parent 86adbc4973
commit 8258e7a3ef
6 changed files with 81 additions and 38 deletions

View File

@ -71,6 +71,7 @@ static gboolean _cmd_tiny(const char * const inp, struct cmd_help_t help);
static gboolean _cmd_close(const char * const inp, struct cmd_help_t help); static gboolean _cmd_close(const char * const inp, struct cmd_help_t help);
static gboolean _cmd_set_beep(const char * const inp, struct cmd_help_t help); static gboolean _cmd_set_beep(const char * const inp, struct cmd_help_t help);
static gboolean _cmd_set_notify(const char * const inp, struct cmd_help_t help); static gboolean _cmd_set_notify(const char * const inp, struct cmd_help_t help);
static gboolean _cmd_set_intype(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_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_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_chlog(const char * const inp, struct cmd_help_t help);
@ -256,6 +257,17 @@ static struct cmd_t setting_commands[] =
"Config file value : flash=true|false", "Config file value : flash=true|false",
NULL } } }, NULL } } },
{ "/intype",
_cmd_set_intype,
{ "/intype on|off", "Show when contact is typing.",
{ "/intype on|off",
"--------------",
"Show when a contact is typing in the console, and in active message window.",
"",
"Config file section : [ui]",
"Config file value : intype=true|false",
NULL } } },
{ "/showsplash", { "/showsplash",
_cmd_set_showsplash, _cmd_set_showsplash,
{ "/showsplash on|off", "Splash logo on startup.", { "/showsplash on|off", "Splash logo on startup.",
@ -941,6 +953,13 @@ _cmd_set_flash(const char * const inp, struct cmd_help_t help)
"Screen flash", prefs_set_flash); "Screen flash", prefs_set_flash);
} }
static gboolean
_cmd_set_intype(const char * const inp, struct cmd_help_t help)
{
return _cmd_set_boolean_preference(inp, help, "/intype",
"Show contact typing", prefs_set_intype);
}
static gboolean static gboolean
_cmd_set_showsplash(const char * const inp, struct cmd_help_t help) _cmd_set_showsplash(const char * const inp, struct cmd_help_t help)
{ {

View File

@ -362,6 +362,8 @@ _handle_edit(const int ch, char *input, int *size)
cmd_help_complete); cmd_help_complete);
_parameter_autocomplete(input, size, "/beep", _parameter_autocomplete(input, size, "/beep",
prefs_autocomplete_boolean_choice); prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/intype",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/flash", _parameter_autocomplete(input, size, "/flash",
prefs_autocomplete_boolean_choice); prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/showsplash", _parameter_autocomplete(input, size, "/showsplash",

View File

@ -290,7 +290,7 @@ _message_handler(xmpp_conn_t * const conn,
// if no message, check for chatstates // if no message, check for chatstates
if (body == NULL) { if (body == NULL) {
if (prefs_get_notify_typing()) { if (prefs_get_notify_typing() || prefs_get_intype()) {
if (xmpp_stanza_get_child_by_name(stanza, "active") != NULL) { if (xmpp_stanza_get_child_by_name(stanza, "active") != NULL) {
// active // active
} else if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) { } else if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) {

View File

@ -300,6 +300,19 @@ prefs_set_flash(gboolean value)
_save_prefs(); _save_prefs();
} }
gboolean
prefs_get_intype(void)
{
return g_key_file_get_boolean(prefs, "ui", "intype", NULL);
}
void
prefs_set_intype(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "intype", value);
_save_prefs();
}
gboolean gboolean
prefs_get_chlog(void) prefs_get_chlog(void)
{ {

View File

@ -54,6 +54,8 @@ gboolean prefs_get_showsplash(void);
void prefs_set_showsplash(gboolean value); void prefs_set_showsplash(gboolean value);
gboolean prefs_get_vercheck(void); gboolean prefs_get_vercheck(void);
void prefs_set_vercheck(gboolean value); void prefs_set_vercheck(gboolean value);
gboolean prefs_get_intype(void);
void prefs_set_intype(gboolean value);
void prefs_set_notify_message(gboolean value); void prefs_set_notify_message(gboolean value);
gboolean prefs_get_notify_message(void); gboolean prefs_get_notify_message(void);

View File

@ -222,23 +222,25 @@ win_show_typing(const char * const from)
int win_index = _find_prof_win_index(short_from); int win_index = _find_prof_win_index(short_from);
// no chat window for user if (prefs_get_intype()) {
if (win_index == NUM_WINS) { // no chat window for user
_cons_show_typing(short_from); if (win_index == NUM_WINS) {
_cons_show_typing(short_from);
// have chat window but not currently in it // have chat window but not currently in it
} else if (win_index != _curr_prof_win) { } else if (win_index != _curr_prof_win) {
_cons_show_typing(short_from); _cons_show_typing(short_from);
dirty = TRUE; dirty = TRUE;
// in chat window with user // in chat window with user
} else { } else {
title_bar_set_typing(TRUE); title_bar_set_typing(TRUE);
title_bar_draw(); title_bar_draw();
status_bar_active(win_index); status_bar_active(win_index);
dirty = TRUE; dirty = TRUE;
} }
}
#ifdef HAVE_LIBNOTIFY #ifdef HAVE_LIBNOTIFY
if (prefs_get_notify_typing()) if (prefs_get_notify_typing())
@ -509,52 +511,57 @@ cons_prefs(void)
cons_show(""); cons_show("");
if (prefs_get_beep()) if (prefs_get_beep())
cons_show("Terminal beep : ON"); cons_show("Terminal beep : ON");
else else
cons_show("Terminal beep : OFF"); cons_show("Terminal beep : OFF");
if (prefs_get_flash()) if (prefs_get_flash())
cons_show("Terminal flash : ON"); cons_show("Terminal flash : ON");
else else
cons_show("Terminal flash : OFF"); cons_show("Terminal flash : OFF");
if (prefs_get_notify_message()) if (prefs_get_intype())
cons_show("Message notifications : ON"); cons_show("Show typing : ON");
else else
cons_show("Message notifications : OFF"); cons_show("Show typing : OFF");
if (prefs_get_notify_typing())
cons_show("Typing notifications : ON");
else
cons_show("Typing notifications : OFF");
if (prefs_get_showsplash()) if (prefs_get_showsplash())
cons_show("Splash screen : ON"); cons_show("Splash screen : ON");
else else
cons_show("Splash screen : OFF"); cons_show("Splash screen : OFF");
if (prefs_get_chlog()) if (prefs_get_chlog())
cons_show("Chat logging : ON"); cons_show("Chat logging : ON");
else else
cons_show("Chat logging : OFF"); cons_show("Chat logging : OFF");
if (prefs_get_history()) if (prefs_get_history())
cons_show("Chat history : ON"); cons_show("Chat history : ON");
else else
cons_show("Chat history : OFF"); cons_show("Chat history : OFF");
if (prefs_get_vercheck()) if (prefs_get_vercheck())
cons_show("Version checking : ON"); cons_show("Version checking : ON");
else else
cons_show("Version checking : OFF"); cons_show("Version checking : OFF");
if (prefs_get_notify_message())
cons_show("Message notifications : ON");
else
cons_show("Message notifications : OFF");
if (prefs_get_notify_typing())
cons_show("Typing notifications : ON");
else
cons_show("Typing notifications : OFF");
gint remind_period = prefs_get_notify_remind(); gint remind_period = prefs_get_notify_remind();
if (remind_period == 0) { if (remind_period == 0) {
cons_show("Message reminder period : OFF"); cons_show("Reminder notification period : OFF");
} else if (remind_period == 1) { } else if (remind_period == 1) {
cons_show("Message reminder period : 1 second"); cons_show("Reminder notification period : 1 second");
} else { } else {
cons_show("Message reminder period : %d seconds", remind_period); cons_show("Reminder notification period : %d seconds", remind_period);
} }
cons_show(""); cons_show("");