~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

Viewing changes to app/actions/view-commands.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The GIMP -- an image manipulation program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "libgimpwidgets/gimpwidgets.h"
 
24
 
 
25
#include "actions-types.h"
 
26
 
 
27
#include "config/gimpguiconfig.h"
 
28
 
 
29
#include "core/gimp.h"
 
30
#include "core/gimpcontext.h"
 
31
#include "core/gimpimage.h"
 
32
 
 
33
#include "display/gimpdisplay.h"
 
34
#include "display/gimpdisplay-foreach.h"
 
35
#include "display/gimpdisplayoptions.h"
 
36
#include "display/gimpdisplayshell.h"
 
37
#include "display/gimpdisplayshell-appearance.h"
 
38
#include "display/gimpdisplayshell-close.h"
 
39
#include "display/gimpdisplayshell-filter-dialog.h"
 
40
#include "display/gimpdisplayshell-scale.h"
 
41
 
 
42
#include "widgets/gimpactiongroup.h"
 
43
#include "widgets/gimpcolordialog.h"
 
44
#include "widgets/gimpdock.h"
 
45
#include "widgets/gimpdialogfactory.h"
 
46
#include "widgets/gimpuimanager.h"
 
47
 
 
48
#include "dialogs/dialogs.h"
 
49
#include "dialogs/info-dialog.h"
 
50
#include "dialogs/info-window.h"
 
51
 
 
52
#include "actions.h"
 
53
#include "view-commands.h"
 
54
 
 
55
#include "gimp-intl.h"
 
56
 
 
57
 
 
58
#define SET_ACTIVE(manager,action_name,active) \
 
59
  { GimpActionGroup *group = \
 
60
      gimp_ui_manager_get_action_group (manager, "view"); \
 
61
    gimp_action_group_set_action_active (group, action_name, active); }
 
62
 
 
63
#define IS_ACTIVE_DISPLAY(gdisp) \
 
64
  ((gdisp) == \
 
65
   gimp_context_get_display (gimp_get_user_context ((gdisp)->gimage->gimp)))
 
66
 
 
67
 
 
68
/*  local function prototypes  */
 
69
 
 
70
static void   view_padding_color_dialog_update    (GimpColorDialog      *dialog,
 
71
                                                   const GimpRGB        *color,
 
72
                                                   GimpColorDialogState  state,
 
73
                                                   GimpDisplayShell     *shell);
 
74
static void   view_change_screen_confirm_callback (GtkWidget            *dialog,
 
75
                                                   gint                  value,
 
76
                                                   gpointer              data);
 
77
static void   view_change_screen_destroy_callback (GtkWidget            *dialog,
 
78
                                                   GtkWidget            *shell);
 
79
 
 
80
 
 
81
/*  public functions  */
 
82
 
 
83
void
 
84
view_new_view_cmd_callback (GtkAction *action,
 
85
                            gpointer   data)
 
86
{
 
87
  GimpDisplay      *gdisp;
 
88
  GimpDisplayShell *shell;
 
89
  return_if_no_display (gdisp, data);
 
90
 
 
91
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
92
 
 
93
  gimp_create_display (gdisp->gimage->gimp,
 
94
                       gdisp->gimage,
 
95
                       shell->unit, shell->scale);
 
96
}
 
97
 
 
98
void
 
99
view_close_view_cmd_callback (GtkAction *action,
 
100
                              gpointer   data)
 
101
{
 
102
  GimpDisplay *gdisp;
 
103
  return_if_no_display (gdisp, data);
 
104
 
 
105
  gimp_display_shell_close (GIMP_DISPLAY_SHELL (gdisp->shell), FALSE);
 
106
}
 
107
 
 
108
void
 
109
view_zoom_fit_in_cmd_callback (GtkAction *action,
 
110
                               gpointer   data)
 
111
{
 
112
  GimpDisplay *gdisp;
 
113
  return_if_no_display (gdisp, data);
 
114
 
 
115
  gimp_display_shell_scale_fit_in (GIMP_DISPLAY_SHELL (gdisp->shell));
 
116
}
 
117
 
 
118
void
 
119
view_zoom_fit_to_cmd_callback (GtkAction *action,
 
120
                               gpointer   data)
 
121
{
 
122
  GimpDisplay *gdisp;
 
123
  return_if_no_display (gdisp, data);
 
124
 
 
125
  gimp_display_shell_scale_fit_to (GIMP_DISPLAY_SHELL (gdisp->shell));
 
126
}
 
127
 
 
128
void
 
