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.");
|
cons_show("Roster resource char removed.");
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
} else {
|
} else {
|
||||||
prefs_set_roster_resource_char(args[2][0]);
|
prefs_set_roster_resource_char(args[2]);
|
||||||
cons_show("Roster resource char set to %c.", args[2][0]);
|
cons_show("Roster resource char set to %s.", args[2]);
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
} else if (g_strcmp0(args[1], "indent") == 0) {
|
} 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);
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
char*
|
||||||
prefs_get_roster_resource_char(void)
|
prefs_get_roster_resource_char(void)
|
||||||
{
|
{
|
||||||
char result = 0;
|
char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
prefs_set_roster_resource_char(char ch)
|
prefs_set_roster_resource_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.resource.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.resource.char", str);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -260,8 +260,8 @@ void prefs_clear_roster_header_char(void);
|
|||||||
char* prefs_get_roster_contact_char(void);
|
char* prefs_get_roster_contact_char(void);
|
||||||
void prefs_set_roster_contact_char(char* ch);
|
void prefs_set_roster_contact_char(char* ch);
|
||||||
void prefs_clear_roster_contact_char(void);
|
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);
|
||||||
|
@ -438,8 +438,8 @@ _load_preferences(void)
|
|||||||
|
|
||||||
if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) {
|
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);
|
gchar* ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
|
||||||
if (ch && strlen(ch) > 0) {
|
if (ch && g_utf8_strlen(ch, 4) == 1) {
|
||||||
prefs_set_roster_resource_char(ch[0]);
|
prefs_set_roster_resource_char(ch);
|
||||||
g_free(ch);
|
g_free(ch);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1491,11 +1491,13 @@ cons_roster_setting(void)
|
|||||||
cons_show("Roster contact char (/roster) : none");
|
cons_show("Roster contact char (/roster) : none");
|
||||||
}
|
}
|
||||||
|
|
||||||
char resource_ch = prefs_get_roster_resource_char();
|
char* resource_ch = prefs_get_roster_resource_char();
|
||||||
if (resource_ch)
|
if (resource_ch) {
|
||||||
cons_show("Roster resource char (/roster) : %c", resource_ch);
|
cons_show("Roster resource char (/roster) : %s", resource_ch);
|
||||||
else
|
free(resource_ch);
|
||||||
|
} else {
|
||||||
cons_show("Roster resource char (/roster) : none");
|
cons_show("Roster resource char (/roster) : none");
|
||||||
|
}
|
||||||
|
|
||||||
char room_ch = prefs_get_roster_room_char();
|
char room_ch = prefs_get_roster_room_char();
|
||||||
if (room_ch)
|
if (room_ch)
|
||||||
|
@ -317,6 +317,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin)
|
|||||||
char *ch = prefs_get_roster_contact_char();
|
char *ch = prefs_get_roster_contact_char();
|
||||||
if (ch) {
|
if (ch) {
|
||||||
g_string_append_printf(msg, "%s", ch);
|
g_string_append_printf(msg, "%s", ch);
|
||||||
|
free(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
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();
|
char *ch = prefs_get_roster_contact_char();
|
||||||
if (ch) {
|
if (ch) {
|
||||||
g_string_append_printf(msg, "%s", ch);
|
g_string_append_printf(msg, "%s", ch);
|
||||||
|
free(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
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));
|
wattron(layout->subwin, theme_attrs(resource_presence_colour));
|
||||||
GString* msg = g_string_new("");
|
GString* msg = g_string_new("");
|
||||||
char ch = prefs_get_roster_resource_char();
|
char* ch = prefs_get_roster_resource_char();
|
||||||
if (ch) {
|
if (ch) {
|
||||||
g_string_append_printf(msg, "%c", ch);
|
g_string_append_printf(msg, "%s", ch);
|
||||||
|
free(ch);
|
||||||
} else {
|
} else {
|
||||||
g_string_append(msg, " ");
|
g_string_append(msg, " ");
|
||||||
}
|
}
|
||||||
@ -590,9 +593,10 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
|
|||||||
g_string_append(msg, " ");
|
g_string_append(msg, " ");
|
||||||
this_indent--;
|
this_indent--;
|
||||||
}
|
}
|
||||||
char ch = prefs_get_roster_resource_char();
|
char* ch = prefs_get_roster_resource_char();
|
||||||
if (ch) {
|
if (ch) {
|
||||||
g_string_append_printf(msg, "%c", ch);
|
g_string_append_printf(msg, "%s", ch);
|
||||||
|
free(ch);
|
||||||
}
|
}
|
||||||
g_string_append(msg, resource->name);
|
g_string_append(msg, resource->name);
|
||||||
if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) {
|
if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user