diff options
author | James Booth <boothj5@gmail.com> | 2015-11-22 02:04:59 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-22 02:04:59 +0000 |
commit | c4e8af0b6dfbb787ab29e52d63845d48e01aef2d (patch) | |
tree | d1469f69cc34d340d0aa67be0fe5886b355f60d4 | |
parent | fade5469df19c217c06c73cd28f3b3eb0576d749 (diff) | |
download | profani-tty-c4e8af0b6dfbb787ab29e52d63845d48e01aef2d.tar.gz |
Added /roster char resource
-rw-r--r-- | src/command/command.c | 8 | ||||
-rw-r--r-- | src/command/commands.c | 12 | ||||
-rw-r--r-- | src/config/preferences.c | 34 | ||||
-rw-r--r-- | src/config/preferences.h | 3 | ||||
-rw-r--r-- | src/config/theme.c | 7 | ||||
-rw-r--r-- | src/ui/console.c | 6 | ||||
-rw-r--r-- | src/ui/rosterwin.c | 4 | ||||
-rw-r--r-- | theme_template | 1 | ||||
-rw-r--r-- | themes/complex | 1 |
9 files changed, 76 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c index d3895247..c80ce2b4 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -280,6 +280,7 @@ static struct cmd_t command_defs[] = "/roster order name|presence", "/roster char header <char>|none", "/roster char contact <char>|none", + "/roster char resource <char>|none", "/roster indent contact <indent>", "/roster indent resource <indent>", "/roster indent presence <indent>", @@ -320,6 +321,8 @@ static struct cmd_t command_defs[] = { "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." }, + { "char resource <char>", "Prefix roster resources with specificed character." }, + { "char resource none", "Remove roster resource character prefix." }, { "indent contact <indent>", "Indent contact line by <indent> spaces (0 to 10)." }, { "indent resource <indent>", "Indent resource line by <indent> spaces (0 to 10)." }, { "indent presence <indent>", "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." }, @@ -2048,6 +2051,7 @@ cmd_init(void) roster_char_ac = autocomplete_new(); autocomplete_add(roster_char_ac, "header"); autocomplete_add(roster_char_ac, "contact"); + autocomplete_add(roster_char_ac, "resource"); roster_char_none_ac = autocomplete_new(); autocomplete_add(roster_char_none_ac, "none"); @@ -2916,6 +2920,10 @@ _roster_autocomplete(ProfWin *window, const char *const input) if (result) { return result; } + result = autocomplete_param_with_ac(input, "/roster char resource", roster_char_none_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index e1710ae1..4bc1f880 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1787,6 +1787,18 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_show("Roster contact char set to %c.", args[2][0]); rosterwin_roster(); } + } else if (g_strcmp0(args[1], "resource") == 0) { + if (!args[2]) { + cons_bad_cmd_usage(command); + } else if (g_strcmp0(args[2], "none") == 0) { + prefs_clear_roster_resource_char(); + 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]); + rosterwin_roster(); + } } else { cons_bad_cmd_usage(command); } diff --git a/src/config/preferences.c b/src/config/preferences.c index 958ed97c..3a261897 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -506,6 +506,40 @@ prefs_clear_roster_contact_char(void) _save_prefs(); } +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); + + return result; +} + +void +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); + _save_prefs(); +} + +void +prefs_clear_roster_resource_char(void) +{ + g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.resource.char", NULL); + _save_prefs(); +} + gint prefs_get_roster_contact_indent(void) { diff --git a/src/config/preferences.h b/src/config/preferences.h index b187cb0b..9139e3b4 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -172,6 +172,9 @@ 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); +void prefs_clear_roster_resource_char(void); gint prefs_get_roster_contact_indent(void); void prefs_set_roster_contact_indent(gint value); diff --git a/src/config/theme.c b/src/config/theme.c index 6175bd7a..d87acbc2 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -484,6 +484,13 @@ _load_preferences(void) g_free(ch); } } + 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]); + g_free(ch); + } + } if (g_key_file_has_key(theme, "ui", "roster.contact.indent", NULL)) { gint contact_indent = g_key_file_get_integer(theme, "ui", "roster.contact.indent", NULL); prefs_set_roster_contact_indent(contact_indent); diff --git a/src/ui/console.c b/src/ui/console.c index bcf2de7e..f3cbb739 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1255,6 +1255,12 @@ cons_roster_setting(void) else 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 + cons_show("Roster resource char (/roster) : none"); + gint contact_indent = prefs_get_roster_contact_indent(); cons_show("Roster contact indent (/roster) : %d", contact_indent); diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index 1e43ed8d..ac5a642e 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -148,6 +148,10 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde g_string_append(msg, " "); this_indent--; } + char ch = prefs_get_roster_resource_char(); + if (ch) { + g_string_append_printf(msg, "%c", ch); + } g_string_append(msg, resource->name); if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) { g_string_append_printf(msg, " %d", resource->priority); diff --git a/theme_template b/theme_template index ddd41c81..2b22558f 100644 --- a/theme_template +++ b/theme_template @@ -84,6 +84,7 @@ roster.priority= roster.size= roster.header.char= roster.contact.char= +roster.resource.char= roster.contact.indent= roster.resource.indent= roster.presence.indent= diff --git a/themes/complex b/themes/complex index a8456dcd..a1540278 100644 --- a/themes/complex +++ b/themes/complex @@ -31,6 +31,7 @@ roster.priority=true roster.size=25 roster.header.char=- roster.contact.char=- +roster.resource.char=- roster.contact.indent=2 roster.resource.indent=2 roster.presence.indent=2 |