comparison console/libgnt/gntbox.c @ 13916:fdf2dbed6faa

[gaim-migrate @ 16418] Make the conversation windows bigger ... which is better *wink*. Use Panel library to manage the windows. Add a window-list that you can use to quickly switch to a window (press Alt+w to bring it up). Get rid of some unused codes. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 04 Jul 2006 01:32:39 +0000
parents cc60d0861337
children 9309d27d780c
comparison
equal deleted inserted replaced
13915:e78d113f82db 13916:fdf2dbed6faa
165 find_focusable_widget(GNT_BOX(widget)); 165 find_focusable_widget(GNT_BOX(widget));
166 } 166 }
167 DEBUG; 167 DEBUG;
168 } 168 }
169 169
170 #if 0
171 static GntWidget *
172 find_next_focus(GntBox *box)
173 {
174 GntWidget *w = box->active;
175 GList *iter;
176
177 if (w == NULL)
178 {
179 return find_focusable_widget(box);
180 }
181
182 while (w && !(iter = g_list_find(box->list, w)))
183 w = w->parent;
184
185 if (!w)
186 box->active = NULL;
187 else if (iter)
188 {
189 GntWidget *next = NULL;
190
191 while (!next && (iter = iter->next))
192 {
193 if (GNT_IS_BOX(iter->data))
194 next = find_next_focus(iter->data);
195 else
196 {
197 if (GNT_WIDGET_IS_FLAG_SET(iter->data, GNT_WIDGET_CAN_TAKE_FOCUS) &&
198 GNT_WIDGET_IS_FLAG_SET(iter->data, GNT_WIDGET_HAS_FOCUS))
199 next = iter->data;
200 else
201 next = NULL;
202 }
203 }
204 box->active = next;
205 }
206
207 if (box->active == NULL && GNT_WIDGET(box)->parent == NULL)
208 {
209 box->active = find_focusable_widget(box);
210 }
211
212 if (box->active)
213 GNT_WIDGET_SET_FLAGS(box->active, GNT_WIDGET_HAS_FOCUS);
214
215 return box->active;
216 }
217 #endif
218
219 /* Ensures that the current widget can take focus */ 170 /* Ensures that the current widget can take focus */
220 static GntWidget * 171 static GntWidget *
221 find_focusable_widget(GntBox *box) 172 find_focusable_widget(GntBox *box)
222 { 173 {
223 if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL) 174 if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL)
225 176
226 if (box->active == NULL && box->focus) 177 if (box->active == NULL && box->focus)
227 box->active = box->focus->data; 178 box->active = box->focus->data;
228 179
229 return box->active; 180 return box->active;
230
231 #if 0
232 for (iter = box->list; iter; iter = iter->next)
233 {
234 w = iter->data;
235 if (GNT_IS_BOX(w))
236 {
237 w = find_focusable_widget(GNT_BOX(w));
238 if (w)
239 break;
240 }
241 else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS))
242 break;
243 }
244
245 if (iter)
246 box->active = w;
247 else
248 box->active = NULL;
249
250 if (box->active)
251 GNT_WIDGET_SET_FLAGS(box->active, GNT_WIDGET_HAS_FOCUS);
252
253 return box->active;
254
255 #if 0
256 if (box->active == NULL && box->list)
257 box->active = box->list->data;
258 else
259 w = box->active;
260
261 total = g_list_length(box->list);
262
263 while (box->active && !GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_CAN_TAKE_FOCUS))
264 {
265 box->active = box->active->next;
266 investigated++;
267 }
268
269 /* Rotate if necessary */
270 if (!box->active && investigated < total)
271 {
272 box->active = box->list;
273 while (investigated < total && !GNT_WIDGET_IS_FLAG_SET(box->active->data, GNT_WIDGET_CAN_TAKE_FOCUS))
274 {
275 box->active = box->active->next;
276 investigated++;
277 }
278 }
279
280 if (box->active)
281 gnt_widget_set_focus(box->active->data, TRUE);
282 if (w && w != box->active->data)
283 gnt_widget_set_focus(w, FALSE);
284 #endif
285 #endif
286 } 181 }
287 182
288 static gboolean 183 static gboolean
289 gnt_box_key_pressed(GntWidget *widget, const char *text) 184 gnt_box_key_pressed(GntWidget *widget, const char *text)
290 { 185 {
333 } 228 }
334 229
335 return FALSE; 230 return FALSE;
336 } 231 }
337 232
338 #if 0 233 static void
339 static GntWidget *find_focused_widget(GntBox *box) 234 gnt_box_lost_focus(GntWidget *widget)
340 { 235 {
341 GList *iter; 236 GntWidget *w = GNT_BOX(widget)->active;
342 237 if (w)
343 for (iter = box->list; iter; iter = iter->next) 238 gnt_widget_set_focus(w, FALSE);
344 {
345 GntWidget *w = iter->data;
346
347 if (GNT_IS_BOX(w))
348 {
349 if ((w = find_focused_widget(GNT_BOX(w))) != NULL)
350 return w;
351 }
352 else
353 {
354 if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS) &&
355 GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_HAS_FOCUS))
356 return w;
357 }
358 }
359 return NULL;
360 }
361 #endif
362
363 #if 0
364 static void
365 gnt_box_set_focus(GntWidget *widget, gboolean set)
366 {
367 GntWidget *p = widget;
368
369 while (p->parent)
370 p = p->parent;
371
372 p = find_focused_widget(GNT_BOX(p));
373 if (p)
374 gnt_widget_set_focus(p, set);
375 gnt_widget_draw(widget); 239 gnt_widget_draw(widget);
376 } 240 }
377 241
378 static void 242 static void
379 gnt_box_lost_focus(GntWidget *widget)
380 {
381 gnt_box_set_focus(widget, FALSE);
382 }
383
384 static void
385 gnt_box_gained_focus(GntWidget *widget) 243 gnt_box_gained_focus(GntWidget *widget)
386 { 244 {
387 GntWidget *p; 245 GntWidget *w = GNT_BOX(widget)->active;
388 246 if (w)
389 while (widget->parent) 247 gnt_widget_set_focus(w, TRUE);
390 widget = widget->parent; 248 gnt_widget_draw(widget);
391 249 }
392 p = find_focused_widget(GNT_BOX(widget));
393 GNT_BOX(widget)->active = g_list_find(GNT_BOX(widget)->list, p);
394 if (p)
395 gnt_widget_draw(p);
396 }
397 #endif
398 250
399 static void 251 static void
400 gnt_box_destroy(GntWidget *w) 252 gnt_box_destroy(GntWidget *w)
401 { 253 {
402 GntBox *box = GNT_BOX(w); 254 GntBox *box = GNT_BOX(w);
430 parent_class->expose = gnt_box_expose; 282 parent_class->expose = gnt_box_expose;
431 parent_class->map = gnt_box_map; 283 parent_class->map = gnt_box_map;
432 parent_class->size_request = gnt_box_size_request; 284 parent_class->size_request = gnt_box_size_request;
433 parent_class->set_position = gnt_box_set_position; 285 parent_class->set_position = gnt_box_set_position;
434 parent_class->key_pressed = gnt_box_key_pressed; 286 parent_class->key_pressed = gnt_box_key_pressed;
435 #if 0
436 /* We are going to need this when there are multiple focusble widgets in a box */
437 parent_class->lost_focus = gnt_box_lost_focus; 287 parent_class->lost_focus = gnt_box_lost_focus;
438 parent_class->gained_focus = gnt_box_gained_focus; 288 parent_class->gained_focus = gnt_box_gained_focus;
439 #endif
440 289
441 DEBUG; 290 DEBUG;
442 } 291 }
443 292
444 static void 293 static void
511 360
512 void gnt_box_set_toplevel(GntBox *box, gboolean set) 361 void gnt_box_set_toplevel(GntBox *box, gboolean set)
513 { 362 {
514 GntWidget *widget = GNT_WIDGET(box); 363 GntWidget *widget = GNT_WIDGET(box);
515 if (set) 364 if (set)
365 {
516 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); 366 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
367 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
368 }
517 else 369 else
370 {
518 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); 371 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
372 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
373 }
519 } 374 }
520 375
521 void gnt_box_sync_children(GntBox *box) 376 void gnt_box_sync_children(GntBox *box)
522 { 377 {
523 GList *iter; 378 GList *iter;