mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow utf8 in roster resource char
This commit is contained in:
parent
a668ca45b7
commit
83ee4a27cb
@ -2442,8 +2442,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_show("Roster resource char removed.");
|
||||
rosterwin_roster();
|
||||
} else {
|
||||
prefs_set_roster_resource_char(args[2][0]);
|
||||
cons_show("Roster resource char set to %c.", args[2][0]);
|
||||
prefs_set_roster_resource_char(args[2]);
|
||||
cons_show("Roster resource char set to %s.", args[2]);
|
||||
rosterwin_roster();
|
||||
}
|
||||
} else if (g_strcmp0(args[1], "indent") == 0) {
|
||||
|
@ -1134,30 +1134,22 @@ prefs_clear_roster_contact_char(void)
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
|
||||
}
|
||||
|
||||
char
|
||||
char*
|
||||
prefs_get_roster_resource_char(void)
|
||||
{
|
||||
char result = 0;
|
||||
|
||||
char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
||||
if (!resultstr) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = resultstr[0];
|
||||
}
|
||||
free(resultstr);
|
||||
char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_resource_char(char ch)
|
||||
prefs_set_roster_resource_char(char* ch)
|
||||
{
|
||||
char str[2];
|
||||
str[0] = ch;
|
||||
str[1] = '\0';
|
||||
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.resource.char", str);
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.resource.char", ch);
|
||||
} else {
|
||||
log_error("Could not set roster resource char: %s", ch);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -260,8 +260,8 @@ void prefs_clear_roster_header_char(void);
|
||||
char* prefs_get_roster_contact_char(void);
|
||||
void prefs_set_roster_contact_char(char* ch);
|
||||
void prefs_clear_roster_contact_char(void);
|
||||
char prefs_get_roster_resource_char(void);
|
||||
void prefs_set_roster_resource_char(char ch);
|
||||
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);
|
||||
|
@ -438,8 +438,8 @@ _load_preferences(void)
|
||||
|
||||
if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) {
|
||||
gchar* ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_resource_char(ch[0]);
|
||||
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||
prefs_set_roster_resource_char(ch);
|
||||
g_free(ch);
|
||||
}
|
||||
} else {
|
||||
|
@ -1491,11 +1491,13 @@ cons_roster_setting(void)
|
||||
cons_show("Roster contact char (/roster) : none");
|
||||
}
|
||||
|
||||
char resource_ch = prefs_get_roster_resource_char();
|
||||
if (resource_ch)
|
||||
cons_show("Roster resource char (/roster) : %c", resource_ch);
|
||||
else
|
||||
char* resource_ch = prefs_get_roster_resource_char();
|
||||
if (resource_ch) {
|
||||
cons_show("Roster resource char (/roster) : %s", resource_ch);
|
||||
free(resource_ch);
|
||||
} else {
|
||||
cons_show("Roster resource char (/roster) : none");
|
||||
}
|
||||
|
||||
char room_ch = prefs_get_roster_room_char();
|
||||
if (room_ch)
|
||||
|
@ -317,6 +317,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin)
|
||||
char *ch = prefs_get_roster_contact_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(msg, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
@ -379,6 +380,7 @@ _rosterwin_contact(ProfLayoutSplit* layout, PContact contact)
|
||||
char *ch = prefs_get_roster_contact_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(msg, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
@ -527,9 +529,10 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
|
||||
|
||||
wattron(layout->subwin, theme_attrs(resource_presence_colour));
|
||||
GString* msg = g_string_new("");
|
||||
char ch = prefs_get_roster_resource_char();
|
||||
char* ch = prefs_get_roster_resource_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
g_string_append_printf(msg, "%s", ch);
|
||||
free(ch);
|
||||
} else {
|
||||
g_string_append(msg, " ");
|
||||
}
|
||||
@ -590,9 +593,10 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
|
||||
g_string_append(msg, " ");
|
||||
this_indent--;
|
||||
}
|
||||
char ch = prefs_get_roster_resource_char();
|
||||
char* ch = prefs_get_roster_resource_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
g_string_append_printf(msg, "%s", ch);
|
||||
free(ch);
|
||||
}
|
||||
g_string_append(msg, resource->name);
|
||||
if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) {
|
||||
|
Loading…
Reference in New Issue
Block a user