mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Allow utf8 in roster header char
This and the following commits should make a couple of more configs allow utf8 chars so people can use their weird icons :-) We did the same for the otr/omemo/pgp indicators at:1f8b1eb740
5cf6ee1bc6
This commit is contained in:
parent
37e1699c84
commit
91898597dd
@ -2388,8 +2388,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_show("Roster header char removed.");
|
||||
rosterwin_roster();
|
||||
} else {
|
||||
prefs_set_roster_header_char(args[2][0]);
|
||||
cons_show("Roster header char set to %c.", args[2][0]);
|
||||
prefs_set_roster_header_char(args[2]);
|
||||
cons_show("Roster header char set to %c.", args[2]);
|
||||
rosterwin_roster();
|
||||
}
|
||||
} else {
|
||||
|
@ -1080,32 +1080,30 @@ prefs_set_omemo_char(char* ch)
|
||||
return _prefs_set_encryption_char(ch, PREF_GROUP_OMEMO, "omemo.char");
|
||||
}
|
||||
|
||||
char
|
||||
char*
|
||||
prefs_get_roster_header_char(void)
|
||||
{
|
||||
char result = 0;
|
||||
char* result = NULL;
|
||||
|
||||
char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.header.char", NULL);
|
||||
if (!resultstr) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = resultstr[0];
|
||||
if (resultstr) {
|
||||
result = resultstr;
|
||||
}
|
||||
free(resultstr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_header_char(char ch)
|
||||
prefs_set_roster_header_char(char* ch)
|
||||
{
|
||||
char str[2];
|
||||
str[0] = ch;
|
||||
str[1] = '\0';
|
||||
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.header.char", str);
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.header.char", ch);
|
||||
} else {
|
||||
log_error("Could not set roster header char: %s", ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
prefs_clear_roster_header_char(void)
|
||||
{
|
||||
|
@ -254,8 +254,8 @@ gboolean prefs_set_omemo_char(char* ch);
|
||||
char* prefs_get_ox_char(void);
|
||||
gboolean prefs_set_ox_char(char* ch);
|
||||
|
||||
char prefs_get_roster_header_char(void);
|
||||
void prefs_set_roster_header_char(char ch);
|
||||
char* prefs_get_roster_header_char(void);
|
||||
void prefs_set_roster_header_char(char* ch);
|
||||
void prefs_clear_roster_header_char(void);
|
||||
char prefs_get_roster_contact_char(void);
|
||||
void prefs_set_roster_contact_char(char ch);
|
||||
|
@ -422,8 +422,8 @@ _load_preferences(void)
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.header.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_header_char(ch[0]);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_header_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
@ -1475,11 +1475,12 @@ cons_roster_setting(void)
|
||||
else
|
||||
cons_show("Roster offline (/roster) : hide");
|
||||
|
||||
char header_ch = prefs_get_roster_header_char();
|
||||
char* header_ch = prefs_get_roster_header_char();
|
||||
if (header_ch)
|
||||
cons_show("Roster header char (/roster) : %c", header_ch);
|
||||
cons_show("Roster header char (/roster) : %s", header_ch);
|
||||
else
|
||||
cons_show("Roster header char (/roster) : none");
|
||||
free(header_ch);
|
||||
|
||||
char contact_ch = prefs_get_roster_contact_char();
|
||||
if (contact_ch)
|
||||
|
@ -1028,9 +1028,10 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins)
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString* header = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
char* ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(header, "%c", ch);
|
||||
g_string_append_printf(header, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
|
||||
g_string_append(header, "Unsubscribed");
|
||||
@ -1074,9 +1075,10 @@ _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSL
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString* header = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
char* ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(header, "%c", ch);
|
||||
g_string_append_printf(header, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
|
||||
g_string_append(header, title);
|
||||
@ -1125,9 +1127,10 @@ _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title)
|
||||
{
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
GString* header = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
char* ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(header, "%c", ch);
|
||||
g_string_append_printf(header, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
g_string_append(header, title);
|
||||
|
||||
@ -1188,9 +1191,10 @@ _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs)
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString* title_str = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
char* ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(title_str, "%c", ch);
|
||||
g_string_append_printf(title_str, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
g_string_append(title_str, "Private chats");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user