gimpdisplayshell-draw.c 36.3 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
 */
Tor Lillqvist's avatar
Tor Lillqvist committed
18
19
#include "config.h"

20
#include <string.h>
Elliot Lee's avatar
Elliot Lee committed
21
22
23
24
#include "appenv.h"
#include "app_procs.h"
#include "color_area.h"
#include "commands.h"
25
#include "devices.h"
Tor Lillqvist's avatar
Tor Lillqvist committed
26
#include "dialog_handler.h"
Elliot Lee's avatar
Elliot Lee committed
27
#include "disp_callbacks.h"
28
#include "fileops.h"
Elliot Lee's avatar
Elliot Lee committed
29
30
31
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "gimage.h"
32
#include "gimpdnd.h"
33
#include "gimphelp.h"
Elliot Lee's avatar
Elliot Lee committed
34
#include "gimprc.h"
35
#include "gimpui.h"
Manish Singh's avatar
Manish Singh committed
36
#include "gtkhwrapbox.h"
Manish Singh's avatar
Manish Singh committed
37
#include "gtkvwrapbox.h"
38
#include "indicator_area.h"
Elliot Lee's avatar
Elliot Lee committed
39
40
#include "interface.h"
#include "menus.h"
41
#include "nav_window.h"
42
#include "qmask.h"
43
#include "session.h"
Elliot Lee's avatar
Elliot Lee committed
44
45
46
#include "tools.h"

#include "pixmaps.h"
47
48
#include "pixmaps/qmasksel.xpm"
#include "pixmaps/qmasknosel.xpm"
49
#include "pixmaps/navbutton.xpm"
Elliot Lee's avatar
Elliot Lee committed
50

51
52
#include "libgimp/gimpintl.h"

53

Elliot Lee's avatar
Elliot Lee committed
54
/*  local functions  */
55
56
57
static void  tools_select_update   (GtkWidget      *widget,
				    gpointer        data);
static gint  tools_button_press    (GtkWidget      *widget,
Elliot Lee's avatar
Elliot Lee committed
58
				    GdkEventButton *bevent,
59
60
61
				    gpointer        data);
static void  gdisplay_destroy      (GtkWidget      *widget,
				    GDisplay       *display);
Elliot Lee's avatar
Elliot Lee committed
62

63
64
65
static gint  gdisplay_delete       (GtkWidget      *widget,
				    GdkEvent       *event,
				    GDisplay       *display);
Elliot Lee's avatar
Elliot Lee committed
66
67

static void  toolbox_destroy       (void);
68
69
70
71
72
73
74
75
76
77
78
79
static gint  toolbox_delete        (GtkWidget      *widget,
				    GdkEvent       *event,
				    gpointer        data);
static gint  toolbox_check_device  (GtkWidget      *widget,
				    GdkEvent       *event,
				    gpointer        data);

static GdkPixmap *create_pixmap    (GdkWindow      *parent,
				    GdkBitmap     **mask,
				    gchar         **data,
				    gint            width,
				    gint            height);
80
81
82
83
84
85
86
87
88
89
90
91
92
93

static void     toolbox_set_drag_dest      (GtkWidget *);
static void     toolbox_drag_data_received (GtkWidget *,
					    GdkDragContext *,
					    gint,
					    gint,
					    GtkSelectionData *,
					    guint,
					    guint);
static gboolean toolbox_drag_drop          (GtkWidget *,
					    GdkDragContext *,
					    gint,
					    gint,
					    guint);
94
95
static ToolType toolbox_drag_tool          (GtkWidget *,
					    gpointer);
Michael Natterer's avatar
Michael Natterer committed
96
97
98
static void     toolbox_drop_tool          (GtkWidget *,
					    ToolType,
					    gpointer);
99
static void     gimp_dnd_open_files        (gchar *);
Elliot Lee's avatar
Elliot Lee committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113

static int pixmap_colors[8][3] =
{
  { 0x00, 0x00, 0x00 }, /* a - 0   */
  { 0x24, 0x24, 0x24 }, /* b - 36  */
  { 0x49, 0x49, 0x49 }, /* c - 73  */
  { 0x6D, 0x6D, 0x6D }, /* d - 109 */
  { 0x92, 0x92, 0x92 }, /* e - 146 */
  { 0xB6, 0xB6, 0xB6 }, /* f - 182 */
  { 0xDB, 0xDB, 0xDB }, /* g - 219 */
  { 0xFF, 0xFF, 0xFF }, /* h - 255 */
};

#define COLUMNS   3
114
#define ROWS      8
Elliot Lee's avatar
Elliot Lee committed
115
116
#define MARGIN    2

117
/*  local variables  */
118
static GdkColor    colors[11];
119
static GtkWidget * toolbox_shell = NULL;
Elliot Lee's avatar
Elliot Lee committed
120

121
static GtkTargetEntry toolbox_target_table[] =
122
{
123
124
125
126
127
  GIMP_TARGET_URI_LIST,
  GIMP_TARGET_TEXT_PLAIN,
  GIMP_TARGET_NETSCAPE_URL,
  GIMP_TARGET_LAYER,
  GIMP_TARGET_CHANNEL,
Michael Natterer's avatar
Michael Natterer committed
128
129
  GIMP_TARGET_LAYER_MASK,
  GIMP_TARGET_TOOL
130
};
131
132
static guint toolbox_n_targets = (sizeof (toolbox_target_table) /
				  sizeof (toolbox_target_table[0]));
