about-dialog.c 18.5 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

33
#include "gui-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
43
#include "libgimp/gimpintl.h"

44
45
#include "pixmaps/wilber2.xpm"

46

Elliot Lee's avatar
Elliot Lee committed
47
#define ANIMATION_STEPS 16
48
#define ANIMATION_SIZE   2
Elliot Lee's avatar
Elliot Lee committed
49

50

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


Michael Natterer's avatar
Michael Natterer committed
71
72
extern gboolean     double_speed;

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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 PangoLayout *scroll_layout    = NULL;
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;
static gint         hadja_state      = 0;
static gchar      **scroll_text      = authors;
static gint         nscroll_texts    = G_N_ELEMENTS (authors);
static gint         scroll_text_widths[G_N_ELEMENTS (authors)];
static gint         cur_scroll_text  = 0;
static gint         cur_scroll_index = 0;
static gint         shuffle_array[G_N_ELEMENTS (authors)];
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
  "Tvärtom!"
Manish Singh's avatar
Manish Singh committed
110
};
111

Michael Natterer's avatar
Michael Natterer committed
112

113
GtkWidget *
114
about_dialog_create (void)
Elliot Lee's avatar
Elliot Lee committed
115
116
{
  GtkWidget *vbox;
117
  GtkWidget *aboutframe;
Elliot Lee's avatar
Elliot Lee committed
118
119
  GtkWidget *label;
  GtkWidget *alignment;
120
  gint       max_width;
121
122
  gint       width;
  gint       height;
123
124
  gint       i;
  gchar     *label_text;
125
126
127
  GRand     *gr;

  gr = g_rand_new();
Elliot Lee's avatar
Elliot Lee committed
128

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

139
140
      gimp_help_connect (about_dialog, gimp_standard_help_func,
			 "dialogs/about.html");
141

142
      g_signal_connect (about_dialog, "destroy",
143
144
			G_CALLBACK (about_dialog_destroy),
			NULL);
145
      g_signal_connect (about_dialog, "unmap",
146
147
			G_CALLBACK (about_dialog_unmap),
			NULL);
148
      g_signal_connect (about_dialog, "button_press_event",
149
150
			G_CALLBACK (about_dialog_button),
			NULL);
151
      g_signal_connect (about_dialog, "key_press_event",
152
153
			G_CALLBACK (about_dialog_key),
			NULL);
Manish Singh's avatar
Manish Singh committed
154
      
155
      /*  dnd stuff  */
Michael Natterer's avatar
Michael Natterer committed
156
157
158
159
160
161
      gtk_drag_dest_set (about_dialog,
                         GTK_DEST_DEFAULT_MOTION |
                         GTK_DEST_DEFAULT_DROP,
                         NULL, 0,
                         GDK_ACTION_COPY); 
      gimp_dnd_viewable_dest_add (about_dialog,
162
163
				  GIMP_TYPE_TOOL_INFO,
				  about_dialog_tool_drop, NULL);
164

Elliot Lee's avatar
Elliot Lee committed
165
166
      gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK);

167
      if (! about_dialog_load_logo (about_dialog))
Elliot Lee's avatar
Elliot Lee committed
168
169
170
	{
	  gtk_widget_destroy (about_dialog);
	  about_dialog = NULL;
171
	  return NULL;
Elliot Lee's avatar
Elliot Lee committed
172
173
174
	}

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

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

      logo_area = gtk_drawing_area_new ();
186
      gtk_widget_set_size_request (logo_area, logo_width, logo_height);
Elliot Lee's avatar
Elliot Lee committed
187
      gtk_widget_set_events (logo_area, GDK_EXPOSURE_MASK);
188
      gtk_container_add (GTK_CONTAINER (aboutframe), logo_area);
Elliot Lee's avatar
Elliot Lee committed
189
190
      gtk_widget_show (logo_area);

191
      g_signal_connect (logo_area, "expose_event",
192
193
194
			G_CALLBACK (about_dialog_logo_expose),
			NULL);

Elliot Lee's avatar
Elliot Lee committed
195
196
197
      gtk_widget_realize (logo_area);
      gdk_window_set_background (logo_area->window, &logo_area->style->black);

198
199
      label_text = g_strdup_printf (_("Version %s brought to you by"),
				    GIMP_VERSION);
200
      label = gtk_label_new (label_text);
201
202
      g_free (label_text);
      label_text = NULL;
Elliot Lee's avatar
Elliot Lee committed
203
204
205
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

Sven Neumann's avatar
Sven Neumann committed
206
      label = gtk_label_new ("Spencer Kimball & Peter Mattis");
Elliot Lee's avatar
Elliot Lee committed
207
208
209
210
211
212
213
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

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

214
215
      aboutframe = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (aboutframe), GTK_SHADOW_IN);
216
      gtk_container_set_border_width (GTK_CONTAINER (aboutframe), 0);
217
218
      gtk_container_add (GTK_CONTAINER (alignment), aboutframe);
      gtk_widget_show (aboutframe);
Elliot Lee's avatar
Elliot Lee committed
219

220
221
222
223
      scroll_layout = gtk_widget_create_pango_layout (aboutframe, NULL);
      g_object_weak_ref (G_OBJECT (aboutframe), 
                         (GWeakNotify) g_object_unref, scroll_layout);

Elliot Lee's avatar
Elliot Lee committed
224
225
226
      max_width = 0;
      for (i = 0; i < nscroll_texts; i++)
	{
227
228
229
          pango_layout_set_text (scroll_layout, scroll_text[i], -1);
	  pango_layout_get_pixel_size (scroll_layout,
                                       &scroll_text_widths[i], &height);
Elliot Lee's avatar
Elliot Lee committed
230
231
	  max_width = MAX (max_width, scroll_text_widths[i]);
	}
232
233
      for (i = 0; i < (sizeof (drop_text) / sizeof (drop_text[0])); i++)
	{
234
235
236
          pango_layout_set_text (scroll_layout, drop_text[i], -1);
          pango_layout_get_pixel_size (scroll_layout, &width, NULL);
	  max_width = MAX (max_width, width);
237
	}
Manish Singh's avatar
Manish Singh committed
238
239
      for (i = 0; i < (sizeof (hadja_text) / sizeof (hadja_text[0])); i++)
	{
240
241
242
243
          pango_layout_set_text (scroll_layout, hadja_text[i], -1);
          pango_layout_get_pixel_size (scroll_layout, &width, NULL);
	  max_width = MAX (max_width, width);
        }
Elliot Lee's avatar
Elliot Lee committed
244
      scroll_area = gtk_drawing_area_new ();
245
      gtk_widget_set_size_request (scroll_area, max_width + 6, height + 1);
246
247
      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
248
249
      gtk_widget_show (scroll_area);

250
      label = gtk_label_new (_("Visit http://www.gimp.org/ for more information"));
251
252
253
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
      gtk_widget_show (label);

Elliot Lee's avatar
Elliot Lee committed
254
      gtk_widget_realize (scroll_area);
255
256
      gdk_window_set_background (scroll_area->window,
				 &scroll_area->style->white);
Elliot Lee's avatar
Elliot Lee committed
257
258
    }

259
  if (! GTK_WIDGET_VISIBLE (about_dialog))
Elliot Lee's avatar
Elliot Lee committed
260
    {
261
262
263
264
265
      do_animation    = TRUE;
      do_scrolling    = FALSE;
      scroll_state    = 0;
      frame           = 0;
      offset          = 0;
266
      cur_scroll_text = 0;
Elliot Lee's avatar
Elliot Lee committed
267

268
      if (! double_speed && hadja_state != 7)
Elliot Lee's avatar
Elliot Lee committed
269
	{
270
271
272
273
	  for (i = 0; i < nscroll_texts; i++) 
	    {
	      shuffle_array[i] = i;
	    }
Elliot Lee's avatar
Elliot Lee committed
274

275
	  for (i = 0; i < nscroll_texts; i++) 
Elliot Lee's avatar
Elliot Lee committed
276
	    {
277
278
	      gint j;

279
	      j = g_rand_int_range (gr, 0, nscroll_texts);
280
281
282
283
284
285
286
287
	      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
288
	    }
289
	  cur_scroll_text = g_rand_int_range(gr, 0, nscroll_texts);          
290
291
292
          pango_layout_set_text (scroll_layout, 
                                 scroll_text[cur_scroll_text], -1);

Elliot Lee's avatar
Elliot Lee committed
293
294
	}
    }
295
296

  gtk_window_present (GTK_WINDOW (about_dialog));
297

298
299
  g_rand_free (gr);

300
  return about_dialog;
Elliot Lee's avatar
Elliot Lee committed
301
302
}

303
static gboolean
Elliot Lee's avatar
Elliot Lee committed
304
305
about_dialog_load_logo (GtkWidget *window)
{
306
  gchar     *filename;
307
308
  GdkPixbuf *pixbuf;
  GdkGC     *gc;
309
  gint       i, j, k;
310
311
312
  GRand     *gr;

  gr = g_rand_new();
Elliot Lee's avatar
Elliot Lee committed
313
314
315
316

  if (logo_pixmap)
    return TRUE;

317
  filename = g_build_filename (gimp_data_directory (), "images",
318
                               "gimp_logo.png", NULL);
Elliot Lee's avatar
Elliot Lee committed
319

320
  pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
Elliot Lee's avatar
Elliot Lee committed
321

322
  g_free (filename);
Elliot Lee's avatar
Elliot Lee committed
323

324
325
  if (! pixbuf)
    return FALSE;
Elliot Lee's avatar
Elliot Lee committed
326

327
328
  logo_width  = gdk_pixbuf_get_width (pixbuf);
  logo_height = gdk_pixbuf_get_height (pixbuf);
Elliot Lee's avatar
Elliot Lee committed
329

330
  gtk_widget_realize (window);
Elliot Lee's avatar
Elliot Lee committed
331

332
333
334
  logo_pixmap = gdk_pixmap_new (window->window,
                                logo_width, logo_height,
                                gtk_widget_get_visual (window)->depth);
Elliot Lee's avatar
Elliot Lee committed
335

336
  gc = gdk_gc_new (logo_pixmap);
Elliot Lee's avatar
Elliot Lee committed
337

338
339
340
341
342
343
344
  gdk_pixbuf_render_to_drawable (pixbuf,
                                 GDK_DRAWABLE (logo_pixmap),
                                 gc,
                                 0, 0,
                                 0, 0,
                                 logo_width,
                                 logo_height,
345
                                 GDK_RGB_DITHER_NORMAL,
346
                                 0, 0);
Elliot Lee's avatar
Elliot Lee committed
347

348
349
  g_object_unref (gc);
  g_object_unref (pixbuf);
Elliot Lee's avatar
Elliot Lee committed
350

351
  dissolve_width =
352
353
354
    (logo_width / ANIMATION_SIZE) +
    (logo_width % ANIMATION_SIZE == 0 ? 0 : 1);

355
  dissolve_height =
356
357
    (logo_height / ANIMATION_SIZE) +
    (logo_height % ANIMATION_SIZE == 0 ? 0 : 1);
Elliot Lee's avatar
Elliot Lee committed
358
359
360
361
362

  dissolve_map = g_new (guchar, dissolve_width * dissolve_height);

  for (i = 0, k = 0; i < dissolve_height; i++)
    for (j = 0; j < dissolve_width; j++, k++)
363
364
365
      dissolve_map[k] = g_rand_int_range (gr, 0, ANIMATION_STEPS);

  g_rand_free (gr);
Elliot Lee's avatar
Elliot Lee committed
366
367
368
369
370

  return TRUE;
}

static void
371
372
about_dialog_destroy (GtkObject *object,
		      gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
373
374
{
  about_dialog = NULL;
375
  about_dialog_unmap (NULL, NULL);
Elliot Lee's avatar
Elliot Lee committed
376
377
378
}

static void
379
about_dialog_unmap (GtkWidget *widget,
380
                    gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
381
382
383
{
  if (timer)
    {
384
      g_source_remove (timer);
Elliot Lee's avatar
Elliot Lee committed
385
386
387
388
      timer = 0;
    }
}

389
static gint
Elliot Lee's avatar
Elliot Lee committed
390
about_dialog_logo_expose (GtkWidget      *widget,
391
392
			  GdkEventExpose *event,
			  gpointer        data)
Elliot Lee's avatar
Elliot Lee committed
393
394
395
396
397
398
{
  if (do_animation)
    {
      if (!timer)
	{
	  about_dialog_timer (widget);
399
	  timer = g_timeout_add (75, about_dialog_timer, NULL);
Elliot Lee's avatar
Elliot Lee committed
400
401
402
403
404
405
406
407
408
409
410
	}
    }
  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. */

411
412
413
414
415
416
      gdk_draw_drawable (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);
Elliot Lee's avatar
Elliot Lee committed
417
418
419
420
421
    }

  return FALSE;
}

422
static gint
Elliot Lee's avatar
Elliot Lee committed
423
about_dialog_button (GtkWidget      *widget,
424
425
		     GdkEventButton *event,
		     gpointer        data)
Elliot Lee's avatar
Elliot Lee committed
426
427
{
  if (timer)
428
429
430
431
432
    {
      g_source_remove (timer);
      timer = 0;
    }

Elliot Lee's avatar
Elliot Lee committed
433
434
435
436
437
438
439
  frame = 0;

  gtk_widget_hide (about_dialog);

  return FALSE;
}

Manish Singh's avatar
Manish Singh committed
440
441
442
443
444
445
446
static gint
about_dialog_key (GtkWidget      *widget,
		  GdkEventKey    *event,
		  gpointer        data)
{
  gint i;
  
447
448
449
  if (hadja_state == 7)
    return FALSE;
    
Manish Singh's avatar
Manish Singh committed
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
  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;
487
      nscroll_texts = G_N_ELEMENTS (hadja_text);
Manish Singh's avatar
Manish Singh committed
488
489
490
491
      
      for (i = 0; i < nscroll_texts; i++)
	{
	  shuffle_array[i] = i;
492
493
494
          pango_layout_set_text (scroll_layout, scroll_text[i], -1);
          pango_layout_get_pixel_size (scroll_layout, 
                                       &scroll_text_widths[i], NULL);
Manish Singh's avatar
Manish Singh committed
495
496
	}
      
497
      scroll_state     = 0;
Manish Singh's avatar
Manish Singh committed
498
      cur_scroll_index = 0;
499
500
      cur_scroll_text  = 0;
      offset           = 0;
501
      pango_layout_set_text (scroll_layout, scroll_text[cur_scroll_text], -1);
Manish Singh's avatar
Manish Singh committed
502
503
504
505
506
    }
  
  return FALSE;
}

507
static void
508
509
510
about_dialog_tool_drop (GtkWidget    *widget,
			GimpViewable *viewable,
			gpointer      data)
511
512
513
{
  GdkPixmap *pixmap = NULL;
  GdkBitmap *mask   = NULL;
514
515
516
  gint       width  = 0;
  gint       height = 0;
  gint       i;
517

518
519
520
521
  if (do_animation)
    return;

  if (timer)
522
    g_source_remove (timer);
523

524
  timer = g_timeout_add (75, about_dialog_timer, NULL);
525

526
  frame        = 0;
527
528
529
530
531
532
533
534
535
536
  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);

537
538
539
540
  pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
					 &mask,
					 NULL,
					 wilber2_xpm);
541

542
  gdk_drawable_get_size (pixmap, &width, &height);
543
544
545
546
547
548
549
550
551
552
553
554

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

555
556
557
558
559
      gdk_draw_drawable (logo_pixmap,
                         logo_area->style->black_gc,
                         pixmap, 0, 0,
                         x, y,
                         width, height);
560
561
562
563
564

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

565
566
  g_object_unref (pixmap);
  g_object_unref (mask);
567

568
  scroll_text = drop_text;
569
  nscroll_texts = G_N_ELEMENTS (drop_text);
570
571
572
573

  for (i = 0; i < nscroll_texts; i++)
    {
      shuffle_array[i] = i;
574
575
576
      pango_layout_set_text (scroll_layout, scroll_text[i], -1);
      pango_layout_get_pixel_size (scroll_layout, 
                                   &scroll_text_widths[i], NULL);
577
578
    }

579
  scroll_state     = 0;
580
  cur_scroll_index = 0;
581
582
  cur_scroll_text  = 0;
  offset           = 0;
583
  pango_layout_set_text (scroll_layout, scroll_text[cur_scroll_text], -1);
584

585
586
587
  double_speed = TRUE;
}

