about-dialog.c 18.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* 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
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
18
19
20

#include "config.h"

Elliot Lee's avatar
Elliot Lee committed
21
22
#include <stdio.h>
#include <stdlib.h>
Tor Lillqvist's avatar
Tor Lillqvist committed
23
#include <string.h>
Elliot Lee's avatar
Elliot Lee committed
24
#include <time.h>
Manish Singh's avatar
Manish Singh committed
25

26
#include <gtk/gtk.h>
Manish Singh's avatar
Manish Singh committed
27

28
29
30
#include "appenv.h"
#include "about_dialog.h"
#include "gimpdnd.h"
31
32
#include "gimphelp.h"

Manish Singh's avatar
Manish Singh committed
33
34
#include "libgimp/gimpfeatures.h"

Tor Lillqvist's avatar
Tor Lillqvist committed
35
#include "libgimp/gimpenv.h"
36
37
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
38

39
40
#include "pixmaps/wilber2.xpm"

41

Elliot Lee's avatar
Elliot Lee committed
42
#define ANIMATION_STEPS 16
43
#define ANIMATION_SIZE   2
Elliot Lee's avatar
Elliot Lee committed
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
static gboolean  about_dialog_load_logo   (GtkWidget      *window);
static void      about_dialog_destroy     (GtkObject      *object,
					   gpointer        data);
static void      about_dialog_unmap       (GtkWidget      *widget,
					   GdkEvent       *event,
					   gpointer        data);
static gint      about_dialog_logo_expose (GtkWidget      *widget,
					   GdkEventExpose *event,
					   gpointer        data);
static gint      about_dialog_button      (GtkWidget      *widget,
					   GdkEventButton *event,
					   gpointer        data);
static void      about_dialog_tool_drop   (GtkWidget      *widget,
					   ToolType        tool,
					   gpointer        data);
static gint      about_dialog_timer       (gpointer        data);
Elliot Lee's avatar
Elliot Lee committed
61
62


63
64
65
66
static GtkWidget *about_dialog  = NULL;
static GtkWidget *logo_area     = NULL;
static GtkWidget *scroll_area   = NULL;
static GdkPixmap *logo_pixmap   = NULL;
Elliot Lee's avatar
Elliot Lee committed
67
static GdkPixmap *scroll_pixmap = NULL;
68
69
70
71
72
73
74
75
76
77
78
static guchar    *dissolve_map  = NULL;
static gint       dissolve_width;
static gint       dissolve_height;
static gint       logo_width  = 0;
static gint       logo_height = 0;
static gboolean   do_animation = FALSE;
static gboolean   do_scrolling = FALSE;
static gint       scroll_state = 0;
static gint       frame  = 0;
static gint       offset = 0;
static gint       timer  = 0;
79

