Mercurial > pidgin
annotate finch/libgnt/gntws.c @ 28604:a18f421696dc
Fix showing umlauts etc. on non-utf8 locales.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 20 Nov 2009 21:45:44 +0000 |
parents | bec28e60aff6 |
children | 1a349e6a27da |
rev | line source |
---|---|
17699 | 1 #include <gmodule.h> |
2 | |
28604
a18f421696dc
Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22763
diff
changeset
|
3 #include "gntinternal.h" |
17699 | 4 #include "gntbox.h" |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
diff
changeset
|
5 #include "gntwidget.h" |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
diff
changeset
|
6 #include "gntwindow.h" |
17699 | 7 #include "gntwm.h" |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
diff
changeset
|
8 #include "gntws.h" |
17699 | 9 |
10 static void | |
11 widget_hide(gpointer data, gpointer nodes) | |
12 { | |
13 GntWidget *widget = GNT_WIDGET(data); | |
14 GntNode *node = g_hash_table_lookup(nodes, widget); | |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
diff
changeset
|
15 if (GNT_IS_WINDOW(widget)) |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
17702
diff
changeset
|
16 gnt_window_workspace_hiding(GNT_WINDOW(widget)); |
22763
bec28e60aff6
Fix a possible crash when creating a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21250
diff
changeset
|
17 if (node) |
bec28e60aff6
Fix a possible crash when creating a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21250
diff
changeset
|
18 hide_panel(node->panel); |
17699 | 19 } |
20 | |
21 static void | |
22 widget_show(gpointer data, gpointer nodes) | |
23 { | |
24 GntNode *node = g_hash_table_lookup(nodes, data); | |
25 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(data), GNT_WIDGET_INVISIBLE); | |
26 if (node) { | |
27 show_panel(node->panel); | |
28 gnt_wm_copy_win(GNT_WIDGET(data), node); | |
29 } | |
30 } | |
31 | |
32 void | |
33 gnt_ws_draw_taskbar(GntWS *ws, gboolean reposition) | |
34 { | |
35 static WINDOW *taskbar = NULL; | |
36 GList *iter; | |
37 int n, width = 0; | |
38 int i; | |
39 | |
18421
e16d097c5739
Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18416
diff
changeset
|
40 if (gnt_is_refugee()) |
e16d097c5739
Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18416
diff
changeset
|
41 return; |
e16d097c5739
Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18416
diff
changeset
|
42 |
17699 | 43 if (taskbar == NULL) { |
44 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); | |
45 } else if (reposition) { | |
46 int Y_MAX = getmaxy(stdscr) - 1; | |
47 mvwin(taskbar, Y_MAX, 0); | |
48 } | |
49 | |
21250
9187d331aebe
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18421
diff
changeset
|
50 wbkgdset(taskbar, '\0' | gnt_color_pair(GNT_COLOR_NORMAL)); |
17699 | 51 werase(taskbar); |
52 | |
53 n = g_list_length(ws->list); | |
54 if (n) | |
55 width = getmaxx(stdscr) / n; | |
56 | |
57 for (i = 0, iter = ws->list; iter; iter = iter->next, i++) { | |
58 GntWidget *w = iter->data; | |
59 int color; | |
60 const char *title; | |
61 | |
62 if (w == ws->ordered->data) { | |
63 /* This is the current window in focus */ | |
64 color = GNT_COLOR_TITLE; | |
65 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) { | |
66 /* This is a window with the URGENT hint set */ | |
67 color = GNT_COLOR_URGENT; | |
68 } else { | |
69 color = GNT_COLOR_NORMAL; | |
70 } | |
21250
9187d331aebe
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18421
diff
changeset
|
71 wbkgdset(taskbar, '\0' | gnt_color_pair(color)); |
17699 | 72 if (iter->next) |
21250
9187d331aebe
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18421
diff
changeset
|
73 mvwhline(taskbar, 0, width * i, ' ' | gnt_color_pair(color), width); |
17699 | 74 else |
21250
9187d331aebe
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18421
diff
changeset
|
75 mvwhline(taskbar, 0, width * i, ' ' | gnt_color_pair(color), getmaxx(stdscr) - width * i); |
17699 | 76 title = GNT_BOX(w)->title; |
28604
a18f421696dc
Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22763
diff
changeset
|
77 mvwprintw(taskbar, 0, width * i, "%s", title ? C_(title) : "<gnt>"); |
17699 | 78 if (i) |
21250
9187d331aebe
Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18421
diff
changeset
|
79 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | gnt_color_pair(GNT_COLOR_NORMAL)); |
17699 | 80 } |
81 wrefresh(taskbar); | |
82 } | |
83 | |
84 static void | |
85 gnt_ws_init(GTypeInstance *instance, gpointer class) | |
86 { | |
87 GntWS *ws = GNT_WS(instance); | |
88 ws->list = NULL; | |
89 ws->ordered = NULL; | |
90 ws->name = NULL; | |
91 } | |
92 | |
93 void gnt_ws_add_widget(GntWS *ws, GntWidget* wid) | |
94 { | |
18223
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
95 GntWidget *oldfocus; |
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
96 oldfocus = ws->ordered ? ws->ordered->data : NULL; |
17699 | 97 ws->list = g_list_append(ws->list, wid); |
98 ws->ordered = g_list_prepend(ws->ordered, wid); | |
18223
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
99 if (oldfocus) |
5023ad94ebc9
Notify a window when it loses focus because another window was moved to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
100 gnt_widget_set_focus(oldfocus, FALSE); |
17699 | 101 } |
102 | |
103 void gnt_ws_remove_widget(GntWS *ws, GntWidget* wid) | |
104 { | |
105 ws->list = g_list_remove(ws->list, wid); | |
106 ws->ordered = g_list_remove(ws->ordered, wid); | |
107 } | |
108 | |
109 void | |
110 gnt_ws_set_name(GntWS *ws, const gchar *name) | |
111 { | |
112 g_free(ws->name); | |
113 ws->name = g_strdup(name); | |
114 } | |
115 | |
116 void | |
117 gnt_ws_hide(GntWS *ws, GHashTable *nodes) | |
118 { | |
119 g_list_foreach(ws->ordered, widget_hide, nodes); | |
120 } | |
121 | |
18416
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
122 void gnt_ws_widget_hide(GntWidget *widget, GHashTable *nodes) |
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
123 { |
17699 | 124 widget_hide(widget, nodes); |
125 } | |
126 | |
18416
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
127 void gnt_ws_widget_show(GntWidget *widget, GHashTable *nodes) |
93c5c785a811
Fix some focus issues.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18223
diff
changeset
|
128 { |
17699 | 129 widget_show(widget, nodes); |
130 } | |
131 | |
132 void | |
133 gnt_ws_show(GntWS *ws, GHashTable *nodes) | |
134 { | |
135 GList *l; | |
136 for (l = g_list_last(ws->ordered); l; l = g_list_previous(l)) | |
137 widget_show(l->data, nodes); | |
138 } | |
139 | |
140 GType | |
141 gnt_ws_get_gtype(void) | |
142 { | |
143 static GType type = 0; | |
144 | |
145 if(type == 0) { | |
146 static const GTypeInfo info = { | |
147 sizeof(GntWSClass), | |
148 NULL, /* base_init */ | |
149 NULL, /* base_finalize */ | |
150 NULL, | |
151 /*(GClassInitFunc)gnt_ws_class_init,*/ | |
152 NULL, | |
153 NULL, /* class_data */ | |
154 sizeof(GntWS), | |
155 0, /* n_preallocs */ | |
156 gnt_ws_init, /* instance_init */ | |
157 NULL /* value_table */ | |
158 }; | |
159 | |
160 type = g_type_register_static(GNT_TYPE_BINDABLE, | |
161 "GntWS", | |
162 &info, 0); | |
163 } | |
164 | |
165 return type; | |
166 } | |
167 | |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
168 GntWS *gnt_ws_new(const char *name) |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
169 { |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
170 GntWS *ws = GNT_WS(g_object_new(GNT_TYPE_WS, NULL)); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
171 ws->name = g_strdup(name ? name : "(noname)"); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
172 return ws; |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
173 } |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17707
diff
changeset
|
174 |
17702
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
175 const char * gnt_ws_get_name(GntWS *ws) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
176 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
177 return ws->name; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
178 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17699
diff
changeset
|
179 |