129
view_zoom_cmd_callback (GtkAction *action,
 
130
                        gint       value,
 
131
                        gpointer   data)
 
132
{
 
133
  GimpDisplay      *gdisp;
 
134
  GimpDisplayShell *shell;
 
135
  gdouble           scale;
 
136
  return_if_no_display (gdisp, data);
 
137
 
 
138
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
139
 
 
140
  scale = shell->scale;
 
141
 
 
142
  switch ((GimpActionSelectType) value)
 
143
    {
 
144
    case GIMP_ACTION_SELECT_FIRST:
 
145
      gimp_display_shell_scale (shell, GIMP_ZOOM_TO, 1.0 / 256.0);
 
146
      break;
 
147
 
 
148
    case GIMP_ACTION_SELECT_LAST:
 
149
      gimp_display_shell_scale (shell, GIMP_ZOOM_TO, 256.0);
 
150
      break;
 
151
 
 
152
    case GIMP_ACTION_SELECT_PREVIOUS:
 
153
      gimp_display_shell_scale (shell, GIMP_ZOOM_OUT, 0.0);
 
154
      break;
 
155
 
 
156
    case GIMP_ACTION_SELECT_NEXT:
 
157
      gimp_display_shell_scale (shell, GIMP_ZOOM_IN, 0.0);
 
158
      break;
 
159
 
 
160
    case GIMP_ACTION_SELECT_SKIP_PREVIOUS:
 
161
      scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_OUT, scale);
 
162
      scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_OUT, scale);
 
163
      scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_OUT, scale);
 
164
      gimp_display_shell_scale (shell, GIMP_ZOOM_TO, scale);
 
165
      break;
 
166
 
 
167
    case GIMP_ACTION_SELECT_SKIP_NEXT:
 
168
      scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_IN, scale);
 
169
      scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_IN, scale);
 
170
      scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_IN, scale);
 
171
      gimp_display_shell_scale (shell, GIMP_ZOOM_TO, scale);
 
172
      break;
 
173
 
 
174
    default:
 
175
      scale = action_select_value ((GimpActionSelectType) value,
 
176
                                   scale,
 
177
                                   0.0, 512.0,
 
178
                                   1.0, 16.0,
 
179
                                   FALSE);
 
180
 
 
181
      /* min = 1.0 / 256,  max = 256.0                */
 
182
      /* scale = min *  (max / min)**(i/n), i = 0..n  */
 
183
      scale = pow (65536.0, scale / 512.0) / 256.0;
 
184
 
 
185
      gimp_display_shell_scale (shell, GIMP_ZOOM_TO, scale);
 
186
      break;
 
187
    }
 
188
}
 
189
 
 
190
void
 
191
view_zoom_explicit_cmd_callback (GtkAction *action,
 
192
                                 GtkAction *current,
 
193
                                 gpointer   data)
 
194
{
 
195
  GimpDisplay      *gdisp;
 
196
  GimpDisplayShell *shell;
 
197
  gint              value;
 
198
  return_if_no_display (gdisp, data);
 
199
 
 
200
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
201
 
 
202
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
203
 
 
204
  if (value != 0 /* not Other... */)
 
205
    {
 
206
      if (fabs (value - shell->scale) > 0.0001)
 
207
        gimp_display_shell_scale (shell, GIMP_ZOOM_TO, (gdouble) value / 10000);
 
208
    }
 
209
}
 
210
 
 
211
void
 
212
view_zoom_other_cmd_callback (GtkAction *action,
 
213
                              gpointer   data)
 
214
{
 
215
  GimpDisplay      *gdisp;
 
216
  GimpDisplayShell *shell;
 
217
  return_if_no_display (gdisp, data);
 
218
 
 
219
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
220
 
 
221
  /* check if we are activated by the user or from
 
222
   * view_actions_set_zoom()
 
223
   */
 
224
  if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) &&
 
225
      shell->scale != shell->other_scale)
 
226
    {
 
227
      gimp_display_shell_scale_dialog (shell);
 
228
    }
 
229
}
 
230
 
 
231
void
 
232
view_dot_for_dot_cmd_callback (GtkAction *action,
 
233
                               gpointer   data)
 