80
/* See the end of the list for how to add names with Non-ASCII characters */
81
static gchar *scroll_text[] =
Elliot Lee's avatar
Elliot Lee committed
82
83
84
{
  "Lauri Alanko",
  "Shawn Amundson",
85
86
  "Sven Anders",
  "Karl-Johan Andersson",
Elliot Lee's avatar
Elliot Lee committed
87
88
89
90
  "John Beale",
  "Zach Beane",
  "Tom Bech",
  "Marc Bless",
91
  "Edward Blevins",
92
93
  "Reagan Blundell",
  "Xavier Bouchoux",
Elliot Lee's avatar
Elliot Lee committed
94
  "Roberto Boyd",
Adrian Likins's avatar
ooops    
Adrian Likins committed
95
  "Stanislav Brabec",
96
97
  "Robert Brady",
  "Hans Breuer",
98
  "Simon Budig",
99
  "Carey Bunks",
100
  "Seth Burgess",
Elliot Lee's avatar
Elliot Lee committed
101
  "Brent Burton",
102
  "Francisco Bustamante",
103
104
105
106
107
  "Albert Cahalan",
  "Sean Cier",
  "Winston Chang",
  "Kenneth Christiansen",
  "Zbigniew Chyla",
Elliot Lee's avatar
Elliot Lee committed
108
  "Ed Connel",
109
110
  "Piers Cornwell",
  "Daniel Cotting",
111
  "Jay Cox",
112
113
  "Brian Degenhardt",
  "Gert Dewit",
Elliot Lee's avatar
Elliot Lee committed
114
  "Andreas Dilger",
115
  "Austin Donnelly",
Adrian Likins's avatar
ooops    
Adrian Likins committed
116
  "Scott Draves",
117
  "Daniel Dunbar",
Manish Singh's avatar
Manish Singh committed
118
  "Misha Dynin",
Adrian Likins's avatar
ooops    
Adrian Likins committed
119
  "Daniel Egger",
120
  "Morton Eriksen",
Elliot Lee's avatar
Elliot Lee committed
121
  "Larry Ewing",
122
  "Nick Fetchak",
Adrian Likins's avatar
ooops    
Adrian Likins committed
123
  "Valek Filippov",
Elliot Lee's avatar
Elliot Lee committed
124
  "David Forsyth",
125
126
127
  "Raphael Francois",
  "Jochen Friedrich",
  "Sami Gerdt",
Elliot Lee's avatar
Elliot Lee committed
128
  "Jim Geuther",
129
  "Graeme Gill",
Elliot Lee's avatar
Elliot Lee committed
130
131
  "Scott Goehring",
  "Heiko Goller",
132
133
  "Marcelo de Gomensoro Malheiros",
  "Pavel Grinfeld",
Elliot Lee's avatar
Elliot Lee committed
134
  "Michael Hammel",
135
  "Henrik Hansen",
Adrian Likins's avatar
ooops    
Adrian Likins committed
136
  "James Henstridge",
137
  "Eric Hernes",
Elliot Lee's avatar
Elliot Lee committed
138
  "Christoph Hoegl",
139
  "Wolfgang Hofer",
Elliot Lee's avatar
Elliot Lee committed
140
  "Jan Hubicka",
141
142
143
  "Andreas Hyden",
  "Ben Jackson",
  "Krzysztof Jakubowski",
Elliot Lee's avatar
Elliot Lee committed
144
145
  "Simon Janes",
  "Tim Janik",
146
147
  "Fellmann Joaquim",
  "Andrew Kieschnick",
148
  "Peter Kirchgessner",
149
150
151
  "Philipp Klaus",
  "David Koblas",
  "Tuomas Kuosmanen",
152
  "Karin Kylander",
153
  "Olof S Kylander",
154
  "Karl La Rocca",
Adrian Likins's avatar
ooops    
Adrian Likins committed
155
  "Chris Lahey",
156
157
  "Nick Lamb",
  "Marco Lamberto",
Elliot Lee's avatar
Elliot Lee committed
158
  "Jens Lautenbacher",
159
  "Laramie Leavitt",
160
  "Elliot Lee",
161
  "Marc Lehmann",
162
  "Ray Lahtiniemi",
Elliot Lee's avatar
Elliot Lee committed
163
  "Raph Levien",
Adrian Likins's avatar
ooops    
Adrian Likins committed
164
  "Wing Tung Leung",
Elliot Lee's avatar
Elliot Lee committed
165
  "Adrian Likins",
166
  "Tor Lillqvist",
Elliot Lee's avatar
Elliot Lee committed
167
168
169
  "Ingo Luetkebohle",
  "Josh MacDonald",
  "Ed Mackey",
170
  "Vidar Madsen",
Elliot Lee's avatar
Elliot Lee committed
171
172
  "Marcelo Malheiros",
  "Ian Main",
Adrian Likins's avatar
ooops    
Adrian Likins committed
173
174
  "Kjartan Maraas",
  "Kelly Martin",
Elliot Lee's avatar
Elliot Lee committed
175
  "Torsten Martinsen",
176
177
178
179
180
181
  "Gordon Matzigkeit",
  "Gregory McLean",
  "Daniele Medri",
  "Federico Mena Quintero",
  "James Mitchell",
  "Hirotsuna Mizuno",
Adrian Likins's avatar
ooops    
Adrian Likins committed
182
  "David Monniaux",
183
184
185
  "Adam D Moss",
  "Balazs Nagy",
  "Yukihiro Nakai",
Adrian Likins's avatar
ooops    
Adrian Likins committed
186
  "Sung-Hyun Nam",
Elliot Lee's avatar
Elliot Lee committed
187
  "Shuji Narazaki",
188
  "Felix Natter",
189
  "Michael Natterer",
190
  "Sven Neumann",
Elliot Lee's avatar
Elliot Lee committed
191
  "Stephen Robert Norris",
192
  "Tim Newsome",
Elliot Lee's avatar
Elliot Lee committed
193
194
  "Erik Nygren",
  "Miles O'Neal",
195
196
197
  "Thom van Os",
  "Gary Osgood",
  "Alan Paeth",
Elliot Lee's avatar
Elliot Lee committed
198
  "Jay Painter",
199
  "Sergey Panov",
200
  "Asbjorn Pettersen",
Elliot Lee's avatar
Elliot Lee committed
201
  "Mike Phillips",
202
  "Artur Polaczyaski",
Elliot Lee's avatar
Elliot Lee committed
203
  "Raphael Quinet",
Adrian Likins's avatar
ooops    
Adrian Likins committed
204
  "Vincent Renardias",
205
206
207
  "Jens Restemeier",
  "Maurits Rijk",
  "Daniel Risacher",
Elliot Lee's avatar
Elliot Lee committed
208
  "James Robinson",
209
210
  "Tim Rowley",
  "Pablo Saratxaga",
Elliot Lee's avatar
Elliot Lee committed
211
  "Mike Schaeffer",
212
213
214
215
  "John Schlag",
  "Norbert Schmitz",
  "Thorsten Schnier",
  "Alexander Schulz",
Elliot Lee's avatar
Elliot Lee committed
216
  "Tracy Scott",
217
  "Craig Setera",
218
  "Aaron Sherman",
219
  "Manish Singh",
220
  "Daniel Skarda",
221
  "Nathan Summers",
222
  "Mike Sweet",
223
  "Yuri Syrota",
Elliot Lee's avatar
Elliot Lee committed
224
225
  "Eiichi Takamori",
  "Tristan Tarrant",
226
  "Michael Taylor",
Elliot Lee's avatar
Elliot Lee committed
227
228
  "Owen Taylor",
  "Ian Tester",
229
  "Andy Thomas",
230
231
  "Kevin Turner",
  "Martin Weber",
Elliot Lee's avatar
Elliot Lee committed
232
233
  "James Wang",
  "Kris Wehner",
234
235
  "Nigel Wetten",
  "Calvin Williamson",
236
  "Matthew Wilson",
Adrian Likins's avatar
ooops    
Adrian Likins committed
237
  "Shirasaki Yasuhiro",
238
239
240
241
242
243
244
#ifndef GDK_USE_UTF8_MBS
  "Ville Hautamki",
  "Tomas gren",
#else  /* Win32 GDK uses UTF-8 */
  "Ville Hautamäki",
  "Tomas Ögren",
#endif
Elliot Lee's avatar
Elliot Lee committed
245
};
246
static gint nscroll_texts = sizeof (scroll_text) / sizeof (scroll_text[0]);
247
248
249
static gint scroll_text_widths[sizeof (scroll_text) / sizeof (scroll_text[0])];
static gint cur_scroll_text  = 0;
static gint cur_scroll_index = 0;
Elliot Lee's avatar
Elliot Lee committed
250

