diff options
Diffstat (limited to 'src/ui/chats.c')
-rw-r--r-- | src/ui/chats.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/src/ui/chats.c b/src/ui/chats.c index 991e43b..5d991a7 100644 --- a/src/ui/chats.c +++ b/src/ui/chats.c | |||
@@ -61,6 +61,12 @@ chats_event(UI_CHATS_Handle *chats, | |||
61 | MESSENGER_Application *app, | 61 | MESSENGER_Application *app, |
62 | int key) | 62 | int key) |
63 | { | 63 | { |
64 | if (chats->open_dialog.window) | ||
65 | { | ||
66 | chat_open_dialog_event(&(chats->open_dialog), app, key); | ||
67 | return; | ||
68 | } | ||
69 | |||
64 | chats->line_index = 0; | 70 | chats->line_index = 0; |
65 | chats->selected = NULL; | 71 | chats->selected = NULL; |
66 | 72 | ||
@@ -68,7 +74,7 @@ chats_event(UI_CHATS_Handle *chats, | |||
68 | app->chat.handle, | 74 | app->chat.handle, |
69 | &_chats_iterate, | 75 | &_chats_iterate, |
70 | chats | 76 | chats |
71 | ); | 77 | ) + 1; |
72 | 78 | ||
73 | switch (key) | 79 | switch (key) |
74 | { | 80 | { |
@@ -108,7 +114,8 @@ chats_event(UI_CHATS_Handle *chats, | |||
108 | 114 | ||
109 | app->chat.context = chats->selected; | 115 | app->chat.context = chats->selected; |
110 | } | 116 | } |
111 | 117 | else | |
118 | chats->open_dialog.window = chats->window; | ||
112 | break; | 119 | break; |
113 | } | 120 | } |
114 | default: | 121 | default: |
@@ -137,13 +144,12 @@ chats_event(UI_CHATS_Handle *chats, | |||
137 | chats->line_offset = count - 1; | 144 | chats->line_offset = count - 1; |
138 | } | 145 | } |
139 | 146 | ||
140 | int | 147 | static int |
141 | _chats_iterate_print(void *cls, | 148 | _chats_print_entry(UI_CHATS_Handle *chats, |
142 | UNUSED struct GNUNET_CHAT_Handle *handle, | 149 | char type, |
143 | struct GNUNET_CHAT_Group *group) | 150 | char chat_type, |
151 | const char *text) | ||
144 | { | 152 | { |
145 | UI_CHATS_Handle *chats = cls; | ||
146 | |||
147 | const bool selected = (chats->line_selected == chats->line_index); | 153 | const bool selected = (chats->line_selected == chats->line_index); |
148 | const int y = chats->line_index - chats->line_offset; | 154 | const int y = chats->line_index - chats->line_offset; |
149 | 155 | ||
@@ -157,24 +163,44 @@ _chats_iterate_print(void *cls, | |||
157 | if (y >= height) | 163 | if (y >= height) |
158 | return GNUNET_NO; | 164 | return GNUNET_NO; |
159 | 165 | ||
160 | const char *name = GNUNET_CHAT_group_get_name(group); | ||
161 | |||
162 | const int attrs_select = A_BOLD; | 166 | const int attrs_select = A_BOLD; |
163 | 167 | ||
164 | if (selected) wattron(chats->window, attrs_select); | 168 | if (selected) wattron(chats->window, attrs_select); |
165 | 169 | ||
166 | wmove(chats->window, y, 0); | 170 | wmove(chats->window, y, 0); |
167 | wprintw(chats->window, "%s", name); | 171 | |
172 | if (chat_type) | ||
173 | wprintw(chats->window, "[%c][%c] %s", type, chat_type, text); | ||
174 | else | ||
175 | wprintw(chats->window, "[%c] %s", type, text); | ||
168 | 176 | ||
169 | if (selected) wattroff(chats->window, attrs_select); | 177 | if (selected) wattroff(chats->window, attrs_select); |
170 | 178 | ||
171 | return GNUNET_YES; | 179 | return GNUNET_YES; |
172 | } | 180 | } |
173 | 181 | ||
182 | int | ||
183 | _chats_iterate_print(void *cls, | ||
184 | UNUSED struct GNUNET_CHAT_Handle *handle, | ||
185 | struct GNUNET_CHAT_Group *group) | ||
186 | { | ||
187 | UI_CHATS_Handle *chats = cls; | ||
188 | |||
189 | const char *name = GNUNET_CHAT_group_get_name(group); | ||
190 | |||
191 | return _chats_print_entry(chats, 'x', 'G', name); | ||
192 | } | ||
193 | |||
174 | void | 194 | void |
175 | chats_print(UI_CHATS_Handle *chats, | 195 | chats_print(UI_CHATS_Handle *chats, |
176 | MESSENGER_Application *app) | 196 | MESSENGER_Application *app) |
177 | { | 197 | { |
198 | if (chats->open_dialog.window) | ||
199 | { | ||
200 | chat_open_dialog_print(&(chats->open_dialog), app); | ||
201 | return; | ||
202 | } | ||
203 | |||
178 | if (!(chats->window)) | 204 | if (!(chats->window)) |
179 | return; | 205 | return; |
180 | 206 | ||
@@ -186,4 +212,6 @@ chats_print(UI_CHATS_Handle *chats, | |||
186 | &_chats_iterate_print, | 212 | &_chats_iterate_print, |
187 | chats | 213 | chats |
188 | ); | 214 | ); |
215 | |||
216 | _chats_print_entry(chats, '+', '\0', "Add chat"); | ||
189 | } | 217 | } |