1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -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_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_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_showsplash(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",
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",
_cmd_set_showsplash,
{ "/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);
}
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
_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);
_parameter_autocomplete(input, size, "/beep",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/intype",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/flash",
prefs_autocomplete_boolean_choice);
_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 (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) {
// active
} else if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) {

View File

@ -300,6 +300,19 @@ prefs_set_flash(gboolean value)
_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
prefs_get_chlog(void)
{

View File

@ -54,6 +54,8 @@ gboolean prefs_get_showsplash(void);
void prefs_set_showsplash(gboolean value);
gboolean prefs_get_vercheck(void);
void prefs_set_vercheck(gboolean value);
gboolean prefs_get_intype(void);
void prefs_set_intype(gboolean value);
void prefs_set_notify_message(gboolean value);
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);
// no chat window for user
if (win_index == NUM_WINS) {
_cons_show_typing(short_from);
if (prefs_get_intype()) {
// no chat window for user
if (win_index == NUM_WINS) {
_cons_show_typing(short_from);
// have chat window but not currently in it
} else if (win_index != _curr_prof_win) {
_cons_show_typing(short_from);
dirty = TRUE;
// have chat window but not currently in it
} else if (win_index != _curr_prof_win) {
_cons_show_typing(short_from);
dirty = TRUE;
// in chat window with user
} else {
title_bar_set_typing(TRUE);
title_bar_draw();
// in chat window with user
} else {
title_bar_set_typing(TRUE);
title_bar_draw();
status_bar_active(win_index);
dirty = TRUE;
}
status_bar_active(win_index);
dirty = TRUE;
}
}
#ifdef HAVE_LIBNOTIFY
if (prefs_get_notify_typing())
@ -509,52 +511,57 @@ 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_message())
cons_show("Message notifications : ON");
if (prefs_get_intype())
cons_show("Show typing : ON");
else
cons_show("Message notifications : OFF");
if (prefs_get_notify_typing())
cons_show("Typing notifications : ON");
else
cons_show("Typing notifications : OFF");
cons_show("Show typing : 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");
if (prefs_get_history())
cons_show("Chat history : ON");
cons_show("Chat history : ON");
else
cons_show("Chat history : OFF");
cons_show("Chat history : OFF");
if (prefs_get_vercheck())
cons_show("Version checking : ON");
cons_show("Version checking : ON");
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();
if (remind_period == 0) {
cons_show("Message reminder period : OFF");
cons_show("Reminder notification period : OFF");
} else if (remind_period == 1) {
cons_show("Message reminder period : 1 second");
cons_show("Reminder notification period : 1 second");
} else {
cons_show("Message reminder period : %d seconds", remind_period);
cons_show("Reminder notification period : %d seconds", remind_period);
}
cons_show("");