234
{
 
235
  GimpDisplay      *gdisp;
 
236
  GimpDisplayShell *shell;
 
237
  gboolean          active;
 
238
  return_if_no_display (gdisp, data);
 
239
 
 
240
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
241
 
 
242
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
243
 
 
244
  if (active != shell->dot_for_dot)
 
245
    {
 
246
      gimp_display_shell_scale_set_dot_for_dot (shell, active);
 
247
 
 
248
      SET_ACTIVE (shell->menubar_manager, "view-dot-for-dot",
 
249
                  shell->dot_for_dot);
 
250
 
 
251
      if (IS_ACTIVE_DISPLAY (gdisp))
 
252
        SET_ACTIVE (shell->popup_manager, "view-dot-for-dot",
 
253
                    shell->dot_for_dot);
 
254
    }
 
255
}
 
256
 
 
257
void
 
258
view_scroll_horizontal_cmd_callback (GtkAction *action,
 
259
                                     gint       value,
 
260
                                     gpointer   data)
 
261
{
 
262
  GimpDisplay      *gdisp;
 
263
  GimpDisplayShell *shell;
 
264
  gdouble           offset;
 
265
  return_if_no_display (gdisp, data);
 
266
 
 
267
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
268
 
 
269
  offset = action_select_value ((GimpActionSelectType) value,
 
270
                                shell->hsbdata->value,
 
271
                                shell->hsbdata->lower,
 
272
                                shell->hsbdata->upper -
 
273
                                shell->hsbdata->page_size,
 
274
                                shell->hsbdata->step_increment,
 
275
                                shell->hsbdata->page_increment,
 
276
                                FALSE);
 
277
  gtk_adjustment_set_value (shell->hsbdata, offset);
 
278
}
 
279
 
 
280
void
 
281
view_scroll_vertical_cmd_callback (GtkAction *action,
 
282
                                   gint       value,
 
283
                                   gpointer   data)
 
284
{
 
285
  GimpDisplay      *gdisp;
 
286
  GimpDisplayShell *shell;
 
287
  gdouble           offset;
 
288
  return_if_no_display (gdisp, data);
 
289
 
 
290
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
291
 
 
292
  offset = action_select_value ((GimpActionSelectType) value,
 
293
                                shell->vsbdata->value,
 
294
                                shell->vsbdata->lower,
 
295
                                shell->vsbdata->upper -
 
296
                                shell->vsbdata->page_size,
 
297
                                shell->vsbdata->step_increment,
 
298
                                shell->vsbdata->page_increment,
 
299
                                FALSE);
 
300
  gtk_adjustment_set_value (shell->vsbdata, offset);
 
301
}
 
302
 
 
303
void
 
304
view_info_window_cmd_callback (GtkAction *action,
 
305
                               gpointer   data)
 
306
{
 
307
  GimpDisplay      *gdisp;
 
308
  GimpDisplayShell *shell;
 
309
  return_if_no_display (gdisp, data);
 
310
 
 
311
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
312
 
 
313
  if (GIMP_GUI_CONFIG (gdisp->gimage->gimp->config)->info_window_per_display)
 
314
    {
 
315
      if (! shell->info_dialog)
 
316
        shell->info_dialog = info_window_create (gdisp);
 
317
 
 
318
      /* To update the fields of the info window for the first time. *
 
319
       * It's no use updating it in info_window_create() because the *
 
320
       * pointer of the info window is not present in the shell yet. */
 
321
      info_window_update (gdisp);
 
322
 
 
323
      info_dialog_present (shell->info_dialog);
 
324
    }
 
325
  else
 
326
    {
 
327
      info_window_follow_auto (gdisp->gimage->gimp);
 
328
    }
 
329
}
 
330
 
 
331
void
 
332
view_navigation_window_cmd_callback (GtkAction *action,
 
333
                                     gpointer   data)
 
334
{
 
335
  GimpDisplay      *gdisp;
 
336
  GimpDisplayShell *shell;
 
337
  return_if_no_display (gdisp, data);
 
338
 
 
339
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
340
 
 
341
  gimp_dialog_factory_dialog_raise (global_dock_factory,
 
342
                                    gtk_widget_get_screen (gdisp->shell),
 
343
                                    "gimp-navigation-view", -1);
 
344
}
 
345
 
 
346
void
 
347
view_display_filters_cmd_callback (GtkAction *action,
 
348
                                   gpointer   data)
 
349
{
 
350
  GimpDisplay      *gdisp;
 
351
  GimpDisplayShell *shell;
 
352
  return_if_no_display (gdisp, data);
 
353
 
 
354
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
355
 
 
356
  if (! shell->filters_dialog)
 
357
    {
 
358
      shell->filters_dialog = gimp_display_shell_filter_dialog_new (shell);
 
359
 
 
360
      g_signal_connect (shell->filters_dialog, "destroy",
 
361
                        G_CALLBACK (gtk_widget_destroyed),
 
362
                        &shell->filters_dialog);
 
363
    }
 
364
 
 
365
  gtk_window_present (GTK_WINDOW (shell->filters_dialog));
 
366
}
 