133

134
135
136
137
138
139
140
static GtkTargetEntry tool_target_table[] =
{
  GIMP_TARGET_TOOL
};
static guint tool_n_targets = (sizeof (tool_target_table) /
			       sizeof (tool_target_table[0]));

141
142
143
144
static GtkTargetEntry display_target_table[] =
{
  GIMP_TARGET_LAYER,
  GIMP_TARGET_CHANNEL,
145
  GIMP_TARGET_LAYER_MASK,
Sven Neumann's avatar
Sven Neumann committed
146
147
  GIMP_TARGET_COLOR,
  GIMP_TARGET_PATTERN
148
149
150
};
static guint display_n_targets = (sizeof (display_target_table) /
				  sizeof (display_target_table[0]));
151

Elliot Lee's avatar
Elliot Lee committed
152
static void
153
tools_select_update (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
154
155
156
157
158
159
		     gpointer   data)
{
  ToolType tool_type;

  tool_type = (ToolType) data;

160
  if ((tool_type != -1) && GTK_TOGGLE_BUTTON (widget)->active)
161
    gimp_context_set_tool (gimp_context_get_user (), tool_type);
Elliot Lee's avatar
Elliot Lee committed
162
163
164
}

static gint
165
tools_button_press (GtkWidget      *widget,
Elliot Lee's avatar
Elliot Lee committed
166
167
168
		    GdkEventButton *event,
		    gpointer        data)
{
169
170
171
  GDisplay * gdisp;
  gdisp = data;
 
172
173
  if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
    tool_options_dialog_show ();
Elliot Lee's avatar
Elliot Lee committed
174
175
176
177
178

  return FALSE;
}

static gint
179
180
toolbox_delete (GtkWidget *widget,
		GdkEvent  *event,
181
		gpointer   data)
182
{
183
  app_exit (FALSE);
Elliot Lee's avatar
Elliot Lee committed
184

185
  return TRUE;
Elliot Lee's avatar
Elliot Lee committed
186
187
188
}

static void
Manish Singh's avatar
Manish Singh committed
189
toolbox_destroy (void)
190
191
{
  app_exit_finish ();
Elliot Lee's avatar
Elliot Lee committed
192
193
}

194
static gint
195
196
toolbox_check_device (GtkWidget *widget,
		      GdkEvent  *event,
197
		      gpointer   data)
198
{
199
  devices_check_change (event);
200

201
202
203
  return FALSE;
}

Elliot Lee's avatar
Elliot Lee committed
204
static void
205
gdisplay_destroy (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
206
207
208
209
210
211
		  GDisplay  *gdisp)
{
  gdisplay_remove_and_delete (gdisp);
}

static gint
212
213
gdisplay_delete (GtkWidget *widget,
		 GdkEvent  *event,
214
		 GDisplay  *gdisp)
Elliot Lee's avatar
Elliot Lee committed
215
216
217
{
  gdisplay_close_window (gdisp, FALSE);

218
  return TRUE;
Elliot Lee's avatar
Elliot Lee committed
219
220
221
222
223
224
}

static void
allocate_colors (GtkWidget *parent)
{
  GdkColormap *colormap;
225
  gint i;
Elliot Lee's avatar
Elliot Lee committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248

  gtk_widget_realize (parent);
  colormap = gdk_window_get_colormap (parent->window);

  for (i = 0; i < 8; i++)
    {
      colors[i].red = pixmap_colors[i][0] << 8;
      colors[i].green = pixmap_colors[i][1] << 8;
      colors[i].blue = pixmap_colors[i][2] << 8;

      gdk_color_alloc (colormap, &colors[i]);
    }

  colors[8] = parent->style->bg[GTK_STATE_NORMAL];
  gdk_color_alloc (colormap, &colors[8]);

  colors[9] = parent->style->bg[GTK_STATE_ACTIVE];
  gdk_color_alloc (colormap, &colors[9]);

  colors[10] = parent->style->bg[GTK_STATE_PRELIGHT];
  gdk_color_alloc (colormap, &colors[10]);
}

249
250
251
252
253
254
255
256
257
258
259
static void
create_indicator_area (GtkWidget *parent)
{
  GtkWidget *frame;
  GtkWidget *alignment;
  GtkWidget *ind_area;

  gtk_widget_realize (parent);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
260
  gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
261
262
263
264
265
266
  gtk_widget_realize (frame);

  alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
  gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
  gtk_container_add (GTK_CONTAINER (frame), alignment);

267
268
  gimp_help_set_help_data (alignment, NULL, "#indicator_area");

269
  ind_area = indicator_area_create ();
270
271
272
273
274
275
  gtk_container_add (GTK_CONTAINER (alignment), ind_area);
  gtk_widget_show (ind_area);
  gtk_widget_show (alignment);
  gtk_widget_show (frame);
}