251
252
253
254
255
256
257
258
259
static gint shuffle_array[sizeof (scroll_text) / sizeof (scroll_text[0])];

/*  dnd stuff  */
static GtkTargetEntry tool_target_table[] =
{
  GIMP_TARGET_TOOL
};
static guint n_tool_targets = (sizeof (tool_target_table) /
                               sizeof (tool_target_table[0]));
Elliot Lee's avatar
Elliot Lee committed
260
261

void
262
about_dialog_create (void)
Elliot Lee's avatar
Elliot Lee committed
263
264
{
  GtkWidget *vbox;
265
  GtkWidget *aboutframe;
Elliot Lee's avatar
Elliot Lee committed
266
267
  GtkWidget *label;
  GtkWidget *alignment;
268
269
270
271
272
  GtkStyle  *style;
  GdkFont   *font;
  gint       max_width;
  gint       i;
  gchar     *label_text;
Elliot Lee's avatar
Elliot Lee committed
273
274
275
276

  if (!about_dialog)
    {
      about_dialog = gtk_window_new (GTK_WINDOW_DIALOG);
277
      gtk_window_set_wmclass (GTK_WINDOW (about_dialog), "about_dialog", "Gimp");
278
      gtk_window_set_title (GTK_WINDOW (about_dialog), _("About the GIMP"));
Elliot Lee's avatar
Elliot Lee committed
279
      gtk_window_set_policy (GTK_WINDOW (about_dialog), FALSE, FALSE, FALSE);
280
281
      gtk_window_set_position (GTK_WINDOW (about_dialog), GTK_WIN_POS_CENTER);

282
283
284
      gimp_help_connect_help_accel (about_dialog, gimp_standard_help_func,
				    "dialogs/about.html");

Elliot Lee's avatar
Elliot Lee committed
285
      gtk_signal_connect (GTK_OBJECT (about_dialog), "destroy",
286
287
			  GTK_SIGNAL_FUNC (about_dialog_destroy),
			  NULL);
Elliot Lee's avatar
Elliot Lee committed
288
      gtk_signal_connect (GTK_OBJECT (about_dialog), "unmap_event",
289
290
			  GTK_SIGNAL_FUNC (about_dialog_unmap),
			  NULL);
Elliot Lee's avatar
Elliot Lee committed
291
      gtk_signal_connect (GTK_OBJECT (about_dialog), "button_press_event",
292
293
294
			  GTK_SIGNAL_FUNC (about_dialog_button),
			  NULL);

295
296
297
298
299
300
301
302
      /*  dnd stuff  */
      gtk_drag_dest_set (about_dialog,
			 GTK_DEST_DEFAULT_MOTION |
			 GTK_DEST_DEFAULT_DROP,
			 tool_target_table, n_tool_targets,
			 GDK_ACTION_COPY); 
      gimp_dnd_tool_dest_set (about_dialog, about_dialog_tool_drop, NULL);

Elliot Lee's avatar
Elliot Lee committed
303
304
305
306
307
308
309
310
311
312
      gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK);

      if (!about_dialog_load_logo (about_dialog))
	{
	  gtk_widget_destroy (about_dialog);
	  about_dialog = NULL;
	  return;
	}

      vbox = gtk_vbox_new (FALSE, 1);
313
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
Elliot Lee's avatar
Elliot Lee committed
314
315
316
      gtk_container_add (GTK_CONTAINER (about_dialog), vbox);
      gtk_widget_show (vbox);

317
318
      aboutframe = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (aboutframe), GTK_SHADOW_IN);
