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 | 10 | ||||
-rw-r--r-- | src/ui/rosterwin.c | 7 |
6 files changed, 24 insertions, 29 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 0e024e91..77e12e3a 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -2720,8 +2720,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args) cons_show("Roster room char removed."); rosterwin_roster(); } else { - prefs_set_roster_room_char(args[2][0]); - cons_show("Roster room char set to %c.", args[2][0]); + prefs_set_roster_room_char(args[2]); + cons_show("Roster room char set to %s.", args[2]); rosterwin_roster(); } return TRUE; diff --git a/src/config/preferences.c b/src/config/preferences.c index 6af779db..edbf6f63 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1182,30 +1182,22 @@ prefs_clear_roster_private_char(void) g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.private.char", NULL); } -char +char* prefs_get_roster_room_char(void) { - char result = 0; - - char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL); - if (!resultstr) { - result = 0; - } else { - result = resultstr[0]; - } - free(resultstr); + char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL); return result; } void -prefs_set_roster_room_char(char ch) +prefs_set_roster_room_char(char* ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.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 e26deeaf..972dfa8a 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -266,8 +266,8 @@ void prefs_clear_roster_resource_char(void); 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); +char* prefs_get_roster_room_char(void); +void prefs_set_roster_room_char(char* ch); void prefs_clear_roster_room_char(void); char prefs_get_roster_room_private_char(void); void prefs_set_roster_room_private_char(char ch); diff --git a/src/config/theme.c b/src/config/theme.c index 868601be..407fb82e 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -448,8 +448,8 @@ _load_preferences(void) if (g_key_file_has_key(theme, "ui", "roster.rooms.char", NULL)) { gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_roster_room_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_roster_room_char(ch); g_free(ch); } } diff --git a/src/ui/console.c b/src/ui/console.c index 76295d63..5702f26f 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1499,11 +1499,13 @@ cons_roster_setting(void) cons_show("Roster resource char (/roster) : none"); } - char room_ch = prefs_get_roster_room_char(); - if (room_ch) - cons_show("Roster room char (/roster) : %c", room_ch); - else + char* room_ch = prefs_get_roster_room_char(); + if (room_ch) { + cons_show("Roster room char (/roster) : %s", room_ch); + free(room_ch); + } else { cons_show("Roster room char (/roster) : none"); + } char room_priv_ch = prefs_get_roster_room_private_char(); if (room_priv_ch) diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index b9a84950..fbfbd9cc 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -756,9 +756,10 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin) indent--; } } - char ch = prefs_get_roster_room_char(); + char* ch = prefs_get_roster_room_char(); if (ch) { - g_string_append_printf(msg, "%c", ch); + g_string_append_printf(msg, "%s", ch); + free(ch); } char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); @@ -856,7 +857,7 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin) g_string_append_printf(privmsg, "(%d) ", privwin->unread); } - ch = prefs_get_roster_room_private_char(); + char ch = prefs_get_roster_room_private_char(); if (ch) { g_string_append_printf(privmsg, "%c", ch); } |