Elliot Lee's avatar
Elliot Lee committed
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
static void
create_color_area (GtkWidget *parent)
{
  GtkWidget *frame;
  GtkWidget *alignment;
  GtkWidget *col_area;
  GdkPixmap *default_pixmap;
  GdkPixmap *swap_pixmap;

  gtk_widget_realize (parent);

  default_pixmap = create_pixmap (parent->window, NULL, default_bits,
				  default_width, default_height);
  swap_pixmap    = create_pixmap (parent->window, NULL, swap_bits,
				  swap_width, swap_height);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
294
295
  gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
  gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
Elliot Lee's avatar
Elliot Lee committed
296
297
298
  gtk_widget_realize (frame);

  alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
299
  gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
Elliot Lee's avatar
Elliot Lee committed
300
301
  gtk_container_add (GTK_CONTAINER (frame), alignment);

302
303
  gimp_help_set_help_data (alignment, NULL, "#color_area");

Elliot Lee's avatar
Elliot Lee committed
304
305
  col_area = color_area_create (54, 42, default_pixmap, swap_pixmap);
  gtk_container_add (GTK_CONTAINER (alignment), col_area);
306
307
308
309
310
  gimp_help_set_help_data
    (col_area,
     _("Foreground & background colors.  The black "
       "and white squares reset colors.  The arrows swap colors. Double "
       "click to select a color from a colorrequester."), NULL);
Elliot Lee's avatar
Elliot Lee committed
311
312
313
314
315
  gtk_widget_show (col_area);
  gtk_widget_show (alignment);
  gtk_widget_show (frame);
}

316
317
318
/* creates all icons */
static void
create_tool_pixmaps (GtkWidget *parent)
319
{
320
321
322
  gint i;

  g_return_if_fail (parent != NULL);
323

324
325
  for (i = 0; i < num_tools; i++)
    {
326
      if (tool_info[i].icon_data)
327
	tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL,
328
						  tool_info[i].icon_data,
329
330
331
332
333
334
335
						  22, 22);
      
      else
	tool_info[i].icon_pixmap = create_pixmap (parent->window, NULL,
						  dialog_bits,
						  22, 22);
    }
336
337
}

Elliot Lee's avatar
Elliot Lee committed
338
339
340
static void
create_tools (GtkWidget *parent)
{
Manish Singh's avatar
Manish Singh committed
341
  GtkWidget *wbox;
Elliot Lee's avatar
Elliot Lee committed
342
343
344
345
  GtkWidget *button;
  GtkWidget *alignment;
  GtkWidget *pixmap;
  GSList *group;
346
  gint i, j;
Elliot Lee's avatar
Elliot Lee committed
347

348
  wbox = parent;
Manish Singh's avatar
Manish Singh committed
349
350

  gtk_widget_realize (gtk_widget_get_toplevel (wbox));
351
352
  
  create_tool_pixmaps (wbox);
Elliot Lee's avatar
Elliot Lee committed
353
354
355

  group = NULL;

356
357
  i = 0;
  for (j = 0; j < num_tools; j++)
Elliot Lee's avatar
Elliot Lee committed
358
    {
359
360
      if (j <= LAST_TOOLBOX_TOOL &&
	  j != SCALE && j!= SHEAR && j != PERSPECTIVE)
361
362
	{
	  tool_info[j].tool_widget = button = gtk_radio_button_new (group);
363
	  gtk_container_set_border_width (GTK_CONTAINER (button), 0);
364
	  group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
365

366
	  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
367

Manish Singh's avatar
Manish Singh committed
368
	  gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
369
			     FALSE, FALSE, FALSE, FALSE);
370
371

	  alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
372
	  gtk_container_set_border_width (GTK_CONTAINER (alignment), 0);
373
	  gtk_container_add (GTK_CONTAINER (button), alignment);
374

375
	  pixmap = gtk_pixmap_new (tool_get_pixmap ((ToolType)j), NULL);
376
	  gtk_container_add (GTK_CONTAINER (alignment), pixmap);
377

378
	  gtk_signal_connect (GTK_OBJECT (button), "toggled",
379
			      GTK_SIGNAL_FUNC (tools_select_update),
380
			      (gpointer) tool_info[j].tool_id);
381

382
	  gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
383
			      GTK_SIGNAL_FUNC (tools_button_press),
384
			      (gpointer) tool_info[j].tool_id);
385

386
387
388
389
390
391
392
393
394
395
396
	  /*  dnd stuff  */
	  gtk_drag_source_set (tool_info[j].tool_widget,
			       GDK_BUTTON2_MASK,
			       tool_target_table, tool_n_targets,
			       GDK_ACTION_COPY);
	  gimp_dnd_tool_source_set (tool_info[j].tool_widget,
				    toolbox_drag_tool, (gpointer) j);

	  gimp_help_set_help_data (button,
				   gettext(tool_info[j].tool_desc),
				   tool_info[j].private_tip);
397

398
399
400
401
402
	  gtk_widget_show (pixmap);
	  gtk_widget_show (alignment);
	  gtk_widget_show (button);
	  i++;
	}
403
      else
404
405
406
	{
	  tool_info[j].tool_widget = button = gtk_radio_button_new (group);
	  group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
Elliot Lee's avatar
Elliot Lee committed
407

408
	  gtk_signal_connect (GTK_OBJECT (button), "clicked",
409
			      GTK_SIGNAL_FUNC (tools_select_update),
410
411
			      (gpointer) tool_info[j].tool_id);
	}
412
    }
Manish Singh's avatar
Manish Singh committed
413
  gtk_widget_show (wbox);
Elliot Lee's avatar
Elliot Lee committed
414
415
416
}

