mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added /roster char contact
This commit is contained in:
parent
3f18c8c35d
commit
16fbdedceb
@ -279,6 +279,7 @@ static struct cmd_t command_defs[] =
|
||||
"/roster by group|presence|none",
|
||||
"/roster order name|presence",
|
||||
"/roster char header <char>|none",
|
||||
"/roster char contact <char>|none",
|
||||
"/roster size <percent>",
|
||||
"/roster add <jid> [<nick>]",
|
||||
"/roster remove <jid>",
|
||||
@ -313,6 +314,8 @@ static struct cmd_t command_defs[] =
|
||||
{ "order presence", "Order roster items by presence, and then by name." },
|
||||
{ "char header <char>", "Prefix roster headers with specificed character." },
|
||||
{ "char header none", "Remove roster header character prefix." },
|
||||
{ "char contact <char>", "Prefix roster contacts with specificed character." },
|
||||
{ "char contact none", "Remove roster contact character prefix." },
|
||||
{ "size <precent>", "Percentage of the screen taken up by the roster (1-99)." },
|
||||
{ "add <jid> [<nick>]", "Add a new item to the roster." },
|
||||
{ "remove <jid>", "Removes an item from the roster." },
|
||||
@ -2033,6 +2036,7 @@ cmd_init(void)
|
||||
|
||||
roster_char_ac = autocomplete_new();
|
||||
autocomplete_add(roster_char_ac, "header");
|
||||
autocomplete_add(roster_char_ac, "contact");
|
||||
|
||||
roster_char_none_ac = autocomplete_new();
|
||||
autocomplete_add(roster_char_none_ac, "none");
|
||||
@ -2890,6 +2894,10 @@ _roster_autocomplete(ProfWin *window, const char *const input)
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_ac(input, "/roster char contact", roster_char_none_ac, TRUE);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete);
|
||||
if (result) {
|
||||
return result;
|
||||
|
@ -1764,6 +1764,18 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Roster header char set to %c.", args[2][0]);
|
||||
rosterwin_roster();
|
||||
}
|
||||
} else if (g_strcmp0(args[1], "contact") == 0) {
|
||||
if (!args[2]) {
|
||||
cons_bad_cmd_usage(command);
|
||||
} else if (g_strcmp0(args[2], "none") == 0) {
|
||||
prefs_clear_roster_contact_char();
|
||||
cons_show("Roster contact char removed.");
|
||||
rosterwin_roster();
|
||||
} else {
|
||||
prefs_set_roster_contact_char(args[2][0]);
|
||||
cons_show("Roster contact char set to %c.", args[2][0]);
|
||||
rosterwin_roster();
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
@ -478,6 +478,40 @@ prefs_clear_roster_header_char(void)
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
char
|
||||
prefs_get_roster_contact_char(void)
|
||||
{
|
||||
char result = 0;
|
||||
|
||||
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
|
||||
if (!resultstr) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = resultstr[0];
|
||||
}
|
||||
free(resultstr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_contact_char(char ch)
|
||||
{
|
||||
char str[2];
|
||||
str[0] = ch;
|
||||
str[1] = '\0';
|
||||
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.contact.char", str);
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
void
|
||||
prefs_clear_roster_contact_char(void)
|
||||
{
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_add_alias(const char *const name, const char *const value)
|
||||
{
|
||||
|
@ -168,6 +168,9 @@ void prefs_set_pgp_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);
|
||||
void prefs_clear_roster_contact_char(void);
|
||||
|
||||
void prefs_add_login(const char *jid);
|
||||
|
||||
|
@ -476,6 +476,13 @@ _load_preferences(void)
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
if (g_key_file_has_key(theme, "ui", "roster.contact.char", NULL)) {
|
||||
gchar *ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
|
||||
if (ch && strlen(ch) > 0) {
|
||||
prefs_set_roster_contact_char(ch[0]);
|
||||
g_free(ch);
|
||||
}
|
||||
}
|
||||
|
||||
_set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
|
||||
|
||||
|
@ -1242,6 +1242,18 @@ cons_roster_setting(void)
|
||||
|
||||
int size = prefs_get_roster_size();
|
||||
cons_show("Roster size (/roster) : %d", size);
|
||||
|
||||
char header_ch = prefs_get_roster_header_char();
|
||||
if (header_ch)
|
||||
cons_show("Roster header char (/roster) : %c", header_ch);
|
||||
else
|
||||
cons_show("Roster header char (/roster) : none");
|
||||
|
||||
char contact_ch = prefs_get_roster_contact_char();
|
||||
if (contact_ch)
|
||||
cons_show("Roster contact char (/roster) : %c", contact_ch);
|
||||
else
|
||||
cons_show("Roster contact char (/roster) : none");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -139,6 +139,10 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
|
||||
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
GString *msg = g_string_new(" ");
|
||||
char ch = prefs_get_roster_contact_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
}
|
||||
g_string_append(msg, name);
|
||||
win_printline_nowrap(layout->subwin, msg->str);
|
||||
g_string_free(msg, TRUE);
|
||||
|
@ -83,6 +83,7 @@ roster.count=
|
||||
roster.priority=
|
||||
roster.size=
|
||||
roster.header.char=
|
||||
roster.contact.char=
|
||||
occupants=
|
||||
occupants.size=
|
||||
occupants.jid=
|
||||
|
@ -83,6 +83,7 @@ roster.count=true
|
||||
roster.priority=true
|
||||
roster.size=25
|
||||
roster.header.char=@
|
||||
roster.contact.char=-
|
||||
occupants=true
|
||||
occupants.size=15
|
||||
occupants.jid=false
|
||||
|
@ -30,6 +30,7 @@ roster.count=true
|
||||
roster.priority=true
|
||||
roster.size=25
|
||||
roster.header.char=-
|
||||
roster.contact.char=-
|
||||
privileges=true
|
||||
presence=true
|
||||
intype=true
|
||||
|
Loading…
Reference in New Issue
Block a user