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