319
      gtk_container_set_border_width (GTK_CONTAINER (aboutframe), 0);
320
321
      gtk_box_pack_start (GTK_BOX (vbox), aboutframe, TRUE, TRUE, 0);
      gtk_widget_show (aboutframe);
Elliot Lee's avatar
Elliot Lee committed
322
323
324

      logo_area = gtk_drawing_area_new ();
      gtk_signal_connect (GTK_OBJECT (logo_area), "expose_event",
325
326
327
328
			  GTK_SIGNAL_FUNC (about_dialog_logo_expose),
			  NULL);
      gtk_drawing_area_size (GTK_DRAWING_AREA (logo_area),
			     logo_width, logo_height);
Elliot Lee's avatar
Elliot Lee committed
329
      gtk_widget_set_events (logo_area, GDK_EXPOSURE_MASK);
330
      gtk_container_add (GTK_CONTAINER (aboutframe), logo_area);
Elliot Lee's avatar
Elliot Lee committed
331
332
333
334
335
      gtk_widget_show (logo_area);

      gtk_widget_realize (logo_area);
      gdk_window_set_background (logo_area->window, &logo_area->style->black);

336
337
338
339
340
341
342
      /* this is a font, provide only one single font definition */
      font = gdk_font_load (_("-*-helvetica-medium-r-normal--*-140-*-*-*-*-*-*"));
      if (font)
	{
	  style = gtk_style_new ();
	  gdk_font_unref (style->font);
	  style->font = font;
343
	  gdk_font_ref (style->font);
344
345
346
	  gtk_widget_push_style (style);
	  gtk_style_unref (style);
	}
