mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow utf8 in occupants header char
This commit is contained in:
parent
1c96115f97
commit
a9bcc8e8bd
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user