Mercurial > pidgin
comparison console/libgnt/gntmain.c @ 13896:a621329e8c85
[gaim-migrate @ 16381]
Changes in GntTextView. Things go somewhat 'smooth' when run inside
valgrind. Otherwise, it's kind of flaky. I don't mind a single bit
if someone gave me a hint :)
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 01 Jul 2006 00:56:05 +0000 |
parents | ab671b76fb96 |
children | eaaf73de9188 |
comparison
equal
deleted
inserted
replaced
13895:8f910263b4bb | 13896:a621329e8c85 |
---|---|
11 | 11 |
12 static GList *focus_list; | 12 static GList *focus_list; |
13 static int max_x; | 13 static int max_x; |
14 static int max_y; | 14 static int max_y; |
15 | 15 |
16 typedef struct | |
17 { | |
18 GntWidget *me; | |
19 GList *below; /* List of widgets below me */ | |
20 GList *above; /* List of widgets above me */ | |
21 } GntNode; | |
22 | |
16 static GHashTable *nodes; | 23 static GHashTable *nodes; |
17 | 24 |
18 static void free_node(gpointer data); | 25 static void free_node(gpointer data); |
19 | 26 |
20 void gnt_screen_take_focus(GntWidget *widget) | 27 void gnt_screen_take_focus(GntWidget *widget) |
21 { | 28 { |
29 GntWidget *w = NULL; | |
30 if (focus_list) | |
31 w = focus_list->data; | |
22 focus_list = g_list_prepend(focus_list, widget); | 32 focus_list = g_list_prepend(focus_list, widget); |
33 gnt_widget_set_focus(widget, TRUE); | |
34 if (w) | |
35 gnt_widget_set_focus(w, FALSE); | |
23 } | 36 } |
24 | 37 |
25 void gnt_screen_remove_widget(GntWidget *widget) | 38 void gnt_screen_remove_widget(GntWidget *widget) |
26 { | 39 { |
27 focus_list = g_list_remove(focus_list, widget); | 40 focus_list = g_list_remove(focus_list, widget); |
28 if (focus_list) | 41 if (focus_list) |
42 { | |
43 gnt_widget_set_focus(focus_list->data, TRUE); | |
29 gnt_widget_draw(focus_list->data); | 44 gnt_widget_draw(focus_list->data); |
45 } | |
46 } | |
47 | |
48 static void | |
49 bring_on_top(GntWidget *widget) | |
50 { | |
51 GntNode *node = g_hash_table_lookup(nodes, widget); | |
52 GList *iter; | |
53 | |
54 if (!node) | |
55 return; | |
56 | |
57 for (iter = node->above; iter;) | |
58 { | |
59 GntNode *n = iter->data; | |
60 iter = iter->next; | |
61 n->below = g_list_remove(n->below, node); | |
62 n->above = g_list_prepend(n->above, node); | |
63 | |
64 node->above = g_list_remove(node->above, n); | |
65 node->below = g_list_prepend(node->below, n); | |
66 } | |
30 } | 67 } |
31 | 68 |
32 static gboolean | 69 static gboolean |
33 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) | 70 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
34 { | 71 { |
77 exit(1); | 114 exit(1); |
78 } | 115 } |
79 else if (strcmp(buffer + 1, "n") == 0) | 116 else if (strcmp(buffer + 1, "n") == 0) |
80 { | 117 { |
81 /* Alt + n to go to the next window */ | 118 /* Alt + n to go to the next window */ |
119 GntWidget *w = NULL; | |
120 if (focus_list) | |
121 w = focus_list->data; | |
122 | |
82 if (focus_list && focus_list->next) | 123 if (focus_list && focus_list->next) |
83 focus_list = focus_list->next; | 124 focus_list = focus_list->next; |
84 else | 125 else |
85 focus_list = g_list_first(focus_list); | 126 focus_list = g_list_first(focus_list); |
86 if (focus_list) | 127 if (focus_list) |
87 { | 128 { |
88 /* XXX: Need a way to bring it on top */ | 129 gnt_widget_set_focus(focus_list->data, TRUE); |
130 bring_on_top(focus_list->data); | |
89 gnt_widget_draw(focus_list->data); | 131 gnt_widget_draw(focus_list->data); |
90 } | 132 } |
133 | |
134 if (w && w != focus_list->data) | |
135 gnt_widget_set_focus(w, FALSE); | |
91 } | 136 } |
92 } | 137 } |
93 refresh(); | 138 refresh(); |
94 | 139 |
95 return TRUE; | 140 return TRUE; |
131 } | 176 } |
132 | 177 |
133 /********************************* | 178 /********************************* |
134 * Stuff for 'window management' * | 179 * Stuff for 'window management' * |
135 *********************************/ | 180 *********************************/ |
136 | |
137 typedef struct | |
138 { | |
139 GntWidget *me; | |
140 GList *below; /* List of widgets below me */ | |
141 GList *above; /* List of widgets above me */ | |
142 } GntNode; | |
143 | 181 |
144 static void | 182 static void |
145 free_node(gpointer data) | 183 free_node(gpointer data) |
146 { | 184 { |
147 GntNode *node = data; | 185 GntNode *node = data; |
282 | 320 |
283 wrefresh(win); | 321 wrefresh(win); |
284 delwin(win); | 322 delwin(win); |
285 } | 323 } |
286 | 324 |
325 gboolean gnt_widget_has_focus(GntWidget *widget) | |
326 { | |
327 GntWidget *w; | |
328 if (!widget) | |
329 return FALSE; | |
330 | |
331 w = widget; | |
332 | |
333 while (widget->parent) | |
334 { | |
335 fprintf(stderr, "%p %p\n", widget, widget->parent); | |
336 widget = widget->parent; | |
337 } | |
338 fprintf(stderr, "%p %p\n", widget, widget->parent); | |
339 | |
340 if (focus_list && focus_list->data == widget && | |
341 (!GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS) || | |
342 GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_HAS_FOCUS))) | |
343 return TRUE; | |
344 | |
345 return FALSE; | |
346 } | |
347 |