about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-18 02:14:11 +0000
committerJames Booth <boothj5@gmail.com>2015-11-18 02:14:11 +0000
commit8e84d160e6a7eded077be3e32012e9725961a0cd (patch)
tree90878779a11ab7703e11f1afb90d03084946bfd3
parent4505102fa83e00c70d1ee15967b977957dcf3aa5 (diff)
downloadprofani-tty-8e84d160e6a7eded077be3e32012e9725961a0cd.tar.gz
Added option to show resource priority in roster
-rw-r--r--src/command/command.c7
-rw-r--r--src/command/commands.c14
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/ui/console.c5
-rw-r--r--src/ui/rosterwin.c3
6 files changed, 32 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 1057084c..a7f0d718 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -274,8 +274,8 @@ static struct cmd_t command_defs[] =
         CMD_SYN(
             "/roster",
             "/roster online",
-            "/roster show [offline|resource|presence|status|empty|count]",
-            "/roster hide [offline|resource|presence|status|empty|count]",
+            "/roster show [offline|resource|presence|status|empty|count|priority]",
+            "/roster hide [offline|resource|presence|status|empty|count|priority]",
             "/roster by group|presence|none",
             "/roster order name|presence"
             "/roster size <percent>",
@@ -296,6 +296,7 @@ static struct cmd_t command_defs[] =
             { "show status",         "Show contact's status message in the roster panel." },
             { "show empty",          "When grouping by presence, show empty presence groups." },
             { "show count",          "Show number of contacts in group/presence." },
+            { "show priority",       "Show resource priority." },
             { "hide",                "Hide the roster panel." },
             { "hide offline",        "Hide offline contacts in the roster panel." },
             { "hide resource",       "Hide contact's connected resources in the roster panel." },
@@ -303,6 +304,7 @@ static struct cmd_t command_defs[] =
             { "hide status",         "Hide contact's status message in the roster panel." },
             { "hide empty",          "When grouping by presence, hide empty presence groups." },
             { "hide count",          "Hide number of contacts in group/presence." },
+            { "hide priority",       "Hide resource priority." },
             { "by group",            "Group contacts in the roster panel by roster group." },
             { "by presence",         "Group contacts in the roster panel by presence." },
             { "by none",             "No grouping in the roster panel." },
@@ -2030,6 +2032,7 @@ cmd_init(void)
     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_by_ac = autocomplete_new();
     autocomplete_add(roster_by_ac, "group");
diff --git a/src/command/commands.c b/src/command/commands.c
index 4d8933bd..92ca5daf 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1801,6 +1801,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "priority") == 0) {
+            cons_show("Roster priority enabled");
+            prefs_set_boolean(PREF_ROSTER_PRIORITY, TRUE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else {
             cons_bad_cmd_usage(command);
             return TRUE;
@@ -1855,6 +1862,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "priority") == 0) {
+            cons_show("Roster priority disabled");
+            prefs_set_boolean(PREF_ROSTER_PRIORITY, FALSE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else {
             cons_bad_cmd_usage(command);
             return TRUE;
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 46cd3169..f55895e2 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -603,6 +603,7 @@ _get_group(preference_t pref)
         case PREF_ROSTER_BY:
         case PREF_ROSTER_ORDER:
         case PREF_ROSTER_COUNT:
+        case PREF_ROSTER_PRIORITY:
         case PREF_RESOURCE_TITLE:
         case PREF_RESOURCE_MESSAGE:
         case PREF_ENC_WARN:
@@ -784,6 +785,8 @@ _get_key(preference_t pref)
             return "roster.order";
         case PREF_ROSTER_COUNT:
             return "roster.count";
+        case PREF_ROSTER_PRIORITY:
+            return "roster.priority";
         case PREF_RESOURCE_TITLE:
             return "resource.title";
         case PREF_RESOURCE_MESSAGE:
@@ -839,6 +842,7 @@ _get_default_boolean(preference_t pref)
         case PREF_ROSTER_STATUS:
         case PREF_ROSTER_EMPTY:
         case PREF_ROSTER_COUNT:
+        case PREF_ROSTER_PRIORITY:
         case PREF_TLS_SHOW:
         case PREF_LASTACTIVITY:
             return TRUE;
diff --git a/src/config/preferences.h b/src/config/preferences.h
index dcc0f441..c5f60469 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -70,6 +70,7 @@ typedef enum {
     PREF_ROSTER_BY,
     PREF_ROSTER_ORDER,
     PREF_ROSTER_COUNT,
+    PREF_ROSTER_PRIORITY,
     PREF_MUC_PRIVILEGES,
     PREF_PRESENCE,
     PREF_WRAP,
diff --git a/src/ui/console.c b/src/ui/console.c
index b145aa6d..64eff932 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1227,6 +1227,11 @@ cons_roster_setting(void)
     else
         cons_show("Roster count (/roster)        : hide");
 
+    if (prefs_get_boolean(PREF_ROSTER_PRIORITY))
+        cons_show("Roster priority (/roster)     : show");
+    else
+        cons_show("Roster priority (/roster)     : hide");
+
     char *by = prefs_get_string(PREF_ROSTER_BY);
     cons_show("Roster by (/roster)           : %s", by);
     prefs_free_string(by);
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index 28ac25ce..6d51adf9 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -89,6 +89,9 @@ _rosterwin_resource(ProfLayoutSplit *layout, PContact contact)
             wattron(layout->subwin, theme_attrs(resource_presence_colour));
             GString *msg = g_string_new("     ");
             g_string_append(msg, resource->name);
+            if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) {
+                g_string_append_printf(msg, " [%d]", resource->priority);
+            }
             win_printline_nowrap(layout->subwin, msg->str);
             g_string_free(msg, TRUE);
             wattroff(layout->subwin, theme_attrs(resource_presence_colour));