mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Allow utf8 in roster private char
This commit is contained in:
parent
83ee4a27cb
commit
7faf15a18c
@ -2680,8 +2680,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
|||||||
cons_show("Roster private room chat char removed.");
|
cons_show("Roster private room chat char removed.");
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
} else {
|
} else {
|
||||||
prefs_set_roster_private_char(args[2][0]);
|
prefs_set_roster_private_char(args[2]);
|
||||||
cons_show("Roster private room chat char set to %c.", args[2][0]);
|
cons_show("Roster private room chat char set to %s.", args[2]);
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1158,30 +1158,22 @@ prefs_clear_roster_resource_char(void)
|
|||||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
char*
|
||||||
prefs_get_roster_private_char(void)
|
prefs_get_roster_private_char(void)
|
||||||
{
|
{
|
||||||
char result = 0;
|
char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
prefs_set_roster_private_char(char ch)
|
prefs_set_roster_private_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.private.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.private.char", str);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -263,8 +263,8 @@ void prefs_clear_roster_contact_char(void);
|
|||||||
char* prefs_get_roster_resource_char(void);
|
char* prefs_get_roster_resource_char(void);
|
||||||
void prefs_set_roster_resource_char(char* ch);
|
void prefs_set_roster_resource_char(char* ch);
|
||||||
void prefs_clear_roster_resource_char(void);
|
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);
|
||||||
|
@ -464,8 +464,8 @@ _load_preferences(void)
|
|||||||
|
|
||||||
if (g_key_file_has_key(theme, "ui", "roster.private.char", NULL)) {
|
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);
|
gchar* ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL);
|
||||||
if (ch && strlen(ch) > 0) {
|
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||||
prefs_set_roster_private_char(ch[0]);
|
prefs_set_roster_private_char(ch);
|
||||||
g_free(ch);
|
g_free(ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1511,11 +1511,13 @@ cons_roster_setting(void)
|
|||||||
else
|
else
|
||||||
cons_show("Roster room private char (/roster) : none");
|
cons_show("Roster room private char (/roster) : none");
|
||||||
|
|
||||||
char private_ch = prefs_get_roster_private_char();
|
char* private_ch = prefs_get_roster_private_char();
|
||||||
if (private_ch)
|
if (private_ch) {
|
||||||
cons_show("Roster private char (/roster) : %c", private_ch);
|
cons_show("Roster private char (/roster) : %c", private_ch);
|
||||||
else
|
free(private_ch);
|
||||||
|
} else {
|
||||||
cons_show("Roster private char (/roster) : none");
|
cons_show("Roster private char (/roster) : none");
|
||||||
|
}
|
||||||
|
|
||||||
gint contact_indent = prefs_get_roster_contact_indent();
|
gint contact_indent = prefs_get_roster_contact_indent();
|
||||||
cons_show("Roster contact indent (/roster) : %d", contact_indent);
|
cons_show("Roster contact indent (/roster) : %d", contact_indent);
|
||||||
|
@ -951,9 +951,10 @@ _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats)
|
|||||||
g_string_append_printf(privmsg, "(%d) ", privwin->unread);
|
g_string_append_printf(privmsg, "(%d) ", privwin->unread);
|
||||||
}
|
}
|
||||||
|
|
||||||
char ch = prefs_get_roster_private_char();
|
char* ch = prefs_get_roster_private_char();
|
||||||
if (ch) {
|
if (ch) {
|
||||||
g_string_append_printf(privmsg, "%c", ch);
|
g_string_append_printf(privmsg, "%s", ch);
|
||||||
|
free(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append(privmsg, privwin->fulljid);
|
g_string_append(privmsg, privwin->fulljid);
|
||||||
|
Loading…
Reference in New Issue
Block a user