1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Allow utf8 in roster private char

This commit is contained in:
Michael Vetter 2021-10-22 16:33:10 +02:00
parent 83ee4a27cb
commit 7faf15a18c
6 changed files with 22 additions and 27 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);