From 0f22179eef2c5b88b3fa30c76a09308987376d0c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 22 Nov 2015 16:37:05 +0000 Subject: [PATCH 1/2] Added /roster resource join --- src/command/command.c | 17 +++++++++++ src/command/commands.c | 11 +++++++ src/config/preferences.c | 4 +++ src/config/preferences.h | 1 + src/ui/rosterwin.c | 63 +++++++++++++++++++++++++++++----------- 5 files changed, 79 insertions(+), 17 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index c80ce2b4..367d3c29 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -284,6 +284,7 @@ static struct cmd_t command_defs[] = "/roster indent contact ", "/roster indent resource ", "/roster indent presence ", + "/roster resource join on|off", "/roster size ", "/roster wrap on|off", "/roster add []", @@ -326,6 +327,7 @@ static struct cmd_t command_defs[] = { "indent contact ", "Indent contact line by spaces (0 to 10)." }, { "indent resource ", "Indent resource line by spaces (0 to 10)." }, { "indent presence ", "Indent presence line by spaces (-1 to 10), a value of -1 will show presence on the previous line." }, + { "resource join on|off", "Join resource with previous line when only one available resource." }, { "size ", "Percentage of the screen taken up by the roster (1-99)." }, { "wrap on|off", "Enabled or disanle line wrapping in roster panel." }, { "add []", "Add a new item to the roster." }, @@ -1793,6 +1795,7 @@ static Autocomplete disco_ac; static Autocomplete close_ac; static Autocomplete wins_ac; static Autocomplete roster_ac; +static Autocomplete roster_resource_ac; static Autocomplete roster_char_ac; static Autocomplete roster_char_none_ac; static Autocomplete roster_indent_ac; @@ -2047,6 +2050,10 @@ cmd_init(void) autocomplete_add(roster_ac, "char"); autocomplete_add(roster_ac, "indent"); autocomplete_add(roster_ac, "wrap"); + autocomplete_add(roster_ac, "resource"); + + roster_resource_ac = autocomplete_new(); + autocomplete_add(roster_resource_ac, "join"); roster_char_ac = autocomplete_new(); autocomplete_add(roster_char_ac, "header"); @@ -2331,6 +2338,7 @@ cmd_uninit(void) autocomplete_free(close_ac); autocomplete_free(wins_ac); autocomplete_free(roster_ac); + autocomplete_free(roster_resource_ac); autocomplete_free(roster_char_ac); autocomplete_free(roster_char_none_ac); autocomplete_free(roster_indent_ac); @@ -2521,6 +2529,7 @@ cmd_reset_autocomplete(ProfWin *window) autocomplete_reset(close_ac); autocomplete_reset(wins_ac); autocomplete_reset(roster_ac); + autocomplete_reset(roster_resource_ac); autocomplete_reset(roster_char_ac); autocomplete_reset(roster_char_none_ac); autocomplete_reset(roster_indent_ac); @@ -2912,6 +2921,10 @@ static char* _roster_autocomplete(ProfWin *window, const char *const input) { char *result = NULL; + result = autocomplete_param_with_func(input, "/roster resource join", prefs_autocomplete_boolean_choice); + if (result) { + return result; + } result = autocomplete_param_with_ac(input, "/roster char header", roster_char_none_ac, TRUE); if (result) { return result; @@ -2968,6 +2981,10 @@ _roster_autocomplete(ProfWin *window, const char *const input) if (result) { return result; } + result = autocomplete_param_with_ac(input, "/roster resource", roster_resource_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index 4bc1f880..d352fd5a 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1761,6 +1761,17 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return res; } + // roster join with previous line + } else if (g_strcmp0(args[0], "resource") == 0) { + if (g_strcmp0(args[1], "join") == 0) { + int res = _cmd_set_boolean_preference(args[2], command, "Roster join", PREF_ROSTER_RESOURCE_JOIN); + rosterwin_roster(); + return res; + } else { + cons_bad_cmd_usage(command); + return TRUE; + } + // set header character } else if (g_strcmp0(args[0], "char") == 0) { if (g_strcmp0(args[1], "header") == 0) { diff --git a/src/config/preferences.c b/src/config/preferences.c index 3a261897..07985efc 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -767,6 +767,7 @@ _get_group(preference_t pref) case PREF_ROSTER_COUNT: case PREF_ROSTER_PRIORITY: case PREF_ROSTER_WRAP: + case PREF_ROSTER_RESOURCE_JOIN: case PREF_RESOURCE_TITLE: case PREF_RESOURCE_MESSAGE: case PREF_ENC_WARN: @@ -952,6 +953,8 @@ _get_key(preference_t pref) return "roster.priority"; case PREF_ROSTER_WRAP: return "roster.wrap"; + case PREF_ROSTER_RESOURCE_JOIN: + return "roster.resource.join"; case PREF_RESOURCE_TITLE: return "resource.title"; case PREF_RESOURCE_MESSAGE: @@ -1005,6 +1008,7 @@ _get_default_boolean(preference_t pref) case PREF_ROSTER_EMPTY: case PREF_ROSTER_COUNT: case PREF_ROSTER_PRIORITY: + case PREF_ROSTER_RESOURCE_JOIN: case PREF_TLS_SHOW: case PREF_LASTACTIVITY: return TRUE; diff --git a/src/config/preferences.h b/src/config/preferences.h index 9139e3b4..607a1abe 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -72,6 +72,7 @@ typedef enum { PREF_ROSTER_COUNT, PREF_ROSTER_PRIORITY, PREF_ROSTER_WRAP, + PREF_ROSTER_RESOURCE_JOIN, PREF_MUC_PRIVILEGES, PREF_PRESENCE, PREF_WRAP, diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index ac5a642e..4dd1178b 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -128,45 +128,74 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr static void _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent) { + gboolean join = prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN); + GList *resources = p_contact_get_available_resources(contact); if (resources) { - int resource_indent = prefs_get_roster_resource_indent(); - if (resource_indent > 0) { - current_indent += resource_indent; - } - - GList *curr_resource = resources; - while (curr_resource) { - Resource *resource = curr_resource->data; + if (join && (g_list_length(resources) == 1)) { + Resource *resource = resources->data; const char *resource_presence = string_from_resource_presence(resource->presence); theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence); wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(" "); - int this_indent = current_indent; - while (this_indent > 0) { - g_string_append(msg, " "); - this_indent--; - } + GString *msg = g_string_new(""); char ch = prefs_get_roster_resource_char(); if (ch) { g_string_append_printf(msg, "%c", ch); + } else { + g_string_append(msg, " "); } g_string_append(msg, resource->name); if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) { g_string_append_printf(msg, " %d", resource->priority); } - win_sub_newline_lazy(layout->subwin); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent); + win_sub_print(layout->subwin, msg->str, FALSE, wrap, 0); g_string_free(msg, TRUE); wattroff(layout->subwin, theme_attrs(resource_presence_colour)); if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { _rosterwin_presence(layout, resource_presence_colour, resource_presence, resource->status, current_indent); } + } else { + int resource_indent = prefs_get_roster_resource_indent(); + if (resource_indent > 0) { + current_indent += resource_indent; + } - curr_resource = g_list_next(curr_resource); + GList *curr_resource = resources; + while (curr_resource) { + Resource *resource = curr_resource->data; + const char *resource_presence = string_from_resource_presence(resource->presence); + theme_item_t resource_presence_colour = theme_main_presence_attrs(resource_presence); + + wattron(layout->subwin, theme_attrs(resource_presence_colour)); + GString *msg = g_string_new(" "); + int this_indent = current_indent; + while (this_indent > 0) { + 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); + } + win_sub_newline_lazy(layout->subwin); + gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); + win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent); + g_string_free(msg, TRUE); + wattroff(layout->subwin, theme_attrs(resource_presence_colour)); + + if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { + _rosterwin_presence(layout, resource_presence_colour, resource_presence, resource->status, current_indent); + } + + curr_resource = g_list_next(curr_resource); + } } } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { const char *presence = p_contact_presence(contact); From 216493ef07662e8f53f7c0de2391a43ef9bd3a8a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 22 Nov 2015 17:45:38 +0000 Subject: [PATCH 2/2] Tidied roster commands --- src/command/command.c | 148 ++++++++++++++++++++++------------------- src/command/commands.c | 86 +++++++++++++----------- src/config/theme.c | 7 ++ src/ui/console.c | 59 ++++++++-------- theme_template | 11 +-- themes/boothj5 | 26 ++++---- themes/complex | 19 +++--- themes/simple | 10 ++- 8 files changed, 200 insertions(+), 166 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 367d3c29..972b849f 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -278,12 +278,12 @@ static struct cmd_t command_defs[] = "/roster hide [offline|resource|presence|status|empty|count|priority]", "/roster by group|presence|none", "/roster order name|presence", - "/roster char header |none", - "/roster char contact |none", - "/roster char resource |none", - "/roster indent contact ", - "/roster indent resource ", - "/roster indent presence ", + "/roster header char |none", + "/roster presence indent ", + "/roster contact char |none", + "/roster contact indent ", + "/roster resource char |none", + "/roster resource indent ", "/roster resource join on|off", "/roster size ", "/roster wrap on|off", @@ -318,16 +318,16 @@ static struct cmd_t command_defs[] = { "by none", "No grouping in the roster panel." }, { "order name", "Order roster items by name only." }, { "order presence", "Order roster items by presence, and then by name." }, - { "char header ", "Prefix roster headers with specificed character." }, - { "char header none", "Remove roster header character prefix." }, - { "char contact ", "Prefix roster contacts with specificed character." }, - { "char contact none", "Remove roster contact character prefix." }, - { "char resource ", "Prefix roster resources with specificed character." }, - { "char resource none", "Remove roster resource character prefix." }, - { "indent contact ", "Indent contact line by spaces (0 to 10)." }, - { "indent resource ", "Indent resource line by spaces (0 to 10)." }, - { "indent presence ", "Indent presence line by spaces (-1 to 10), a value of -1 will show presence on the previous line." }, + { "header char ", "Prefix roster headers with specificed character." }, + { "header char none", "Remove roster header character prefix." }, + { "contact char ", "Prefix roster contacts with specificed character." }, + { "contact char none", "Remove roster contact character prefix." }, + { "contact indent ", "Indent contact line by spaces (0 to 10)." }, + { "resource char ", "Prefix roster resources with specificed character." }, + { "resource char none", "Remove roster resource character prefix." }, + { "resource indent ", "Indent resource line by spaces (0 to 10)." }, { "resource join on|off", "Join resource with previous line when only one available resource." }, + { "presence indent ", "Indent presence line by spaces (-1 to 10), a value of -1 will show presence on the previous line." }, { "size ", "Percentage of the screen taken up by the roster (1-99)." }, { "wrap on|off", "Enabled or disanle line wrapping in roster panel." }, { "add []", "Add a new item to the roster." }, @@ -1795,13 +1795,14 @@ static Autocomplete disco_ac; static Autocomplete close_ac; static Autocomplete wins_ac; static Autocomplete roster_ac; -static Autocomplete roster_resource_ac; -static Autocomplete roster_char_ac; -static Autocomplete roster_char_none_ac; -static Autocomplete roster_indent_ac; -static Autocomplete roster_option_ac; +static Autocomplete roster_show_ac; static Autocomplete roster_by_ac; static Autocomplete roster_order_ac; +static Autocomplete roster_header_ac; +static Autocomplete roster_contact_ac; +static Autocomplete roster_resource_ac; +static Autocomplete roster_presence_ac; +static Autocomplete roster_char_ac; static Autocomplete roster_remove_all_ac; static Autocomplete group_ac; static Autocomplete bookmark_ac; @@ -2047,35 +2048,38 @@ cmd_init(void) autocomplete_add(roster_ac, "by"); autocomplete_add(roster_ac, "order"); autocomplete_add(roster_ac, "size"); - autocomplete_add(roster_ac, "char"); - autocomplete_add(roster_ac, "indent"); autocomplete_add(roster_ac, "wrap"); + autocomplete_add(roster_ac, "header"); + autocomplete_add(roster_ac, "contact"); autocomplete_add(roster_ac, "resource"); + autocomplete_add(roster_ac, "presence"); + + roster_header_ac = autocomplete_new(); + autocomplete_add(roster_header_ac, "char"); + + roster_contact_ac = autocomplete_new(); + autocomplete_add(roster_contact_ac, "char"); + autocomplete_add(roster_contact_ac, "indent"); roster_resource_ac = autocomplete_new(); + autocomplete_add(roster_resource_ac, "char"); + autocomplete_add(roster_resource_ac, "indent"); autocomplete_add(roster_resource_ac, "join"); + roster_presence_ac = autocomplete_new(); + autocomplete_add(roster_presence_ac, "indent"); + roster_char_ac = autocomplete_new(); - autocomplete_add(roster_char_ac, "header"); - autocomplete_add(roster_char_ac, "contact"); - autocomplete_add(roster_char_ac, "resource"); + autocomplete_add(roster_char_ac, "none"); - roster_char_none_ac = autocomplete_new(); - autocomplete_add(roster_char_none_ac, "none"); - - roster_indent_ac = autocomplete_new(); - autocomplete_add(roster_indent_ac, "contact"); - autocomplete_add(roster_indent_ac, "resource"); - autocomplete_add(roster_indent_ac, "presence"); - - roster_option_ac = autocomplete_new(); - autocomplete_add(roster_option_ac, "offline"); - autocomplete_add(roster_option_ac, "resource"); - autocomplete_add(roster_option_ac, "presence"); - autocomplete_add(roster_option_ac, "status"); - autocomplete_add(roster_option_ac, "empty"); - autocomplete_add(roster_option_ac, "count"); - autocomplete_add(roster_option_ac, "priority"); + roster_show_ac = autocomplete_new(); + autocomplete_add(roster_show_ac, "offline"); + autocomplete_add(roster_show_ac, "resource"); + autocomplete_add(roster_show_ac, "presence"); + autocomplete_add(roster_show_ac, "status"); + autocomplete_add(roster_show_ac, "empty"); + autocomplete_add(roster_show_ac, "count"); + autocomplete_add(roster_show_ac, "priority"); roster_by_ac = autocomplete_new(); autocomplete_add(roster_by_ac, "group"); @@ -2338,11 +2342,12 @@ cmd_uninit(void) autocomplete_free(close_ac); autocomplete_free(wins_ac); autocomplete_free(roster_ac); + autocomplete_free(roster_header_ac); + autocomplete_free(roster_contact_ac); autocomplete_free(roster_resource_ac); + autocomplete_free(roster_presence_ac); autocomplete_free(roster_char_ac); - autocomplete_free(roster_char_none_ac); - autocomplete_free(roster_indent_ac); - autocomplete_free(roster_option_ac); + autocomplete_free(roster_show_ac); autocomplete_free(roster_by_ac); autocomplete_free(roster_order_ac); autocomplete_free(roster_remove_all_ac); @@ -2529,11 +2534,12 @@ cmd_reset_autocomplete(ProfWin *window) autocomplete_reset(close_ac); autocomplete_reset(wins_ac); autocomplete_reset(roster_ac); + autocomplete_reset(roster_header_ac); + autocomplete_reset(roster_contact_ac); autocomplete_reset(roster_resource_ac); + autocomplete_reset(roster_presence_ac); autocomplete_reset(roster_char_ac); - autocomplete_reset(roster_char_none_ac); - autocomplete_reset(roster_indent_ac); - autocomplete_reset(roster_option_ac); + autocomplete_reset(roster_show_ac); autocomplete_reset(roster_by_ac); autocomplete_reset(roster_order_ac); autocomplete_reset(roster_remove_all_ac); @@ -2921,22 +2927,22 @@ static char* _roster_autocomplete(ProfWin *window, const char *const input) { char *result = NULL; + result = autocomplete_param_with_ac(input, "/roster header char", roster_char_ac, TRUE); + if (result) { + return result; + } + result = autocomplete_param_with_ac(input, "/roster contact char", roster_char_ac, TRUE); + if (result) { + return result; + } + result = autocomplete_param_with_ac(input, "/roster resource char", roster_char_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_func(input, "/roster resource join", prefs_autocomplete_boolean_choice); if (result) { return result; } - result = autocomplete_param_with_ac(input, "/roster char header", roster_char_none_ac, TRUE); - 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_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; @@ -2953,11 +2959,11 @@ _roster_autocomplete(ProfWin *window, const char *const input) if (result) { return result; } - result = autocomplete_param_with_ac(input, "/roster show", roster_option_ac, TRUE); + result = autocomplete_param_with_ac(input, "/roster show", roster_show_ac, TRUE); if (result) { return result; } - result = autocomplete_param_with_ac(input, "/roster hide", roster_option_ac, TRUE); + result = autocomplete_param_with_ac(input, "/roster hide", roster_show_ac, TRUE); if (result) { return result; } @@ -2969,22 +2975,26 @@ _roster_autocomplete(ProfWin *window, const char *const input) if (result) { return result; } - result = autocomplete_param_with_ac(input, "/roster char", roster_char_ac, TRUE); - if (result) { - return result; - } - result = autocomplete_param_with_ac(input, "/roster indent", roster_indent_ac, TRUE); - if (result) { - return result; - } result = autocomplete_param_with_func(input, "/roster wrap", prefs_autocomplete_boolean_choice); if (result) { return result; } + result = autocomplete_param_with_ac(input, "/roster header", roster_header_ac, TRUE); + if (result) { + return result; + } + result = autocomplete_param_with_ac(input, "/roster contact", roster_contact_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_ac(input, "/roster resource", roster_resource_ac, TRUE); if (result) { return result; } + result = autocomplete_param_with_ac(input, "/roster presence", roster_presence_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index d352fd5a..8d2306e8 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1756,25 +1756,14 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } else { - int res = _cmd_set_boolean_preference(args[1], command, "Roster panel line wrap", PREF_ROSTER_WRAP); + int res = _cmd_set_boolean_preference(args[1], command, "Roster panel line wrap", PREF_ROSTER_WRAP); rosterwin_roster(); return res; } - // roster join with previous line - } else if (g_strcmp0(args[0], "resource") == 0) { - if (g_strcmp0(args[1], "join") == 0) { - int res = _cmd_set_boolean_preference(args[2], command, "Roster join", PREF_ROSTER_RESOURCE_JOIN); - rosterwin_roster(); - return res; - } else { - cons_bad_cmd_usage(command); - return TRUE; - } - - // set header character - } else if (g_strcmp0(args[0], "char") == 0) { - if (g_strcmp0(args[1], "header") == 0) { + // header settings + } else if (g_strcmp0(args[0], "header") == 0) { + if (g_strcmp0(args[1], "char") == 0) { if (!args[2]) { cons_bad_cmd_usage(command); } else if (g_strcmp0(args[2], "none") == 0) { @@ -1786,7 +1775,14 @@ 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) { + } else { + cons_bad_cmd_usage(command); + } + return TRUE; + + // contact settings + } else if (g_strcmp0(args[0], "contact") == 0) { + if (g_strcmp0(args[1], "char") == 0) { if (!args[2]) { cons_bad_cmd_usage(command); } else if (g_strcmp0(args[2], "none") == 0) { @@ -1798,26 +1794,7 @@ 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); - } - return TRUE; - - // set indentations - } else if (g_strcmp0(args[0], "indent") == 0) { - if (g_strcmp0(args[1], "contact") == 0) { + } else if (g_strcmp0(args[1], "indent") == 0) { if (!args[2]) { cons_bad_cmd_usage(command); } else { @@ -1833,7 +1810,26 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) free(err_msg); } } - } else if (g_strcmp0(args[1], "resource") == 0) { + } else { + cons_bad_cmd_usage(command); + } + return TRUE; + + // resource settings + } else if (g_strcmp0(args[0], "resource") == 0) { + if (g_strcmp0(args[1], "char") == 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 if (g_strcmp0(args[1], "indent") == 0) { if (!args[2]) { cons_bad_cmd_usage(command); } else { @@ -1849,7 +1845,18 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) free(err_msg); } } - } else if (g_strcmp0(args[1], "presence") == 0) { + } else if (g_strcmp0(args[1], "join") == 0) { + int res = _cmd_set_boolean_preference(args[2], command, "Roster join", PREF_ROSTER_RESOURCE_JOIN); + rosterwin_roster(); + return res; + } else { + cons_bad_cmd_usage(command); + } + return TRUE; + + // presence settings + } else if (g_strcmp0(args[0], "presence") == 0) { + if (g_strcmp0(args[1], "indent") == 0) { if (!args[2]) { cons_bad_cmd_usage(command); } else { @@ -1993,6 +2000,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } + // roster grouping } else if (g_strcmp0(args[0], "by") == 0) { if (g_strcmp0(args[1], "group") == 0) { @@ -2020,6 +2028,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } + // roster item order } else if (g_strcmp0(args[0], "order") == 0) { if (g_strcmp0(args[1], "name") == 0) { @@ -2040,6 +2049,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } + // add contact } else if (strcmp(args[0], "add") == 0) { if (conn_status != JABBER_CONNECTED) { diff --git a/src/config/theme.c b/src/config/theme.c index d87acbc2..0c0ff26c 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -458,6 +458,7 @@ _load_preferences(void) _set_boolean_preference("roster", PREF_ROSTER); _set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE); _set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE); + _set_boolean_preference("roster.resource.join", PREF_ROSTER_RESOURCE_JOIN); _set_boolean_preference("roster.presence", PREF_ROSTER_PRESENCE); _set_boolean_preference("roster.status", PREF_ROSTER_STATUS); _set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY); @@ -476,6 +477,8 @@ _load_preferences(void) prefs_set_roster_header_char(ch[0]); g_free(ch); } + } else { + prefs_clear_roster_header_char(); } 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); @@ -483,6 +486,8 @@ _load_preferences(void) prefs_set_roster_contact_char(ch[0]); g_free(ch); } + } else { + prefs_clear_roster_contact_char(); } 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); @@ -490,6 +495,8 @@ _load_preferences(void) prefs_set_roster_resource_char(ch[0]); g_free(ch); } + } else { + prefs_clear_roster_resource_char(); } 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); diff --git a/src/ui/console.c b/src/ui/console.c index f3cbb739..54cd8d53 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1202,16 +1202,48 @@ cons_roster_setting(void) else cons_show("Roster offline (/roster) : hide"); + 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"); + + gint contact_indent = prefs_get_roster_contact_indent(); + cons_show("Roster contact indent (/roster) : %d", contact_indent); + if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) cons_show("Roster resource (/roster) : show"); else cons_show("Roster resource (/roster) : hide"); + 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 resource_indent = prefs_get_roster_resource_indent(); + cons_show("Roster resource indent (/roster) : %d", resource_indent); + + if (prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN)) + cons_show("Roster resource join (/roster) : on"); + else + cons_show("Roster resource join (/roster) : off"); + if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) cons_show("Roster presence (/roster) : show"); else cons_show("Roster presence (/roster) : hide"); + gint presence_indent = prefs_get_roster_presence_indent(); + cons_show("Roster presence indent (/roster) : %d", presence_indent); + if (prefs_get_boolean(PREF_ROSTER_STATUS)) cons_show("Roster status (/roster) : show"); else @@ -1243,33 +1275,6 @@ 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"); - - 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); - - gint resource_indent = prefs_get_roster_resource_indent(); - cons_show("Roster resource indent (/roster) : %d", resource_indent); - - gint presence_indent = prefs_get_roster_presence_indent(); - cons_show("Roster presence indent (/roster) : %d", presence_indent); - if (prefs_get_boolean(PREF_ROSTER_WRAP)) cons_show("Roster wrap (/roster) : ON"); else diff --git a/theme_template b/theme_template index 2b22558f..39778ad9 100644 --- a/theme_template +++ b/theme_template @@ -73,22 +73,23 @@ statuses.chat= statuses.muc= roster= roster.offline= -roster.resource= -roster.presence= -roster.status= roster.empty= roster.by= roster.order= roster.count= roster.priority= roster.size= +roster.wrap= roster.header.char= roster.contact.char= -roster.resource.char= roster.contact.indent= +roster.resource= +roster.resource.char= roster.resource.indent= +roster.resource.join= +roster.presence= roster.presence.indent= -roster.wrap= +roster.status= occupants= occupants.size= occupants.jid= diff --git a/themes/boothj5 b/themes/boothj5 index 29a84455..0d6f20d1 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -71,22 +71,24 @@ resource.message=true statuses.console=all statuses.chat=all statuses.muc=all -roster.by=presence -roster.offline=true -roster.empty=false -roster.presence=true -roster.order=presence -roster.status=true -roster.resource=true -roster.priority=false roster=true +roster.offline=true +roster.empty=true +roster.by=group +roster.order=presence roster.count=true +roster.priority=true roster.size=25 -roster.contact.indent=1 -roster.resource.indent=2 -roster.presence.indent=-1 -roster.header.char=@ roster.wrap=true +roster.header.char=@ +roster.contact.indent=1 +roster.resource=true +roster.resource.char=/ +roster.resource.indent=1 +roster.resource.join=true +roster.presence=true +roster.presence.indent=-1 +roster.status=true occupants=true occupants.size=15 occupants.jid=false diff --git a/themes/complex b/themes/complex index a1540278..bc29d195 100644 --- a/themes/complex +++ b/themes/complex @@ -20,22 +20,23 @@ occupants.size=15 occupants.jid=true roster=true roster.offline=true -roster.resource=true -roster.presence=true -roster.status=true roster.empty=true roster.by=presence roster.order=presence roster.count=true 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 roster.wrap=true +roster.header.char=@ +roster.contact.char=- +roster.contact.indent=1 +roster.resource=true +roster.resource.char=/ +roster.resource.indent=1 +roster.resource.join=false +roster.presence=true +roster.presence.indent=1 +roster.status=true privileges=true presence=true intype=true diff --git a/themes/simple b/themes/simple index 9b3c573b..f8147f05 100644 --- a/themes/simple +++ b/themes/simple @@ -19,19 +19,17 @@ occupants=true occupants.size=15 roster=true roster.offline=false -roster.resource=false -roster.presence=false -roster.status=false roster.empty=false roster.by=none roster.order=presence roster.count=false roster.priority=false roster.size=25 -roster.contact.indent=0 -roster.resource.indent=0 -roster.presence.indent=-1 roster.wrap=false +roster.contact.indent=0 +roster.resource=false +roster.presence=false +roster.status=false privileges=false presence=false intype=false