347
348
      label_text = g_strdup_printf (_("Version %s brought to you by"),
				    GIMP_VERSION);
349
      label = gtk_label_new (label_text);
350
351
      g_free (label_text);
      label_text = NULL;
Elliot Lee's avatar
Elliot Lee committed
352
353
354
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

Sven Neumann's avatar
Sven Neumann committed
355
      label = gtk_label_new ("Spencer Kimball & Peter Mattis");
Elliot Lee's avatar
Elliot Lee committed
356
357
358
359
360
361
362
363
364
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

      gtk_widget_pop_style ();

      alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
      gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, TRUE, 0);
      gtk_widget_show (alignment);

365
366
      aboutframe = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (aboutframe), GTK_SHADOW_IN);
367
      gtk_container_set_border_width (GTK_CONTAINER (aboutframe), 0);
368
369
      gtk_container_add (GTK_CONTAINER (alignment), aboutframe);
      gtk_widget_show (aboutframe);
Elliot Lee's avatar
Elliot Lee committed
370
371
372
373

      max_width = 0;
      for (i = 0; i < nscroll_texts; i++)
	{
374
	  scroll_text_widths[i] = gdk_string_width (aboutframe->style->font, scroll_text[i]);
Elliot Lee's avatar
Elliot Lee committed
375
376
377
378
379
380
	  max_width = MAX (max_width, scroll_text_widths[i]);
	}

      scroll_area = gtk_drawing_area_new ();
      gtk_drawing_area_size (GTK_DRAWING_AREA (scroll_area),
			     max_width + 10,
381
382
383
384
			     aboutframe->style->font->ascent +
			     aboutframe->style->font->descent);
      gtk_widget_set_events (scroll_area, GDK_BUTTON_PRESS_MASK);
      gtk_container_add (GTK_CONTAINER (aboutframe), scroll_area);
Elliot Lee's avatar
Elliot Lee committed
385
386
      gtk_widget_show (scroll_area);

387
      label = gtk_label_new (_("Please visit http://www.gimp.org/ for more info"));
388
389
390
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

Elliot Lee's avatar
Elliot Lee committed
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
      gtk_widget_realize (scroll_area);
      gdk_window_set_background (scroll_area->window, &scroll_area->style->white);
    }

  if (!GTK_WIDGET_VISIBLE (about_dialog))
    {
      gtk_widget_show (about_dialog);

      do_animation = TRUE;
      do_scrolling = FALSE;
      scroll_state = 0;
      frame = 0;
      offset = 0;

      for (i = 0; i < nscroll_texts; i++) 
	{
	  shuffle_array[i] = i;
	}

      for (i = 0; i < nscroll_texts; i++) 
	{
412
	  int j;
Elliot Lee's avatar
Elliot Lee committed
413
	  j = rand() % nscroll_texts;
414
	  if (i != j) 
Elliot Lee's avatar
Elliot Lee committed
415
416
417
	    {
	      int t;
	      t = shuffle_array[j];
418
419
	      shuffle_array[j] = shuffle_array[i];
	      shuffle_array[i] = t;
Elliot Lee's avatar
Elliot Lee committed
420
421
	    }
	}
422
      cur_scroll_text = rand() % nscroll_texts;
Elliot Lee's avatar
Elliot Lee committed
423
424
425
    }
  else 
    {
426
      gdk_window_raise (about_dialog->window);
Elliot Lee's avatar
Elliot Lee committed
427
428
429
430
    }
}