static GdkPixmap *
417
418
419
420
421
create_pixmap (GdkWindow  *parent,
	       GdkBitmap **mask,
	       gchar     **data,
	       gint        width,
	       gint        height)
Elliot Lee's avatar
Elliot Lee committed
422
423
424
425
426
427
428
429
430
431
432
433
434
{
  GdkPixmap *pixmap;
  GdkImage *image;
  GdkGC *gc;
  GdkVisual *visual;
  GdkColormap *cmap;
  gint r, s, t, cnt;
  guchar *mem;
  guchar value;
  guint32 pixel;

  visual = gdk_window_get_visual (parent);
  cmap = gdk_window_get_colormap (parent);
435
  image = gdk_image_new (GDK_IMAGE_NORMAL, visual, width, height);
Elliot Lee's avatar
Elliot Lee committed
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
  pixmap = gdk_pixmap_new (parent, width, height, -1);
  gc = NULL;

  if (mask)
    {
      GdkColor tmp_color;

      *mask = gdk_pixmap_new (parent, width, height, 1);
      gc = gdk_gc_new (*mask);
      gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);

      tmp_color.pixel = 1;
      gdk_gc_set_foreground (gc, &tmp_color);
    }

  for (r = 0; r < height; r++)
    {
      mem = image->mem;
      mem += image->bpl * r;

      for (s = 0, cnt = 0; s < width; s++)
	{
	  value = data[r][s];

	  if (value == '.')
	    {
	      pixel = colors[8].pixel;

	      if (mask)
		{
		  if (cnt < s)
		    gdk_draw_line (*mask, gc, cnt, r, s - 1, r);
		  cnt = s + 1;
		}
	    }
	  else
	    {
	      pixel = colors[value - 'a'].pixel;
	    }

	  if (image->byte_order == GDK_LSB_FIRST)
	    {
	      for (t = 0; t < image->bpp; t++)
		*mem++ = (unsigned char) ((pixel >> (t * 8)) & 0xFF);
	    }
	  else
	    {
	      for (t = 0; t < image->bpp; t++)
		*mem++ = (unsigned char) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
	    }
	}

      if (mask && (cnt < s))
	gdk_draw_line (*mask, gc, cnt, r, s - 1, r);
    }

  if (mask)
    gdk_gc_destroy (gc);

  gc = gdk_gc_new (parent);
  gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, width, height);
  gdk_gc_destroy (gc);
  gdk_image_destroy (image);

  return pixmap;
}


void
Manish Singh's avatar
Manish Singh committed
505
create_toolbox (void)
Elliot Lee's avatar
Elliot Lee committed
506
507
508
{
  GtkWidget *window;
  GtkWidget *main_vbox;
Manish Singh's avatar
Manish Singh committed
509
  GtkWidget *wbox;
Elliot Lee's avatar
Elliot Lee committed
510
  GtkWidget *menubar;
511
  GList *list;
512
  GtkAccelGroup *table;
Elliot Lee's avatar
Elliot Lee committed
513
514

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
515
516

  /* Register dialog */
517
  dialog_register_toolbox (window);
518

519
  gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
520
  gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
521
  gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
522
  session_set_window_geometry (window, &toolbox_session_info, TRUE);
Elliot Lee's avatar
Elliot Lee committed
523
524
525
526
527
  gtk_signal_connect (GTK_OBJECT (window), "delete_event",
		      GTK_SIGNAL_FUNC (toolbox_delete),
		      NULL);

  gtk_signal_connect (GTK_OBJECT (window), "destroy",
528
		      GTK_SIGNAL_FUNC (toolbox_destroy),
Elliot Lee's avatar
Elliot Lee committed
529
530
		      NULL);

531
532
533
534
535
536
537
  /* We need to know when the current device changes, so we can update
   * the correct tool - to do this we connect to motion events.
   * We can't just use EXTENSION_EVENTS_CURSOR though, since that
   * would get us extension events for the mouse pointer, and our
   * device would change to that and not change back. So we check
   * manually that all devices have a cursor, before establishing the check.
   */
538
  for (list = gdk_input_list_devices (); list; list = g_list_next (list))
539
    {
540
      if (!((GdkDeviceInfo *) (list->data))->has_cursor)
541
542
543
	break;
    }

544
  if (!list)  /* all devices have cursor */
545
546
    {
      gtk_signal_connect (GTK_OBJECT (window), "motion_notify_event",
547
548
			  GTK_SIGNAL_FUNC (toolbox_check_device),
			  NULL);
549

550
551
552
553
      gtk_widget_set_events (window, GDK_POINTER_MOTION_MASK);
      gtk_widget_set_extension_events (window, GDK_EXTENSION_EVENTS_CURSOR);
    }

Elliot Lee's avatar
Elliot Lee committed
554
  main_vbox = gtk_vbox_new (FALSE, 1);
555
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
Elliot Lee's avatar
Elliot Lee committed
556
557
558
559
560
561
562
  gtk_container_add (GTK_CONTAINER (window), main_vbox);
  gtk_widget_show (main_vbox);

  /*  allocate the colors for creating pixmaps  */
  allocate_colors (main_vbox);

  /*  tooltips  */
563
  gimp_help_init ();
Manish Singh's avatar
Manish Singh committed
564
  if (!show_tool_tips)
565
    gimp_help_disable_tooltips ();
Elliot Lee's avatar
Elliot Lee committed
566
567
568
569
570
571
572

  /*  Build the menu bar with menus  */
  menus_get_toolbox_menubar (&menubar, &table);
  gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
  gtk_widget_show (menubar);

  /*  Install the accelerator table in the main window  */
573
  gtk_window_add_accel_group (GTK_WINDOW (window), table);
Elliot Lee's avatar
Elliot Lee committed
574

575
576
577
  /*  Connect the "F1" help key  */
  gimp_help_connect_help_accel (window,
				gimp_standard_help_func,
Michael Natterer's avatar
Michael Natterer committed
578
				"toolbox/toolbox.html");
579

580
581
582
  wbox = gtk_hwrap_box_new (FALSE);
  gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_TOP);
  gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_LEFT);
