Mercurial > pidgin.yaz
annotate finch/libgnt/gntwm.c @ 16473:5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
This changes the ~/.gntrc config for workspaces to the following format:
[Workspace-1]
name = blist
window-names = buddylist;debug-window
[Workspace-2]
name = im
window-names = conversation-window
window-titles = Preferences
[Workspace-3]
name = chats
window-titles = IRC;conference
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Sun, 29 Apr 2007 00:37:28 +0000 |
parents | 4ea517cb7ceb |
children | 3af867ef5a15 |
rev | line source |
---|---|
15818 | 1 #define _GNU_SOURCE |
2 #if defined(__APPLE__) | |
3 #define _XOPEN_SOURCE_EXTENDED | |
4 #endif | |
5 | |
6 #include "config.h" | |
7 | |
8 #include <ctype.h> | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
9 #include <glib/gprintf.h> |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
10 #include <gmodule.h> |
15818 | 11 #include <stdlib.h> |
12 #include <string.h> | |
13 #include <time.h> | |
14 | |
15 #include "gntwm.h" | |
16 #include "gntstyle.h" | |
17 #include "gntmarshal.h" | |
18 #include "gnt.h" | |
19 #include "gntbox.h" | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
20 #include "gntlabel.h" |
15818 | 21 #include "gntmenu.h" |
22 #include "gnttextview.h" | |
23 #include "gnttree.h" | |
24 #include "gntutils.h" | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
25 #include "gntwindow.h" |
15818 | 26 |
27 #define IDLE_CHECK_INTERVAL 5 /* 5 seconds */ | |
28 | |
29 enum | |
30 { | |
31 SIG_NEW_WIN, | |
32 SIG_DECORATE_WIN, | |
33 SIG_CLOSE_WIN, | |
34 SIG_CONFIRM_RESIZE, | |
35 SIG_RESIZED, | |
36 SIG_CONFIRM_MOVE, | |
37 SIG_MOVED, | |
38 SIG_UPDATE_WIN, | |
39 SIG_GIVE_FOCUS, | |
40 SIG_KEY_PRESS, | |
41 SIG_MOUSE_CLICK, | |
42 SIGS | |
43 }; | |
44 | |
45 static guint signals[SIGS] = { 0 }; | |
46 static void gnt_wm_new_window_real(GntWM *wm, GntWidget *widget); | |
47 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); | |
48 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); | |
49 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); | |
50 static void update_window_in_list(GntWM *wm, GntWidget *wid); | |
51 static void shift_window(GntWM *wm, GntWidget *widget, int dir); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
52 static gboolean workspace_next(GntBindable *wm, GList *n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
53 static gboolean workspace_prev(GntBindable *wm, GList *n); |
15818 | 54 |
55 static gboolean write_already(gpointer data); | |
56 static int write_timeout; | |
57 static time_t last_active_time; | |
58 static gboolean idle_update; | |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
59 static GList *act = NULL; /* list of WS with unseen activitiy */ |
15818 | 60 |
61 static GList * | |
62 g_list_bring_to_front(GList *list, gpointer data) | |
63 { | |
64 list = g_list_remove(list, data); | |
65 list = g_list_prepend(list, data); | |
66 return list; | |
67 } | |
68 | |
69 static void | |
70 free_node(gpointer data) | |
71 { | |
72 GntNode *node = data; | |
73 hide_panel(node->panel); | |
74 del_panel(node->panel); | |
75 g_free(node); | |
76 } | |
77 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
78 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
79 gnt_wm_copy_win(GntWidget *widget, GntNode *node) |
15818 | 80 { |
81 WINDOW *src, *dst; | |
82 int shadow; | |
83 if (!node) | |
84 return; | |
85 src = widget->window; | |
86 dst = node->window; | |
87 shadow = gnt_widget_has_shadow(widget) ? 1 : 0; | |
88 copywin(src, dst, node->scroll, 0, 0, 0, getmaxy(dst) - 1, getmaxx(dst) - 1, 0); | |
89 } | |
90 | |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
91 static void |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
92 update_act_msg() |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
93 { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
94 GntWidget *label; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
95 GList *iter; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
96 static GntWidget *message = NULL; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
97 GString *text = g_string_new("act: "); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
98 if (message) |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
99 gnt_widget_destroy(message); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
100 if (g_list_length(act) == 0) |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
101 return; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
102 for (iter = act; iter; iter = iter->next) { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
103 GntWS *ws = iter->data; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
104 g_string_sprintfa(text, "%s, ", gnt_ws_get_name(ws)); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
105 } |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
106 g_string_erase(text, text->len - 2, 2); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
107 message = gnt_vbox_new(FALSE); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
108 label = gnt_label_new_with_format(text->str, GNT_TEXT_FLAG_BOLD | GNT_TEXT_FLAG_HIGHLIGHT); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
109 GNT_WIDGET_UNSET_FLAGS(GNT_BOX(message), GNT_WIDGET_CAN_TAKE_FOCUS); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
110 GNT_WIDGET_SET_FLAGS(GNT_BOX(message), GNT_WIDGET_TRANSIENT); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
111 gnt_box_add_widget(GNT_BOX(message), label); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
112 gnt_widget_set_name(message, "wm-message"); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
113 gnt_widget_set_position(message, 0, 0); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
114 gnt_widget_draw(message); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
115 g_string_free(text, TRUE); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
116 } |
15818 | 117 static gboolean |
118 update_screen(GntWM *wm) | |
119 { | |
120 if (wm->menu) { | |
121 GntMenu *top = wm->menu; | |
122 while (top) { | |
123 GntNode *node = g_hash_table_lookup(wm->nodes, top); | |
124 if (node) | |
125 top_panel(node->panel); | |
126 top = top->submenu; | |
127 } | |
128 } | |
129 update_panels(); | |
130 doupdate(); | |
131 return TRUE; | |
132 } | |
133 | |
134 static gboolean | |
135 sanitize_position(GntWidget *widget, int *x, int *y) | |
136 { | |
137 int X_MAX = getmaxx(stdscr); | |
138 int Y_MAX = getmaxy(stdscr) - 1; | |
139 int w, h; | |
140 int nx, ny; | |
141 gboolean changed = FALSE; | |
142 | |
143 gnt_widget_get_size(widget, &w, &h); | |
144 if (x) { | |
145 if (*x + w > X_MAX) { | |
146 nx = MAX(0, X_MAX - w); | |
147 if (nx != *x) { | |
148 *x = nx; | |
149 changed = TRUE; | |
150 } | |
151 } | |
152 } | |
153 if (y) { | |
154 if (*y + h > Y_MAX) { | |
155 ny = MAX(0, Y_MAX - h); | |
156 if (ny != *y) { | |
157 *y = ny; | |
158 changed = TRUE; | |
159 } | |
160 } | |
161 } | |
162 return changed; | |
163 } | |
164 | |
165 static void | |
166 refresh_node(GntWidget *widget, GntNode *node, gpointer null) | |
167 { | |
168 int x, y, w, h; | |
169 int nw, nh; | |
170 | |
171 int X_MAX = getmaxx(stdscr); | |
172 int Y_MAX = getmaxy(stdscr) - 1; | |
173 | |
174 gnt_widget_get_position(widget, &x, &y); | |
175 gnt_widget_get_size(widget, &w, &h); | |
176 | |
177 if (sanitize_position(widget, &x, &y)) | |
178 gnt_screen_move_widget(widget, x, y); | |
179 | |
180 nw = MIN(w, X_MAX); | |
181 nh = MIN(h, Y_MAX); | |
182 if (nw != w || nh != h) | |
183 gnt_screen_resize_widget(widget, nw, nh); | |
184 } | |
185 | |
186 static void | |
187 read_window_positions(GntWM *wm) | |
188 { | |
189 #if GLIB_CHECK_VERSION(2,6,0) | |
190 GKeyFile *gfile = g_key_file_new(); | |
191 char *filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); | |
192 GError *error = NULL; | |
193 char **keys; | |
194 gsize nk; | |
195 | |
196 if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) { | |
197 g_printerr("GntWM: %s\n", error->message); | |
198 g_error_free(error); | |
199 g_free(filename); | |
200 return; | |
201 } | |
202 | |
203 keys = g_key_file_get_keys(gfile, "positions", &nk, &error); | |
204 if (error) { | |
205 g_printerr("GntWM: %s\n", error->message); | |
206 g_error_free(error); | |
207 error = NULL; | |
208 } else { | |
209 while (nk--) { | |
210 char *title = keys[nk]; | |
211 gsize l; | |
212 char **coords = g_key_file_get_string_list(gfile, "positions", title, &l, NULL); | |
213 if (l == 2) { | |
214 int x = atoi(coords[0]); | |
215 int y = atoi(coords[1]); | |
216 GntPosition *p = g_new0(GntPosition, 1); | |
217 p->x = x; | |
218 p->y = y; | |
219 g_hash_table_replace(wm->positions, g_strdup(title + 1), p); | |
220 } else { | |
221 g_printerr("GntWM: Invalid number of arguments for positioing a window.\n"); | |
222 } | |
223 g_strfreev(coords); | |
224 } | |
225 g_strfreev(keys); | |
226 } | |
227 | |
228 g_free(filename); | |
15964 | 229 g_key_file_free(gfile); |
15818 | 230 #endif |
231 } | |
232 | |
233 static gboolean check_idle(gpointer n) | |
234 { | |
235 if (idle_update) { | |
236 time(&last_active_time); | |
237 idle_update = FALSE; | |
238 } | |
239 return TRUE; | |
240 } | |
241 | |
242 static void | |
243 gnt_wm_init(GTypeInstance *instance, gpointer class) | |
244 { | |
245 GntWM *wm = GNT_WM(instance); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
246 wm->workspaces = NULL; |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
247 wm->name_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
248 wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
249 gnt_style_read_workspaces(wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
250 if (wm->workspaces == NULL) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
251 wm->cws = g_object_new(GNT_TYPE_WS, NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
252 gnt_ws_set_name(wm->cws, "default"); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
253 gnt_wm_add_workspace(wm, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
254 } else { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
255 wm->cws = wm->workspaces->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
256 } |
15818 | 257 wm->event_stack = FALSE; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
258 wm->tagged = NULL; |
15818 | 259 wm->windows = NULL; |
260 wm->actions = NULL; | |
261 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); | |
262 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
263 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) | |
264 read_window_positions(wm); | |
265 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); | |
266 time(&last_active_time); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
267 gnt_wm_switch_workspace(wm, 0); |
15818 | 268 } |
269 | |
270 static void | |
271 switch_window(GntWM *wm, int direction) | |
272 { | |
273 GntWidget *w = NULL, *wid = NULL; | |
274 int pos; | |
275 | |
276 if (wm->_list.window || wm->menu) | |
277 return; | |
278 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
279 if (!wm->cws->ordered || !wm->cws->ordered->next) |
15818 | 280 return; |
281 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
282 w = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
283 pos = g_list_index(wm->cws->list, w); |
15818 | 284 pos += direction; |
285 | |
286 if (pos < 0) | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
287 wid = g_list_last(wm->cws->list)->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
288 else if (pos >= g_list_length(wm->cws->list)) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
289 wid = wm->cws->list->data; |
15818 | 290 else if (pos >= 0) |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
291 wid = g_list_nth_data(wm->cws->list, pos); |
15818 | 292 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
293 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, wid); |
15818 | 294 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
295 gnt_wm_raise_window(wm, wm->cws->ordered->data); |
15818 | 296 |
297 if (w != wid) { | |
298 gnt_widget_set_focus(w, FALSE); | |
299 } | |
300 } | |
301 | |
302 static gboolean | |
303 window_next(GntBindable *bindable, GList *null) | |
304 { | |
305 GntWM *wm = GNT_WM(bindable); | |
306 switch_window(wm, 1); | |
307 return TRUE; | |
308 } | |
309 | |
310 static gboolean | |
311 window_prev(GntBindable *bindable, GList *null) | |
312 { | |
313 GntWM *wm = GNT_WM(bindable); | |
314 switch_window(wm, -1); | |
315 return TRUE; | |
316 } | |
317 | |
318 static gboolean | |
319 switch_window_n(GntBindable *bind, GList *list) | |
320 { | |
321 GntWM *wm = GNT_WM(bind); | |
322 GntWidget *w = NULL; | |
323 GList *l; | |
324 int n; | |
325 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
326 if (!wm->cws->ordered) |
15818 | 327 return TRUE; |
328 | |
329 if (list) | |
330 n = GPOINTER_TO_INT(list->data); | |
331 else | |
332 n = 0; | |
333 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
334 w = wm->cws->ordered->data; |
15818 | 335 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
336 if ((l = g_list_nth(wm->cws->list, n)) != NULL) |
15818 | 337 { |
338 gnt_wm_raise_window(wm, l->data); | |
339 } | |
340 | |
341 if (l && w != l->data) | |
342 { | |
343 gnt_widget_set_focus(w, FALSE); | |
344 } | |
345 return TRUE; | |
346 } | |
347 | |
348 static gboolean | |
349 window_scroll_up(GntBindable *bindable, GList *null) | |
350 { | |
351 GntWM *wm = GNT_WM(bindable); | |
352 GntWidget *window; | |
353 GntNode *node; | |
354 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
355 if (!wm->cws->ordered) |
15818 | 356 return TRUE; |
357 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
358 window = wm->cws->ordered->data; |
15818 | 359 node = g_hash_table_lookup(wm->nodes, window); |
360 if (!node) | |
361 return TRUE; | |
362 | |
363 if (node->scroll) { | |
364 node->scroll--; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
365 gnt_wm_copy_win(window, node); |
15818 | 366 update_screen(wm); |
367 } | |
368 return TRUE; | |
369 } | |
370 | |
371 static gboolean | |
372 window_scroll_down(GntBindable *bindable, GList *null) | |
373 { | |
374 GntWM *wm = GNT_WM(bindable); | |
375 GntWidget *window; | |
376 GntNode *node; | |
377 int w, h; | |
378 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
379 if (!wm->cws->ordered) |
15818 | 380 return TRUE; |
381 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
382 window = wm->cws->ordered->data; |
15818 | 383 node = g_hash_table_lookup(wm->nodes, window); |
384 if (!node) | |
385 return TRUE; | |
386 | |
387 gnt_widget_get_size(window, &w, &h); | |
388 if (h - node->scroll > getmaxy(node->window)) { | |
389 node->scroll++; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
390 gnt_wm_copy_win(window, node); |
15818 | 391 update_screen(wm); |
392 } | |
393 return TRUE; | |
394 } | |
395 | |
396 static gboolean | |
397 window_close(GntBindable *bindable, GList *null) | |
398 { | |
399 GntWM *wm = GNT_WM(bindable); | |
400 | |
401 if (wm->_list.window) | |
402 return TRUE; | |
403 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
404 if (wm->cws->ordered) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
405 gnt_widget_destroy(wm->cws->ordered->data); |
15818 | 406 } |
407 | |
408 return TRUE; | |
409 } | |
410 | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
411 static gboolean |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
412 help_for_widget(GntBindable *bindable, GList *null) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
413 { |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
414 GntWM *wm = GNT_WM(bindable); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
415 GntWidget *widget, *tree, *win, *active; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
416 char *title; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
417 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
418 if (!wm->cws->ordered) |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
419 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
420 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
421 widget = wm->cws->ordered->data; |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
422 if (!GNT_IS_BOX(widget)) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
423 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
424 active = GNT_BOX(widget)->active; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
425 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
426 tree = gnt_widget_bindings_view(active); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
427 win = gnt_window_new(); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
428 title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(active))); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
429 gnt_box_set_title(GNT_BOX(win), title); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
430 if (tree) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
431 gnt_box_add_widget(GNT_BOX(win), tree); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
432 else |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
433 gnt_box_add_widget(GNT_BOX(win), gnt_label_new("This widget has no customizable bindings.")); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
434 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
435 gnt_widget_show(win); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
436 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
437 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
438 } |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
439 |
15818 | 440 static void |
441 destroy__list(GntWidget *widget, GntWM *wm) | |
442 { | |
443 wm->_list.window = NULL; | |
444 wm->_list.tree = NULL; | |
445 wm->windows = NULL; | |
446 wm->actions = NULL; | |
447 update_screen(wm); | |
448 } | |
449 | |
450 static void | |
451 setup__list(GntWM *wm) | |
452 { | |
453 GntWidget *tree, *win; | |
454 win = wm->_list.window = gnt_box_new(FALSE, FALSE); | |
455 gnt_box_set_toplevel(GNT_BOX(win), TRUE); | |
456 gnt_box_set_pad(GNT_BOX(win), 0); | |
457 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_TRANSIENT); | |
458 | |
459 tree = wm->_list.tree = gnt_tree_new(); | |
460 gnt_box_add_widget(GNT_BOX(win), tree); | |
461 | |
462 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(destroy__list), wm); | |
463 } | |
464 | |
465 static void | |
466 window_list_activate(GntTree *tree, GntWM *wm) | |
467 { | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
468 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(tree)); |
15818 | 469 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
470 gnt_widget_destroy(wm->_list.window); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
471 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
472 if (!sel) |
15818 | 473 return; |
474 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
475 if (GNT_IS_WS(sel)) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
476 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, sel)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
477 } else { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
478 GntNode *node = g_hash_table_lookup(wm->nodes, sel); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
479 if (node && node->ws != wm->cws) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
480 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, node->ws)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
481 gnt_wm_raise_window(wm, GNT_WIDGET(sel)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
482 } |
15818 | 483 } |
484 | |
485 static void | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
486 populate_window_list(GntWM *wm, gboolean workspace) |
15818 | 487 { |
488 GList *iter; | |
489 GntTree *tree = GNT_TREE(wm->windows->tree); | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
490 if (!workspace) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
491 for (iter = wm->cws->list; iter; iter = iter->next) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
492 GntBox *box = GNT_BOX(iter->data); |
15818 | 493 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
494 gnt_tree_add_row_last(tree, box, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
495 gnt_tree_create_row(tree, box->title), NULL); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
496 update_window_in_list(wm, GNT_WIDGET(box)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
497 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
498 } else { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
499 GList *ws = wm->workspaces; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
500 for (; ws; ws = ws->next) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
501 gnt_tree_add_row_last(tree, ws->data, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
502 gnt_tree_create_row(tree, gnt_ws_get_name(GNT_WS(ws->data))), NULL); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
503 for (iter = GNT_WS(ws->data)->list; iter; iter = iter->next) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
504 GntBox *box = GNT_BOX(iter->data); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
505 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
506 gnt_tree_add_row_last(tree, box, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
507 gnt_tree_create_row(tree, box->title), ws->data); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
508 update_window_in_list(wm, GNT_WIDGET(box)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
509 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
510 } |
15818 | 511 } |
512 } | |
513 | |
514 static gboolean | |
515 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) | |
516 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
517 if (text[1] == 0 && wm->cws->ordered) { |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
518 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); |
15818 | 519 switch (text[0]) { |
520 case '-': | |
16127
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
521 case ',': |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
522 if (GNT_IS_WS(sel)) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
523 /* reorder the workspace. */ |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
524 } else |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
525 shift_window(wm, GNT_WIDGET(sel), -1); |
15818 | 526 break; |
16127
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
527 case '=': |
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
528 case '.': |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
529 if (GNT_IS_WS(sel)) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
530 /* reorder the workspace. */ |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
531 } else |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
532 shift_window(wm, GNT_WIDGET(sel), 1); |
15818 | 533 break; |
534 default: | |
535 return FALSE; | |
536 } | |
537 gnt_tree_remove_all(GNT_TREE(widget)); | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
538 populate_window_list(wm, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "workspace"))); |
15818 | 539 gnt_tree_set_selected(GNT_TREE(widget), sel); |
540 return TRUE; | |
541 } | |
542 return FALSE; | |
543 } | |
544 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
545 static void |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
546 list_of_windows(GntWM *wm, gboolean workspace) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
547 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
548 GntWidget *tree, *win; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
549 setup__list(wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
550 wm->windows = &wm->_list; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
551 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
552 win = wm->windows->window; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
553 tree = wm->windows->tree; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
554 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
555 gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List"); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
556 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
557 populate_window_list(wm, workspace); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
558 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
559 if (wm->cws->ordered) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
560 gnt_tree_set_selected(GNT_TREE(tree), wm->cws->ordered->data); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
561 else if (workspace) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
562 gnt_tree_set_selected(GNT_TREE(tree), wm->cws); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
563 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
564 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
565 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
566 g_object_set_data(G_OBJECT(tree), "workspace", GINT_TO_POINTER(workspace)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
567 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
568 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
569 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
570 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
571 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
572 gnt_widget_show(win); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
573 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
574 |
15818 | 575 static gboolean |
576 window_list(GntBindable *bindable, GList *null) | |
577 { | |
578 GntWM *wm = GNT_WM(bindable); | |
579 | |
580 if (wm->_list.window || wm->menu) | |
581 return TRUE; | |
582 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
583 if (!wm->cws->ordered) |
15818 | 584 return TRUE; |
585 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
586 list_of_windows(wm, FALSE); |
15818 | 587 |
588 return TRUE; | |
589 } | |
590 | |
591 static gboolean | |
592 dump_screen(GntBindable *bindable, GList *null) | |
593 { | |
594 int x, y; | |
595 chtype old = 0, now = 0; | |
596 FILE *file = fopen("dump.html", "w"); | |
597 | |
598 fprintf(file, "<pre>"); | |
599 for (y = 0; y < getmaxy(stdscr); y++) { | |
600 for (x = 0; x < getmaxx(stdscr); x++) { | |
601 char ch; | |
602 now = mvwinch(curscr, y, x); | |
603 ch = now & A_CHARTEXT; | |
604 now ^= ch; | |
605 | |
606 #define CHECK(attr, start, end) \ | |
607 do \ | |
608 { \ | |
609 if (now & attr) \ | |
610 { \ | |
611 if (!(old & attr)) \ | |
612 fprintf(file, "%s", start); \ | |
613 } \ | |
614 else if (old & attr) \ | |
615 { \ | |
616 fprintf(file, "%s", end); \ | |
617 } \ | |
618 } while (0) | |
619 | |
620 CHECK(A_BOLD, "<b>", "</b>"); | |
621 CHECK(A_UNDERLINE, "<u>", "</u>"); | |
622 CHECK(A_BLINK, "<blink>", "</blink>"); | |
623 | |
624 if ((now & A_COLOR) != (old & A_COLOR) || | |
625 (now & A_REVERSE) != (old & A_REVERSE)) | |
626 { | |
627 int ret; | |
628 short fgp, bgp, r, g, b; | |
629 struct | |
630 { | |
631 int r, g, b; | |
632 } fg, bg; | |
633 | |
634 ret = pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp); | |
635 if (fgp == -1) | |
636 fgp = COLOR_BLACK; | |
637 if (bgp == -1) | |
638 bgp = COLOR_WHITE; | |
639 if (now & A_REVERSE) | |
640 fgp ^= bgp ^= fgp ^= bgp; /* *wink* */ | |
641 ret = color_content(fgp, &r, &g, &b); | |
642 fg.r = r; fg.b = b; fg.g = g; | |
643 ret = color_content(bgp, &r, &g, &b); | |
644 bg.r = r; bg.b = b; bg.g = g; | |
645 #define ADJUST(x) (x = x * 255 / 1000) | |
646 ADJUST(fg.r); | |
647 ADJUST(fg.g); | |
648 ADJUST(fg.b); | |
649 ADJUST(bg.r); | |
650 ADJUST(bg.b); | |
651 ADJUST(bg.g); | |
652 | |
653 if (x) fprintf(file, "</span>"); | |
654 fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">", | |
655 bg.r, bg.g, bg.b, fg.r, fg.g, fg.b); | |
656 } | |
657 if (now & A_ALTCHARSET) | |
658 { | |
659 switch (ch) | |
660 { | |
661 case 'q': | |
662 ch = '-'; break; | |
663 case 't': | |
664 case 'u': | |
665 case 'x': | |
666 ch = '|'; break; | |
667 case 'v': | |
668 case 'w': | |
669 case 'l': | |
670 case 'm': | |
671 case 'k': | |
672 case 'j': | |
673 case 'n': | |
674 ch = '+'; break; | |
675 case '-': | |
676 ch = '^'; break; | |
677 case '.': | |
678 ch = 'v'; break; | |
679 case 'a': | |
680 ch = '#'; break; | |
681 default: | |
682 ch = ' '; break; | |
683 } | |
684 } | |
685 if (ch == '&') | |
686 fprintf(file, "&"); | |
687 else if (ch == '<') | |
688 fprintf(file, "<"); | |
689 else if (ch == '>') | |
690 fprintf(file, ">"); | |
691 else | |
692 fprintf(file, "%c", ch); | |
693 old = now; | |
694 } | |
695 fprintf(file, "</span>\n"); | |
696 old = 0; | |
697 } | |
698 fprintf(file, "</pre>"); | |
699 fclose(file); | |
700 return TRUE; | |
701 } | |
702 | |
703 static void | |
704 shift_window(GntWM *wm, GntWidget *widget, int dir) | |
705 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
706 GList *all = wm->cws->list; |
15818 | 707 GList *list = g_list_find(all, widget); |
708 int length, pos; | |
709 if (!list) | |
710 return; | |
711 | |
712 length = g_list_length(all); | |
713 pos = g_list_position(all, list); | |
714 | |
715 pos += dir; | |
716 if (dir > 0) | |
717 pos++; | |
718 | |
719 if (pos < 0) | |
720 pos = length; | |
721 else if (pos > length) | |
722 pos = 0; | |
723 | |
724 all = g_list_insert(all, widget, pos); | |
725 all = g_list_delete_link(all, list); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
726 wm->cws->list = all; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
727 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 728 } |
729 | |
730 static gboolean | |
731 shift_left(GntBindable *bindable, GList *null) | |
732 { | |
733 GntWM *wm = GNT_WM(bindable); | |
734 if (wm->_list.window) | |
735 return TRUE; | |
736 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
737 shift_window(wm, wm->cws->ordered->data, -1); |
15818 | 738 return TRUE; |
739 } | |
740 | |
741 static gboolean | |
742 shift_right(GntBindable *bindable, GList *null) | |
743 { | |
744 GntWM *wm = GNT_WM(bindable); | |
745 if (wm->_list.window) | |
746 return TRUE; | |
747 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
748 shift_window(wm, wm->cws->ordered->data, 1); |
15818 | 749 return TRUE; |
750 } | |
751 | |
752 static void | |
753 action_list_activate(GntTree *tree, GntWM *wm) | |
754 { | |
755 GntAction *action = gnt_tree_get_selection_data(tree); | |
756 action->callback(); | |
757 gnt_widget_destroy(wm->_list.window); | |
758 } | |
759 | |
760 static int | |
761 compare_action(gconstpointer p1, gconstpointer p2) | |
762 { | |
763 const GntAction *a1 = p1; | |
764 const GntAction *a2 = p2; | |
765 | |
766 return g_utf8_collate(a1->label, a2->label); | |
767 } | |
768 | |
769 static gboolean | |
770 list_actions(GntBindable *bindable, GList *null) | |
771 { | |
772 GntWidget *tree, *win; | |
773 GList *iter; | |
774 GntWM *wm = GNT_WM(bindable); | |
775 if (wm->_list.window || wm->menu) | |
776 return TRUE; | |
777 | |
778 if (wm->acts == NULL) | |
779 return TRUE; | |
780 | |
781 setup__list(wm); | |
782 wm->actions = &wm->_list; | |
783 | |
784 win = wm->actions->window; | |
785 tree = wm->actions->tree; | |
786 | |
787 gnt_box_set_title(GNT_BOX(win), "Actions"); | |
788 GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER); | |
789 /* XXX: Do we really want this? */ | |
790 gnt_tree_set_compare_func(GNT_TREE(tree), compare_action); | |
791 | |
792 for (iter = wm->acts; iter; iter = iter->next) { | |
793 GntAction *action = iter->data; | |
794 gnt_tree_add_row_last(GNT_TREE(tree), action, | |
795 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL); | |
796 } | |
797 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm); | |
798 gnt_widget_set_size(tree, 0, g_list_length(wm->acts)); | |
799 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - g_list_length(wm->acts)); | |
800 | |
801 gnt_widget_show(win); | |
802 return TRUE; | |
803 } | |
804 | |
805 #ifndef NO_WIDECHAR | |
806 static int | |
807 widestringwidth(wchar_t *wide) | |
808 { | |
809 int len, ret; | |
810 char *string; | |
811 | |
812 len = wcstombs(NULL, wide, 0) + 1; | |
813 string = g_new0(char, len); | |
814 wcstombs(string, wide, len); | |
815 ret = gnt_util_onscreen_width(string, NULL); | |
816 g_free(string); | |
817 return ret; | |
818 } | |
819 #endif | |
820 | |
821 /* Returns the onscreen width of the character at the position */ | |
822 static int | |
823 reverse_char(WINDOW *d, int y, int x, gboolean set) | |
824 { | |
825 #define DECIDE(ch) (set ? ((ch) | A_REVERSE) : ((ch) & ~A_REVERSE)) | |
826 | |
827 #ifdef NO_WIDECHAR | |
828 chtype ch; | |
829 ch = mvwinch(d, y, x); | |
830 mvwaddch(d, y, x, DECIDE(ch)); | |
831 return 1; | |
832 #else | |
833 cchar_t ch; | |
834 int wc = 1; | |
835 if (mvwin_wch(d, y, x, &ch) == OK) { | |
836 wc = widestringwidth(ch.chars); | |
837 ch.attr = DECIDE(ch.attr); | |
838 ch.attr &= WA_ATTRIBUTES; /* XXX: This is a workaround for a bug */ | |
839 mvwadd_wch(d, y, x, &ch); | |
840 } | |
841 | |
842 return wc; | |
843 #endif | |
844 } | |
845 | |
846 static void | |
847 window_reverse(GntWidget *win, gboolean set, GntWM *wm) | |
848 { | |
849 int i; | |
850 int w, h; | |
851 WINDOW *d; | |
852 | |
853 if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER)) | |
854 return; | |
855 | |
856 d = win->window; | |
857 gnt_widget_get_size(win, &w, &h); | |
858 | |
859 if (gnt_widget_has_shadow(win)) { | |
860 --w; | |
861 --h; | |
862 } | |
863 | |
864 /* the top and bottom */ | |
865 for (i = 0; i < w; i += reverse_char(d, 0, i, set)); | |
866 for (i = 0; i < w; i += reverse_char(d, h-1, i, set)); | |
867 | |
868 /* the left and right */ | |
869 for (i = 0; i < h; i += reverse_char(d, i, 0, set)); | |
870 for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); | |
871 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
872 gnt_wm_copy_win(win, g_hash_table_lookup(wm->nodes, win)); |
15818 | 873 update_screen(wm); |
874 } | |
875 | |
876 static gboolean | |
877 start_move(GntBindable *bindable, GList *null) | |
878 { | |
879 GntWM *wm = GNT_WM(bindable); | |
880 if (wm->_list.window || wm->menu) | |
881 return TRUE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
882 if (!wm->cws->ordered) |
15818 | 883 return TRUE; |
884 | |
885 wm->mode = GNT_KP_MODE_MOVE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
886 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
15818 | 887 |
888 return TRUE; | |
889 } | |
890 | |
891 static gboolean | |
892 start_resize(GntBindable *bindable, GList *null) | |
893 { | |
894 GntWM *wm = GNT_WM(bindable); | |
895 if (wm->_list.window || wm->menu) | |
896 return TRUE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
897 if (!wm->cws->ordered) |
15818 | 898 return TRUE; |
899 | |
900 wm->mode = GNT_KP_MODE_RESIZE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
901 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
15818 | 902 |
903 return TRUE; | |
904 } | |
905 | |
906 static gboolean | |
907 wm_quit(GntBindable *bindable, GList *list) | |
908 { | |
909 GntWM *wm = GNT_WM(bindable); | |
910 if (write_timeout) | |
911 write_already(wm); | |
912 g_main_loop_quit(wm->loop); | |
913 return TRUE; | |
914 } | |
915 | |
916 static gboolean | |
917 return_true(GntWM *wm, GntWidget *w, int *a, int *b) | |
918 { | |
919 return TRUE; | |
920 } | |
921 | |
922 static gboolean | |
923 refresh_screen(GntBindable *bindable, GList *null) | |
924 { | |
925 GntWM *wm = GNT_WM(bindable); | |
926 | |
927 endwin(); | |
928 refresh(); | |
929 curs_set(0); /* endwin resets the cursor to normal */ | |
930 | |
931 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL); | |
932 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
933 gnt_ws_draw_taskbar(wm->cws, TRUE); |
15818 | 934 |
935 return FALSE; | |
936 } | |
937 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
938 static void remove_tag(gpointer wid, gpointer wim) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
939 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
940 GntWM *wm = GNT_WM(wim); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
941 GntWidget *w = GNT_WIDGET(wid); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
942 wm->tagged = g_list_remove(wm->tagged, w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
943 mvwhline(w->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), 3); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
944 gnt_widget_draw(w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
945 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
946 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
947 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
948 tag_widget(GntBindable *b, GList *params) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
949 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
950 GntWM *wm = GNT_WM(b); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
951 GntWidget *widget; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
952 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
953 if (!wm->cws->ordered) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
954 return FALSE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
955 widget = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
956 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
957 if (g_list_find(wm->tagged, widget)) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
958 remove_tag(widget, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
959 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
960 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
961 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
962 wm->tagged = g_list_prepend(wm->tagged, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
963 wbkgdset(widget->window, ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
964 mvwprintw(widget->window, 0, 1, "[T]"); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
965 gnt_widget_draw(widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
966 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
967 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
968 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
969 static void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
970 widget_move_ws(gpointer wid, gpointer w) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
971 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
972 GntWM *wm = GNT_WM(w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
973 gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
974 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
975 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
976 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
977 place_tagged(GntBindable *b, GList *params) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
978 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
979 GntWM *wm = GNT_WM(b); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
980 g_list_foreach(wm->tagged, widget_move_ws, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
981 g_list_foreach(wm->tagged, remove_tag, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
982 g_list_free(wm->tagged); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
983 wm->tagged = NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
984 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
985 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
986 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
987 static gboolean |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
988 workspace_list(GntBindable *b, GList *params) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
989 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
990 GntWM *wm = GNT_WM(b); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
991 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
992 if (wm->_list.window || wm->menu) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
993 return TRUE; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
994 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
995 list_of_windows(wm, TRUE); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
996 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
997 return TRUE; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
998 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
999 |
15818 | 1000 static void |
1001 gnt_wm_class_init(GntWMClass *klass) | |
1002 { | |
1003 int i; | |
1004 | |
1005 klass->new_window = gnt_wm_new_window_real; | |
1006 klass->decorate_window = NULL; | |
1007 klass->close_window = NULL; | |
1008 klass->window_resize_confirm = return_true; | |
1009 klass->window_resized = gnt_wm_win_resized; | |
1010 klass->window_move_confirm = return_true; | |
1011 klass->window_moved = gnt_wm_win_moved; | |
1012 klass->window_update = NULL; | |
1013 klass->key_pressed = NULL; | |
1014 klass->mouse_clicked = NULL; | |
1015 klass->give_focus = gnt_wm_give_focus; | |
1016 | |
1017 signals[SIG_NEW_WIN] = | |
1018 g_signal_new("new_win", | |
1019 G_TYPE_FROM_CLASS(klass), | |
1020 G_SIGNAL_RUN_LAST, | |
1021 G_STRUCT_OFFSET(GntWMClass, new_window), | |
1022 NULL, NULL, | |
1023 g_cclosure_marshal_VOID__POINTER, | |
1024 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1025 signals[SIG_DECORATE_WIN] = | |
1026 g_signal_new("decorate_win", | |
1027 G_TYPE_FROM_CLASS(klass), | |
1028 G_SIGNAL_RUN_LAST, | |
1029 G_STRUCT_OFFSET(GntWMClass, decorate_window), | |
1030 NULL, NULL, | |
1031 g_cclosure_marshal_VOID__POINTER, | |
1032 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1033 signals[SIG_CLOSE_WIN] = | |
1034 g_signal_new("close_win", | |
1035 G_TYPE_FROM_CLASS(klass), | |
1036 G_SIGNAL_RUN_LAST, | |
1037 G_STRUCT_OFFSET(GntWMClass, close_window), | |
1038 NULL, NULL, | |
1039 g_cclosure_marshal_VOID__POINTER, | |
1040 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1041 signals[SIG_CONFIRM_RESIZE] = | |
1042 g_signal_new("confirm_resize", | |
1043 G_TYPE_FROM_CLASS(klass), | |
1044 G_SIGNAL_RUN_LAST, | |
1045 G_STRUCT_OFFSET(GntWMClass, window_resize_confirm), | |
1046 gnt_boolean_handled_accumulator, NULL, | |
1047 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
1048 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); | |
1049 | |
1050 signals[SIG_CONFIRM_MOVE] = | |
1051 g_signal_new("confirm_move", | |
1052 G_TYPE_FROM_CLASS(klass), | |
1053 G_SIGNAL_RUN_LAST, | |
1054 G_STRUCT_OFFSET(GntWMClass, window_move_confirm), | |
1055 gnt_boolean_handled_accumulator, NULL, | |
1056 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
1057 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); | |
1058 | |
1059 signals[SIG_RESIZED] = | |
1060 g_signal_new("window_resized", | |
1061 G_TYPE_FROM_CLASS(klass), | |
1062 G_SIGNAL_RUN_LAST, | |
1063 G_STRUCT_OFFSET(GntWMClass, window_resized), | |
1064 NULL, NULL, | |
1065 g_cclosure_marshal_VOID__POINTER, | |
1066 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1067 signals[SIG_MOVED] = | |
1068 g_signal_new("window_moved", | |
1069 G_TYPE_FROM_CLASS(klass), | |
1070 G_SIGNAL_RUN_LAST, | |
1071 G_STRUCT_OFFSET(GntWMClass, window_moved), | |
1072 NULL, NULL, | |
1073 g_cclosure_marshal_VOID__POINTER, | |
1074 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1075 signals[SIG_UPDATE_WIN] = | |
1076 g_signal_new("window_update", | |
1077 G_TYPE_FROM_CLASS(klass), | |
1078 G_SIGNAL_RUN_LAST, | |
1079 G_STRUCT_OFFSET(GntWMClass, window_update), | |
1080 NULL, NULL, | |
1081 g_cclosure_marshal_VOID__POINTER, | |
1082 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1083 | |
1084 signals[SIG_GIVE_FOCUS] = | |
1085 g_signal_new("give_focus", | |
1086 G_TYPE_FROM_CLASS(klass), | |
1087 G_SIGNAL_RUN_LAST, | |
1088 G_STRUCT_OFFSET(GntWMClass, give_focus), | |
1089 NULL, NULL, | |
1090 g_cclosure_marshal_VOID__POINTER, | |
1091 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1092 | |
1093 signals[SIG_MOUSE_CLICK] = | |
1094 g_signal_new("mouse_clicked", | |
1095 G_TYPE_FROM_CLASS(klass), | |
1096 G_SIGNAL_RUN_LAST, | |
1097 G_STRUCT_OFFSET(GntWMClass, mouse_clicked), | |
1098 gnt_boolean_handled_accumulator, NULL, | |
1099 gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER, | |
1100 G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER); | |
1101 | |
1102 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next", window_next, | |
1103 "\033" "n", NULL); | |
1104 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev", window_prev, | |
1105 "\033" "p", NULL); | |
1106 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close, | |
1107 "\033" "c", NULL); | |
1108 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list, | |
1109 "\033" "w", NULL); | |
1110 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen, | |
1111 "\033" "d", NULL); | |
1112 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left, | |
1113 "\033" ",", NULL); | |
1114 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right, | |
1115 "\033" ".", NULL); | |
1116 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions, | |
1117 "\033" "a", NULL); | |
1118 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-move", start_move, | |
1119 "\033" "m", NULL); | |
1120 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-resize", start_resize, | |
1121 "\033" "r", NULL); | |
1122 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "wm-quit", wm_quit, | |
1123 "\033" "q", NULL); | |
1124 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "refresh-screen", refresh_screen, | |
1125 "\033" "l", NULL); | |
1126 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "switch-window-n", switch_window_n, | |
1127 NULL, NULL); | |
1128 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-down", window_scroll_down, | |
1129 "\033" GNT_KEY_CTRL_J, NULL); | |
1130 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, | |
1131 "\033" GNT_KEY_CTRL_K, NULL); | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1132 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1133 "\033" "/", NULL); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1134 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-next", workspace_next, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1135 "\033" ">", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1136 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-prev", workspace_prev, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1137 "\033" "<", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1138 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-tag", tag_widget, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1139 "\033" "t", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1140 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "place-tagged", place_tagged, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1141 "\033" "T", NULL); |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1142 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-list", workspace_list, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1143 "\033" "s", NULL); |
15818 | 1144 |
1145 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); | |
1146 | |
1147 /* Make sure Alt+x are detected properly. */ | |
1148 for (i = '0'; i <= '9'; i++) { | |
1149 char str[] = "\033X"; | |
1150 str[1] = i; | |
1151 gnt_keys_add_combination(str); | |
1152 } | |
1153 | |
1154 GNTDEBUG; | |
1155 } | |
1156 | |
1157 /****************************************************************************** | |
1158 * GntWM API | |
1159 *****************************************************************************/ | |
1160 GType | |
1161 gnt_wm_get_gtype(void) | |
1162 { | |
1163 static GType type = 0; | |
1164 | |
1165 if(type == 0) { | |
1166 static const GTypeInfo info = { | |
1167 sizeof(GntWMClass), | |
1168 NULL, /* base_init */ | |
1169 NULL, /* base_finalize */ | |
1170 (GClassInitFunc)gnt_wm_class_init, | |
1171 NULL, | |
1172 NULL, /* class_data */ | |
1173 sizeof(GntWM), | |
1174 0, /* n_preallocs */ | |
1175 gnt_wm_init, /* instance_init */ | |
1176 NULL /* value_table */ | |
1177 }; | |
1178 | |
1179 type = g_type_register_static(GNT_TYPE_BINDABLE, | |
1180 "GntWM", | |
1181 &info, 0); | |
1182 } | |
1183 | |
1184 return type; | |
1185 } | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1186 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1187 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1188 gnt_wm_add_workspace(GntWM *wm, GntWS *ws) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1189 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1190 wm->workspaces = g_list_append(wm->workspaces, ws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1191 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1192 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1193 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1194 gnt_wm_switch_workspace(GntWM *wm, gint n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1195 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1196 GntWS *s = g_list_nth_data(wm->workspaces, n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1197 if (!s) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1198 return FALSE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1199 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1200 if (wm->_list.window) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1201 gnt_widget_destroy(wm->_list.window); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1202 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1203 gnt_ws_hide(wm->cws, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1204 wm->cws = s; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1205 gnt_ws_show(wm->cws, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1206 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1207 gnt_ws_draw_taskbar(wm->cws, TRUE); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1208 update_screen(wm); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1209 if (wm->cws->ordered) { |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1210 gnt_widget_set_focus(wm->cws->ordered->data, TRUE); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1211 gnt_wm_raise_window(wm, wm->cws->ordered->data); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1212 } |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1213 |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1214 if (act && g_list_find(act, wm->cws)) { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1215 act = g_list_remove(act, wm->cws); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1216 update_act_msg(); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1217 } |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1218 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1219 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1220 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1221 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1222 gnt_wm_switch_workspace_prev(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1223 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1224 int n = g_list_index(wm->workspaces, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1225 return gnt_wm_switch_workspace(wm, --n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1226 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1227 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1228 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1229 gnt_wm_switch_workspace_next(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1230 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1231 int n = g_list_index(wm->workspaces, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1232 return gnt_wm_switch_workspace(wm, ++n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1233 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1234 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1235 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1236 workspace_next(GntBindable *wm, GList *n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1237 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1238 return gnt_wm_switch_workspace_next(GNT_WM(wm)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1239 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1240 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1241 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1242 workspace_prev(GntBindable *wm, GList *n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1243 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1244 return gnt_wm_switch_workspace_prev(GNT_WM(wm)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1245 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1246 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1247 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1248 gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1249 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1250 GntWS *oldw = gnt_wm_widget_find_workspace(wm, widget); |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1251 GntNode *node; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1252 if (!oldw || oldw == neww) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1253 return; |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1254 node = g_hash_table_lookup(wm->nodes, widget); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1255 if (node && node->ws == neww) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1256 return; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1257 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1258 if (node) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1259 node->ws = neww; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1260 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1261 gnt_ws_remove_widget(oldw, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1262 gnt_ws_add_widget(neww, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1263 if (neww == wm->cws) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1264 gnt_ws_widget_show(widget, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1265 } else { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1266 gnt_ws_widget_hide(widget, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1267 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1268 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1269 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1270 static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1271 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1272 GntWS *s = (GntWS *)workspace; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1273 if (s->list && g_list_find(s->list, wid)) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1274 return 0; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1275 return 1; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1276 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1277 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1278 GntWS *gnt_wm_widget_find_workspace(GntWM *wm, GntWidget *widget) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1279 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1280 GList *l = g_list_find_custom(wm->workspaces, widget, widget_in_workspace); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1281 if (l) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1282 return l->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1283 return NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1284 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1285 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1286 static void free_workspaces(gpointer data, gpointer n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1287 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1288 GntWS *s = data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1289 g_free(s->name); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1290 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1291 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1292 void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1293 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1294 g_list_foreach(wm->workspaces, free_workspaces, NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1295 wm->workspaces = workspaces; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1296 gnt_wm_switch_workspace(wm, 0); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1297 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1298 |
15818 | 1299 static void |
1300 update_window_in_list(GntWM *wm, GntWidget *wid) | |
1301 { | |
1302 GntTextFormatFlags flag = 0; | |
1303 | |
1304 if (wm->windows == NULL) | |
1305 return; | |
1306 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1307 if (wm->cws->ordered && wid == wm->cws->ordered->data) |
15818 | 1308 flag |= GNT_TEXT_FLAG_DIM; |
1309 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) | |
1310 flag |= GNT_TEXT_FLAG_BOLD; | |
1311 | |
1312 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); | |
1313 } | |
1314 | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1315 static gboolean |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1316 match_title(gpointer title, gpointer n, gpointer wid_title) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1317 { |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1318 /* maybe check for regex.h? */ |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1319 if (g_strrstr((gchar *)wid_title, (gchar *)title)) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1320 return TRUE; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1321 return FALSE; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1322 } |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1323 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1324 static GntWS * |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1325 new_widget_find_workspace(GntWM *wm, GntWidget *widget, gchar *wid_title) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1326 { |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1327 GntWS *ret; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1328 const gchar *name; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1329 ret = g_hash_table_find(wm->title_places, match_title, wid_title); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1330 if (ret) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1331 return ret; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1332 name = gnt_widget_get_name(widget); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1333 if (name) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1334 ret = g_hash_table_lookup(wm->name_places, name); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1335 return ret ? ret : wm->cws; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1336 } |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1337 |
15818 | 1338 static void |
1339 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) | |
1340 { | |
1341 GntNode *node; | |
1342 gboolean transient = FALSE; | |
1343 | |
1344 if (widget->window == NULL) | |
1345 return; | |
1346 | |
1347 node = g_new0(GntNode, 1); | |
1348 node->me = widget; | |
1349 node->scroll = 0; | |
1350 | |
1351 g_hash_table_replace(wm->nodes, widget, node); | |
1352 | |
1353 refresh_node(widget, node, NULL); | |
1354 | |
1355 transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT); | |
1356 | |
1357 #if 1 | |
1358 { | |
1359 int x, y, w, h, maxx, maxy; | |
1360 gboolean shadow = TRUE; | |
1361 | |
1362 if (!gnt_widget_has_shadow(widget)) | |
1363 shadow = FALSE; | |
1364 x = widget->priv.x; | |
1365 y = widget->priv.y; | |
1366 w = widget->priv.width; | |
1367 h = widget->priv.height; | |
1368 | |
1369 getmaxyx(stdscr, maxy, maxx); | |
1370 maxy -= 1; /* room for the taskbar */ | |
1371 maxy -= shadow; | |
1372 maxx -= shadow; | |
1373 | |
1374 x = MAX(0, x); | |
1375 y = MAX(0, y); | |
1376 if (x + w >= maxx) | |
1377 x = MAX(0, maxx - w); | |
1378 if (y + h >= maxy) | |
1379 y = MAX(0, maxy - h); | |
1380 | |
1381 w = MIN(w, maxx); | |
1382 h = MIN(h, maxy); | |
1383 node->window = newwin(h + shadow, w + shadow, y, x); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1384 gnt_wm_copy_win(widget, node); |
15818 | 1385 } |
1386 #endif | |
1387 | |
1388 node->panel = new_panel(node->window); | |
1389 set_panel_userptr(node->panel, node); | |
1390 | |
1391 if (!transient) { | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1392 GntWS *ws = wm->cws; |
15818 | 1393 if (node->me != wm->_list.window) { |
1394 GntWidget *w = NULL; | |
1395 | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1396 if (GNT_IS_BOX(widget)) { |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1397 char *title = GNT_BOX(widget)->title; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1398 ws = new_widget_find_workspace(wm, widget, title); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1399 } |
15818 | 1400 |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1401 if (ws->ordered) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1402 w = ws->ordered->data; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1403 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1404 node->ws = ws; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1405 ws->list = g_list_append(ws->list, widget); |
15818 | 1406 |
1407 if (wm->event_stack) | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1408 ws->ordered = g_list_prepend(ws->ordered, widget); |
15818 | 1409 else |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1410 ws->ordered = g_list_append(ws->ordered, widget); |
15818 | 1411 |
1412 gnt_widget_set_focus(widget, TRUE); | |
1413 if (w) | |
1414 gnt_widget_set_focus(w, FALSE); | |
1415 } | |
1416 | |
1417 if (wm->event_stack || node->me == wm->_list.window) { | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1418 if (wm->cws != ws) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1419 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); |
15818 | 1420 gnt_wm_raise_window(wm, node->me); |
1421 } else { | |
1422 bottom_panel(node->panel); /* New windows should not grab focus */ | |
1423 gnt_widget_set_urgent(node->me); | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1424 if (wm->cws != ws) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1425 gnt_ws_widget_hide(widget, wm->nodes); |
15818 | 1426 } |
1427 } | |
1428 } | |
1429 | |
1430 void gnt_wm_new_window(GntWM *wm, GntWidget *widget) | |
1431 { | |
1432 while (widget->parent) | |
1433 widget = widget->parent; | |
1434 | |
1435 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE) || | |
1436 g_hash_table_lookup(wm->nodes, widget)) { | |
1437 update_screen(wm); | |
1438 return; | |
1439 } | |
1440 | |
1441 if (GNT_IS_BOX(widget)) { | |
1442 const char *title = GNT_BOX(widget)->title; | |
1443 GntPosition *p = NULL; | |
1444 if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) { | |
1445 sanitize_position(widget, &p->x, &p->y); | |
1446 gnt_widget_set_position(widget, p->x, p->y); | |
1447 mvwin(widget->window, p->y, p->x); | |
1448 } | |
1449 } | |
1450 | |
1451 g_signal_emit(wm, signals[SIG_NEW_WIN], 0, widget); | |
1452 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | |
1453 | |
1454 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { | |
1455 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget | |
1456 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { | |
1457 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, | |
1458 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title), | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1459 g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL); |
15818 | 1460 update_window_in_list(wm, widget); |
1461 } | |
1462 } | |
1463 | |
1464 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1465 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1466 } |
1467 | |
1468 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) | |
1469 { | |
1470 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | |
1471 } | |
1472 | |
1473 void gnt_wm_window_close(GntWM *wm, GntWidget *widget) | |
1474 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1475 GntWS *s; |
15818 | 1476 GntNode *node; |
1477 int pos; | |
1478 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1479 s = gnt_wm_widget_find_workspace(wm, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1480 |
15818 | 1481 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL) |
1482 return; | |
1483 | |
1484 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); | |
1485 g_hash_table_remove(wm->nodes, widget); | |
1486 | |
1487 if (wm->windows) { | |
1488 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); | |
1489 } | |
1490 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1491 if (s) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1492 pos = g_list_index(s->list, widget); |
15818 | 1493 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1494 if (pos != -1) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1495 s->list = g_list_remove(s->list, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1496 s->ordered = g_list_remove(s->ordered, widget); |
15818 | 1497 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1498 if (s->ordered && wm->cws == s) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1499 gnt_wm_raise_window(wm, s->ordered->data); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1500 } |
15818 | 1501 } |
1502 | |
1503 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1504 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1505 } |
1506 | |
1507 time_t gnt_wm_get_idle_time() | |
1508 { | |
1509 return time(NULL) - last_active_time; | |
1510 } | |
1511 | |
1512 gboolean gnt_wm_process_input(GntWM *wm, const char *keys) | |
1513 { | |
1514 gboolean ret = FALSE; | |
1515 | |
1516 keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); | |
1517 | |
1518 idle_update = TRUE; | |
1519 | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1520 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { |
15818 | 1521 return TRUE; |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1522 } |
15818 | 1523 |
1524 /* Do some manual checking */ | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1525 if (wm->cws->ordered && wm->mode != GNT_KP_MODE_NORMAL) { |
15818 | 1526 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; |
1527 int x, y, w, h; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1528 GntWidget *widget = GNT_WIDGET(wm->cws->ordered->data); |
15818 | 1529 int ox, oy, ow, oh; |
1530 | |
1531 gnt_widget_get_position(widget, &x, &y); | |
1532 gnt_widget_get_size(widget, &w, &h); | |
1533 ox = x; oy = y; | |
1534 ow = w; oh = h; | |
1535 | |
1536 if (wm->mode == GNT_KP_MODE_MOVE) { | |
1537 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | |
1538 if (x > xmin) | |
1539 x--; | |
1540 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | |
1541 if (x + w < xmax) | |
1542 x++; | |
1543 } else if (strcmp(keys, GNT_KEY_UP) == 0) { | |
1544 if (y > ymin) | |
1545 y--; | |
1546 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { | |
1547 if (y + h < ymax) | |
1548 y++; | |
1549 } | |
1550 if (ox != x || oy != y) { | |
1551 gnt_screen_move_widget(widget, x, y); | |
1552 window_reverse(widget, TRUE, wm); | |
1553 return TRUE; | |
1554 } | |
1555 } else if (wm->mode == GNT_KP_MODE_RESIZE) { | |
1556 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | |
1557 w--; | |
1558 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | |
1559 if (x + w < xmax) | |
1560 w++; | |
1561 } else if (strcmp(keys, GNT_KEY_UP) == 0) { | |
1562 h--; | |
1563 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { | |
1564 if (y + h < ymax) | |
1565 h++; | |
1566 } | |
1567 if (oh != h || ow != w) { | |
1568 gnt_screen_resize_widget(widget, w, h); | |
1569 window_reverse(widget, TRUE, wm); | |
1570 return TRUE; | |
1571 } | |
1572 } | |
1573 if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) { | |
1574 window_reverse(widget, FALSE, wm); | |
1575 wm->mode = GNT_KP_MODE_NORMAL; | |
1576 } | |
1577 return TRUE; | |
1578 } | |
1579 | |
1580 /* Escape to close the window-list or action-list window */ | |
1581 if (strcmp(keys, "\033") == 0) { | |
1582 if (wm->_list.window) { | |
1583 gnt_widget_destroy(wm->_list.window); | |
1584 return TRUE; | |
1585 } | |
1586 } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') { | |
1587 /* Alt+x for quick switch */ | |
1588 int n = *(keys + 1) - '0'; | |
1589 GList *list = NULL; | |
1590 | |
1591 if (n == 0) | |
1592 n = 10; | |
1593 | |
1594 list = g_list_append(list, GINT_TO_POINTER(n - 1)); | |
1595 switch_window_n(GNT_BINDABLE(wm), list); | |
1596 g_list_free(list); | |
1597 return TRUE; | |
1598 } | |
1599 | |
1600 if (wm->menu) | |
1601 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); | |
1602 else if (wm->_list.window) | |
1603 ret = gnt_widget_key_pressed(wm->_list.window, keys); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1604 else if (wm->cws->ordered) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1605 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys); |
15818 | 1606 return ret; |
1607 } | |
1608 | |
1609 static void | |
1610 gnt_wm_win_resized(GntWM *wm, GntNode *node) | |
1611 { | |
1612 /*refresh_node(node->me, node, NULL);*/ | |
1613 } | |
1614 | |
1615 static void | |
1616 gnt_wm_win_moved(GntWM *wm, GntNode *node) | |
1617 { | |
1618 refresh_node(node->me, node, NULL); | |
1619 } | |
1620 | |
1621 void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height) | |
1622 { | |
1623 gboolean ret = TRUE; | |
1624 GntNode *node; | |
1625 int shadow; | |
1626 int maxx, maxy; | |
1627 | |
1628 while (widget->parent) | |
1629 widget = widget->parent; | |
1630 node = g_hash_table_lookup(wm->nodes, widget); | |
1631 if (!node) | |
1632 return; | |
1633 | |
1634 g_signal_emit(wm, signals[SIG_CONFIRM_RESIZE], 0, widget, &width, &height, &ret); | |
1635 if (!ret) | |
1636 return; /* resize is not permitted */ | |
1637 hide_panel(node->panel); | |
1638 gnt_widget_set_size(widget, width, height); | |
1639 gnt_widget_draw(widget); | |
1640 | |
1641 shadow = gnt_widget_has_shadow(widget) ? 1 : 0; | |
1642 maxx = getmaxx(stdscr) - shadow; | |
1643 maxy = getmaxy(stdscr) - 1 - shadow; | |
1644 height = MIN(height, maxy); | |
1645 width = MIN(width, maxx); | |
15978
2a82bc8d57f7
More fixes for resizing when shadow is turned on.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
1646 wresize(node->window, height, width); |
15818 | 1647 replace_panel(node->panel, node->window); |
1648 | |
1649 g_signal_emit(wm, signals[SIG_RESIZED], 0, node); | |
1650 | |
1651 show_panel(node->panel); | |
1652 update_screen(wm); | |
1653 } | |
1654 | |
1655 static void | |
1656 write_gdi(gpointer key, gpointer value, gpointer data) | |
1657 { | |
1658 GntPosition *p = value; | |
1659 fprintf(data, ".%s = %d;%d\n", (char *)key, p->x, p->y); | |
1660 } | |
1661 | |
1662 static gboolean | |
1663 write_already(gpointer data) | |
1664 { | |
1665 GntWM *wm = data; | |
1666 FILE *file; | |
1667 char *filename; | |
1668 | |
1669 filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); | |
1670 | |
1671 file = fopen(filename, "wb"); | |
1672 if (file == NULL) { | |
1673 g_printerr("GntWM: error opening file to save positions\n"); | |
1674 } else { | |
1675 fprintf(file, "[positions]\n"); | |
1676 g_hash_table_foreach(wm->positions, write_gdi, file); | |
1677 fclose(file); | |
1678 } | |
1679 | |
1680 g_free(filename); | |
1681 g_source_remove(write_timeout); | |
1682 write_timeout = 0; | |
1683 return FALSE; | |
1684 } | |
1685 | |
1686 static void | |
1687 write_positions_to_file(GntWM *wm) | |
1688 { | |
1689 if (write_timeout) { | |
1690 g_source_remove(write_timeout); | |
1691 } | |
1692 write_timeout = g_timeout_add(10000, write_already, wm); | |
1693 } | |
1694 | |
1695 void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y) | |
1696 { | |
1697 gboolean ret = TRUE; | |
1698 GntNode *node; | |
1699 | |
1700 while (widget->parent) | |
1701 widget = widget->parent; | |
1702 node = g_hash_table_lookup(wm->nodes, widget); | |
1703 if (!node) | |
1704 return; | |
1705 | |
1706 g_signal_emit(wm, signals[SIG_CONFIRM_MOVE], 0, widget, &x, &y, &ret); | |
1707 if (!ret) | |
1708 return; /* resize is not permitted */ | |
1709 | |
1710 gnt_widget_set_position(widget, x, y); | |
1711 move_panel(node->panel, y, x); | |
1712 | |
1713 g_signal_emit(wm, signals[SIG_MOVED], 0, node); | |
15995
bc2dd3358d46
Don't remember the position of transient windows
Richard Nelson <wabz@pidgin.im>
parents:
15978
diff
changeset
|
1714 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE) && GNT_IS_BOX(widget) && |
bc2dd3358d46
Don't remember the position of transient windows
Richard Nelson <wabz@pidgin.im>
parents:
15978
diff
changeset
|
1715 !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
15818 | 1716 const char *title = GNT_BOX(widget)->title; |
1717 if (title) { | |
1718 GntPosition *p = g_new0(GntPosition, 1); | |
1719 GntWidget *wid = node->me; | |
1720 p->x = wid->priv.x; | |
1721 p->y = wid->priv.y; | |
1722 g_hash_table_replace(wm->positions, g_strdup(title), p); | |
1723 write_positions_to_file(wm); | |
1724 } | |
1725 } | |
1726 | |
1727 update_screen(wm); | |
1728 } | |
1729 | |
1730 static void | |
1731 gnt_wm_give_focus(GntWM *wm, GntWidget *widget) | |
1732 { | |
1733 GntNode *node = g_hash_table_lookup(wm->nodes, widget); | |
1734 | |
1735 if (!node) | |
1736 return; | |
1737 | |
1738 if (widget != wm->_list.window && !GNT_IS_MENU(widget) && | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1739 wm->cws->ordered->data != widget) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1740 GntWidget *w = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1741 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget); |
15818 | 1742 gnt_widget_set_focus(w, FALSE); |
1743 } | |
1744 | |
1745 gnt_widget_set_focus(widget, TRUE); | |
1746 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); | |
1747 gnt_widget_draw(widget); | |
1748 top_panel(node->panel); | |
1749 | |
1750 if (wm->_list.window) { | |
1751 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); | |
1752 top_panel(nd->panel); | |
1753 } | |
1754 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1755 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1756 } |
1757 | |
1758 void gnt_wm_update_window(GntWM *wm, GntWidget *widget) | |
1759 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1760 GntNode *node = NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1761 GntWS *ws; |
15818 | 1762 |
1763 while (widget->parent) | |
1764 widget = widget->parent; | |
1765 if (!GNT_IS_MENU(widget)) | |
1766 gnt_box_sync_children(GNT_BOX(widget)); | |
1767 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1768 ws = gnt_wm_widget_find_workspace(wm, widget); |
15818 | 1769 node = g_hash_table_lookup(wm->nodes, widget); |
1770 if (node == NULL) { | |
1771 gnt_wm_new_window(wm, widget); | |
1772 } else | |
1773 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); | |
1774 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1775 if (ws == wm->cws || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1776 gnt_wm_copy_win(widget, node); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1777 update_screen(wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1778 gnt_ws_draw_taskbar(wm->cws, FALSE); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1779 } else if (ws != wm->cws && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_URGENT)) { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1780 if (!act || (act && !g_list_find(act, ws))) |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1781 act = g_list_prepend(act, ws); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1782 update_act_msg(); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1783 } |
15818 | 1784 } |
1785 | |
1786 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) | |
1787 { | |
1788 gboolean ret = TRUE; | |
1789 idle_update = TRUE; | |
1790 g_signal_emit(wm, signals[SIG_MOUSE_CLICK], 0, event, x, y, widget, &ret); | |
1791 return ret; | |
1792 } | |
1793 | |
1794 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget) | |
1795 { | |
1796 g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget); | |
1797 } | |
1798 | |
16281
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1799 void gnt_wm_set_event_stack(GntWM *wm, gboolean set) |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1800 { |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1801 wm->event_stack = set; |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1802 } |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1803 |