367
 
 
368
void
 
369
view_toggle_selection_cmd_callback (GtkAction *action,
 
370
                                    gpointer   data)
 
371
{
 
372
  GimpDisplay      *gdisp;
 
373
  GimpDisplayShell *shell;
 
374
  gboolean          active;
 
375
  return_if_no_display (gdisp, data);
 
376
 
 
377
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
378
 
 
379
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
380
 
 
381
  gimp_display_shell_set_show_selection (shell, active);
 
382
}
 
383
 
 
384
void
 
385
view_toggle_layer_boundary_cmd_callback (GtkAction *action,
 
386
                                         gpointer   data)
 
387
{
 
388
  GimpDisplay      *gdisp;
 
389
  GimpDisplayShell *shell;
 
390
  gboolean          active;
 
391
  return_if_no_display (gdisp, data);
 
392
 
 
393
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
394
 
 
395
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
396
 
 
397
  gimp_display_shell_set_show_layer (shell, active);
 
398
}
 
399
 
 
400
void
 
401
view_toggle_menubar_cmd_callback (GtkAction *action,
 
402
                                  gpointer   data)
 
403
{
 
404
  GimpDisplay      *gdisp;
 
405
  GimpDisplayShell *shell;
 
406
  gboolean          active;
 
407
  return_if_no_display (gdisp, data);
 
408
 
 
409
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
410
 
 
411
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
412
 
 
413
  gimp_display_shell_set_show_menubar (shell, active);
 
414
}
 
415
 
 
416
void
 
417
view_toggle_rulers_cmd_callback (GtkAction *action,
 
418
                                 gpointer   data)
 
419
{
 
420
  GimpDisplay      *gdisp;
 
421
  GimpDisplayShell *shell;
 
422
  gboolean          active;
 
423
  return_if_no_display (gdisp, data);
 
424
 
 
425
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
426
 
 
427
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
428
 
 
429
  gimp_display_shell_set_show_rulers (shell, active);
 
430
}
 
431
 
 
432
void
 
433
view_toggle_scrollbars_cmd_callback (GtkAction *action,
 
434
                                     gpointer   data)
 
435
{
 
436
  GimpDisplay      *gdisp;
 
437
  GimpDisplayShell *shell;
 
438
  gboolean          active;
 
439
  return_if_no_display (gdisp, data);
 
440
 
 
441
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
442
 
 
443
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
444
 
 
445
  gimp_display_shell_set_show_scrollbars (shell, active);
 
446
}
 
447
 
 
448
void
 
449
view_toggle_statusbar_cmd_callback (GtkAction *action,
 
450
                                    gpointer   data)
 
451
{
 
452
  GimpDisplay      *gdisp;
 
453
  GimpDisplayShell *shell;
 
454
  gboolean          active;
 
455
  return_if_no_display (gdisp, data);
 
456
 
 
457
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
458
 
 
459
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
460
 
 
461
  gimp_display_shell_set_show_statusbar (shell, active);
 
462
}
 
463
 
 
464
void
 
465
view_toggle_guides_cmd_callback (GtkAction *action,
 
466
                                 gpointer   data)
 
467
{
 
468
  GimpDisplay      *gdisp;
 
469
  GimpDisplayShell *shell;
 
470
  gboolean          active;
 
471
  return_if_no_display (gdisp, data);
 
472
 
 
473
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
474
 
 
475
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
476
 
 
477
  gimp_display_shell_set_show_guides (shell, active);
 
478
}
 
479
 
 
480
void
 
481
view_snap_to_guides_cmd_callback (GtkAction *action,
 
482
                                  gpointer   data)
 
483
{
 
484
  GimpDisplay      *gdisp;
 
485
  GimpDisplayShell *shell;
 
486
  gboolean          active;
 
487
  return_if_no_display (gdisp, data);
 
488
 
 
489
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
490
 
 
491
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
492
 
 
493
  gimp_display_shell_set_snap_to_guides (shell, active);
 
494
}
 
495
 
 
496
 
 
497
void
 
498
view_toggle_grid_cmd_callback (GtkAction *action,
 
499
                               gpointer   data)
 
