about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-10 01:10:43 +0000
committerJames Booth <boothj5@gmail.com>2014-11-10 01:10:43 +0000
commit04bacdcf385e16f944dccc1f184ea3782e0dd907 (patch)
tree0d5339fca56130b18bd663422de6dddd884817bf /src/ui
parent48afa523900db68f561d07b5ff6da5a8d0d7b80b (diff)
downloadprofani-tty-04bacdcf385e16f944dccc1f184ea3782e0dd907.tar.gz
Order resources in roster, allow paging roster
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 1231adc2..c7b15f98 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -2815,9 +2815,9 @@ _ui_roster(void)
             wattron(window->subwin, COLOUR_ROOMINFO);
             wprintw(window->subwin, " -Roster\n");
             wattroff(window->subwin, COLOUR_ROOMINFO);
-            GSList *curr = contacts;
-            while (curr) {
-                PContact contact = curr->data;
+            GSList *curr_contact = contacts;
+            while (curr_contact) {
+                PContact contact = curr_contact->data;
                 if (p_contact_subscribed(contact)) {
                     const char *name = p_contact_name_or_jid(contact);
                     const char *presence = p_contact_presence(contact);
@@ -2826,19 +2826,31 @@ _ui_roster(void)
                     wattron(window->subwin, presence_colour);
                     wprintw(window->subwin, "   %s\n", name);
                     wattroff(window->subwin, presence_colour);
+
                     GList *resources = p_contact_get_available_resources(contact);
-                    GList *curr_resource = resources;
-                    while (curr_resource) {
-                        Resource *resource = curr_resource->data;
+                    GList *ordered_resources = NULL;
+
+                    // sort in order of availabiltiy
+                    while (resources != NULL) {
+                        Resource *resource = resources->data;
+                        ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability);
+                        resources = g_list_next(resources);
+                    }
+
+                    g_list_free(resources);
+
+                    while (ordered_resources) {
+                        Resource *resource = ordered_resources->data;
                         const char *resource_presence = string_from_resource_presence(resource->presence);
                         int resource_presence_colour = win_presence_colour(resource_presence);
                         wattron(window->subwin, resource_presence_colour);
                         wprintw(window->subwin, "     %s\n", resource->name);
                         wattroff(window->subwin, resource_presence_colour);
-                        curr_resource = g_list_next(curr_resource);
+                        ordered_resources = g_list_next(ordered_resources);
                     }
+                    g_list_free(ordered_resources);
                 }
-                curr = g_slist_next(curr);
+                curr_contact = g_slist_next(curr_contact);
             }
         }
         g_slist_free(contacts);
@@ -3056,7 +3068,7 @@ _win_handle_page(const wint_t * const ch, const int result)
         current->paged = 0;
     }
 
-    if (current->type == WIN_MUC) {
+    if ((current->type == WIN_MUC) || (current->type == WIN_CONSOLE)) {
         // alt up arrow
         if ((result == KEY_CODE_YES) && ((*ch == 565) || (*ch == 337))) {
             current->sub_y_pos -= page_space;
6'>26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140