Mercurial > geeqie.yaz
annotate src/fullscreen.c @ 1179:de19d176bdbd
Fix up format vs type warning.
author | zas_ |
---|---|
date | Wed, 26 Nov 2008 20:37:14 +0000 |
parents | 5fe3b8b3a612 |
children | 8b89e3ff286b |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 | |
281 | 14 #include "main.h" |
9 | 15 #include "fullscreen.h" |
16 | |
17 #include "image.h" | |
1144
5fe3b8b3a612
Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
zas_
parents:
1055
diff
changeset
|
18 #include "misc.h" |
9 | 19 #include "ui_fileops.h" |
20 #include "ui_menu.h" | |
21 #include "ui_misc.h" | |
648
e34c1002e553
Move some functions from main.[ch] to new window.[ch].
zas_
parents:
512
diff
changeset
|
22 #include "window.h" |
1011 | 23 #include "image-load.h" |
9 | 24 |
25 enum { | |
26 FULLSCREEN_CURSOR_HIDDEN = 1 << 0, | |
27 FULLSCREEN_CURSOR_NORMAL = 1 << 1, | |
28 FULLSCREEN_CURSOR_BUSY = 1 << 2 | |
29 }; | |
30 | |
31 | |
32 /* | |
33 *---------------------------------------------------------------------------- | |
34 * full screen functions | |
35 *---------------------------------------------------------------------------- | |
36 */ | |
37 | |
38 static void clear_mouse_cursor(GtkWidget *widget, gint state) | |
39 { | |
40 if (!widget->window) return; | |
41 | |
42 if (state & FULLSCREEN_CURSOR_BUSY) | |
43 { | |
44 GdkCursor *cursor; | |
45 | |
46 cursor = gdk_cursor_new(GDK_WATCH); | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
47 gdk_window_set_cursor(widget->window, cursor); |
9 | 48 gdk_cursor_unref(cursor); |
49 } | |
50 else if (state & FULLSCREEN_CURSOR_NORMAL) | |
51 { | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
52 gdk_window_set_cursor(widget->window, NULL); |
9 | 53 } |
54 else | |
55 { | |
56 GdkCursor *cursor; | |
57 GdkPixmap *p; | |
58 | |
59 p = gdk_bitmap_create_from_data(widget->window, "\0\0\0", 1, 1); | |
60 | |
61 cursor = gdk_cursor_new_from_pixmap(p, p, | |
62 &widget->style->fg[GTK_STATE_ACTIVE], | |
63 &widget->style->bg[GTK_STATE_ACTIVE], | |
64 0, 0); | |
65 | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
66 gdk_window_set_cursor(widget->window, cursor); |
9 | 67 |
68 gdk_cursor_unref(cursor); | |
69 g_object_unref(p); | |
70 } | |
71 } | |
72 | |
73 static gint fullscreen_hide_mouse_cb(gpointer data) | |
74 { | |
75 FullScreenData *fs = data; | |
76 | |
77 if (fs->hide_mouse_id == -1) return FALSE; | |
78 | |
79 fs->cursor_state &= ~FULLSCREEN_CURSOR_NORMAL; | |
80 if (!(fs->cursor_state & FULLSCREEN_CURSOR_BUSY)) clear_mouse_cursor(fs->window, fs->cursor_state); | |
81 | |
82 fs->hide_mouse_id = -1; | |
83 return FALSE; | |
84 } | |
85 | |
86 static void fullscreen_hide_mouse_disable(FullScreenData *fs) | |
87 { | |
88 if (fs->hide_mouse_id != -1) | |
89 { | |
90 g_source_remove(fs->hide_mouse_id); | |
91 fs->hide_mouse_id = -1; | |
92 } | |
93 } | |
94 | |
95 static void fullscreen_hide_mouse_reset(FullScreenData *fs) | |
96 { | |
97 fullscreen_hide_mouse_disable(fs); | |
98 fs->hide_mouse_id = g_timeout_add(FULL_SCREEN_HIDE_MOUSE_DELAY, fullscreen_hide_mouse_cb, fs); | |
99 } | |
100 | |
101 static gint fullscreen_mouse_moved(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
102 { | |
103 FullScreenData *fs = data; | |
104 | |
105 if (!(fs->cursor_state & FULLSCREEN_CURSOR_NORMAL)) | |
106 { | |
107 fs->cursor_state |= FULLSCREEN_CURSOR_NORMAL; | |
108 if (!(fs->cursor_state & FULLSCREEN_CURSOR_BUSY)) clear_mouse_cursor(fs->window, fs->cursor_state); | |
109 } | |
110 fullscreen_hide_mouse_reset(fs); | |
111 | |
112 return FALSE; | |
113 } | |
114 | |
115 static void fullscreen_busy_mouse_disable(FullScreenData *fs) | |
116 { | |
117 if (fs->busy_mouse_id != -1) | |
118 { | |
119 g_source_remove(fs->busy_mouse_id); | |
120 fs->busy_mouse_id = -1; | |
121 } | |
122 } | |
123 | |
124 static void fullscreen_mouse_set_busy(FullScreenData *fs, gint busy) | |
125 { | |
126 fullscreen_busy_mouse_disable(fs); | |
127 | |
128 if ((fs->cursor_state & FULLSCREEN_CURSOR_BUSY) == (busy)) return; | |
129 | |
130 if (busy) | |
131 { | |
132 fs->cursor_state |= FULLSCREEN_CURSOR_BUSY; | |
133 } | |
134 else | |
135 { | |
136 fs->cursor_state &= ~FULLSCREEN_CURSOR_BUSY; | |
137 } | |
138 | |
139 clear_mouse_cursor(fs->window, fs->cursor_state); | |
140 } | |
141 | |
142 static gboolean fullscreen_mouse_set_busy_cb(gpointer data) | |
143 { | |
144 FullScreenData *fs = data; | |
145 | |
146 fs->busy_mouse_id = -1; | |
147 fullscreen_mouse_set_busy(fs, TRUE); | |
148 return FALSE; | |
149 } | |
150 | |
151 static void fullscreen_mouse_set_busy_idle(FullScreenData *fs) | |
152 { | |
153 if (fs->busy_mouse_id == -1) | |
154 { | |
155 fs->busy_mouse_id = g_timeout_add(FULL_SCREEN_BUSY_MOUSE_DELAY, | |
156 fullscreen_mouse_set_busy_cb, fs); | |
157 } | |
158 } | |
159 | |
160 static void fullscreen_image_update_cb(ImageWindow *imd, gpointer data) | |
161 { | |
162 FullScreenData *fs = data; | |
163 | |
164 if (fs->imd->il && | |
1011 | 165 image_loader_get_pixbuf(fs->imd->il) != image_get_pixbuf(fs->imd)) |
9 | 166 { |
167 fullscreen_mouse_set_busy_idle(fs); | |
168 } | |
169 } | |
170 | |
171 static void fullscreen_image_complete_cb(ImageWindow *imd, gint preload, gpointer data) | |
172 { | |
173 FullScreenData *fs = data; | |
174 | |
175 if (!preload) fullscreen_mouse_set_busy(fs, FALSE); | |
176 } | |
177 | |
178 #define XSCREENSAVER_BINARY "xscreensaver-command" | |
179 #define XSCREENSAVER_COMMAND "xscreensaver-command -deactivate >&- 2>&- &" | |
180 | |
181 static void fullscreen_saver_deactivate(void) | |
182 { | |
183 static gint checked = FALSE; | |
184 static gint found = FALSE; | |
185 | |
186 if (!checked) | |
187 { | |
188 checked = TRUE; | |
189 found = file_in_path(XSCREENSAVER_BINARY); | |
190 } | |
191 | |
192 if (found) | |
193 { | |
1144
5fe3b8b3a612
Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
zas_
parents:
1055
diff
changeset
|
194 runcmd(XSCREENSAVER_COMMAND); |
9 | 195 } |
196 } | |
197 | |
198 static gboolean fullscreen_saver_block_cb(gpointer data) | |
199 { | |
322 | 200 if (options->fullscreen.disable_saver) |
9 | 201 { |
202 fullscreen_saver_deactivate(); | |
203 } | |
204 | |
205 return TRUE; | |
206 } | |
207 | |
208 static gint fullscreen_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) | |
209 { | |
210 FullScreenData *fs = data; | |
211 | |
212 fullscreen_stop(fs); | |
213 return TRUE; | |
214 } | |
215 | |
216 FullScreenData *fullscreen_start(GtkWidget *window, ImageWindow *imd, | |
217 void (*stop_func)(FullScreenData *, gpointer), gpointer stop_data) | |
218 { | |
219 FullScreenData *fs; | |
220 GdkScreen *screen; | |
221 gint same; | |
222 gint x, y; | |
223 gint w, h; | |
224 GdkGeometry geometry; | |
225 | |
226 if (!window || !imd) return NULL; | |
227 | |
228 fs = g_new0(FullScreenData, 1); | |
229 | |
230 fs->hide_mouse_id = -1; | |
231 fs->busy_mouse_id = -1; | |
232 fs->cursor_state = FULLSCREEN_CURSOR_HIDDEN; | |
233 | |
234 fs->normal_window = window; | |
235 fs->normal_imd = imd; | |
236 | |
237 fs->stop_func = stop_func; | |
238 fs->stop_data = stop_data; | |
239 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
240 DEBUG_1("full screen requests screen %d", options->fullscreen.screen); |
322 | 241 fullscreen_prefs_get_geometry(options->fullscreen.screen, window, &x, &y, &w, &h, |
9 | 242 &screen, &same); |
243 | |
289
6a7298988a7a
Simplify and unify gtk_window creation with the help of
zas_
parents:
288
diff
changeset
|
244 fs->window = window_new(GTK_WINDOW_TOPLEVEL, "fullscreen", NULL, NULL, _("Full screen")); |
9 | 245 |
246 /* this requests no decorations, if you still have them complain to the window manager author(s) */ | |
247 gtk_window_set_decorated(GTK_WINDOW(fs->window), FALSE); | |
248 | |
322 | 249 if (options->fullscreen.screen < 0) |
9 | 250 { |
251 /* If we want control of the window size and position this is not what we want. | |
196 | 252 * Geeqie needs control of which monitor(s) to use for full screen. |
9 | 253 */ |
254 gtk_window_fullscreen(GTK_WINDOW(fs->window)); | |
255 } | |
322 | 256 else if (options->fullscreen.above) |
9 | 257 { |
258 /* request to be above other windows */ | |
259 gtk_window_set_keep_above(GTK_WINDOW(fs->window), TRUE); | |
260 } | |
261 | |
262 gtk_window_set_resizable(GTK_WINDOW(fs->window), FALSE); | |
263 | |
264 gtk_window_set_screen(GTK_WINDOW(fs->window), screen); | |
265 gtk_container_set_border_width(GTK_CONTAINER(fs->window), 0); | |
266 g_signal_connect(G_OBJECT(fs->window), "delete_event", | |
267 G_CALLBACK(fullscreen_delete_cb), fs); | |
268 | |
269 geometry.min_width = w; | |
270 geometry.min_height = h; | |
271 geometry.max_width = w; | |
272 geometry.max_height = h; | |
273 geometry.base_width = w; | |
274 geometry.base_height = h; | |
275 geometry.win_gravity = GDK_GRAVITY_STATIC; | |
276 /* By setting USER_POS and USER_SIZE, most window managers will | |
277 * not request positioning of the full screen window (for example twm). | |
278 * | |
279 * In addition, setting gravity to STATIC will result in the | |
280 * decorations of twm to not effect the requested window position, | |
281 * the decorations will simply be off screen, except in multi monitor setups :-/ | |
282 */ | |
283 gtk_window_set_geometry_hints(GTK_WINDOW(fs->window), fs->window, &geometry, | |
284 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | | |
285 GDK_HINT_WIN_GRAVITY | | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
23
diff
changeset
|
286 GDK_HINT_USER_POS); |
9 | 287 |
288 gtk_window_set_default_size(GTK_WINDOW(fs->window), w, h); | |
289 gtk_window_move(GTK_WINDOW(fs->window), x, y); | |
290 | |
291 fs->imd = image_new(FALSE); | |
292 | |
293 gtk_container_add(GTK_CONTAINER(fs->window), fs->imd->widget); | |
294 | |
339
de1c2cd06fce
Rename user_specified_window_background and window_background_color
zas_
parents:
322
diff
changeset
|
295 if (options->image.use_custom_border_color) |
9 | 296 { |
339
de1c2cd06fce
Rename user_specified_window_background and window_background_color
zas_
parents:
322
diff
changeset
|
297 image_background_set_color(fs->imd, &options->image.border_color); |
9 | 298 } |
299 | |
322 | 300 image_set_delay_flip(fs->imd, options->fullscreen.clean_flip); |
888 | 301 image_auto_refresh_enable(fs->imd, fs->normal_imd->auto_refresh); |
9 | 302 |
322 | 303 if (options->fullscreen.clean_flip) |
9 | 304 { |
305 image_set_update_func(fs->imd, fullscreen_image_update_cb, fs); | |
306 image_set_complete_func(fs->imd, fullscreen_image_complete_cb, fs); | |
307 } | |
308 | |
309 gtk_widget_show(fs->imd->widget); | |
310 | |
311 image_change_from_image(fs->imd, fs->normal_imd); | |
312 | |
313 gtk_widget_show(fs->window); | |
314 | |
315 /* for hiding the mouse */ | |
23
17acca639a86
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
316 g_signal_connect(G_OBJECT(fs->imd->pr), "motion_notify_event", |
9 | 317 G_CALLBACK(fullscreen_mouse_moved), fs); |
318 clear_mouse_cursor(fs->window, fs->cursor_state); | |
319 | |
320 /* set timer to block screen saver */ | |
321 fs->saver_block_id = g_timeout_add(60 * 1000, fullscreen_saver_block_cb, fs); | |
322 | |
323 /* hide normal window | |
324 * FIXME: properly restore this window on show | |
325 */ | |
326 #ifdef HIDE_WINDOW_IN_FULLSCREEN | |
327 gtk_widget_hide(fs->normal_window); | |
328 #endif | |
138 | 329 image_change_fd(fs->normal_imd, NULL, image_zoom_get(fs->normal_imd)); |
9 | 330 |
331 return fs; | |
332 } | |
333 | |
334 void fullscreen_stop(FullScreenData *fs) | |
335 { | |
336 if (!fs) return; | |
337 | |
338 g_source_remove(fs->saver_block_id); | |
339 | |
340 fullscreen_hide_mouse_disable(fs); | |
341 fullscreen_busy_mouse_disable(fs); | |
342 gdk_keyboard_ungrab(GDK_CURRENT_TIME); | |
343 | |
344 image_change_from_image(fs->normal_imd, fs->imd); | |
345 #ifdef HIDE_WINDOW_IN_FULLSCREEN | |
346 gtk_widget_show(fs->normal_window); | |
347 #endif | |
348 if (fs->stop_func) fs->stop_func(fs, fs->stop_data); | |
349 | |
350 gtk_widget_destroy(fs->window); | |
351 | |
352 g_free(fs); | |
353 } | |
354 | |
355 | |
356 /* | |
357 *---------------------------------------------------------------------------- | |
358 * full screen preferences and utils | |
359 *---------------------------------------------------------------------------- | |
360 */ | |
361 | |
362 GList *fullscreen_prefs_list(void) | |
363 { | |
364 GList *list = NULL; | |
365 GdkDisplay *display; | |
366 gint number; | |
367 gint i; | |
368 | |
369 display = gdk_display_get_default(); | |
370 number = gdk_display_get_n_screens(display); | |
371 | |
995 | 372 for (i = 0; i < number; i++) |
9 | 373 { |
374 GdkScreen *screen; | |
375 gint monitors; | |
376 gint j; | |
377 | |
378 screen = gdk_display_get_screen(display, i); | |
379 monitors = gdk_screen_get_n_monitors(screen); | |
380 | |
381 for (j = -1; j < monitors; j++) | |
382 { | |
383 ScreenData *sd; | |
384 GdkRectangle rect; | |
385 gchar *name; | |
386 gchar *subname; | |
387 | |
388 name = gdk_screen_make_display_name(screen); | |
389 | |
390 if (j < 0) | |
391 { | |
392 rect.x = 0; | |
393 rect.y = 0; | |
394 rect.width = gdk_screen_get_width(screen); | |
395 rect.height = gdk_screen_get_height(screen); | |
396 subname = g_strdup(_("Full size")); | |
397 } | |
398 else | |
399 { | |
400 gdk_screen_get_monitor_geometry(screen, j, &rect); | |
401 subname = g_strdup_printf("%s %d", _("Monitor"), j + 1); | |
402 } | |
403 | |
404 sd = g_new0(ScreenData, 1); | |
405 sd->number = (i+1) * 100 + j + 1; | |
406 sd->description = g_strdup_printf("%s %s, %s", _("Screen"), name, subname); | |
407 sd->x = rect.x; | |
408 sd->y = rect.y; | |
409 sd->width = rect.width; | |
410 sd->height = rect.height; | |
411 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
412 DEBUG_1("Screen %d %30s %4d,%4d (%4dx%4d)", |
9 | 413 sd->number, sd->description, sd->x, sd->y, sd->width, sd->height); |
414 | |
415 list = g_list_append(list, sd); | |
416 | |
417 g_free(name); | |
418 g_free(subname); | |
419 } | |
420 } | |
421 | |
422 return list; | |
423 } | |
424 | |
425 void fullscreen_prefs_list_free(GList *list) | |
426 { | |
427 GList *work; | |
428 | |
429 work = list; | |
430 while (work) | |
431 { | |
432 ScreenData *sd = work->data; | |
433 work = work->next; | |
434 | |
442 | 435 g_free(sd->description); |
9 | 436 g_free(sd); |
437 } | |
438 | |
439 g_list_free(list); | |
440 } | |
441 | |
442 ScreenData *fullscreen_prefs_list_find(GList *list, gint screen) | |
443 { | |
444 GList *work; | |
445 | |
446 work = list; | |
447 while (work) | |
448 { | |
449 ScreenData *sd = work->data; | |
450 work = work->next; | |
451 | |
452 if (sd->number == screen) return sd; | |
453 } | |
454 | |
455 return NULL; | |
456 } | |
457 | |
458 /* screen is interpreted as such: | |
459 * -1 window manager determines size and position, fallback is (1) active monitor | |
460 * 0 full size of screen containing widget | |
461 * 1 size of monitor containing widget | |
462 * 100 full size of screen 1 (screen, monitor counts start at 1) | |
463 * 101 size of monitor 1 on screen 1 | |
464 * 203 size of monitor 3 on screen 2 | |
465 * returns: | |
466 * dest_screen: screen to place widget [use gtk_window_set_screen()] | |
467 * same_region: the returned region will overlap the current location of widget. | |
468 */ | |
469 void fullscreen_prefs_get_geometry(gint screen, GtkWidget *widget, gint *x, gint *y, gint *width, gint *height, | |
470 GdkScreen **dest_screen, gint *same_region) | |
471 { | |
472 GList *list; | |
473 ScreenData *sd; | |
474 | |
475 list = fullscreen_prefs_list(); | |
476 if (screen >= 100) | |
477 { | |
478 sd = fullscreen_prefs_list_find(list, screen); | |
479 } | |
480 else | |
481 { | |
482 sd = NULL; | |
483 if (screen < 0) screen = 1; | |
484 } | |
485 | |
486 if (sd) | |
487 { | |
488 GdkDisplay *display; | |
489 GdkScreen *screen; | |
490 gint n; | |
491 | |
492 display = gdk_display_get_default(); | |
493 n = sd->number / 100 - 1; | |
494 if (n >= 0 && n < gdk_display_get_n_screens(display)) | |
495 { | |
496 screen = gdk_display_get_screen(display, n); | |
497 } | |
498 else | |
499 { | |
500 screen = gdk_display_get_default_screen(display); | |
501 } | |
502 | |
503 if (x) *x = sd->x; | |
504 if (y) *y = sd->y; | |
505 if (width) *width = sd->width; | |
506 if (height) *height = sd->height; | |
507 | |
508 if (dest_screen) *dest_screen = screen; | |
509 if (same_region) *same_region = (!widget || !widget->window || | |
510 (screen == gtk_widget_get_screen(widget) && | |
511 (sd->number%100 == 0 || | |
512 sd->number%100 == gdk_screen_get_monitor_at_window(screen, widget->window)+1))); | |
513 | |
514 } | |
515 else if (screen != 1 || !widget || !widget->window) | |
516 { | |
517 GdkScreen *screen; | |
518 | |
519 if (widget) | |
520 { | |
521 screen = gtk_widget_get_screen(widget); | |
522 } | |
523 else | |
524 { | |
525 screen = gdk_screen_get_default(); | |
526 } | |
527 | |
528 if (x) *x = 0; | |
529 if (y) *y = 0; | |
530 if (width) *width = gdk_screen_get_width(screen); | |
531 if (height) *height = gdk_screen_get_height(screen); | |
532 | |
533 if (dest_screen) *dest_screen = screen; | |
534 if (same_region) *same_region = TRUE; | |
535 } | |
536 else | |
537 { | |
538 GdkScreen *screen; | |
539 gint monitor; | |
540 GdkRectangle rect; | |
541 | |
542 screen = gtk_widget_get_screen(widget); | |
543 monitor = gdk_screen_get_monitor_at_window(screen, widget->window); | |
544 | |
545 gdk_screen_get_monitor_geometry(screen, monitor, &rect); | |
546 | |
547 if (x) *x = rect.x; | |
548 if (y) *y = rect.y; | |
549 if (width) *width = rect.width; | |
550 if (height) *height = rect.height; | |
551 | |
552 if (dest_screen) *dest_screen = screen; | |
553 if (same_region) *same_region = TRUE; | |
554 } | |
555 | |
556 fullscreen_prefs_list_free(list); | |
557 } | |
558 | |
559 gint fullscreen_prefs_find_screen_for_widget(GtkWidget *widget) | |
560 { | |
561 GdkScreen *screen; | |
562 gint monitor; | |
563 gint n; | |
564 | |
565 if (!widget || !widget->window) return 0; | |
566 | |
567 screen = gtk_widget_get_screen(widget); | |
568 monitor = gdk_screen_get_monitor_at_window(screen, widget->window); | |
569 | |
570 n = (gdk_screen_get_number(screen)+1) * 100 + monitor + 1; | |
571 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
495
diff
changeset
|
572 DEBUG_1("Screen appears to be %d", n); |
9 | 573 |
574 return n; | |
575 } | |
576 | |
577 enum { | |
578 FS_MENU_COLUMN_NAME = 0, | |
579 FS_MENU_COLUMN_VALUE | |
580 }; | |
581 | |
582 #define BUTTON_ABOVE_KEY "button_above" | |
583 | |
584 static void fullscreen_prefs_selection_cb(GtkWidget *combo, gpointer data) | |
585 { | |
586 gint *value = data; | |
587 GtkTreeModel *store; | |
588 GtkTreeIter iter; | |
589 GtkWidget *button; | |
590 | |
591 if (!value) return; | |
592 | |
593 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | |
594 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; | |
595 gtk_tree_model_get(store, &iter, FS_MENU_COLUMN_VALUE, value, -1); | |
596 | |
597 button = g_object_get_data(G_OBJECT(combo), BUTTON_ABOVE_KEY); | |
598 if (button) | |
599 { | |
600 gtk_widget_set_sensitive(button, *value != -1); | |
601 } | |
602 } | |
603 | |
604 static void fullscreen_prefs_selection_add(GtkListStore *store, const gchar *text, gint value) | |
605 { | |
606 GtkTreeIter iter; | |
607 | |
608 gtk_list_store_append(store, &iter); | |
609 gtk_list_store_set(store, &iter, FS_MENU_COLUMN_NAME, text, | |
610 FS_MENU_COLUMN_VALUE, value, -1); | |
611 } | |
612 | |
613 GtkWidget *fullscreen_prefs_selection_new(const gchar *text, gint *screen_value, gint *above_value) | |
614 { | |
615 GtkWidget *vbox; | |
616 GtkWidget *hbox; | |
617 GtkWidget *combo; | |
618 GtkListStore *store; | |
619 GtkCellRenderer *renderer; | |
620 GtkWidget *button = NULL; | |
621 GList *list; | |
622 GList *work; | |
623 gint current = 0; | |
624 gint n; | |
625 | |
626 if (!screen_value) return NULL; | |
627 | |
628 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
629 hbox = pref_box_new(vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | |
630 if (text) pref_label_new(hbox, text); | |
631 | |
632 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); | |
633 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); | |
634 g_object_unref(store); | |
635 | |
636 renderer = gtk_cell_renderer_text_new(); | |
637 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); | |
638 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, | |
639 "text", FS_MENU_COLUMN_NAME, NULL); | |
640 | |
641 if (above_value) | |
642 { | |
643 button = pref_checkbox_new_int(vbox, _("Stay above other windows"), | |
644 *above_value, above_value); | |
645 gtk_widget_set_sensitive(button, *screen_value != -1); | |
646 | |
647 g_object_set_data(G_OBJECT(combo), BUTTON_ABOVE_KEY, button); | |
648 } | |
649 | |
650 fullscreen_prefs_selection_add(store, _("Determined by Window Manager"), -1); | |
651 fullscreen_prefs_selection_add(store, _("Active screen"), 0); | |
652 if (*screen_value == 0) current = 1; | |
653 fullscreen_prefs_selection_add(store, _("Active monitor"), 1); | |
654 if (*screen_value == 1) current = 2; | |
655 | |
656 n = 3; | |
657 list = fullscreen_prefs_list(); | |
658 work = list; | |
659 while (work) | |
660 { | |
661 ScreenData *sd = work->data; | |
662 | |
663 fullscreen_prefs_selection_add(store, sd->description, sd->number); | |
664 if (*screen_value == sd->number) current = n; | |
665 | |
666 work = work->next; | |
667 n++; | |
668 } | |
669 fullscreen_prefs_list_free(list); | |
670 | |
671 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current); | |
672 | |
673 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0); | |
674 gtk_widget_show(combo); | |
675 | |
676 g_signal_connect(G_OBJECT(combo), "changed", | |
677 G_CALLBACK(fullscreen_prefs_selection_cb), screen_value); | |
678 | |
679 return vbox; | |
680 } | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1011
diff
changeset
|
681 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |