about-dialog.c 18.6 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
#include <gdk/gdkkeysyms.h>
Manish Singh's avatar
Manish Singh committed
28

29
#include "libgimpmath/gimpmath.h"
30
#include "libgimpbase/gimpbase.h"
31
#include "libgimpwidgets/gimpwidgets.h"
32

Michael Natterer's avatar
Michael Natterer committed
33
#include "core/core-types.h"
Sven Neumann's avatar
Sven Neumann committed
34

Michael Natterer's avatar
Michael Natterer committed
35
#include "core/gimptoolinfo.h"
36

Michael Natterer's avatar
Michael Natterer committed
37
38
#include "widgets/gimpdnd.h"

39
#include "about-dialog.h"
Michael Natterer's avatar
Michael Natterer committed
40
#include "authors.h"
41

42
#include "appenv.h"
43

44
45
#include "libgimp/gimpintl.h"

46
47
#include "pixmaps/wilber2.xpm"

48

Elliot Lee's avatar
Elliot Lee committed
49
#define ANIMATION_STEPS 16
50
#define ANIMATION_SIZE   2
Elliot Lee's avatar
Elliot Lee committed
51

52
53
54
55
56
57
58
59
60
61
62
63
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);
Manish Singh's avatar
Manish Singh committed
64
65
66
static gint      about_dialog_key         (GtkWidget      *widget,
					   GdkEventKey    *event,
					   gpointer        data);
67
static void      about_dialog_tool_drop   (GtkWidget      *widget,
68
					   GimpViewable   *viewable,
69
70
					   gpointer        data);
static gint      about_dialog_timer       (gpointer        data);
Elliot Lee's avatar
Elliot Lee committed
71
72


73
74
75
76
77
78
static GtkWidget *about_dialog     = NULL;
static GtkWidget *logo_area        = NULL;
static GtkWidget *scroll_area      = NULL;
static GdkPixmap *logo_pixmap      = NULL;
static GdkPixmap *scroll_pixmap    = NULL;
static guchar    *dissolve_map     = NULL;
79
80
static gint       dissolve_width;
static gint       dissolve_height;
81
82
83
84
85
86
87
88
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;
Manish Singh's avatar
Manish Singh committed
89
static gint       hadja_state      = 0;
90
91
92
93
94
95
static gchar    **scroll_text      = authors;
static gint       nscroll_texts    = sizeof (authors) / sizeof (authors[0]);
static gint       scroll_text_widths[sizeof (authors) / sizeof (authors[0])];
static gint       cur_scroll_text  = 0;
static gint       cur_scroll_index = 0;
static gint       shuffle_array[sizeof (authors) / sizeof (authors[0])];
96

Elliot Lee's avatar
Elliot Lee committed
97

98
99
100
101
102
103
104
static gchar *drop_text[] = 
{ 
  "We are The GIMP." ,
  "Prepare to be manipulated.",
  "Resistance is futile."
};

Manish Singh's avatar
Manish Singh committed
105
106
107
108
static gchar *hadja_text[] =
{
  "Hadjaha!",
  "Nej!",
109
#ifndef GDK_USE_UTF8_MBS
Manish Singh's avatar
Manish Singh committed
110
  "Tvrtom!"
111
112
113
#else
  "Tvärtom!"
#endif
Manish Singh's avatar
Manish Singh committed
114
};
115

116
GtkWidget *
117
about_dialog_create (void)
Elliot Lee's avatar
Elliot Lee committed
118
119
{
  GtkWidget *vbox;
120
  GtkWidget *aboutframe;
Elliot Lee's avatar
Elliot Lee committed
121
122
  GtkWidget *label;
  GtkWidget *alignment;
123
#if 0
124
125
  GtkStyle  *style;
  GdkFont   *font;
126
#endif
127
128
129
  gint       max_width;
  gint       i;
  gchar     *label_text;
Elliot Lee's avatar
Elliot Lee committed
130

131
  if (! about_dialog)
Elliot Lee's avatar
Elliot Lee committed
132
    {
133
134
135
      about_dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_type_hint (GTK_WINDOW (about_dialog),
				GDK_WINDOW_TYPE_HINT_DIALOG);
136
      gtk_window_set_wmclass (GTK_WINDOW (about_dialog), "about_dialog", "Gimp");
137
      gtk_window_set_title (GTK_WINDOW (about_dialog), _("About the GIMP"));
Elliot Lee's avatar
Elliot Lee committed
138
      gtk_window_set_policy (GTK_WINDOW (about_dialog), FALSE, FALSE, FALSE);
139
140
      gtk_window_set_position (GTK_WINDOW (about_dialog), GTK_WIN_POS_CENTER);

141
142
143
      gimp_help_connect_help_accel (about_dialog, gimp_standard_help_func,
				    "dialogs/about.html");

Elliot Lee's avatar
Elliot Lee committed
144
      gtk_signal_connect (GTK_OBJECT (about_dialog), "destroy",
145
146
			  GTK_SIGNAL_FUNC (about_dialog_destroy),
			  NULL);
Elliot Lee's avatar
Elliot Lee committed
147
      gtk_signal_connect (GTK_OBJECT (about_dialog), "unmap_event",
148
149
			  GTK_SIGNAL_FUNC (about_dialog_unmap),
			  NULL);
Elliot Lee's avatar
Elliot Lee committed
150
      gtk_signal_connect (GTK_OBJECT (about_dialog), "button_press_event",
151
152
			  GTK_SIGNAL_FUNC (about_dialog_button),
			  NULL);
Manish Singh's avatar
Manish Singh committed
153
154
155
156
      gtk_signal_connect (GTK_OBJECT (about_dialog), "key_press_event",
			  GTK_SIGNAL_FUNC (about_dialog_key),
			  NULL);
      
157
      /*  dnd stuff  */
158
159
160
161
162
163
164
165
      gimp_gtk_drag_dest_set_by_type (about_dialog,
				      GTK_DEST_DEFAULT_MOTION |
				      GTK_DEST_DEFAULT_DROP,
				      GIMP_TYPE_TOOL_INFO,
				      GDK_ACTION_COPY); 
      gimp_dnd_viewable_dest_set (about_dialog,
				  GIMP_TYPE_TOOL_INFO,
				  about_dialog_tool_drop, NULL);
166

Elliot Lee's avatar
Elliot Lee committed
167
168
169
170
171
172
      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;
173
	  return NULL;
Elliot Lee's avatar
Elliot Lee committed
174
175
176
	}

      vbox = gtk_vbox_new (FALSE, 1);
177
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
Elliot Lee's avatar
Elliot Lee committed
178
179
180
      gtk_container_add (GTK_CONTAINER (about_dialog), vbox);
      gtk_widget_show (vbox);

181
182
      aboutframe = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (aboutframe), GTK_SHADOW_IN);
183
      gtk_container_set_border_width (GTK_CONTAINER (aboutframe), 0);
184
185
      gtk_box_pack_start (GTK_BOX (vbox), aboutframe, TRUE, TRUE, 0);
      gtk_widget_show (aboutframe);
Elliot Lee's avatar
Elliot Lee committed
186
187
188

      logo_area = gtk_drawing_area_new ();
      gtk_signal_connect (GTK_OBJECT (logo_area), "expose_event",
189
190
191
192
			  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
193
      gtk_widget_set_events (logo_area, GDK_EXPOSURE_MASK);
194
      gtk_container_add (GTK_CONTAINER (aboutframe), logo_area);
Elliot Lee's avatar
Elliot Lee committed
195
196
197
198
199
      gtk_widget_show (logo_area);

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

200
      /* this is a font, provide only one single font definition */
201
202
203
204
#ifdef __GNUC__
#warning FIXME: font description
#endif
#if 0
205
206
207
208
209
210
      font = gdk_font_load (_("-*-helvetica-medium-r-normal--*-140-*-*-*-*-*-*"));
      if (font)
	{
	  style = gtk_style_new ();
	  gdk_font_unref (style->font);
	  style->font = font;
211
	  gdk_font_ref (style->font);
212
213
214
	  gtk_widget_push_style (style);
	  gtk_style_unref (style);
	}
215
#endif
216
217
      label_text = g_strdup_printf (_("Version %s brought to you by"),
				    GIMP_VERSION);
218
      label = gtk_label_new (label_text);
219
220
      g_free (label_text);
      label_text = NULL;
Elliot Lee's avatar
Elliot Lee committed
221
222
223
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

Sven Neumann's avatar
Sven Neumann committed
224
      label = gtk_label_new ("Spencer Kimball & Peter Mattis");
Elliot Lee's avatar
Elliot Lee committed
225
226
227
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

228
#if 0
Elliot Lee's avatar
Elliot Lee committed
229
      gtk_widget_pop_style ();
230
#endif
Elliot Lee's avatar
Elliot Lee committed
231
232
233
234
235

      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);

236
237
      aboutframe = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (aboutframe), GTK_SHADOW_IN);
238
      gtk_container_set_border_width (GTK_CONTAINER (aboutframe), 0);
239
240
      gtk_container_add (GTK_CONTAINER (alignment), aboutframe);
      gtk_widget_show (aboutframe);
Elliot Lee's avatar
Elliot Lee committed
241
242
243
244

      max_width = 0;
      for (i = 0; i < nscroll_texts; i++)
	{
245
246
	  scroll_text_widths[i] = gdk_string_width (aboutframe->style->font,
						    scroll_text[i]);
Elliot Lee's avatar
Elliot Lee committed
247
248
	  max_width = MAX (max_width, scroll_text_widths[i]);
	}
249
250
251
252
253
      for (i = 0; i < (sizeof (drop_text) / sizeof (drop_text[0])); i++)
	{
	  max_width = MAX (max_width, 
			   gdk_string_width (aboutframe->style->font, drop_text[i]));
	}
Manish Singh's avatar
Manish Singh committed
254
255
256
257
258
      for (i = 0; i < (sizeof (hadja_text) / sizeof (hadja_text[0])); i++)
	{
	  max_width = MAX (max_width,
			   gdk_string_width (aboutframe->style->font, hadja_text[i]));
	}
Elliot Lee's avatar
Elliot Lee committed
259
260
261
      scroll_area = gtk_drawing_area_new ();
      gtk_drawing_area_size (GTK_DRAWING_AREA (scroll_area),
			     max_width + 10,
262
263
264
265
			     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
266
267
      gtk_widget_show (scroll_area);

268
      label = gtk_label_new (_("Please visit http://www.gimp.org/ for more info"));
269
270
271
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

Elliot Lee's avatar
Elliot Lee committed
272
      gtk_widget_realize (scroll_area);
273
274
      gdk_window_set_background (scroll_area->window,
				 &scroll_area->style->white);
Elliot Lee's avatar
Elliot Lee committed
275
276
    }

277
  if (! GTK_WIDGET_VISIBLE (about_dialog))
Elliot Lee's avatar
Elliot Lee committed
278
279
280
    {
      gtk_widget_show (about_dialog);

281
282
283
284
285
      do_animation    = TRUE;
      do_scrolling    = FALSE;
      scroll_state    = 0;
      frame           = 0;
      offset          = 0;
286
      cur_scroll_text = 0;
Elliot Lee's avatar
Elliot Lee committed
287

288
      if (! double_speed && hadja_state != 7)
Elliot Lee's avatar
Elliot Lee committed
289
	{
290
291
292
293
	  for (i = 0; i < nscroll_texts; i++) 
	    {
	      shuffle_array[i] = i;
	    }
Elliot Lee's avatar
Elliot Lee committed
294

295
	  for (i = 0; i < nscroll_texts; i++) 
Elliot Lee's avatar
Elliot Lee committed
296
	    {
297
298
299
300
301
302
303
304
305
306
307
	      gint j;

	      j = rand() % nscroll_texts;
	      if (i != j) 
		{
		  gint t;

		  t = shuffle_array[j];
		  shuffle_array[j] = shuffle_array[i];
		  shuffle_array[i] = t;
		}
Elliot Lee's avatar
Elliot Lee committed
308
	    }
309
	  cur_scroll_text = rand() % nscroll_texts;
Elliot Lee's avatar
Elliot Lee committed
310
311
312
313
	}
    }
  else 
    {
314
      gdk_window_raise (about_dialog->window);
Elliot Lee's avatar
Elliot Lee committed
315
    }
316
317

  return about_dialog;
Elliot Lee's avatar
Elliot Lee committed
318
319
}

320
static gboolean
Elliot Lee's avatar
Elliot Lee committed
321
322
323
about_dialog_load_logo (GtkWidget *window)
{
  GtkWidget *preview;
324
325
326
327
328
329
330
  GdkGC     *gc;
  gchar      buf[1024];
  gchar     *filename;
  guchar    *pixelrow;
  FILE      *fp;
  gint       count;
  gint       i, j, k;
Elliot Lee's avatar
Elliot Lee committed
331
332
333
334

  if (logo_pixmap)
    return TRUE;

335
336
337
338
339
340
  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
341
342

  if (!fp)
343
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
344
345

  fgets (buf, 1024, fp);
346
347

  if (strncmp (buf, "P6", 2) != 0)
Elliot Lee's avatar
Elliot Lee committed
348
349
    {
      fclose (fp);
350
      return FALSE;
Elliot Lee's avatar
Elliot Lee committed
351
352
353
354
355
356
357
    }

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

  fgets (buf, 1024, fp);
358
  if (strncmp (buf, "255", 3) != 0)
Elliot Lee's avatar
Elliot Lee committed
359
360
    {
      fclose (fp);
361
      return FALSE;
Elliot Lee's avatar
Elliot Lee committed
362
363
364
365
366
367
368
369
    }

  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++)
    {
370
      count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
Elliot Lee's avatar
Elliot Lee committed
371
372
373
374
375
      if (count != (logo_width * 3))
	{
	  gtk_widget_destroy (preview);
	  g_free (pixelrow);
	  fclose (fp);
376
	  return FALSE;
Elliot Lee's avatar
Elliot Lee committed
377
378
379
380
381
382
	}

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

  gtk_widget_realize (window);
383
384
385
  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
386
  gtk_preview_put (GTK_PREVIEW (preview),
387
		   logo_pixmap, gc,
Elliot Lee's avatar
Elliot Lee committed
388
		   0, 0, 0, 0, logo_width, logo_height);
389
  gdk_gc_destroy (gc);
Elliot Lee's avatar
Elliot Lee committed
390

391
  gtk_widget_unref (preview);
Elliot Lee's avatar
Elliot Lee committed
392
393
394
395
  g_free (pixelrow);

  fclose (fp);

396
397
398
399
  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
400
401
402
403
404
405
406
407
408
409
410
411
412

  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
413
414
about_dialog_destroy (GtkObject *object,
		      gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
415
416
{
  about_dialog = NULL;
417
  about_dialog_unmap (NULL, NULL, NULL);
Elliot Lee's avatar
Elliot Lee committed
418
419
420
}

static void
421
422
423
about_dialog_unmap (GtkWidget *widget,
		    GdkEvent  *event,
		    gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
424
425
426
427
428
429
430
431
{
  if (timer)
    {
      gtk_timeout_remove (timer);
      timer = 0;
    }
}

432
static gint
Elliot Lee's avatar
Elliot Lee committed
433
about_dialog_logo_expose (GtkWidget      *widget,
434
435
			  GdkEventExpose *event,
			  gpointer        data)
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
{
  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;
}

465
static gint
Elliot Lee's avatar
Elliot Lee committed
466
about_dialog_button (GtkWidget      *widget,
467
468
		     GdkEventButton *event,
		     gpointer        data)
Elliot Lee's avatar
Elliot Lee committed
469
470
471
472
473
474
475
476
477
478
479
{
  if (timer)
    gtk_timeout_remove (timer);
  timer = 0;
  frame = 0;

  gtk_widget_hide (about_dialog);

  return FALSE;
}

Manish Singh's avatar
Manish Singh committed
480
481
482
483
484
485
486
static gint
about_dialog_key (GtkWidget      *widget,
		  GdkEventKey    *event,
		  gpointer        data)
{
  gint i;
  
487
488
489
  if (hadja_state == 7)
    return FALSE;
    
Manish Singh's avatar
Manish Singh committed
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
  switch (event->keyval)
    {
    case GDK_h:
    case GDK_H:
      if (hadja_state == 0 || hadja_state == 5)
	hadja_state++;
      else
	hadja_state = 1;
      break;
    case GDK_a:
    case GDK_A:
      if (hadja_state == 1 || hadja_state == 4 || hadja_state == 6)
	hadja_state++;
      else
	hadja_state = 0;
      break;
    case GDK_d:
    case GDK_D:
      if (hadja_state == 2)
	hadja_state++;
      else
	hadja_state = 0;
      break;
    case GDK_j:
    case GDK_J:
      if (hadja_state == 3)
	hadja_state++;
      else
	hadja_state = 0;
      break;
    default:
      hadja_state = 0;
    }

  if (hadja_state == 7)
    {
      scroll_text = hadja_text;
      nscroll_texts = sizeof (hadja_text) / sizeof (hadja_text[0]);
      
      for (i = 0; i < nscroll_texts; i++)
	{
	  shuffle_array[i] = i;
	  scroll_text_widths[i] = gdk_string_width (scroll_area->style->font,
533
						    scroll_text[i]);
Manish Singh's avatar
Manish Singh committed
534
535
	}
      
536
      scroll_state     = 0;
Manish Singh's avatar
Manish Singh committed
537
      cur_scroll_index = 0;
538
539
      cur_scroll_text  = 0;
      offset           = 0;
Manish Singh's avatar
Manish Singh committed
540
541
542
543
544
    }
  
  return FALSE;
}

545
static void
546
547
548
about_dialog_tool_drop (GtkWidget    *widget,
			GimpViewable *viewable,
			gpointer      data)
549
550
551
{
  GdkPixmap *pixmap = NULL;
  GdkBitmap *mask   = NULL;
552
553
554
  gint       width  = 0;
  gint       height = 0;
  gint       i;
555
  
556
557
558
559
560
561
562
563
  if (do_animation)
    return;

  if (timer)
    gtk_timeout_remove (timer);

  timer = gtk_timeout_add (75, about_dialog_timer, NULL);

564
  frame        = 0;
565
566
567
568
569
570
571
572
573
574
  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);

575
576
577
578
  pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
					 &mask,
					 NULL,
					 wilber2_xpm);
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605

  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);

606
607
  scroll_text = drop_text;
  nscroll_texts = sizeof (drop_text) / sizeof (drop_text[0]);
608
609
610
611
612
613
614
615

  for (i = 0; i < nscroll_texts; i++)
    {
      shuffle_array[i] = i;
      scroll_text_widths[i] = gdk_string_width (scroll_area->style->font,
						scroll_text[i]);
    }

616
  scroll_state     = 0;
617
  cur_scroll_index = 0;
618
619
  cur_scroll_text  = 0;
  offset           = 0;
620

621
622
623
  double_speed = TRUE;
}

624
static gint
Elliot Lee's avatar
Elliot Lee committed
625
626
627
628
629
630
631
632
633
about_dialog_timer (gpointer data)
{
  gint i, j, k;
  gint return_val;

  return_val = TRUE;

  if (do_animation)
    {
634
      if (logo_area->allocation.width != 1)
Elliot Lee's avatar
Elliot Lee committed
635
	{
636
637
	  for (i = 0, k = 0; i < dissolve_height; i++)
	    for (j = 0; j < dissolve_width; j++, k++)
Manish Singh's avatar
Manish Singh committed
638
	      if (frame == dissolve_map[k])
639
640
641
642
		{
		  gdk_draw_pixmap (logo_area->window,
				   logo_area->style->black_gc,
				   logo_pixmap,
643
644
				   j * ANIMATION_SIZE, i * ANIMATION_SIZE,
				   j * ANIMATION_SIZE, i * ANIMATION_SIZE,
645
646
647
648
649
650
651
652
653
				   ANIMATION_SIZE, ANIMATION_SIZE);
		}

	  frame += 1;

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

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

658
659
	      return FALSE;
	    }
Elliot Lee's avatar
Elliot Lee committed
660
661
662
663
664
	}
    }

  if (do_scrolling)
    {
665
      if (! scroll_pixmap)
666
667
668
669
670
	scroll_pixmap = gdk_pixmap_new (scroll_area->window,
					scroll_area->allocation.width,
					scroll_area->allocation.height,
					-1);

Elliot Lee's avatar
Elliot Lee committed
671
672
673
674
675
676
677
678
679
680
681
682
683
684
      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;
	}

685
686
      if (offset > (scroll_text_widths[cur_scroll_text] +
		    scroll_area->allocation.width))
Elliot Lee's avatar
Elliot Lee committed
687
688
689
690
691
	{
	  scroll_state = 0;
	  cur_scroll_index += 1;
	  if (cur_scroll_index == nscroll_texts)
	    cur_scroll_index = 0;
692

Elliot Lee's avatar
Elliot Lee committed
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
	  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)
	{
718
719
	  if (offset > ((scroll_area->allocation.width +
			 scroll_text_widths[cur_scroll_text]) / 2))
Elliot Lee's avatar
Elliot Lee committed
720
721
	    {
	      scroll_state = 1;
722
723
	      offset = (scroll_area->allocation.width +
			scroll_text_widths[cur_scroll_text]) / 2;
Elliot Lee's avatar
Elliot Lee committed
724
725
726
727
728
729
	    }
	}
    }

  return return_val;
}