583
  gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), 252.0 / 136.0);  /*  9x3 tools  */
Manish Singh's avatar
Manish Singh committed
584
585
586
  gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
  gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
  gtk_widget_show (wbox);
Elliot Lee's avatar
Elliot Lee committed
587

Manish Singh's avatar
Manish Singh committed
588
  create_tools (wbox);
589

Manish Singh's avatar
Manish Singh committed
590
  create_color_area (wbox);
591
  if (show_indicators)
592
    create_indicator_area (wbox);
593

594
  gtk_widget_show (window);
595
  toolbox_set_drag_dest (window);
596

Elliot Lee's avatar
Elliot Lee committed
597
598
599
  toolbox_shell = window;
}

600
void
Manish Singh's avatar
Manish Singh committed
601
toolbox_free (void)
602
{
603
  gint i;
604

605
  session_get_window_info (toolbox_shell, &toolbox_session_info);
606

607
  gtk_widget_destroy (toolbox_shell);
608
  for (i = 0; i < num_tools; i++)
609
    {
610
611
612
      if (tool_info[i].icon_pixmap)
	gdk_pixmap_unref (tool_info[i].icon_pixmap);
      
613
      if (!tool_info[i].icon_data)
614
	gtk_object_sink (GTK_OBJECT (tool_info[i].tool_widget));
615
    }
616
  gimp_help_free ();
617
618
}

Elliot Lee's avatar
Elliot Lee committed
619
620
621
622
void
toolbox_raise_callback (GtkWidget *widget,
			gpointer  client_data)
{
623
  gdk_window_raise (toolbox_shell->window);
Elliot Lee's avatar
Elliot Lee committed
624
625
626
}

void
627
create_display_shell (GDisplay* gdisp,
628
629
630
631
		      gint      width,
		      gint      height,
		      gchar    *title,
		      gint      type)
Elliot Lee's avatar
Elliot Lee committed
632
633
{
  static GtkWidget *image_popup_menu = NULL;
634
  static GtkAccelGroup *image_accel_group = NULL;
635
636
637
638
639
640
641

  static GdkPixmap *qmasksel_pixmap   = NULL;
  static GdkBitmap *qmasksel_mask     = NULL;
  static GdkPixmap *qmasknosel_pixmap = NULL;
  static GdkBitmap *qmasknosel_mask   = NULL;
  static GdkPixmap *navbutton_pixmap  = NULL;
  static GdkBitmap *navbutton_mask    = NULL;
642
  
643
  GtkWidget *vbox;
Elliot Lee's avatar
Elliot Lee committed
644
  GtkWidget *table;
645
  GtkWidget *table_inner;
646
  GtkWidget *table_lower;
647
  GtkWidget *frame;
648
  GtkWidget *arrow;
649
  GtkWidget *pixmap;
650
651
  GtkWidget *evbox;
  GtkWidget *navhbox;
652
653
654

  GSList *group = NULL;

655
656
657
658
  gint n_width, n_height;
  gint s_width, s_height;
  gint scalesrc, scaledest;
  gint contextid;
Elliot Lee's avatar
Elliot Lee committed
659
660

  {
661
    /*  adjust the initial scale -- so that window fits on screen */
662
    s_width  = gdk_screen_width ();
Elliot Lee's avatar
Elliot Lee committed
663
664
    s_height = gdk_screen_height ();

665
666
    scalesrc  = SCALESRC (gdisp);
    scaledest = SCALEDEST (gdisp);
Elliot Lee's avatar
Elliot Lee committed
667

668
669
    n_width  = SCALEX (gdisp, width);
    n_height = SCALEX (gdisp, height);
Elliot Lee's avatar
Elliot Lee committed
670
671
672
673
674
675
676
677
678
679

    /*  Limit to the size of the screen...  */
    while (n_width > s_width || n_height > s_height)
      {
	if (scaledest > 1)
	  scaledest--;
	else
	  if (scalesrc < 0xff)
	    scalesrc++;

680
681
682
683
	n_width  = width * 
	  (scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
	n_height = height *
	  (scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
Elliot Lee's avatar
Elliot Lee committed
684
685
686
687
688
689
690
691
692
693
694
      }

    gdisp->scale = (scaledest << 8) + scalesrc;
  }

  /*  The adjustment datums  */
  gdisp->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
  gdisp->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));

  /*  The toplevel shell */
  gdisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
695
  gtk_widget_ref  (gdisp->shell);
Elliot Lee's avatar
Elliot Lee committed
696
  gtk_window_set_title (GTK_WINDOW (gdisp->shell), title);
697
  gtk_window_set_wmclass (GTK_WINDOW (gdisp->shell), "image_window", "Gimp");
Elliot Lee's avatar
Elliot Lee committed
698
699
  gtk_window_set_policy (GTK_WINDOW (gdisp->shell), TRUE, TRUE, TRUE);
  gtk_object_set_user_data (GTK_OBJECT (gdisp->shell), (gpointer) gdisp);
700
701
702
703
704
705
  gtk_widget_set_events (gdisp->shell,
			 GDK_POINTER_MOTION_MASK |
			 GDK_POINTER_MOTION_HINT_MASK |
			 GDK_BUTTON_PRESS_MASK |
			 GDK_KEY_PRESS_MASK |
			 GDK_KEY_RELEASE_MASK);
Elliot Lee's avatar
Elliot Lee committed
706
707
708
709
  gtk_signal_connect (GTK_OBJECT (gdisp->shell), "delete_event",
		      GTK_SIGNAL_FUNC (gdisplay_delete),
		      gdisp);
  gtk_signal_connect (GTK_OBJECT (gdisp->shell), "destroy",
710
		      GTK_SIGNAL_FUNC (gdisplay_destroy),
Elliot Lee's avatar
Elliot Lee committed
711
712
		      gdisp);

713
  /*  active display callback  */
714
  gtk_signal_connect (GTK_OBJECT (gdisp->shell), "button_press_event",
715
		      GTK_SIGNAL_FUNC (gdisplay_shell_events),
716
717
		      gdisp);
  gtk_signal_connect (GTK_OBJECT (gdisp->shell), "key_press_event",
718
		      GTK_SIGNAL_FUNC (gdisplay_shell_events),
719
720
		      gdisp);

721
722
723
724
725
726
727
728
  /*  dnd stuff  */
  gtk_drag_dest_set (gdisp->shell,
		     GTK_DEST_DEFAULT_ALL,
		     display_target_table, display_n_targets,
		     GDK_ACTION_COPY);
  gtk_signal_connect (GTK_OBJECT (gdisp->shell), "drag_drop",
		      GTK_SIGNAL_FUNC (gdisplay_drag_drop),
		      gdisp);
Michael Natterer's avatar
Michael Natterer committed
729
730
  gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
  gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
731

732
  /*  the vbox, table containing all widgets  */
733
734
735
  vbox = gtk_vbox_new (FALSE, 2);
  gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
736
737

  /*  the table widget is pretty stupid so we need 2 tables
738
      or it treats rulers and canvas with equal weight when
739
740
      allocating space, ugh. */
  table = gtk_table_new (2, 2, FALSE);
Elliot Lee's avatar
Elliot Lee committed
741
742
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
743
  gtk_box_pack_start(GTK_BOX (vbox), table, TRUE, TRUE, 0);
744
745

  table_inner = gtk_table_new (2, 2, FALSE);
CDT 1998 Shawn T. Amundson's avatar
CDT 1998 Shawn T. Amundson committed
746
747
  gtk_table_set_col_spacing (GTK_TABLE (table_inner), 0, 1);
  gtk_table_set_row_spacing (GTK_TABLE (table_inner), 0, 1);
748

749
  table_lower = gtk_table_new (1,4,FALSE);
750
  gtk_table_set_col_spacing (GTK_TABLE (table_lower), 0, 1);
751
752
753
754
755
756
757
758
  /* gtk_table_set_row_spacing (GTK_TABLE (table_lower), 0, 1); */

  /*  hbox for statusbar area  */
  evbox = gtk_event_box_new ();
  gtk_box_pack_start (GTK_BOX (vbox), evbox, FALSE, TRUE, 0);
  gtk_widget_show (evbox);

  gimp_help_set_help_data (evbox, NULL, "#status_area");
Elliot Lee's avatar
Elliot Lee committed
759

760
  gdisp->statusarea = gtk_hbox_new (FALSE, 2);
761
  gtk_container_add (GTK_CONTAINER (evbox), gdisp->statusarea);
762

Elliot Lee's avatar
Elliot Lee committed
763
  /*  scrollbars, rulers, canvas, menu popup button  */
764
  gdisp->origin = gtk_button_new ();
765
  GTK_WIDGET_UNSET_FLAGS (gdisp->origin, GTK_CAN_FOCUS);
766
767
768
  gtk_widget_set_events (GTK_WIDGET (gdisp->origin),
			 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
  gtk_signal_connect (GTK_OBJECT (gdisp->origin), "button_press_event",
769
		      GTK_SIGNAL_FUNC (gdisplay_origin_button_press),
770
		      gdisp);
771

772
773
  gimp_help_set_help_data (gdisp->origin, NULL, "#origin_button");

774
  arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
775
  gtk_container_set_border_width (GTK_CONTAINER (gdisp->origin), 0);
776
  gtk_container_add (GTK_CONTAINER (gdisp->origin), arrow);
Elliot Lee's avatar
Elliot Lee committed
777
778
779
780
781

  gdisp->hrule = gtk_hruler_new ();
  gtk_widget_set_events (GTK_WIDGET (gdisp->hrule),
			 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
  gtk_signal_connect_object (GTK_OBJECT (gdisp->shell), "motion_notify_event",
782
			     GTK_SIGNAL_FUNC (GTK_WIDGET_CLASS (GTK_OBJECT (gdisp->hrule)->klass)->motion_notify_event),
Elliot Lee's avatar
Elliot Lee committed
783
784
			     GTK_OBJECT (gdisp->hrule));
  gtk_signal_connect (GTK_OBJECT (gdisp->hrule), "button_press_event",
785
		      GTK_SIGNAL_FUNC (gdisplay_hruler_button_press),
Elliot Lee's avatar
Elliot Lee committed
786
787
		      gdisp);

788
789
  gimp_help_set_help_data (gdisp->hrule, NULL, "#ruler");

Elliot Lee's avatar
Elliot Lee committed
790
791
792
793
  gdisp->vrule = gtk_vruler_new ();
  gtk_widget_set_events (GTK_WIDGET (gdisp->vrule),
			 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
  gtk_signal_connect_object (GTK_OBJECT (gdisp->shell), "motion_notify_event",
794
			     GTK_SIGNAL_FUNC (GTK_WIDGET_CLASS (GTK_OBJECT (gdisp->vrule)->klass)->motion_notify_event),
Elliot Lee's avatar
Elliot Lee committed
795
796
			     GTK_OBJECT (gdisp->vrule));
  gtk_signal_connect (GTK_OBJECT (gdisp->vrule), "button_press_event",
797
		      GTK_SIGNAL_FUNC (gdisplay_vruler_button_press),
Elliot Lee's avatar
Elliot Lee committed
798
799
		      gdisp);

800
801
  gimp_help_set_help_data (gdisp->vrule, NULL, "#ruler");

802
  /* The nav window button */
803
804
805
806
  evbox = gtk_event_box_new ();
  gtk_widget_show (evbox);
  navhbox = gtk_hbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (evbox), navhbox);
807
808
  GTK_WIDGET_UNSET_FLAGS (evbox, GTK_CAN_FOCUS);
  gtk_signal_connect (GTK_OBJECT (evbox), "button_press_event",
809
810
		      GTK_SIGNAL_FUNC (nav_popup_click_handler),
		      gdisp);
811

812
813
  gimp_help_set_help_data (evbox, NULL, "#nav_window_button");

Elliot Lee's avatar
Elliot Lee committed
814
  gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
815
  GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
Elliot Lee's avatar
Elliot Lee committed
816
  gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
817
  GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
Elliot Lee's avatar
Elliot Lee committed
818

819
820
  /* The qmask buttons buttons */
  gdisp->qmaskoff = gtk_radio_button_new (group);
821
822
823
  group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskoff));
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), FALSE);
  gtk_signal_connect (GTK_OBJECT (gdisp->qmaskoff), "toggled",
824
825
		      GTK_SIGNAL_FUNC (qmask_deactivate),
		      gdisp);