431
static gboolean
Elliot Lee's avatar
Elliot Lee committed
432
433
434
about_dialog_load_logo (GtkWidget *window)
{
  GtkWidget *preview;
435
436
437
438
439
440
441
  GdkGC     *gc;
  gchar      buf[1024];
  gchar     *filename;
  guchar    *pixelrow;
  FILE      *fp;
  gint       count;
  gint       i, j, k;
Elliot Lee's avatar
Elliot Lee committed
442
443
444
445

  if (logo_pixmap)
    return TRUE;

446
447
448
449
450
451
  filename = g_strconcat (gimp_data_directory (),
			  G_DIR_SEPARATOR_S,
			  "gimp_logo.ppm",
			  NULL);
  fp = fopen (filename, "rb");
  g_free (filename);
Elliot Lee's avatar
Elliot Lee committed
452
453

  if (!fp)
454
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
455
456

  fgets (buf, 1024, fp);
457
458

  if (strncmp (buf, "P6", 2) != 0)
Elliot Lee's avatar
Elliot Lee committed
459
460
    {
      fclose (fp);
461
      return FALSE;
Elliot Lee's avatar
Elliot Lee committed
462
463
464
465
466
467
468
    }

  fgets (buf, 1024, fp);
  fgets (buf, 1024, fp);
  sscanf (buf, "%d %d", &logo_width, &logo_height);

  fgets (buf, 1024, fp);
469
  if (strncmp (buf, "255", 3) != 0)
Elliot Lee's avatar
Elliot Lee committed
470
471
    {
      fclose (fp);
472
      return FALSE;
Elliot Lee's avatar
Elliot Lee committed
473
474
475
476
477
478
479
480
    }

  preview = gtk_preview_new (GTK_PREVIEW_COLOR);
  gtk_preview_size (GTK_PREVIEW (preview), logo_width, logo_height);
  pixelrow = g_new (guchar, logo_width * 3);

  for (i = 0; i < logo_height; i++)
    {
481
      count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
Elliot Lee's avatar
Elliot Lee committed
482
483
484
485
486
      if (count != (logo_width * 3))
	{
	  gtk_widget_destroy (preview);
	  g_free (pixelrow);
	  fclose (fp);
487
	  return FALSE;
Elliot Lee's avatar
Elliot Lee committed
488
489
490
491
492
493
	}

      gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width);
    }

  gtk_widget_realize (window);
494
495
496
  logo_pixmap = gdk_pixmap_new (window->window, logo_width, logo_height, 
				gtk_preview_get_visual ()->depth);
  gc = gdk_gc_new (logo_pixmap);
Elliot Lee's avatar
Elliot Lee committed
497
  gtk_preview_put (GTK_PREVIEW (preview),
498
		   logo_pixmap, gc,
Elliot Lee's avatar
Elliot Lee committed
499
		   0, 0, 0, 0, logo_width, logo_height);
500
  gdk_gc_destroy (gc);
Elliot Lee's avatar
Elliot Lee committed
501

502
  gtk_widget_unref (preview);
Elliot Lee's avatar
Elliot Lee committed
503
504
505
506
  g_free (pixelrow);

  fclose (fp);

507
508
509
510
  dissolve_width =
    (logo_width / ANIMATION_SIZE) + (logo_width % ANIMATION_SIZE == 0 ? 0 : 1);
  dissolve_height =
    (logo_height / ANIMATION_SIZE) + (logo_height % ANIMATION_SIZE == 0 ? 0 : 1);
Elliot Lee's avatar
Elliot Lee committed
511
512
513
514
515
516
517
518
519
520
521
522
523

  dissolve_map = g_new (guchar, dissolve_width * dissolve_height);

  srand (time (NULL));

  for (i = 0, k = 0; i < dissolve_height; i++)
    for (j = 0; j < dissolve_width; j++, k++)
      dissolve_map[k] = rand () % ANIMATION_STEPS;

  return TRUE;
}

