1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Allow utf8 in roster rooms char

This commit is contained in:
Michael Vetter 2021-10-22 16:39:54 +02:00
parent 7faf15a18c
commit 8fc359ba2d
6 changed files with 24 additions and 29 deletions

View File

@ -2720,8 +2720,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
cons_show("Roster room char removed."); cons_show("Roster room char removed.");
rosterwin_roster(); rosterwin_roster();
} else { } else {
prefs_set_roster_room_char(args[2][0]); prefs_set_roster_room_char(args[2]);
cons_show("Roster room char set to %c.", args[2][0]); cons_show("Roster room char set to %s.", args[2]);
rosterwin_roster(); rosterwin_roster();
} }
return TRUE; return TRUE;

View File

@ -1182,30 +1182,22 @@ prefs_clear_roster_private_char(void)
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.private.char", NULL); g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.private.char", NULL);
} }
char char*
prefs_get_roster_room_char(void) prefs_get_roster_room_char(void)
{ {
char result = 0; char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL);
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);
return result; return result;
} }
void void
prefs_set_roster_room_char(char ch) prefs_set_roster_room_char(char* ch)
{ {
char str[2]; if (g_utf8_strlen(ch, 4) == 1) {
str[0] = ch; g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.char", ch);
str[1] = '\0'; } else {
log_error("Could not set roster resource char: %s", ch);
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.char", str); }
} }
void void

View File

@ -266,8 +266,8 @@ void prefs_clear_roster_resource_char(void);
char* prefs_get_roster_private_char(void); char* prefs_get_roster_private_char(void);
void prefs_set_roster_private_char(char* ch); void prefs_set_roster_private_char(char* ch);
void prefs_clear_roster_private_char(void); void prefs_clear_roster_private_char(void);
char prefs_get_roster_room_char(void); char* prefs_get_roster_room_char(void);
void prefs_set_roster_room_char(char ch); void prefs_set_roster_room_char(char* ch);
void prefs_clear_roster_room_char(void); void prefs_clear_roster_room_char(void);
char prefs_get_roster_room_private_char(void); char prefs_get_roster_room_private_char(void);
void prefs_set_roster_room_private_char(char ch); void prefs_set_roster_room_private_char(char ch);

View File

@ -448,8 +448,8 @@ _load_preferences(void)
if (g_key_file_has_key(theme, "ui", "roster.rooms.char", NULL)) { 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); gchar* ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL);
if (ch && strlen(ch) > 0) { if (ch && g_utf8_strlen(ch, 4) == 1) {
prefs_set_roster_room_char(ch[0]); prefs_set_roster_room_char(ch);
g_free(ch); g_free(ch);
} }
} }

View File

@ -1499,11 +1499,13 @@ cons_roster_setting(void)
cons_show("Roster resource char (/roster) : none"); cons_show("Roster resource char (/roster) : none");
} }
char room_ch = prefs_get_roster_room_char(); char* room_ch = prefs_get_roster_room_char();
if (room_ch) if (room_ch) {
cons_show("Roster room char (/roster) : %c", room_ch); cons_show("Roster room char (/roster) : %s", room_ch);
else free(room_ch);
} else {
cons_show("Roster room char (/roster) : none"); cons_show("Roster room char (/roster) : none");
}
char room_priv_ch = prefs_get_roster_room_private_char(); char room_priv_ch = prefs_get_roster_room_private_char();
if (room_priv_ch) if (room_priv_ch)

View File

@ -756,9 +756,10 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
indent--; indent--;
} }
} }
char ch = prefs_get_roster_room_char(); char* ch = prefs_get_roster_room_char();
if (ch) { 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); 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); 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) { if (ch) {
g_string_append_printf(privmsg, "%c", ch); g_string_append_printf(privmsg, "%c", ch);
} }