826
  gtk_signal_connect (GTK_OBJECT (gdisp->qmaskoff), "button_press_event",
827
828
		      GTK_SIGNAL_FUNC (qmask_click_handler),
		      gdisp);
829

830
831
  gimp_help_set_help_data (gdisp->qmaskoff, NULL, "#qmask_off_button");

832
  gdisp->qmaskon = gtk_radio_button_new (group);
833
834
835
  group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskon));
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskon), FALSE);
  gtk_signal_connect (GTK_OBJECT (gdisp->qmaskon), "toggled",
836
837
		      GTK_SIGNAL_FUNC (qmask_activate),
		      gdisp);
838
  gtk_signal_connect (GTK_OBJECT (gdisp->qmaskon), "button_press_event",
839
840
		      GTK_SIGNAL_FUNC (qmask_click_handler),
		      gdisp);
841

842
843
  gimp_help_set_help_data (gdisp->qmaskon, NULL, "#qmask_on_button");

844
845
846
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), TRUE);
  gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
  gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
847

848
  /* Create pixmaps - note: you must realize the parent prior to doing the
849
     rest! */  
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
  if (!qmasksel_pixmap)
    {
      GtkStyle *style;
      
      gtk_widget_realize (gdisp->shell);
      style = gtk_widget_get_style (gdisp->shell);
      
      qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask,
						      &style->bg[GTK_STATE_NORMAL],
						      qmasksel_xpm);   
      qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask,
							&style->bg[GTK_STATE_NORMAL],
							qmasknosel_xpm);   
      navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask,
						       &style->bg[GTK_STATE_NORMAL],
						       navbutton_xpm);   
    }

  pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask);
  gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap);
  gtk_widget_show (pixmap);

  pixmap = gtk_pixmap_new (qmasknosel_pixmap, qmasknosel_mask);
  gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap);
  gtk_widget_show (pixmap);

  pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask);
  gtk_container_add (GTK_CONTAINER (navhbox), pixmap); 
  gtk_widget_show (pixmap);
879
 
Elliot Lee's avatar
Elliot Lee committed
880
881
882
  gdisp->canvas = gtk_drawing_area_new ();
  gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
  gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
883
  gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
Elliot Lee's avatar
Elliot Lee committed
884
  GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
885
886
887
  gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);

  /* set the active display before doing any other canvas event processing  */
Elliot Lee's avatar
Elliot Lee committed
888
  gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
889
		      GTK_SIGNAL_FUNC (gdisplay_shell_events),
Elliot Lee's avatar
Elliot Lee committed
890
891
		      gdisp);

892
  gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
893
		      GTK_SIGNAL_FUNC (gdisplay_canvas_events),
894
		      gdisp);
