From fa5e9d45555d581a8f4a4762a9166a6c7ffbe23c Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 2 Feb 2017 23:31:19 +0000 Subject: [PATCH] Add correction.char preference --- src/config/preferences.c | 27 +++++++++++++++++++++++++++ src/config/preferences.h | 3 +++ src/ui/chatwin.c | 8 +++++--- src/ui/window.c | 4 ++-- src/ui/window.h | 2 +- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index f759da35..ffaa2ffe 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -733,6 +733,33 @@ prefs_get_roster_size(void) } } +char +prefs_get_correction_char(void) +{ + char result = '+'; + + char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "correction.char", NULL); + if (!resultstr) { + result = '+'; + } else { + result = resultstr[0]; + } + free(resultstr); + + return result; +} + +void +prefs_set_correction_char(char ch) +{ + char str[2]; + str[0] = ch; + str[1] = '\0'; + + g_key_file_set_string(prefs, PREF_GROUP_UI, "correction.char", str); + _save_prefs(); +} + char prefs_get_otr_char(void) { diff --git a/src/config/preferences.h b/src/config/preferences.h index dbc74148..15940795 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -200,6 +200,9 @@ void prefs_free_plugins(gchar **plugins); void prefs_add_plugin(const char *const name); void prefs_remove_plugin(const char *const name); +char prefs_get_correction_char(void); +void prefs_set_correction_char(char ch); + char prefs_get_otr_char(void); void prefs_set_otr_char(char ch); char prefs_get_pgp_char(void); diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 1fd8b0c1..6fc655f5 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -250,7 +250,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha // currently viewing chat window with sender if (wins_is_current(window)) { if (correct_id && win_created == FALSE) { - win_correct_incoming(window, '+', message, id, correct_id); + win_correct_incoming(window, message, id, correct_id); } else { win_print_incoming(window, timestamp, display_name, id, plugin_message, enc_mode); } @@ -281,7 +281,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha } if (correct_id && win_created == FALSE) { - win_correct_incoming(window, '+', message, id, correct_id); + win_correct_incoming(window, message, id, correct_id); } else { win_print_incoming(window, timestamp, display_name, id, plugin_message, enc_mode); } @@ -322,7 +322,9 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, assert(chatwin != NULL); if (correct_id) { - win_correct_outgoing((ProfWin*)chatwin, '+', message, id, request_receipt, correct_id); + char corr_char = prefs_get_correction_char(); + + win_correct_outgoing((ProfWin*)chatwin, corr_char, message, id, request_receipt, correct_id); _chatwin_set_last_message(chatwin, id, message); return; diff --git a/src/ui/window.c b/src/ui/window.c index 45d02389..456699a9 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1227,7 +1227,7 @@ win_correct_outgoing(ProfWin *window, const char ch, const char *const message, } void -win_correct_incoming(ProfWin *window, const char ch, const char *const message, const char *const id, +win_correct_incoming(ProfWin *window, const char *const message, const char *const id, const char *const correct_id) { ProfBuffEntry *entry = buffer_get_entry_by_incoming_id(window->layout->entries, correct_id); @@ -1243,7 +1243,7 @@ win_correct_incoming(ProfWin *window, const char ch, const char *const message, } entry->date = buffer_date_new_now(); - entry->show_char = ch; + entry->show_char = prefs_get_correction_char(); if (entry->message) { free(entry->message); diff --git a/src/ui/window.h b/src/ui/window.h index 17050f23..7188564f 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -69,7 +69,7 @@ void win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message); void win_correct_outgoing(ProfWin *window, const char ch, const char *const message, const char *const id, gboolean request_receipt, const char *const correct_id); -void win_correct_incoming(ProfWin *window, const char ch, const char *const message, const char *const id, +void win_correct_incoming(ProfWin *window, const char *const message, const char *const id, const char *const correct_id); void win_print_upload(ProfWin *window, const char *const message, char *url);