Mercurial > pidgin
comparison console/libgnt/gntmain.c @ 13897:eaaf73de9188
[gaim-migrate @ 16382]
I have added a sort of a taskbar, useful in showing the active windows.
I have also readjusted the blue color a little bit, since this is the
one I am using in a few places right now. And also getting rid of some
code-duplication.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 01 Jul 2006 04:24:31 +0000 |
parents | a621329e8c85 |
children | cc60d0861337 |
comparison
equal
deleted
inserted
replaced
13896:a621329e8c85 | 13897:eaaf73de9188 |
---|---|
21 } GntNode; | 21 } GntNode; |
22 | 22 |
23 static GHashTable *nodes; | 23 static GHashTable *nodes; |
24 | 24 |
25 static void free_node(gpointer data); | 25 static void free_node(gpointer data); |
26 static void draw_taskbar(); | |
26 | 27 |
27 void gnt_screen_take_focus(GntWidget *widget) | 28 void gnt_screen_take_focus(GntWidget *widget) |
28 { | 29 { |
29 GntWidget *w = NULL; | 30 GntWidget *w = NULL; |
30 if (focus_list) | 31 if (focus_list) |
31 w = focus_list->data; | 32 w = focus_list->data; |
32 focus_list = g_list_prepend(focus_list, widget); | 33 focus_list = g_list_prepend(focus_list, widget); |
33 gnt_widget_set_focus(widget, TRUE); | 34 gnt_widget_set_focus(widget, TRUE); |
34 if (w) | 35 if (w) |
35 gnt_widget_set_focus(w, FALSE); | 36 gnt_widget_set_focus(w, FALSE); |
37 draw_taskbar(); | |
36 } | 38 } |
37 | 39 |
38 void gnt_screen_remove_widget(GntWidget *widget) | 40 void gnt_screen_remove_widget(GntWidget *widget) |
39 { | 41 { |
40 focus_list = g_list_remove(focus_list, widget); | 42 focus_list = g_list_remove(focus_list, widget); |
41 if (focus_list) | 43 if (focus_list) |
42 { | 44 { |
43 gnt_widget_set_focus(focus_list->data, TRUE); | 45 gnt_widget_set_focus(focus_list->data, TRUE); |
44 gnt_widget_draw(focus_list->data); | 46 gnt_widget_draw(focus_list->data); |
45 } | 47 } |
48 draw_taskbar(); | |
46 } | 49 } |
47 | 50 |
48 static void | 51 static void |
49 bring_on_top(GntWidget *widget) | 52 bring_on_top(GntWidget *widget) |
50 { | 53 { |
62 n->above = g_list_prepend(n->above, node); | 65 n->above = g_list_prepend(n->above, node); |
63 | 66 |
64 node->above = g_list_remove(node->above, n); | 67 node->above = g_list_remove(node->above, n); |
65 node->below = g_list_prepend(node->below, n); | 68 node->below = g_list_prepend(node->below, n); |
66 } | 69 } |
70 } | |
71 | |
72 static void | |
73 draw_taskbar() | |
74 { | |
75 static WINDOW *taskbar = NULL; | |
76 GList *iter; | |
77 int n, width; | |
78 int i; | |
79 | |
80 if (taskbar == NULL) | |
81 { | |
82 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); | |
83 } | |
84 | |
85 werase(taskbar); | |
86 | |
87 n = g_list_length(g_list_first(focus_list)); | |
88 if (n) | |
89 width = getmaxx(stdscr) / n; | |
90 | |
91 for (i = 0, iter = g_list_first(focus_list); iter; iter = iter->next, i++) | |
92 { | |
93 GntWidget *w = iter->data; | |
94 int color; | |
95 | |
96 if (w == focus_list->data) | |
97 { | |
98 /* This is the current window in focus */ | |
99 color = GNT_COLOR_TITLE; | |
100 GNT_WIDGET_UNSET_FLAGS(w, GNT_WIDGET_URGENT); | |
101 } | |
102 else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) | |
103 { | |
104 /* This is a window with the URGENT hint set */ | |
105 color = GNT_COLOR_TITLE_D; | |
106 } | |
107 else | |
108 { | |
109 color = GNT_COLOR_NORMAL; | |
110 } | |
111 wbkgdset(taskbar, '\0' | COLOR_PAIR(color)); | |
112 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width); | |
113 mvwprintw(taskbar, 0, width * i, "%s", GNT_BOX(w)->title); | |
114 } | |
115 | |
116 wrefresh(taskbar); | |
67 } | 117 } |
68 | 118 |
69 static gboolean | 119 static gboolean |
70 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) | 120 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
71 { | 121 { |
133 | 183 |
134 if (w && w != focus_list->data) | 184 if (w && w != focus_list->data) |
135 gnt_widget_set_focus(w, FALSE); | 185 gnt_widget_set_focus(w, FALSE); |
136 } | 186 } |
137 } | 187 } |
188 | |
189 draw_taskbar(); | |
138 refresh(); | 190 refresh(); |
139 | 191 |
140 return TRUE; | 192 return TRUE; |
141 } | 193 } |
142 | 194 |
343 return TRUE; | 395 return TRUE; |
344 | 396 |
345 return FALSE; | 397 return FALSE; |
346 } | 398 } |
347 | 399 |
400 void gnt_widget_set_urgent(GntWidget *widget) | |
401 { | |
402 while (widget->parent) | |
403 widget = widget->parent; | |
404 | |
405 if (focus_list && focus_list->data == widget) | |
406 return; | |
407 | |
408 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT); | |
409 draw_taskbar(); | |
410 } | |
411 |