Elliot Lee's avatar
Elliot Lee committed
895
896

  /*  pack all the widgets  */
897

898
899
900
  gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1,
		    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
		    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
901
  /* sneak in an extra table here */
902
903
904
  gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1, 
 		    GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); 

905
906
907
908
909
910
911
912
  gtk_table_attach (GTK_TABLE (table_lower), gdisp->hsb, 2, 3, 0, 1,
		    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskoff, 0, 1, 0, 1,
		    GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

  gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskon, 1, 2, 0, 1,
		    GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

913
  gtk_table_attach (GTK_TABLE (table), table_lower, 0, 2, 1, 2,
914
915
		    GTK_FILL | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);

916
917
918
919
  gtk_table_attach (GTK_TABLE (table), gdisp->vsb, 1, 2, 0, 1,
		    GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

  gtk_table_attach (GTK_TABLE (table_inner), gdisp->origin, 0, 1, 0, 1,
Elliot Lee's avatar
Elliot Lee committed
920
		    GTK_FILL, GTK_FILL, 0, 0);
921
  gtk_table_attach (GTK_TABLE (table_inner), gdisp->hrule, 1, 2, 0, 1,
Elliot Lee's avatar
Elliot Lee committed
922
		    GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
923
  gtk_table_attach (GTK_TABLE (table_inner), gdisp->vrule, 0, 1, 1, 2,
Elliot Lee's avatar
Elliot Lee committed
924
		    GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
925
  gtk_table_attach (GTK_TABLE (table_inner), gdisp->canvas, 1, 2, 1, 2,
Elliot Lee's avatar
Elliot Lee committed
926
927
		    GTK_EXPAND | GTK_SHRINK | GTK_FILL,
		    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
928

Elliot Lee's avatar
Elliot Lee committed
929
  if (! image_popup_menu)
930
    menus_get_image_menu (&image_popup_menu, &image_accel_group);
Elliot Lee's avatar
Elliot Lee committed
931

932
933
  gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusarea), 
				 GTK_RESIZE_QUEUE);
934
935

  /* cursor, statusbar, progressbar  */
936
937
938
  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (gdisp->statusarea), frame, FALSE, TRUE, 0);
939

940
  gdisp->cursor_label = gtk_label_new (" ");
941
  gtk_container_add (GTK_CONTAINER (frame), gdisp->cursor_label);
942

943
944
945
  /* we need to realize the cursor_label widget here, so the size gets
     computed correctly */
  gtk_widget_realize (gdisp->cursor_label);
946
947
  gdisplay_resize_cursor_label (gdisp);

948
949
  gdisp->statusbar = gtk_statusbar_new ();
  gtk_widget_set_usize (gdisp->statusbar, 1, -1);
950
951
  gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusbar),
				 GTK_RESIZE_QUEUE);
952
953
  gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->statusbar,
		      TRUE, TRUE, 0);
954
955
  contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
					    "title");
956
957
958
  gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar),
		      contextid,
		      title);
959

960
  gdisp->progressbar = gtk_progress_bar_new ();
961
  gtk_widget_set_usize (gdisp->progressbar, 80, -1);
962
963
  gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->progressbar,
		      FALSE, TRUE, 0);
964

965
  gdisp->cancelbutton = gtk_button_new_with_label(_("Cancel"));
966
967
  gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton,
		      FALSE, TRUE, 0);
968
  gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
969

970
  /*  the popup menu  */
Elliot Lee's avatar
Elliot Lee committed
971
972
  gdisp->popup = image_popup_menu;

973
  /*  The accelerator table for images  */
974
  gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
Elliot Lee's avatar
Elliot Lee committed
975

976
977
978
  /*  Connect the "F1" help key  */
  gimp_help_connect_help_accel (gdisp->shell,
				gimp_standard_help_func,
Michael Natterer's avatar
Michael Natterer committed
979
				"image/image_window.html");
980

981
  gtk_widget_show (arrow);
982
983
  gtk_widget_show (gdisp->qmaskon);
  gtk_widget_show (gdisp->qmaskoff);
984
  gtk_widget_show (navhbox);
985

Elliot Lee's avatar
Elliot Lee committed
986
987
  gtk_widget_show (gdisp->hsb);
  gtk_widget_show (gdisp->vsb);
988

989
990
991
992
993
994
  if (show_rulers)
    {
      gtk_widget_show (gdisp->origin);
      gtk_widget_show (gdisp->hrule);
      gtk_widget_show (gdisp->vrule);
    }
995

Elliot Lee's avatar
Elliot Lee committed
996
  gtk_widget_show (gdisp->canvas);
997
998
  gtk_widget_show (frame);
  gtk_widget_show (gdisp->cursor_label);
999
1000
  gtk_widget_show (gdisp->statusbar);
  gtk_widget_show (gdisp->progressbar);
1001
  gtk_widget_show (gdisp->cancelbutton);
1002
1003
  
  gtk_widget_show (table_lower);
1004
  gtk_widget_show (table_inner);
Elliot Lee's avatar
Elliot Lee committed
1005
  gtk_widget_show (table);
1006
1007
1008
1009
  if (show_statusbar)
    {
      gtk_widget_show (gdisp->statusarea);
    }
1010
  gtk_widget_show (vbox);
Elliot Lee's avatar
Elliot Lee committed
1011

1012
  gtk_widget_show (gdisp->shell);