500
{
 
501
  GimpDisplay      *gdisp;
 
502
  GimpDisplayShell *shell;
 
503
  gboolean          active;
 
504
  return_if_no_display (gdisp, data);
 
505
 
 
506
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
507
 
 
508
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
509
 
 
510
  gimp_display_shell_set_show_grid (shell, active);
 
511
}
 
512
 
 
513
void
 
514
view_snap_to_grid_cmd_callback (GtkAction *action,
 
515
                                gpointer   data)
 
516
{
 
517
  GimpDisplay      *gdisp;
 
518
  GimpDisplayShell *shell;
 
519
  gboolean          active;
 
520
  return_if_no_display (gdisp, data);
 
521
 
 
522
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
523
 
 
524
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
525
 
 
526
  gimp_display_shell_set_snap_to_grid (shell, active);
 
527
}
 
528
 
 
529
void
 
530
view_padding_color_cmd_callback (GtkAction *action,
 
531
                                 gint       value,
 
532
                                 gpointer   data)
 
533
{
 
534
  GimpDisplay        *gdisp;
 
535
  GimpDisplayShell   *shell;
 
536
  GimpDisplayOptions *options;
 
537
  gboolean            fullscreen;
 
538
  return_if_no_display (gdisp, data);
 
539
 
 
540
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
541
 
 
542
  fullscreen = gimp_display_shell_get_fullscreen (shell);
 
543
 
 
544
  if (fullscreen)
 
545
    options = shell->fullscreen_options;
 
546
  else
 
547
    options = shell->options;
 
548
 
 
549
  switch ((GimpCanvasPaddingMode) value)
 
550
    {
 
551
    case GIMP_CANVAS_PADDING_MODE_DEFAULT:
 
552
    case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
 
553
    case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
 
554
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
 
555
 
 
556
      options->padding_mode_set = TRUE;
 
557
 
 
558
      gimp_display_shell_set_padding (shell, (GimpCanvasPaddingMode) value,
 
559
                                      &options->padding_color);
 
560
      break;
 
561
 
 
562
    case GIMP_CANVAS_PADDING_MODE_CUSTOM:
 
563
      {
 
564
        GtkWidget *color_dialog;
 
565
 
 
566
        color_dialog = g_object_get_data (G_OBJECT (shell),
 
567
                                          "padding-color-dialog");
 
568
 
 
569
        if (! color_dialog)
 
570
          {
 
571
            color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (gdisp->gimage),
 
572
                                                  _("Set Canvas Padding Color"),
 
573
                                                  GTK_STOCK_SELECT_COLOR,
 
574
                                                  _("Set Custom Canvas Padding Color"),
 
575
                                                  gdisp->shell,
 
576
                                                  NULL, NULL,
 
577
                                                  &options->padding_color,
 
578
                                                  FALSE, FALSE);
 
579
 
 
580
            g_signal_connect (color_dialog, "update",
 
581
                              G_CALLBACK (view_padding_color_dialog_update),
 
582
                              gdisp->shell);
 
583
 
 
584
            g_object_set_data_full (G_OBJECT (shell), "padding-color-dialog",
 
585
                                    color_dialog,
 
586
                                    (GDestroyNotify) gtk_widget_destroy);
 
587
          }
 
588
 
 
589
        gtk_window_present (GTK_WINDOW (color_dialog));
 
590
      }
 
591
      break;
 
592
 
 
593
    case GIMP_CANVAS_PADDING_MODE_RESET:
 
594
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
 
595
 
 
596
      {
 
597
        GimpDisplayConfig  *config;
 
598
        GimpDisplayOptions *default_options;
 
599
 
 
600
        config = GIMP_DISPLAY_CONFIG (gdisp->gimage->gimp->config);
 
601
 
 
602
        options->padding_mode_set = FALSE;
 
603
 
 
604
        if (fullscreen)
 
605
          default_options = config->default_fullscreen_view;
 
606
        else
 
607
          default_options = config->default_view;
 
608
 
 
609
        gimp_display_shell_set_padding (shell,
 
610
                                        default_options->padding_mode,
 
611
                                        &default_options->padding_color);
 
612
      }
 
613
      break;
 
614
    }
 
615
}
 
616
 
 
617
void
 
618
view_shrink_wrap_cmd_callback (GtkAction *action,
 
619
                               gpointer   data)
 
620
{
 
621
  GimpDisplay *gdisp;
 
622
  return_if_no_display (gdisp, data);
 
623
 
 
624
  gimp_display_shell_scale_shrink_wrap (GIMP_DISPLAY_SHELL (gdisp->shell));
 
625
}
 
626
 
 
627
void
 
628
view_fullscreen_cmd_callback (GtkAction *action,
 
629
                              gpointer   data)
 
630
{
 
631
  GimpDisplay      *gdisp;
 
632
  GimpDisplayShell *shell;
 
633
  gboolean          active;
 
634
  return_if_no_display (gdisp, data);
 
635
 
 
636
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
 
637
 
 
638
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
639
 
 
640
  gimp_display_shell_set_fullscreen (shell, active);
 
641
}
 
642
 
 
643
void
 
644
view_change_screen_cmd_callback (GtkAction *action,
 
645
                                 gpointer   data)
 
646
{
 
647
  GimpDisplay *gdisp;
 
648
  GdkScreen   *screen;
 
649
  GdkDisplay  *display;
 
650
  gint         cur_screen;
 
651
  gint         num_screens;
 
652
  GtkWidget   *dialog;
 
653
  return_if_no_display (gdisp, data);
 
654
 
 
655
  dialog = g_object_get_data (G_OBJECT (gdisp->shell),
 
656
                              "gimp-change-screen-dialog");
 
657
 
 
658
  if (dialog)
 
659
    {
 
660
      gtk_window_present (GTK_WINDOW (dialog));
 
661
      return;
 
662
    }
 
663
 
 
664
  screen  = gtk_widget_get_screen (gdisp->shell);
 
665
  display = gtk_widget_get_display (gdisp->shell);
 
666
 
 
667
  cur_screen  = gdk_screen_get_number (screen);
 
668
  num_screens = gdk_display_get_n_screens (display);
 
669
 
 
670
  dialog = gimp_query_int_box ("Move Display to Screen",
 
671
                               gdisp->shell,
 
672
                               NULL, NULL,
 
673
                               "Enter destination screen",
 
674
                               cur_screen, 0, num_screens - 1,
 
675
                               G_OBJECT (gdisp->shell), "destroy",
 
676
                               view_change_screen_confirm_callback,
 
677
                               gdisp->shell);
 
678
 
 
679
  g_object_set_data (G_OBJECT (gdisp->shell), "gimp-change-screen-dialog",
 
680
                     dialog);
 
681
 
 
682
  g_signal_connect (dialog, "destroy",
 
683
                    G_CALLBACK (view_change_screen_destroy_callback),
 
684
                    gdisp->shell);
 
685
 
 
686
  gtk_widget_show (dialog);
 
687
}
 
688
 
 
689
 
 
690
/*  private functions  */
 
691
 
 
692
static void
 
693
view_padding_color_dialog_update (GimpColorDialog      *dialog,
 
694
                                  const GimpRGB        *color,
 
695
                                  GimpColorDialogState  state,
 
696
                                  GimpDisplayShell     *shell)
 
697
{
 
698
  GimpDisplayOptions *options;
 
699
  gboolean            fullscreen;
 
700
 
 
701
  fullscreen = gimp_display_shell_get_fullscreen (shell);
 
702
 
 
703
  if (fullscreen)
 
704
    options = shell->fullscreen_options;
 
705
  else
 
706
    options = shell->options;
 
707
 
 
708
  switch (state)
 
709
    {
 
710
    case GIMP_COLOR_DIALOG_OK:
 
711
      options->padding_mode_set = TRUE;
 
712
 
 
713
      gimp_display_shell_set_padding (shell, GIMP_CANVAS_PADDING_MODE_CUSTOM,
 
714
                                      color);
 
715
      /* fallthru */
 
716
 
 
717
    case GIMP_COLOR_DIALOG_CANCEL:
 
718
      g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
 
719
      break;
 
720
 
 
721
    default:
 
722
      break;
 
723
    }
 
724
}
 
725
 
 
726
static void
 
727
view_change_screen_confirm_callback (GtkWidget *dialog,
 
728
                                     gint       value,
 
729
                                     gpointer   data)
 
730
{
 
731
  GdkScreen *screen;
 
732
 
 
733
  screen = gdk_display_get_screen (gtk_widget_get_display (GTK_WIDGET (data)),
 
734
                                   value);
 
735
 
 
736
  if (screen)
 
737
    gtk_window_set_screen (GTK_WINDOW (data), screen);
 
738
}
 
739
 
 
740
static void
 
741
view_change_screen_destroy_callback (GtkWidget *dialog,
 
742
                                     GtkWidget *shell)
 
743
{
 
744
  g_object_set_data (G_OBJECT (shell), "gimp-change-screen-dialog", NULL);
 
745
}