about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-30 00:33:46 +0100
committerJames Booth <boothj5@gmail.com>2013-08-30 00:33:46 +0100
commit7f476b3e2cb4739adb6b5ea02a9b86f19637b819 (patch)
tree437382b072ef11b37279068da1070ad42c7b2423 /src/ui
parent48794e324c19f2492593a440e26f8b29f4a4515e (diff)
downloadprofani-tty-7f476b3e2cb4739adb6b5ea02a9b86f19637b819.tar.gz
Fixed /close all and /close read to close extra windows
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c36
-rw-r--r--src/ui/windows.c6
-rw-r--r--src/ui/windows.h1
3 files changed, 33 insertions, 10 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index c97ce67e..d6e17854 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -528,38 +528,54 @@ ui_close_connected_win(int index)
 int
 ui_close_all_wins(void)
 {
-    int curr = 0, count = 0;
+    int count = 0;
     jabber_conn_status_t conn_status = jabber_get_connection_status();
 
-    for (curr = 2; curr <= 10; curr++) {
-        if (ui_win_exists(curr)) {
+    GList *win_nums = wins_get_nums();
+    GList *curr = win_nums;
+
+    while (curr != NULL) {
+        int num = GPOINTER_TO_INT(curr->data);
+        if (num != 1) {
             if (conn_status == JABBER_CONNECTED) {
-                ui_close_connected_win(curr);
+                ui_close_connected_win(num);
             }
-            ui_close_win(curr);
+            ui_close_win(num);
             count++;
         }
+        curr = g_list_next(curr);
     }
 
+    g_list_free(curr);
+    g_list_free(win_nums);
+
     return count;
 }
 
 int
 ui_close_read_wins(void)
 {
-    int curr = 0, count = 0;
+    int count = 0;
     jabber_conn_status_t conn_status = jabber_get_connection_status();
 
-    for (curr = 2; curr <= 10; curr++) {
-        if (ui_win_exists(curr) && (ui_win_unread(curr) == 0)) {
+    GList *win_nums = wins_get_nums();
+    GList *curr = win_nums;
+
+    while (curr != NULL) {
+        int num = GPOINTER_TO_INT(curr->data);
+        if ((num != 1) && (ui_win_unread(num) == 0)) {
             if (conn_status == JABBER_CONNECTED) {
-                ui_close_connected_win(curr);
+                ui_close_connected_win(num);
             }
-            ui_close_win(curr);
+            ui_close_win(num);
             count++;
         }
+        curr = g_list_next(curr);
     }
 
+    g_list_free(curr);
+    g_list_free(win_nums);
+
     return count;
 }
 
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 58e1ec59..81a6d3e6 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -70,6 +70,12 @@ wins_get_current(void)
     return g_hash_table_lookup(windows, GINT_TO_POINTER(current));
 }
 
+GList *
+wins_get_nums(void)
+{
+    return g_hash_table_get_keys(windows);
+}
+
 void
 wins_set_current_by_num(int i)
 {
diff --git a/src/ui/windows.h b/src/ui/windows.h
index f0476896..6d93c434 100644
--- a/src/ui/windows.h
+++ b/src/ui/windows.h
@@ -47,5 +47,6 @@ void wins_lost_connection(void);
 gboolean wins_tidy(void);
 GSList * wins_create_summary(void);
 void wins_destroy(void);
+GList * wins_get_nums(void);
 
 #endif
86cbdf37086265291a358'>71056d61 ^
a90faae9 ^


dd30f56d ^
a90faae9 ^

294b2ab3 ^
a90faae9 ^


dd30f56d ^







a90faae9 ^


6f65d591 ^
55479bc2 ^
a90faae9 ^

dd30f56d ^
294b2ab3 ^

898f03cc ^
294b2ab3 ^
71056d61 ^
ceeb92d4 ^
71056d61 ^
a90faae9 ^
c1585c88 ^
a90faae9 ^

294b2ab3 ^
a90faae9 ^




294b2ab3 ^
a90faae9 ^


dd30f56d ^







a90faae9 ^


67d2a9c0 ^
2d91279b ^
3d8b137c ^
e2b367dc ^
67d2a9c0 ^




dc5f112c ^
67d2a9c0 ^
44bab2e4 ^
294b2ab3 ^
67d2a9c0 ^



ac8acc7b ^

294b2ab3 ^
ac8acc7b ^


67d2a9c0 ^

a90faae9 ^

fa94f4d9 ^
a90faae9 ^
3d8b137c ^


a90faae9 ^
2d91279b ^
a90faae9 ^
3d8b137c ^


a90faae9 ^

dc5f112c ^
a90faae9 ^


dc5f112c ^
4e7186fa ^
ea5e7fd4 ^
ada5eb55 ^
a90faae9 ^


dc5f112c ^
a90faae9 ^
b0403c18 ^
a90faae9 ^
2d91279b ^
3d8b137c ^

a90faae9 ^

dc5f112c ^
a90faae9 ^
2d91279b ^
a90faae9 ^
3d8b137c ^

a90faae9 ^

dc5f112c ^
a90faae9 ^


3d8b137c ^
dc5f112c ^
3d8b137c ^
dc5f112c ^

a90faae9 ^

2d91279b ^
a90faae9 ^
b0403c18 ^
ea19d0dc ^
a90faae9 ^

ea5e7fd4 ^





ea19d0dc ^
ea5e7fd4 ^
a90faae9 ^
a90faae9 ^





ea5e7fd4 ^
ea19d0dc ^
a90faae9 ^
3d8b137c ^
a90faae9 ^
5aac71e8 ^
afdda1ea ^
a90faae9 ^

3d8b137c ^
afdda1ea ^
a90faae9 ^
ada5eb55 ^
a90faae9 ^

07a64183 ^

ea5e7fd4 ^
07a64183 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207