diff options
-rw-r--r-- | src/command/cmd_funcs.c | 6 | ||||
-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/occupantswin.c | 5 |
6 files changed, 24 insertions, 29 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 734401f4..ee27ebbd 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -2389,7 +2389,7 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args) rosterwin_roster(); } else { prefs_set_roster_header_char(args[2]); - cons_show("Roster header char set to %c.", args[2]); + cons_show("Roster header char set to %s.", args[2]); rosterwin_roster(); } } else { @@ -4470,8 +4470,8 @@ cmd_occupants(ProfWin* window, const char* const command, gchar** args) occupantswin_occupants_all(); } else { - prefs_set_occupants_header_char(args[2][0]); - cons_show("Occupants header char set to %c.", args[2][0]); + prefs_set_occupants_header_char(args[2]); + cons_show("Occupants header char set to %s.", args[2]); occupantswin_occupants_all(); } diff --git a/src/config/preferences.c b/src/config/preferences.c index fae150c8..16da777d 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -948,30 +948,22 @@ prefs_set_occupants_indent(gint value) g_key_file_set_integer(prefs, PREF_GROUP_UI, "occupants.indent", value); } -char +char* prefs_get_occupants_header_char(void) { - char result = 0; - - char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.header.char", NULL); - if (!resultstr) { - result = 0; - } else { - result = resultstr[0]; - } - free(resultstr); + char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.header.char", NULL); return result; } void -prefs_set_occupants_header_char(char ch) +prefs_set_occupants_header_char(char* ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.header.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.header.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 1f8df60d..25fc16ad 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -275,8 +275,8 @@ void prefs_clear_roster_room_private_char(void); 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); +char* prefs_get_occupants_header_char(void); +void prefs_set_occupants_header_char(char* ch); void prefs_clear_occupants_header_char(void); gint prefs_get_roster_contact_indent(void); diff --git a/src/config/theme.c b/src/config/theme.c index 1af68afd..9becc833 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -414,8 +414,8 @@ _load_preferences(void) if (g_key_file_has_key(theme, "ui", "occupants.header.char", NULL)) { gchar* ch = g_key_file_get_string(theme, "ui", "occupants.header.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_occupants_header_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_occupants_header_char(ch); g_free(ch); } } diff --git a/src/ui/console.c b/src/ui/console.c index 3ca981ba..61c1f1c2 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1354,11 +1354,13 @@ cons_occupants_setting(void) int size = prefs_get_occupants_size(); cons_show("Occupants size (/occupants) : %d", size); - char header_ch = prefs_get_occupants_header_char(); - if (header_ch) - cons_show("Occupants header char (/occupants) : %c", header_ch); - else + char* header_ch = prefs_get_occupants_header_char(); + if (header_ch) { + cons_show("Occupants header char (/occupants) : %s", header_ch); + free(header_ch); + } else { cons_show("Occupants header char (/occupants) : none"); + } } void diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index 8d06de0e..1524de3f 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -131,9 +131,10 @@ occupantswin_occupants(const char* const roomjid) GString* prefix = g_string_new(" "); - char ch = prefs_get_occupants_header_char(); + char* ch = prefs_get_occupants_header_char(); if (ch) { - g_string_append_printf(prefix, "%c", ch); + g_string_append_printf(prefix, "%s", ch); + free(ch); } if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { |