help-commands.c 32.5 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17
 */
Sven Neumann's avatar
Sven Neumann committed
18

19 20
#include "config.h"

21 22 23 24
#include <stdio.h>
#include <sys/types.h>

#include <gtk/gtk.h>
Sven Neumann's avatar
Sven Neumann committed
25

26
#include "libgimpcolor/gimpcolor.h"
27
#include "libgimpmath/gimpmath.h"
28
#include "libgimpwidgets/gimpwidgets.h"
29

Sven Neumann's avatar
Sven Neumann committed
30 31
#include "apptypes.h"

Elliot Lee's avatar
Elliot Lee committed
32 33 34
#include "appenv.h"
#include "about_dialog.h"
#include "app_procs.h"
35
#include "brush_select.h"
Michael Natterer's avatar
Michael Natterer committed
36
#include "colormap_dialog.h"
37
#include "color_area.h"
Elliot Lee's avatar
Elliot Lee committed
38 39 40
#include "commands.h"
#include "convert.h"
#include "desaturate.h"
41
#include "devices.h"
42
#include "docindex.h"
Elliot Lee's avatar
Elliot Lee committed
43 44 45
#include "channel_ops.h"
#include "drawable.h"
#include "equalize.h"
Sven Neumann's avatar
Sven Neumann committed
46
#include "errorconsole.h"
Elliot Lee's avatar
Elliot Lee committed
47 48 49 50
#include "fileops.h"
#include "floating_sel.h"
#include "gdisplay_ops.h"
#include "gimage_mask.h"
51
#include "gimpcontext.h"
52
#include "gimphelp.h"
53
#include "gimpimage.h"
Elliot Lee's avatar
Elliot Lee committed
54
#include "gimprc.h"
55
#include "gimpui.h"
Elliot Lee's avatar
Elliot Lee committed
56
#include "global_edit.h"
Michael Natterer's avatar
Michael Natterer committed
57
#include "gradient_select.h"
Elliot Lee's avatar
Elliot Lee committed
58
#include "image_render.h"
59
#include "info_dialog.h"
Elliot Lee's avatar
Elliot Lee committed
60
#include "info_window.h"
61
#include "layer.h"
62
#include "nav_window.h"
Elliot Lee's avatar
Elliot Lee committed
63
#include "invert.h"
64
#include "lc_dialog.h"
Elliot Lee's avatar
Elliot Lee committed
65
#include "layer_select.h"
66
#include "layers_dialogP.h"
67
#include "module_db.h"
Elliot Lee's avatar
Elliot Lee committed
68
#include "palette.h"
69
#include "pattern_select.h"
Elliot Lee's avatar
Elliot Lee committed
70 71 72
#include "plug_in.h"
#include "resize.h"
#include "scale.h"
73
#include "selection.h"
Elliot Lee's avatar
Elliot Lee committed
74 75 76
#include "tips_dialog.h"
#include "undo.h"

77 78 79 80
#ifdef DISPLAY_FILTERS
#include "gdisplay_color_ui.h"
#endif /* DISPLAY_FILTERS */

81
#include "tools/tool_options_dialog.h"
82 83
#include "tools/tools.h"

84 85
#include "libgimp/gimpintl.h"

86

87 88 89 90
#define return_if_no_display(gdisp) \
        gdisp = gdisplay_active (); \
        if (!gdisp) return

91

Elliot Lee's avatar
Elliot Lee committed
92
/*  local functions  */
Michael Natterer's avatar
Michael Natterer committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
static void     image_resize_callback        (GtkWidget *widget,
					      gpointer   data);
static void     image_scale_callback         (GtkWidget *widget,
					      gpointer   data);
static void     gimage_mask_feather_callback (GtkWidget *widget,
					      gdouble    size,
					      GimpUnit   unit,
					      gpointer   data);
static void     gimage_mask_border_callback  (GtkWidget *widget,
					      gdouble    size,
					      GimpUnit   unit,
		  			      gpointer   data);
static void     gimage_mask_grow_callback    (GtkWidget *widget,
					      gdouble    size,
					      GimpUnit   unit,
					      gpointer   data);
static void     gimage_mask_shrink_callback  (GtkWidget *widget,
					      gdouble    size,
					      GimpUnit   unit,
					      gpointer   data);
113

Elliot Lee's avatar
Elliot Lee committed
114

115
/*  local variables  */
116 117 118 119 120
static gdouble   selection_feather_radius    = 5.0;
static gint      selection_border_radius     = 5;
static gint      selection_grow_pixels       = 1;
static gint      selection_shrink_pixels     = 1;
static gboolean  selection_shrink_edge_lock  = FALSE;
121 122


123 124
/*****  File  *****/

Elliot Lee's avatar
Elliot Lee committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
void
file_open_cmd_callback (GtkWidget *widget,
			gpointer   client_data)
{
  file_open_callback (widget, client_data);
}

void
file_save_cmd_callback (GtkWidget *widget,
			gpointer   client_data)
{
  file_save_callback (widget, client_data);
}

void
file_save_as_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
{
  file_save_as_callback (widget, client_data);
}

146 147 148 149 150 151 152
void
file_save_a_copy_as_cmd_callback (GtkWidget *widget,
				  gpointer   client_data)
{
  file_save_a_copy_as_callback (widget, client_data);
}

Manish Singh's avatar
Manish Singh committed
153 154 155 156 157 158 159
void
file_revert_cmd_callback (GtkWidget *widget,
			gpointer   client_data)
{
  file_revert_callback (widget, client_data);
}

Elliot Lee's avatar
Elliot Lee committed
160 161 162 163 164
void
file_close_cmd_callback (GtkWidget *widget,
			 gpointer   client_data)
{
  GDisplay *gdisp;
165
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
166 167 168 169 170 171 172 173

  gdisplay_close_window (gdisp, FALSE);
}

void
file_quit_cmd_callback (GtkWidget *widget,
			gpointer   client_data)
{
174
  app_exit (FALSE);
Elliot Lee's avatar
Elliot Lee committed
175 176
}

177
/*****  Edit  *****/
Elliot Lee's avatar
Elliot Lee committed
178 179

void
180
edit_undo_cmd_callback (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
181 182
			gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
183
  GDisplay *gdisp;
184
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
185

186
  undo_pop (gdisp->gimage);
Elliot Lee's avatar
Elliot Lee committed
187 188 189
}

void
190 191
edit_redo_cmd_callback (GtkWidget *widget,
			gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
192
{
Michael Natterer's avatar
Michael Natterer committed
193
  GDisplay *gdisp;
194
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
195

196
  undo_redo (gdisp->gimage);
Elliot Lee's avatar
Elliot Lee committed
197 198 199
}

void
200 201
edit_cut_cmd_callback (GtkWidget *widget,
		       gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
202
{
Michael Natterer's avatar
Michael Natterer committed
203
  GDisplay *gdisp;
204
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
205

206
  global_edit_cut (gdisp);
Elliot Lee's avatar
Elliot Lee committed
207 208
}

209
void
210 211
edit_copy_cmd_callback (GtkWidget *widget,
			gpointer   client_data)
212
{
Michael Natterer's avatar
Michael Natterer committed
213
  GDisplay *gdisp;
214 215
  return_if_no_display (gdisp);

216
  global_edit_copy (gdisp);
217 218
}

Elliot Lee's avatar
Elliot Lee committed
219
void
220
edit_paste_cmd_callback (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
221 222
			 gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
223
  GDisplay *gdisp;
224
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
225

226
  global_edit_paste (gdisp, 0);
Elliot Lee's avatar
Elliot Lee committed
227 228 229
}

void
230 231
edit_paste_into_cmd_callback (GtkWidget *widget,
			      gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
232
{
Michael Natterer's avatar
Michael Natterer committed
233
  GDisplay *gdisp;
234
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
235

236
  global_edit_paste (gdisp, 1);
Elliot Lee's avatar
Elliot Lee committed
237 238 239
}

void
240 241
edit_paste_as_new_cmd_callback (GtkWidget *widget,
				gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
242
{
Michael Natterer's avatar
Michael Natterer committed
243
  GDisplay *gdisp;
244
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
245

246
  global_edit_paste_as_new (gdisp);
Elliot Lee's avatar
Elliot Lee committed
247 248 249
}

void
250 251
edit_named_cut_cmd_callback (GtkWidget *widget,
			     gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
252
{
Michael Natterer's avatar
Michael Natterer committed
253
  GDisplay *gdisp;
254
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
255

256
  named_edit_cut (gdisp);
Elliot Lee's avatar
Elliot Lee committed
257 258 259
}

void
260 261
edit_named_copy_cmd_callback (GtkWidget *widget,
			      gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
262
{
Michael Natterer's avatar
Michael Natterer committed
263
  GDisplay *gdisp;
264
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
265

266
  named_edit_copy (gdisp);
Elliot Lee's avatar
Elliot Lee committed
267 268
}

269
void
270 271
edit_named_paste_cmd_callback (GtkWidget *widget,
			       gpointer   client_data)
272
{
Michael Natterer's avatar
Michael Natterer committed
273
  GDisplay *gdisp;
274 275
  return_if_no_display (gdisp);

276
  named_edit_paste (gdisp);
277 278
}

Elliot Lee's avatar
Elliot Lee committed
279
void
280 281
edit_clear_cmd_callback (GtkWidget *widget,
			 gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
282
{
Michael Natterer's avatar
Michael Natterer committed
283
  GDisplay *gdisp;
284
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
285

286
  edit_clear (gdisp->gimage, gimp_image_active_drawable (gdisp->gimage));
287
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
288 289 290
}

void
291
edit_fill_cmd_callback (GtkWidget *widget,
292 293
			gpointer   callback_data,
			guint      callback_action)
Elliot Lee's avatar
Elliot Lee committed
294
{
295
  GimpFillType fill_type;
Michael Natterer's avatar
Michael Natterer committed
296
  GDisplay *gdisp;
297
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
298

299
  fill_type = (GimpFillType) callback_action;
300 301
  edit_fill (gdisp->gimage, gimp_image_active_drawable (gdisp->gimage),
	     fill_type);
302
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
303 304 305
}

void
306 307
edit_stroke_cmd_callback (GtkWidget *widget,
			  gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
308
{
Michael Natterer's avatar
Michael Natterer committed
309
  GDisplay *gdisp;
310
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
311

312
  gimage_mask_stroke (gdisp->gimage, gimp_image_active_drawable (gdisp->gimage));
313
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
314 315
}

316 317
/*****  Select  *****/

Elliot Lee's avatar
Elliot Lee committed
318 319 320 321
void
select_invert_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
322
  GDisplay *gdisp;
323
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
324 325 326 327 328 329 330 331 332

  gimage_mask_invert (gdisp->gimage);
  gdisplays_flush ();
}

void
select_all_cmd_callback (GtkWidget *widget,
			 gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
333
  GDisplay *gdisp;
334
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
335 336 337 338 339 340 341 342 343

  gimage_mask_all (gdisp->gimage);
  gdisplays_flush ();
}

void
select_none_cmd_callback (GtkWidget *widget,
			  gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
344
  GDisplay *gdisp;
345
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
346 347 348 349 350 351 352 353 354

  gimage_mask_none (gdisp->gimage);
  gdisplays_flush ();
}

void
select_float_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
355
  GDisplay *gdisp;
356
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
357

358
  gimage_mask_float (gdisp->gimage, gimp_image_active_drawable (gdisp->gimage),
359
		     0, 0);
Elliot Lee's avatar
Elliot Lee committed
360 361 362 363 364 365 366
  gdisplays_flush ();
}

void
select_feather_cmd_callback (GtkWidget *widget,
			     gpointer   client_data)
{
367 368 369
  GtkWidget *qbox;
  GDisplay  *gdisp;

370
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
371

372 373
  qbox = gimp_query_size_box (_("Feather Selection"),
			      gimp_standard_help_func,
374
			      "dialogs/feather_selection.html",
Michael Natterer's avatar
Michael Natterer committed
375
			      _("Feather Selection by:"),
376 377 378 379 380 381 382 383
			      selection_feather_radius, 0, 32767, 3,
			      gdisp->gimage->unit,
			      MIN (gdisp->gimage->xresolution,
				   gdisp->gimage->yresolution),
			      gdisp->dot_for_dot,
			      GTK_OBJECT (gdisp->gimage), "destroy",
			      gimage_mask_feather_callback, gdisp->gimage);
  gtk_widget_show (qbox);
Elliot Lee's avatar
Elliot Lee committed
384 385 386
}

void
387 388
select_sharpen_cmd_callback (GtkWidget *widget,
			     gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
389
{
Michael Natterer's avatar
Michael Natterer committed
390
  GDisplay *gdisp;
391
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
392

393 394
  gimage_mask_sharpen (gdisp->gimage);
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
395 396 397 398 399 400
}

void
select_shrink_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
{
401 402 403
  GtkWidget *edge_lock;
  GtkWidget *shrink_dialog;

Michael Natterer's avatar
Michael Natterer committed
404
  GDisplay *gdisp;
405
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
406

407 408 409
  shrink_dialog =
    gimp_query_size_box (N_("Shrink Selection"),
			 gimp_standard_help_func,
410
			 "dialogs/shrink_selection.html",
Michael Natterer's avatar
Michael Natterer committed
411
			 _("Shrink Selection by:"),
412 413 414 415 416 417 418
			 selection_shrink_pixels, 1, 32767, 0,
			 gdisp->gimage->unit,
			 MIN (gdisp->gimage->xresolution,
			      gdisp->gimage->yresolution),
			 gdisp->dot_for_dot,
			 GTK_OBJECT (gdisp->gimage), "destroy",
			 gimage_mask_shrink_callback, gdisp->gimage);
419 420 421 422 423 424 425 426 427 428 429 430

  edge_lock = gtk_check_button_new_with_label (_("Shrink from image border"));
  /* eeek */
  gtk_box_pack_start (GTK_BOX (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (shrink_dialog)->vbox)), 0)), edge_lock,
		      FALSE, FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (shrink_dialog), "edge_lock_toggle",
		       edge_lock);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edge_lock),
				! selection_shrink_edge_lock);
  gtk_widget_show (edge_lock);

  gtk_widget_show (shrink_dialog);
Elliot Lee's avatar
Elliot Lee committed
431 432 433
}

void
434
select_grow_cmd_callback (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
435 436
			  gpointer   client_data)
{
437 438 439
  GtkWidget *qbox;
  GDisplay  *gdisp;

440 441
  return_if_no_display (gdisp);

442 443 444
  qbox = gimp_query_size_box (_("Grow Selection"),
			      gimp_standard_help_func,
			      "dialogs/grow_selection.html",
Michael Natterer's avatar
Michael Natterer committed
445
			      _("Grow Selection by:"),
446 447 448 449 450 451 452 453
			      selection_grow_pixels, 1, 32767, 0,
			      gdisp->gimage->unit,
			      MIN (gdisp->gimage->xresolution,
				   gdisp->gimage->yresolution),
			      gdisp->dot_for_dot,
			      GTK_OBJECT (gdisp->gimage), "destroy",
			      gimage_mask_grow_callback, gdisp->gimage);
  gtk_widget_show (qbox);
Elliot Lee's avatar
Elliot Lee committed
454 455
}

456
void
457 458
select_border_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
459
{
460 461 462
  GtkWidget *qbox;
  GDisplay  *gdisp;

463
  return_if_no_display (gdisp);
464

465 466 467
  qbox = gimp_query_size_box (_("Border Selection"),
			      gimp_standard_help_func,
			      "dialogs/border_selection.html",
Michael Natterer's avatar
Michael Natterer committed
468
			      _("Border Selection by:"),
469 470 471 472 473 474 475 476 477 478 479 480 481 482
			      selection_border_radius, 1, 32767, 0,
			      gdisp->gimage->unit,
			      MIN (gdisp->gimage->xresolution,
				   gdisp->gimage->yresolution),
			      gdisp->dot_for_dot,
			      GTK_OBJECT (gdisp->gimage), "destroy",
			      gimage_mask_border_callback, gdisp->gimage);
  gtk_widget_show (qbox);
}

void
select_save_cmd_callback (GtkWidget *widget,
			  gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
483
  GDisplay *gdisp;
484 485 486 487
  return_if_no_display (gdisp);

  gimage_mask_save (gdisp->gimage);
  gdisplays_flush ();
488 489
}

490 491
/*****  View  *****/

Elliot Lee's avatar
Elliot Lee committed
492 493 494 495 496
void
view_zoomin_cmd_callback (GtkWidget *widget,
			  gpointer   client_data)
{
  GDisplay *gdisp;
497
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
498 499 500 501 502 503 504 505 506

  change_scale (gdisp, ZOOMIN);
}

void
view_zoomout_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
{
  GDisplay *gdisp;
507
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
508 509 510 511 512 513 514 515 516 517

  change_scale (gdisp, ZOOMOUT);
}

static void
view_zoom_val (GtkWidget *widget,
	       gpointer   client_data,
	       int        val)
{
  GDisplay *gdisp;
518
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
519 520 521 522 523

  change_scale (gdisp, val);
}

void
524 525
view_zoom_16_1_cmd_callback (GtkWidget *widget,
			     gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
526 527 528 529 530
{
  view_zoom_val (widget, client_data, 1601);
}

void
531 532
view_zoom_8_1_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
533 534 535 536 537
{
  view_zoom_val (widget, client_data, 801);
}

void
538 539
view_zoom_4_1_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
540 541 542 543 544
{
  view_zoom_val (widget, client_data, 401);
}

void
545 546
view_zoom_2_1_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
547 548 549 550 551
{
  view_zoom_val (widget, client_data, 201);
}

void
552 553
view_zoom_1_1_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
554 555 556 557 558
{
  view_zoom_val (widget, client_data, 101);
}

void
559 560
view_zoom_1_2_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
561 562 563 564 565
{
  view_zoom_val (widget, client_data, 102);
}

void
566 567
view_zoom_1_4_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
568 569 570 571 572
{
  view_zoom_val (widget, client_data, 104);
}

void
573 574
view_zoom_1_8_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
575 576 577 578 579
{
  view_zoom_val (widget, client_data, 108);
}

void
580 581
view_zoom_1_16_cmd_callback (GtkWidget *widget,
			     gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
582 583 584 585 586
{
  view_zoom_val (widget, client_data, 116);
}

void
587 588 589 590 591 592 593 594 595 596 597
view_dot_for_dot_cmd_callback (GtkWidget *widget,
			       gpointer   client_data)
{
  GDisplay *gdisp;
  return_if_no_display (gdisp);

  gdisplay_set_dot_for_dot (gdisp, GTK_CHECK_MENU_ITEM (widget)->active);
}

void
view_info_window_cmd_callback (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
598 599
			       gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
600
  GDisplay *gdisp;
601
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
602

603 604 605 606 607 608 609 610 611 612 613
  if (!info_window_follows_mouse) 
    {
      if (! gdisp->window_info_dialog)
	gdisp->window_info_dialog = info_window_create ((void *) gdisp);
      info_window_update(gdisp);
      info_dialog_popup (gdisp->window_info_dialog);
    }
  else
    {
      info_window_follow_auto();
    }
Elliot Lee's avatar
Elliot Lee committed
614 615 616

}

617
void
618
view_nav_window_cmd_callback (GtkWidget *widget,
619 620
			      gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
621
  GDisplay *gdisp;
622 623
  return_if_no_display (gdisp);

624
  if (nav_window_per_display) 
625 626 627
    {
      if (! gdisp->window_nav_dialog)
	gdisp->window_nav_dialog = nav_window_create ((void *) gdisp);
628

629 630 631 632
      nav_dialog_popup (gdisp->window_nav_dialog);
    }
  else
    {
633
      nav_window_follow_auto ();
634
    }
635 636
}

Michael Natterer's avatar
Michael Natterer committed
637 638 639 640
void
view_toggle_selection_cmd_callback (GtkWidget *widget,
				    gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
641 642
  GDisplay *gdisp;
  gint      new_val;
643

Michael Natterer's avatar
Michael Natterer committed
644 645
  return_if_no_display (gdisp);

646 647 648 649 650 651 652 653
  new_val = GTK_CHECK_MENU_ITEM (widget)->active;

  /*  hidden == TRUE corresponds to the menu toggle being FALSE  */
  if (new_val == gdisp->select->hidden)
    {
      selection_hide (gdisp->select, (void *) gdisp);
      gdisplays_flush ();
    }
Michael Natterer's avatar
Michael Natterer committed
654 655
}

Elliot Lee's avatar
Elliot Lee committed
656 657 658 659
void
view_toggle_rulers_cmd_callback (GtkWidget *widget,
				 gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
660
  GDisplay *gdisp;
661
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
662 663 664 665 666

  if (!GTK_CHECK_MENU_ITEM (widget)->active)
    {
      if (GTK_WIDGET_VISIBLE (gdisp->origin))
	{
667 668 669
	  gtk_widget_hide (gdisp->origin);
	  gtk_widget_hide (gdisp->hrule);
	  gtk_widget_hide (gdisp->vrule);
Elliot Lee's avatar
Elliot Lee committed
670 671 672 673 674 675 676 677

	  gtk_widget_queue_resize (GTK_WIDGET (gdisp->origin->parent));
	}
    }
  else
    {
      if (!GTK_WIDGET_VISIBLE (gdisp->origin))
	{
678 679 680
	  gtk_widget_show (gdisp->origin);
	  gtk_widget_show (gdisp->hrule);
	  gtk_widget_show (gdisp->vrule);
681

Elliot Lee's avatar
Elliot Lee committed
682 683 684 685 686
	  gtk_widget_queue_resize (GTK_WIDGET (gdisp->origin->parent));
	}
    }
}

687 688 689 690
void
view_toggle_statusbar_cmd_callback (GtkWidget *widget,
				    gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
691
  GDisplay *gdisp;
692 693 694 695 696 697 698 699 700 701 702 703 704 705
  return_if_no_display (gdisp);

  if (!GTK_CHECK_MENU_ITEM (widget)->active)
    {
      if (GTK_WIDGET_VISIBLE (gdisp->statusarea))
	gtk_widget_hide (gdisp->statusarea);
    }
  else
    {
      if (!GTK_WIDGET_VISIBLE (gdisp->statusarea))
	gtk_widget_show (gdisp->statusarea);
    }
}

Elliot Lee's avatar
Elliot Lee committed
706 707 708 709
void
view_toggle_guides_cmd_callback (GtkWidget *widget,
				 gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
710 711
  GDisplay *gdisp;
  gint      old_val;
Elliot Lee's avatar
Elliot Lee committed
712

713
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728

  old_val = gdisp->draw_guides;
  gdisp->draw_guides = GTK_CHECK_MENU_ITEM (widget)->active;

  if ((old_val != gdisp->draw_guides) && gdisp->gimage->guides)
    {
      gdisplay_expose_full (gdisp);
      gdisplays_flush ();
    }
}

void
view_snap_to_guides_cmd_callback (GtkWidget *widget,
				  gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
729
  GDisplay *gdisp;
730
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
731 732 733 734 735 736 737 738 739

  gdisp->snap_to_guides = GTK_CHECK_MENU_ITEM (widget)->active;
}

void
view_new_view_cmd_callback (GtkWidget *widget,
			    gpointer   client_data)
{
  GDisplay *gdisp;
740
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
741 742 743 744 745 746 747 748 749

  gdisplay_new_view (gdisp);
}

void
view_shrink_wrap_cmd_callback (GtkWidget *widget,
			       gpointer   client_data)
{
  GDisplay *gdisp;
750
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
751

752
  shrink_wrap_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
753 754
}

755
/*****  Image  *****/
Elliot Lee's avatar
Elliot Lee committed
756 757

void
758 759
image_convert_rgb_cmd_callback (GtkWidget *widget,
				gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
760
{
Michael Natterer's avatar
Michael Natterer committed
761
  GDisplay *gdisp;
762 763
  return_if_no_display (gdisp);

764
  convert_to_rgb (gdisp->gimage);
Elliot Lee's avatar
Elliot Lee committed
765 766 767
}

void
768 769
image_convert_grayscale_cmd_callback (GtkWidget *widget,
				      gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
770
{
Michael Natterer's avatar
Michael Natterer committed
771
  GDisplay *gdisp;
772 773
  return_if_no_display (gdisp);

774
  convert_to_grayscale (gdisp->gimage);
Elliot Lee's avatar
Elliot Lee committed
775 776 777
}

void
778
image_convert_indexed_cmd_callback (GtkWidget *widget,
779
				    gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
780
{
Michael Natterer's avatar
Michael Natterer committed
781
  GDisplay *gdisp;
782 783
  return_if_no_display (gdisp);

784
  convert_to_indexed (gdisp->gimage);
Elliot Lee's avatar
Elliot Lee committed
785 786 787
}

void
788 789
image_desaturate_cmd_callback (GtkWidget *widget,
			       gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
790
{
Michael Natterer's avatar
Michael Natterer committed
791
  GDisplay *gdisp;
792 793
  return_if_no_display (gdisp);

794 795
  image_desaturate (gdisp->gimage);
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
796 797 798
}

void
799 800
image_invert_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
801
{
Michael Natterer's avatar
Michael Natterer committed
802
  GDisplay *gdisp;
803 804
  return_if_no_display (gdisp);

805 806
  image_invert (gdisp->gimage);
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
807 808 809
}

void
810 811
image_equalize_cmd_callback (GtkWidget *widget,
			     gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
812
{
813
  GDisplay *gdisp;
814 815
  return_if_no_display (gdisp);

816 817
  image_equalize (gdisp->gimage);
  gdisplays_flush ();
Elliot Lee's avatar
Elliot Lee committed
818 819 820
}

void
821 822
image_offset_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
823
{
Michael Natterer's avatar
Michael Natterer committed
824
  GDisplay *gdisp;
825 826
  return_if_no_display (gdisp);

827
  channel_ops_offset (gdisp->gimage);
Elliot Lee's avatar
Elliot Lee committed
828 829 830 831
}

void
image_resize_cmd_callback (GtkWidget *widget,
832
			   gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
833
{
Michael Natterer's avatar
Michael Natterer committed
834 835 836
  GDisplay    *gdisp;
  GimpImage   *gimage;
  ImageResize *image_resize;
Elliot Lee's avatar
Elliot Lee committed
837

838
  return_if_no_display (gdisp);
839 840

  gimage = gdisp->gimage;
Elliot Lee's avatar
Elliot Lee committed
841 842

  /*  the ImageResize structure  */
843
  image_resize = g_new (ImageResize, 1);
844 845 846 847
  image_resize->gimage = gimage;
  image_resize->resize = resize_widget_new (ResizeWidget,
					    ResizeImage,
					    GTK_OBJECT (gimage),
848
					    "destroy",
849 850 851 852
					    gimage->width,
					    gimage->height,
					    gimage->xresolution,
					    gimage->yresolution,
853 854
					    gimage->unit,
					    gdisp->dot_for_dot,
855
					    image_resize_callback,
856
					    NULL,
857
					    image_resize);
858

859 860 861 862 863
  gtk_signal_connect_object (GTK_OBJECT (image_resize->resize->resize_shell),
			     "destroy",
			     GTK_SIGNAL_FUNC (g_free),
			     (GtkObject *) image_resize);

864
  gtk_widget_show (image_resize->resize->resize_shell);
Elliot Lee's avatar
Elliot Lee committed
865 866 867 868
}

void
image_scale_cmd_callback (GtkWidget *widget,
869
			  gpointer   client_data)
Elliot Lee's avatar
Elliot Lee committed
870
{
Michael Natterer's avatar
Michael Natterer committed
871 872 873
  GDisplay    *gdisp;
  GimpImage   *gimage;
  ImageResize *image_scale;
Elliot Lee's avatar
Elliot Lee committed
874

875
  return_if_no_display (gdisp);
876 877

  gimage = gdisp->gimage;
Elliot Lee's avatar
Elliot Lee committed
878 879

  /*  the ImageResize structure  */
880
  image_scale = g_new (ImageResize, 1);
881 882 883 884
  image_scale->gimage = gimage;
  image_scale->resize = resize_widget_new (ScaleWidget,
					   ResizeImage,
					   GTK_OBJECT (gimage),
885
					   "destroy",
886 887 888 889
					   gimage->width,
					   gimage->height,
					   gimage->xresolution,
					   gimage->yresolution,
890 891
					   gimage->unit,
					   gdisp->dot_for_dot,
892
					   image_scale_callback,
893
					   NULL,
894
					   image_scale);
Elliot Lee's avatar
Elliot Lee committed
895

896 897 898 899 900
  gtk_signal_connect_object (GTK_OBJECT (image_scale->resize->resize_shell),
			     "destroy",
			     GTK_SIGNAL_FUNC (g_free),
			     (GtkObject *) image_scale);

901
  gtk_widget_show (image_scale->resize->resize_shell);
Elliot Lee's avatar
Elliot Lee committed
902 903
}

904 905 906 907
void
image_duplicate_cmd_callback (GtkWidget *widget,
			      gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
908
  GDisplay *gdisp;
909 910 911 912 913 914 915
  return_if_no_display (gdisp);

  channel_ops_duplicate (gdisp->gimage);
}

/*****  Layers  *****/

916 917 918 919
void
layers_previous_cmd_callback (GtkWidget *widget,
			      gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
920 921 922
  GDisplay *gdisp;
  Layer    *new_layer;
  gint      current_layer;
923

924
  return_if_no_display (gdisp);
925 926

  current_layer =
927
    gimp_image_get_layer_index (gdisp->gimage, gdisp->gimage->active_layer);
928

929
  new_layer = gimp_image_get_layer_by_index (gdisp->gimage, current_layer - 1);
930 931 932

  if (new_layer)
    {
933
      gimp_image_set_active_layer (gdisp->gimage, new_layer);
934
      gdisplays_flush ();
935
      layer_select_init (gdisp->gimage, 0, GDK_CURRENT_TIME);
936 937 938 939 940 941 942
    }
}

void
layers_next_cmd_callback (GtkWidget *widget,
			  gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
943 944 945
  GDisplay *gdisp;
  Layer    *new_layer;
  gint      current_layer;
946

947
  return_if_no_display (gdisp);
948 949

  current_layer =
950
    gimp_image_get_layer_index (gdisp->gimage, gdisp->gimage->active_layer);
951

952
  new_layer = gimp_image_get_layer_by_index (gdisp->gimage, current_layer + 1);
953 954 955

  if (new_layer)
    {
956
      gimp_image_set_active_layer (gdisp->gimage, new_layer);
957
      gdisplays_flush ();
958
      layer_select_init (gdisp->gimage, 0, GDK_CURRENT_TIME);
959 960 961
    }
}

Elliot Lee's avatar
Elliot Lee committed
962 963 964 965
void
layers_raise_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
966
  GDisplay *gdisp;
967
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
968

969
  gimp_image_raise_layer (gdisp->gimage, gdisp->gimage->active_layer);
Elliot Lee's avatar
Elliot Lee committed
970 971 972 973 974 975 976
  gdisplays_flush ();
}

void
layers_lower_cmd_callback (GtkWidget *widget,
			   gpointer   client_data)
{
Michael Natterer's avatar
Michael Natterer committed
977
  GDisplay *gdisp;
978
  return_if_no_display (gdisp);
Elliot Lee's avatar
Elliot Lee committed
979

980
  gimp_image_lower_layer (gdisp->gimage, gdisp->gimage->active_layer);
Elliot Lee's avatar
Elliot Lee committed
981 982 983
  gdisplays_flush ();
}