diff options
author | James Booth <boothj5@gmail.com> | 2012-10-14 18:26:08 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-14 18:26:08 +0100 |
commit | acb152d4f73c252f7bb627c0829d1e5bc163dd99 (patch) | |
tree | a60641aeb36ce6a1ec5fa1a0d68cf0c360be7058 | |
parent | 26802ffed33a2504f1dee838b2fb4e181c05b0a9 (diff) | |
download | profani-tty-acb152d4f73c252f7bb627c0829d1e5bc163dd99.tar.gz |
Added history option
-rw-r--r-- | src/command.c | 20 | ||||
-rw-r--r-- | src/preferences.c | 13 | ||||
-rw-r--r-- | src/preferences.h | 2 | ||||
-rw-r--r-- | src/windows.c | 9 |
4 files changed, 42 insertions, 2 deletions
diff --git a/src/command.c b/src/command.c index 806311cd..5c8e30fa 100644 --- a/src/command.c +++ b/src/command.c @@ -74,6 +74,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_history(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); @@ -275,6 +276,18 @@ static struct cmd_t setting_commands[] = "to myfriend@chatserv.com, the following chat log will be created:", "", " ~/.profanity/log/someuser_at_chatserv.com/myfriend_at_chatserv.com", + NULL } } }, + + { "/history", + _cmd_set_history, + { "/history on|off", "Enable/disable chat history.", + { "/history on|off", + "-------------", + "Switch chat history on or off, requires chlog to be enabled.", + "When history is enabled, previous messages are shown in chat windows.", + "The last day of messages are shown, or if you have had profanity open", + "for more than a day, messages will be shown from the day which", + "you started profanity.", NULL } } } }; @@ -769,6 +782,13 @@ _cmd_set_chlog(const char * const inp, struct cmd_help_t help) } static gboolean +_cmd_set_history(const char * const inp, struct cmd_help_t help) +{ + return _cmd_set_boolean_preference(inp, help, "/history", + "Chat history", prefs_set_history); +} + +static gboolean _cmd_set_remind(const char * const inp, struct cmd_help_t help) { if ((strncmp(inp, "/remind ", 8) != 0) || (strlen(inp) < 9)) { diff --git a/src/preferences.c b/src/preferences.c index 13aa1793..847b1817 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -269,6 +269,19 @@ prefs_set_chlog(gboolean value) _save_prefs(); } +gboolean +prefs_get_history(void) +{ + return g_key_file_get_boolean(prefs, "ui", "history", NULL); +} + +void +prefs_set_history(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "history", value); + _save_prefs(); +} + gint prefs_get_remind(void) { diff --git a/src/preferences.h b/src/preferences.h index e94701e4..8b4f5e68 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -50,6 +50,8 @@ gboolean prefs_get_flash(void); void prefs_set_flash(gboolean value); gboolean prefs_get_chlog(void); void prefs_set_chlog(gboolean value); +gboolean prefs_get_history(void); +void prefs_set_history(gboolean value); gboolean prefs_get_showsplash(void); void prefs_set_showsplash(gboolean value); gint prefs_get_remind(void); diff --git a/src/windows.c b/src/windows.c index 141cf93c..74e51a0f 100644 --- a/src/windows.c +++ b/src/windows.c @@ -283,7 +283,7 @@ win_show_incomming_msg(const char * const from, const char * const message) flash(); _wins[win_index].unread++; - if (prefs_get_chlog()) { + if (prefs_get_chlog() && prefs_get_history()) { if (!_wins[win_index].history_shown) { GSList *history = NULL; history = chat_log_get_previous(jabber_get_jid(), short_from, history); @@ -389,7 +389,7 @@ win_show_outgoing_msg(const char * const from, const char * const to, win_index = _new_prof_win(to); win = _wins[win_index].win; - if (prefs_get_chlog()) { + if (prefs_get_chlog() && prefs_get_history()) { if (!_wins[win_index].history_shown) { GSList *history = NULL; history = chat_log_get_previous(jabber_get_jid(), to, history); @@ -531,6 +531,11 @@ cons_prefs(void) else cons_show("Chat logging : OFF"); + if (prefs_get_history()) + cons_show("Chat history : ON"); + else + cons_show("Chat history : OFF"); + gint remind_period = prefs_get_remind(); if (remind_period == 0) { cons_show("Message reminder period : OFF"); |