588
static gboolean
Elliot Lee's avatar
Elliot Lee committed
589
590
591
592
593
594
595
596
597
about_dialog_timer (gpointer data)
{
  gint i, j, k;
  gint return_val;

  return_val = TRUE;

  if (do_animation)
    {
598
      if (logo_area->allocation.width != 1)
Elliot Lee's avatar
Elliot Lee committed
599
	{
600
601
	  for (i = 0, k = 0; i < dissolve_height; i++)
	    for (j = 0; j < dissolve_width; j++, k++)
Manish Singh's avatar
Manish Singh committed
602
	      if (frame == dissolve_map[k])
603
		{
604
605
606
607
608
609
		  gdk_draw_drawable (logo_area->window,
				     logo_area->style->black_gc,
				     logo_pixmap,
				     j * ANIMATION_SIZE, i * ANIMATION_SIZE,
				     j * ANIMATION_SIZE, i * ANIMATION_SIZE,
				     ANIMATION_SIZE, ANIMATION_SIZE);
610
611
612
613
614
615
616
617
		}

	  frame += 1;

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

620
	      timer = g_timeout_add (75, about_dialog_timer, NULL);
Elliot Lee's avatar
Elliot Lee committed
621

622
623
	      return FALSE;
	    }
Elliot Lee's avatar
Elliot Lee committed
624
625
626
627
628
	}
    }

  if (do_scrolling)
    {
629
      if (! scroll_pixmap)
630
631
632
633
634
	scroll_pixmap = gdk_pixmap_new (scroll_area->window,
					scroll_area->allocation.width,
					scroll_area->allocation.height,
					-1);

Elliot Lee's avatar
Elliot Lee committed
635
636
637
638
      switch (scroll_state)
	{
	case 1:
	  scroll_state = 2;
639
	  timer = g_timeout_add (700, about_dialog_timer, NULL);
Elliot Lee's avatar
Elliot Lee committed
640
641
642
643
	  return_val = FALSE;
	  break;
	case 2:
	  scroll_state = 3;
644
	  timer = g_timeout_add (75, about_dialog_timer, NULL);
Elliot Lee's avatar
Elliot Lee committed
645
646
647
648
	  return_val = FALSE;
	  break;
	}

649
650
      if (offset > (scroll_text_widths[cur_scroll_text] +
		    scroll_area->allocation.width))
Elliot Lee's avatar
Elliot Lee committed
651
652
653
654
655
	{
	  scroll_state = 0;
	  cur_scroll_index += 1;
	  if (cur_scroll_index == nscroll_texts)
	    cur_scroll_index = 0;
656

Elliot Lee's avatar
Elliot Lee committed
657
	  cur_scroll_text = shuffle_array[cur_scroll_index];
658
659
          pango_layout_set_text (scroll_layout, 
                                 scroll_text[cur_scroll_text], -1);
Elliot Lee's avatar
Elliot Lee committed
660
661
662
663
664
665
666
667
	  offset = 0;
	}

      gdk_draw_rectangle (scroll_pixmap,
			  scroll_area->style->white_gc,
			  TRUE, 0, 0,
			  scroll_area->allocation.width,
			  scroll_area->allocation.height);
668
669
670
671
      gdk_draw_layout (scroll_pixmap,
                       scroll_area->style->black_gc,
                       scroll_area->allocation.width - offset, 0,
                       scroll_layout);
672
673
674
675
676
      gdk_draw_drawable (scroll_area->window,
		 	 scroll_area->style->black_gc,
			 scroll_pixmap, 0, 0, 0, 0,
			 scroll_area->allocation.width,
			 scroll_area->allocation.height);
Elliot Lee's avatar
Elliot Lee committed
677
678
679
680

      offset += 15;
      if (scroll_state == 0)
	{
681
682
	  if (offset > ((scroll_area->allocation.width +
			 scroll_text_widths[cur_scroll_text]) / 2))
Elliot Lee's avatar
Elliot Lee committed
683
684
	    {
	      scroll_state = 1;
685
686
	      offset = (scroll_area->allocation.width +
			scroll_text_widths[cur_scroll_text]) / 2;
Elliot Lee's avatar
Elliot Lee committed
687
688
689
690
691
692
	    }
	}
    }

  return return_val;
}