static void
524
525
about_dialog_destroy (GtkObject *object,
		      gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
526
527
{
  about_dialog = NULL;
528
  about_dialog_unmap (NULL, NULL, NULL);
Elliot Lee's avatar
Elliot Lee committed
529
530
531
}

static void
532
533
534
about_dialog_unmap (GtkWidget *widget,
		    GdkEvent  *event,
		    gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
535
536
537
538
539
540
541
542
{
  if (timer)
    {
      gtk_timeout_remove (timer);
      timer = 0;
    }
}

543
static gint
Elliot Lee's avatar
Elliot Lee committed
544
about_dialog_logo_expose (GtkWidget      *widget,
545
546
			  GdkEventExpose *event,
			  gpointer        data)
Elliot Lee's avatar
Elliot Lee committed
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
{
  if (do_animation)
    {
      if (!timer)
	{
	  about_dialog_timer (widget);
	  timer = gtk_timeout_add (75, about_dialog_timer, NULL);
	}
    }
  else
    {
      /* If we draw beyond the boundaries of the pixmap, then X
	 will generate an expose area for those areas, starting
	 an infinite cycle. We now set allow_grow = FALSE, so
	 the drawing area can never be bigger than the preview.
         Otherwise, it would be necessary to intersect event->area
         with the pixmap boundary rectangle. */

      gdk_draw_pixmap (widget->window,
		       widget->style->black_gc,
		       logo_pixmap, 
		       event->area.x, event->area.y,
		       event->area.x, event->area.y,
		       event->area.width, event->area.height);
    }

  return FALSE;
}

576
static gint
Elliot Lee's avatar
Elliot Lee committed
577
about_dialog_button (GtkWidget      *widget,
578
579
		     GdkEventButton *event,
		     gpointer        data)
Elliot Lee's avatar
Elliot Lee committed
580
581
582
583
584
585
586
587
588
589
590
{
  if (timer)
    gtk_timeout_remove (timer);
  timer = 0;
  frame = 0;

  gtk_widget_hide (about_dialog);

  return FALSE;
}

591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
static void
about_dialog_tool_drop (GtkWidget *widget,
			ToolType   tool,
			gpointer   data)
{
  GdkPixmap *pixmap = NULL;
  GdkBitmap *mask   = NULL;
  gint width  = 0;
  gint height = 0;

  if (do_animation)
    return;

  if (timer)
    gtk_timeout_remove (timer);

  timer = gtk_timeout_add (75, about_dialog_timer, NULL);

  frame = 0;
  do_animation = TRUE;
  do_scrolling = FALSE;

  gdk_draw_rectangle (logo_pixmap,
		      logo_area->style->white_gc,
		      TRUE,
		      0, 0,
		      logo_area->allocation.width,
		      logo_area->allocation.height);

  pixmap =
    gdk_pixmap_create_from_xpm_d (widget->window,
                                  &mask,
                                  NULL,
                                  wilber2_xpm);

  gdk_window_get_size (pixmap, &width, &height);

  if (logo_area->allocation.width  >= width &&
      logo_area->allocation.height >= height)
    {
      gint x, y;

      x = (logo_area->allocation.width  - width) / 2;
      y = (logo_area->allocation.height - height) / 2;

      gdk_gc_set_clip_mask (logo_area->style->black_gc, mask);
      gdk_gc_set_clip_origin (logo_area->style->black_gc, x, y);

      gdk_draw_pixmap (logo_pixmap,
                       logo_area->style->black_gc,
                       pixmap, 0, 0,
                       x, y,
                       width, height);

      gdk_gc_set_clip_mask (logo_area->style->black_gc, NULL);
      gdk_gc_set_clip_origin (logo_area->style->black_gc, 0, 0);
    }

  gdk_pixmap_unref (pixmap);
  gdk_bitmap_unref (mask);

  double_speed = TRUE;
}

655
static gint
Elliot Lee's avatar
Elliot Lee committed
656
657
658
659
660
661
662
663
664
about_dialog_timer (gpointer data)
{
  gint i, j, k;
  gint return_val;

  return_val = TRUE;

  if (do_animation)
    {
665
      if (logo_area->allocation.width != 1)
Elliot Lee's avatar
Elliot Lee committed
666
	{
667
668
	  for (i = 0, k = 0; i < dissolve_height; i++)
	    for (j = 0; j < dissolve_width; j++, k++)
Manish Singh's avatar
Manish Singh committed
669
	      if (frame == dissolve_map[k])
670
671
672
673
		{
		  gdk_draw_pixmap (logo_area->window,
				   logo_area->style->black_gc,
				   logo_pixmap,
674
675
				   j * ANIMATION_SIZE, i * ANIMATION_SIZE,
				   j * ANIMATION_SIZE, i * ANIMATION_SIZE,
676
677
678
679
680
681
682
683
684
685
				   ANIMATION_SIZE, ANIMATION_SIZE);
		}

	  frame += 1;

	  if (frame == ANIMATION_STEPS)
	    {
	      do_animation = FALSE;
	      do_scrolling = TRUE;
	      frame = 0;
Elliot Lee's avatar
Elliot Lee committed
686

687
	      timer = gtk_timeout_add (75, about_dialog_timer, NULL);
Elliot Lee's avatar
Elliot Lee committed
688

689
690
	      return FALSE;
	    }
Elliot Lee's avatar
Elliot Lee committed
691
692
693
694
695
	}
    }

  if (do_scrolling)
    {
696
697
698
699
700
701
      if (!scroll_pixmap)
	scroll_pixmap = gdk_pixmap_new (scroll_area->window,
					scroll_area->allocation.width,
					scroll_area->allocation.height,
					-1);

Elliot Lee's avatar
Elliot Lee committed
702
703
704
705
706
707
708
709
710
711
712
713
714
715
      switch (scroll_state)
	{
	case 1:
	  scroll_state = 2;
	  timer = gtk_timeout_add (700, about_dialog_timer, NULL);
	  return_val = FALSE;
	  break;
	case 2:
	  scroll_state = 3;
	  timer = gtk_timeout_add (75, about_dialog_timer, NULL);
	  return_val = FALSE;
	  break;
	}

716
717
      if (offset > (scroll_text_widths[cur_scroll_text] +
		    scroll_area->allocation.width))
Elliot Lee's avatar
Elliot Lee committed
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
	{
	  scroll_state = 0;
	  cur_scroll_index += 1;
	  if (cur_scroll_index == nscroll_texts)
	    cur_scroll_index = 0;
	  
	  cur_scroll_text = shuffle_array[cur_scroll_index];

	  offset = 0;
	}

      gdk_draw_rectangle (scroll_pixmap,
			  scroll_area->style->white_gc,
			  TRUE, 0, 0,
			  scroll_area->allocation.width,
			  scroll_area->allocation.height);
      gdk_draw_string (scroll_pixmap,
		       scroll_area->style->font,
		       scroll_area->style->black_gc,
		       scroll_area->allocation.width - offset,
		       scroll_area->style->font->ascent,
		       scroll_text[cur_scroll_text]);
      gdk_draw_pixmap (scroll_area->window,
		       scroll_area->style->black_gc,
		       scroll_pixmap, 0, 0, 0, 0,
		       scroll_area->allocation.width,
		       scroll_area->allocation.height);

      offset += 15;
      if (scroll_state == 0)
	{
749
750
	  if (offset > ((scroll_area->allocation.width +
			 scroll_text_widths[cur_scroll_text]) / 2))
Elliot Lee's avatar
Elliot Lee committed
751
752
	    {
	      scroll_state = 1;
753
754
	      offset = (scroll_area->allocation.width +
			scroll_text_widths[cur_scroll_text]) / 2;
Elliot Lee's avatar
Elliot Lee committed
755
756
757
758
759
760
	    }
	}
    }

  return return_val;
}