1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "libgimpcolor/gimpcolor.h"
24
#include "libgimpwidgets/gimpwidgets.h"
26
#include "display-types.h"
28
#include "core/gimp.h"
29
#include "core/gimpcontext.h"
30
#include "core/gimpimage.h"
32
#include "widgets/gimpactiongroup.h"
33
#include "widgets/gimpuimanager.h"
34
#include "widgets/gimpwidgets-utils.h"
36
#include "gimpcanvas.h"
37
#include "gimpdisplay.h"
38
#include "gimpdisplayoptions.h"
39
#include "gimpdisplayshell.h"
40
#include "gimpdisplayshell-appearance.h"
41
#include "gimpdisplayshell-callbacks.h"
42
#include "gimpdisplayshell-selection.h"
43
#include "gimpdisplayshell-render.h"
46
#define GET_OPTIONS(shell) \
47
(gimp_display_shell_get_fullscreen (shell) ? \
48
shell->fullscreen_options : shell->options)
50
#define SET_ACTIVE(manager,action_name,active) \
51
{ GimpActionGroup *group = \
52
gimp_ui_manager_get_action_group (manager, "view"); \
53
gimp_action_group_set_action_active (group, action_name, active); }
55
#define SET_COLOR(manager,action_name,color) \
56
{ GimpActionGroup *group = \
57
gimp_ui_manager_get_action_group (manager, "view"); \
58
gimp_action_group_set_action_color (group, action_name, color, FALSE); }
60
#define IS_ACTIVE_DISPLAY(shell) \
62
gimp_context_get_display (gimp_get_user_context \
63
((shell)->gdisp->gimage->gimp)))
67
gimp_display_shell_set_fullscreen (GimpDisplayShell *shell,
70
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
72
if (fullscreen != gimp_display_shell_get_fullscreen (shell))
75
gtk_window_fullscreen (GTK_WINDOW (shell));
77
gtk_window_unfullscreen (GTK_WINDOW (shell));
82
gimp_display_shell_get_fullscreen (GimpDisplayShell *shell)
84
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
86
return (shell->window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
90
gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
93
GimpDisplayOptions *options;
96
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
98
options = GET_OPTIONS (shell);
100
g_object_set (options, "show-menubar", show, NULL);
102
vbox = GTK_CONTAINER (shell->qmask_button->parent->parent);
107
gtk_widget_show (shell->menubar);
109
gtk_widget_hide (shell->menubar);
112
if (options->show_menubar || options->show_statusbar)
113
gtk_container_set_border_width (vbox, 2);
115
gtk_container_set_border_width (vbox, 0);
117
SET_ACTIVE (shell->menubar_manager, "view-show-menubar", show);
119
if (IS_ACTIVE_DISPLAY (shell))
120
SET_ACTIVE (shell->popup_manager, "view-show-menubar", show);
124
gimp_display_shell_get_show_menubar (GimpDisplayShell *shell)
126
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
128
return GET_OPTIONS (shell)->show_menubar;
132
gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
135
GimpDisplayOptions *options;
138
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
140
options = GET_OPTIONS (shell);
142
g_object_set (options, "show-rulers", show, NULL);
144
table = GTK_TABLE (GTK_WIDGET (shell->canvas)->parent);
148
gtk_widget_show (shell->origin_button);
149
gtk_widget_show (shell->hrule);
150
gtk_widget_show (shell->vrule);
152
gtk_table_set_col_spacing (table, 0, 1);
153
gtk_table_set_row_spacing (table, 0, 1);
157
gtk_widget_hide (shell->origin_button);
158
gtk_widget_hide (shell->hrule);
159
gtk_widget_hide (shell->vrule);
161
gtk_table_set_col_spacing (table, 0, 0);
162
gtk_table_set_row_spacing (table, 0, 0);
165
SET_ACTIVE (shell->menubar_manager, "view-show-rulers", show);
167
if (IS_ACTIVE_DISPLAY (shell))
168
SET_ACTIVE (shell->popup_manager, "view-show-rulers", show);
172
gimp_display_shell_get_show_rulers (GimpDisplayShell *shell)
174
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
176
return GET_OPTIONS (shell)->show_rulers;
180
gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
183
GimpDisplayOptions *options;
187
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
189
options = GET_OPTIONS (shell);
191
g_object_set (options, "show-scrollbars", show, NULL);
193
hbox = GTK_BOX (shell->vsb->parent->parent);
194
vbox = GTK_BOX (shell->hsb->parent->parent);
198
gtk_widget_show (shell->nav_ebox);
199
gtk_widget_show (shell->hsb);
200
gtk_widget_show (shell->vsb);
201
gtk_widget_show (shell->qmask_button);
202
gtk_widget_show (shell->zoom_button);
204
gtk_box_set_spacing (hbox, 1);
205
gtk_box_set_spacing (vbox, 1);
209
gtk_widget_hide (shell->nav_ebox);
210
gtk_widget_hide (shell->hsb);
211
gtk_widget_hide (shell->vsb);
212
gtk_widget_hide (shell->qmask_button);
213
gtk_widget_hide (shell->zoom_button);
215
gtk_box_set_spacing (hbox, 0);
216
gtk_box_set_spacing (vbox, 0);
219
SET_ACTIVE (shell->menubar_manager, "view-show-scrollbars", show);
221
if (IS_ACTIVE_DISPLAY (shell))
222
SET_ACTIVE (shell->popup_manager, "view-show-scrollbars", show);
226
gimp_display_shell_get_show_scrollbars (GimpDisplayShell *shell)
228
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
230
return GET_OPTIONS (shell)->show_scrollbars;
234
gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
237
GimpDisplayOptions *options;
240
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
242
options = GET_OPTIONS (shell);
244
g_object_set (options, "show-statusbar", show, NULL);
246
vbox = GTK_CONTAINER (shell->qmask_button->parent->parent);
249
gtk_widget_show (shell->statusbar);
251
gtk_widget_hide (shell->statusbar);
253
if (options->show_menubar || options->show_statusbar)
254
gtk_container_set_border_width (vbox, 2);
256
gtk_container_set_border_width (vbox, 0);
258
SET_ACTIVE (shell->menubar_manager, "view-show-statusbar", show);
260
if (IS_ACTIVE_DISPLAY (shell))
261
SET_ACTIVE (shell->popup_manager, "view-show-statusbar", show);
265
gimp_display_shell_get_show_statusbar (GimpDisplayShell *shell)
267
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
269
return GET_OPTIONS (shell)->show_statusbar;
273
gimp_display_shell_set_show_selection (GimpDisplayShell *shell,
276
GimpDisplayOptions *options;
278
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
280
options = GET_OPTIONS (shell);
282
g_object_set (options, "show-selection", show, NULL);
285
gimp_display_shell_selection_set_hidden (shell->select, ! show);
287
SET_ACTIVE (shell->menubar_manager, "view-show-selection", show);
289
if (IS_ACTIVE_DISPLAY (shell))
290
SET_ACTIVE (shell->popup_manager, "view-show-selection", show);
294
gimp_display_shell_get_show_selection (GimpDisplayShell *shell)
296
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
298
return GET_OPTIONS (shell)->show_selection;
302
gimp_display_shell_set_show_layer (GimpDisplayShell *shell,
305
GimpDisplayOptions *options;
307
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
309
options = GET_OPTIONS (shell);
311
g_object_set (options, "show-layer-boundary", show, NULL);
314
gimp_display_shell_selection_layer_set_hidden (shell->select, ! show);
316
SET_ACTIVE (shell->menubar_manager, "view-show-layer-boundary", show);
318
if (IS_ACTIVE_DISPLAY (shell))
319
SET_ACTIVE (shell->popup_manager, "view-show-layer-boundary", show);
323
gimp_display_shell_get_show_layer (GimpDisplayShell *shell)
325
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
327
return GET_OPTIONS (shell)->show_layer_boundary;
331
gimp_display_shell_set_show_transform (GimpDisplayShell *shell,
334
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
336
shell->show_transform_preview = show;
340
gimp_display_shell_get_show_transform (GimpDisplayShell *shell)
342
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
344
return shell->show_transform_preview;
348
gimp_display_shell_set_show_grid (GimpDisplayShell *shell,
351
GimpDisplayOptions *options;
353
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
355
options = GET_OPTIONS (shell);
357
g_object_set (options, "show-grid", show, NULL);
359
if (shell->gdisp->gimage->grid)
360
gimp_display_shell_expose_full (shell);
362
SET_ACTIVE (shell->menubar_manager, "view-show-grid", show);
364
if (IS_ACTIVE_DISPLAY (shell))
365
SET_ACTIVE (shell->popup_manager, "view-show-grid", show);
369
gimp_display_shell_get_show_grid (GimpDisplayShell *shell)
371
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
373
return GET_OPTIONS (shell)->show_grid;
377
gimp_display_shell_set_snap_to_grid (GimpDisplayShell *shell,
380
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
382
if (snap != shell->snap_to_grid)
384
shell->snap_to_grid = snap ? TRUE : FALSE;
386
SET_ACTIVE (shell->menubar_manager, "view-snap-to-grid", snap);
388
if (IS_ACTIVE_DISPLAY (shell))
389
SET_ACTIVE (shell->popup_manager, "view-snap-to-grid", snap);
394
gimp_display_shell_get_snap_to_grid (GimpDisplayShell *shell)
396
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
398
return shell->snap_to_grid;
402
gimp_display_shell_set_show_guides (GimpDisplayShell *shell,
405
GimpDisplayOptions *options;
407
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
409
options = GET_OPTIONS (shell);
411
g_object_set (options, "show-guides", show, NULL);
413
if (shell->gdisp->gimage->guides)
414
gimp_display_shell_expose_full (shell);
416
SET_ACTIVE (shell->menubar_manager, "view-show-guides", show);
418
if (IS_ACTIVE_DISPLAY (shell))
419
SET_ACTIVE (shell->popup_manager, "view-show-guides", show);
423
gimp_display_shell_get_show_guides (GimpDisplayShell *shell)
425
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
427
return GET_OPTIONS (shell)->show_guides;
431
gimp_display_shell_set_snap_to_guides (GimpDisplayShell *shell,
434
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
436
if (snap != shell->snap_to_guides)
438
shell->snap_to_guides = snap ? TRUE : FALSE;
440
SET_ACTIVE (shell->menubar_manager, "view-snap-to-guides", snap);
442
if (IS_ACTIVE_DISPLAY (shell))
443
SET_ACTIVE (shell->popup_manager, "view-snap-to-guides", snap);
448
gimp_display_shell_get_snap_to_guides (GimpDisplayShell *shell)
450
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
452
return shell->snap_to_guides;
456
gimp_display_shell_set_padding (GimpDisplayShell *shell,
457
GimpCanvasPaddingMode padding_mode,
458
const GimpRGB *padding_color)
460
GimpDisplayOptions *options;
463
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
464
g_return_if_fail (padding_color != NULL);
466
options = GET_OPTIONS (shell);
467
color = *padding_color;
469
switch (padding_mode)
471
case GIMP_CANVAS_PADDING_MODE_DEFAULT:
474
gtk_widget_ensure_style (shell->canvas);
475
gimp_rgb_set_gdk_color (&color,
476
shell->canvas->style->bg + GTK_STATE_NORMAL);
480
case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
481
gimp_rgb_set_uchar (&color,
482
render_blend_light_check[0],
483
render_blend_light_check[1],
484
render_blend_light_check[2]);
487
case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
488
gimp_rgb_set_uchar (&color,
489
render_blend_dark_check[0],
490
render_blend_dark_check[1],
491
render_blend_dark_check[2]);
494
case GIMP_CANVAS_PADDING_MODE_CUSTOM:
495
case GIMP_CANVAS_PADDING_MODE_RESET:
499
g_object_set (options,
500
"padding-mode", padding_mode,
501
"padding-color", &color,
504
gimp_canvas_set_bg_color (GIMP_CANVAS (shell->canvas), &color);
506
SET_COLOR (shell->menubar_manager, "view-padding-color-menu",
507
&options->padding_color);
509
if (IS_ACTIVE_DISPLAY (shell))
510
SET_COLOR (shell->popup_manager, "view-padding-color-menu",
511
&options->padding_color);
513
gimp_display_shell_expose_full (shell);
517
gimp_display_shell_get_padding (GimpDisplayShell *shell,
518
GimpCanvasPaddingMode *padding_mode,
519
GimpRGB *padding_color)
521
GimpDisplayOptions *options;
523
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
525
options = GET_OPTIONS (shell);
528
*padding_mode = options->padding_mode;
531
*padding_color = options->padding_color;