diff options
-rw-r--r-- | src/command/cmd_funcs.c | 4 | ||||
-rw-r--r-- | src/config/preferences.c | 24 | ||||
-rw-r--r-- | src/config/preferences.h | 4 | ||||
-rw-r--r-- | src/config/theme.c | 4 | ||||
-rw-r--r-- | src/ui/console.c | 8 | ||||
-rw-r--r-- | src/ui/rosterwin.c | 5 |
6 files changed, 22 insertions, 27 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index e0747d40..0e024e91 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -2680,8 +2680,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args) cons_show("Roster private room chat char removed."); rosterwin_roster(); } else { - prefs_set_roster_private_char(args[2][0]); - cons_show("Roster private room chat char set to %c.", args[2][0]); + prefs_set_roster_private_char(args[2]); + cons_show("Roster private room chat char set to %s.", args[2]); rosterwin_roster(); } return TRUE; diff --git a/src/config/preferences.c b/src/config/preferences.c index e713598f..6af779db 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1158,30 +1158,22 @@ prefs_clear_roster_resource_char(void) g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.resource.char", NULL); } -char +char* prefs_get_roster_private_char(void) { - char result = 0; - - char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL); - if (!resultstr) { - result = 0; - } else { - result = resultstr[0]; - } - free(resultstr); + char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL); return result; } void -prefs_set_roster_private_char(char ch) +prefs_set_roster_private_char(char* ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.private.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.private.char", ch); + } else { + log_error("Could not set roster resource char: %s", ch); + } } void diff --git a/src/config/preferences.h b/src/config/preferences.h index 79312e76..e26deeaf 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -263,8 +263,8 @@ void prefs_clear_roster_contact_char(void); char* prefs_get_roster_resource_char(void); void prefs_set_roster_resource_char(char* ch); void prefs_clear_roster_resource_char(void); -char prefs_get_roster_private_char(void); -void prefs_set_roster_private_char(char ch); +char* prefs_get_roster_private_char(void); +void prefs_set_roster_private_char(char* ch); void prefs_clear_roster_private_char(void); char prefs_get_roster_room_char(void); void prefs_set_roster_room_char(char ch); diff --git a/src/config/theme.c b/src/config/theme.c index a3f74d94..868601be 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -464,8 +464,8 @@ _load_preferences(void) if (g_key_file_has_key(theme, "ui", "roster.private.char", NULL)) { gchar* ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_roster_private_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_roster_private_char(ch); g_free(ch); } } diff --git a/src/ui/console.c b/src/ui/console.c index d86fb158..76295d63 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1511,11 +1511,13 @@ cons_roster_setting(void) else cons_show("Roster room private char (/roster) : none"); - char private_ch = prefs_get_roster_private_char(); - if (private_ch) + char* private_ch = prefs_get_roster_private_char(); + if (private_ch) { cons_show("Roster private char (/roster) : %c", private_ch); - else + free(private_ch); + } else { cons_show("Roster private char (/roster) : none"); + } gint contact_indent = prefs_get_roster_contact_indent(); cons_show("Roster contact indent (/roster) : %d", contact_indent); diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index 91b8e7cc..b9a84950 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -951,9 +951,10 @@ _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats) g_string_append_printf(privmsg, "(%d) ", privwin->unread); } - char ch = prefs_get_roster_private_char(); + char* ch = prefs_get_roster_private_char(); if (ch) { - g_string_append_printf(privmsg, "%c", ch); + g_string_append_printf(privmsg, "%s", ch); + free(ch); } g_string_append(privmsg, privwin->fulljid); |