diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 58c08331..734401f4 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4414,8 +4414,8 @@ cmd_occupants(ProfWin* window, const char* const command, gchar** args) occupantswin_occupants_all(); } else { - prefs_set_occupants_char(args[1][0]); - cons_show("Occupants char set to %c.", args[1][0]); + prefs_set_occupants_char(args[1]); + cons_show("Occupants char set to %s.", args[1]); occupantswin_occupants_all(); } diff --git a/src/config/preferences.c b/src/config/preferences.c index b1686424..fae150c8 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -902,30 +902,23 @@ prefs_get_occupants_size(void) } } -char +char* prefs_get_occupants_char(void) { - char result = 0; - char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.char", NULL); - if (!resultstr) { - result = 0; - } else { - result = resultstr[0]; - } - free(resultstr); + char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.char", NULL); return result; } void -prefs_set_occupants_char(char ch) +prefs_set_occupants_char(char* ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.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 aec27094..1f8df60d 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -272,8 +272,8 @@ void prefs_clear_roster_room_char(void); char* prefs_get_roster_room_private_char(void); void prefs_set_roster_room_private_char(char* ch); void prefs_clear_roster_room_private_char(void); -char prefs_get_occupants_char(void); -void prefs_set_occupants_char(char ch); +char* prefs_get_occupants_char(void); +void prefs_set_occupants_char(char* ch); void prefs_clear_occupants_char(void); char prefs_get_occupants_header_char(void); void prefs_set_occupants_header_char(char ch); diff --git a/src/config/theme.c b/src/config/theme.c index 118cbaa2..1af68afd 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -406,8 +406,8 @@ _load_preferences(void) // with custom set functions if (g_key_file_has_key(theme, "ui", "occupants.char", NULL)) { gchar* ch = g_key_file_get_string(theme, "ui", "occupants.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_occupants_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_occupants_char(ch); g_free(ch); } } diff --git a/src/ui/console.c b/src/ui/console.c index a20d9fce..3ca981ba 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1340,11 +1340,13 @@ cons_occupants_setting(void) else cons_show("Occupants wrap (/occupants) : OFF"); - char occupants_ch = prefs_get_occupants_char(); - if (occupants_ch) - cons_show("Occupants char (/occupants) : %c", occupants_ch); - else + char* occupants_ch = prefs_get_occupants_char(); + if (occupants_ch) { + cons_show("Occupants char (/occupants) : %s", occupants_ch); + free(occupants_ch); + } else { cons_show("Occupants char (/occupants) : none"); + } gint occupant_indent = prefs_get_occupants_indent(); cons_show("Occupant indent (/occupants) : %d", occupant_indent); @@ -1509,7 +1511,7 @@ cons_roster_setting(void) char* room_priv_ch = prefs_get_roster_room_private_char(); if (room_priv_ch) { - cons_show("Roster room private char (/roster) : %c", room_priv_ch); + cons_show("Roster room private char (/roster) : %s", room_priv_ch); free(room_priv_ch); } else { cons_show("Roster room private char (/roster) : none"); @@ -1517,7 +1519,7 @@ cons_roster_setting(void) char* private_ch = prefs_get_roster_private_char(); if (private_ch) { - cons_show("Roster private char (/roster) : %c", private_ch); + cons_show("Roster private char (/roster) : %s", private_ch); free(private_ch); } else { cons_show("Roster private char (/roster) : none"); diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index 4ceb5575..8d06de0e 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -77,9 +77,10 @@ _occuptantswin_occupant(ProfLayoutSplit* layout, GList* item, gboolean showjid, GString* msg = g_string_new(spaces->str); - char ch = prefs_get_occupants_char(); + char* ch = prefs_get_occupants_char(); if (ch) { - g_string_append_printf(msg, "%c", ch); + g_string_append_printf(msg, "%s", ch); + free(ch); } gboolean wrap = prefs_get_boolean(PREF_OCCUPANTS_WRAP);