2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-05-03 05:50:29 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
2000-07-16 20:49:04 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include <string.h>
|
1998-07-15 10:28:31 +08:00
|
|
|
|
1998-05-03 05:50:29 +08:00
|
|
|
#include <gtk/gtk.h>
|
1998-07-15 10:28:31 +08:00
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2006-09-09 08:36:23 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "core/gimp.h"
|
2005-08-20 00:32:01 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "pdb/gimppdb.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
|
2005-12-29 04:45:52 +08:00
|
|
|
#include "about.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "about-dialog.h"
|
2001-06-05 08:22:25 +08:00
|
|
|
#include "authors.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
#define PDB_URL_LOAD "plug-in-web-browser"
|
1998-05-03 05:50:29 +08:00
|
|
|
|
2003-12-31 04:10:36 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2008-10-10 03:16:54 +08:00
|
|
|
GtkWidget *dialog;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2008-10-10 03:16:54 +08:00
|
|
|
GtkWidget *anim_area;
|
|
|
|
PangoLayout *layout;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2008-10-10 03:16:54 +08:00
|
|
|
gint n_authors;
|
|
|
|
gint shuffle[G_N_ELEMENTS (authors) - 1]; /* NULL terminated */
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2008-10-10 03:16:54 +08:00
|
|
|
guint timer;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2008-10-10 03:16:54 +08:00
|
|
|
gint index;
|
|
|
|
gint animstep;
|
|
|
|
gint textrange[2];
|
|
|
|
gint state;
|
|
|
|
gboolean visible;
|
2005-08-20 00:32:01 +08:00
|
|
|
} GimpAboutDialog;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
static void about_dialog_map (GtkWidget *widget,
|
|
|
|
GimpAboutDialog *dialog);
|
|
|
|
static void about_dialog_unmap (GtkWidget *widget,
|
|
|
|
GimpAboutDialog *dialog);
|
|
|
|
static void about_dialog_load_url (GtkAboutDialog *dialog,
|
|
|
|
const gchar *url,
|
|
|
|
gpointer data);
|
|
|
|
static GdkPixbuf * about_dialog_load_logo (void);
|
|
|
|
static void about_dialog_add_animation (GtkWidget *vbox,
|
|
|
|
GimpAboutDialog *dialog);
|
|
|
|
static gboolean about_dialog_anim_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GimpAboutDialog *dialog);
|
|
|
|
static void about_dialog_reshuffle (GimpAboutDialog *dialog);
|
|
|
|
static gboolean about_dialog_timer (gpointer data);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2006-08-16 18:42:44 +08:00
|
|
|
static void about_dialog_add_message (GtkWidget *vbox);
|
2006-08-16 06:21:32 +08:00
|
|
|
|
2001-10-25 21:30:01 +08:00
|
|
|
|
2001-04-19 00:39:34 +08:00
|
|
|
GtkWidget *
|
2005-08-20 00:32:01 +08:00
|
|
|
about_dialog_create (GimpContext *context)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
static GimpAboutDialog *dialog = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
if (! dialog)
|
2003-12-29 10:57:07 +08:00
|
|
|
{
|
2006-06-19 21:24:44 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *container;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
GList *children;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
if (gimp_pdb_lookup_procedure (context->gimp->pdb, PDB_URL_LOAD))
|
2005-08-20 00:32:01 +08:00
|
|
|
gtk_about_dialog_set_url_hook (about_dialog_load_url,
|
|
|
|
g_object_ref (context),
|
|
|
|
(GDestroyNotify) g_object_unref);
|
|
|
|
|
|
|
|
dialog = g_new0 (GimpAboutDialog, 1);
|
|
|
|
|
|
|
|
dialog->n_authors = G_N_ELEMENTS (authors) - 1;
|
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
pixbuf = about_dialog_load_logo ();
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
widget = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
2005-08-20 01:15:28 +08:00
|
|
|
"role", "about-dialog",
|
|
|
|
"window-position", GTK_WIN_POS_CENTER,
|
2007-05-21 15:53:01 +08:00
|
|
|
"title", _("About GIMP"),
|
|
|
|
"program-name", GIMP_ACRONYM,
|
2005-08-20 00:32:01 +08:00
|
|
|
"version", GIMP_VERSION,
|
2005-12-29 04:45:52 +08:00
|
|
|
"copyright", GIMP_COPYRIGHT,
|
|
|
|
"comments", GIMP_NAME,
|
|
|
|
"license", GIMP_LICENSE,
|
2005-12-29 03:53:46 +08:00
|
|
|
"wrap-license", TRUE,
|
2006-06-19 21:24:44 +08:00
|
|
|
"logo", pixbuf,
|
2005-12-29 04:45:52 +08:00
|
|
|
"website", "http://www.gimp.org/",
|
|
|
|
"website-label", _("Visit the GIMP website"),
|
2005-08-20 00:32:01 +08:00
|
|
|
"authors", authors,
|
2005-08-20 10:28:29 +08:00
|
|
|
"artists", artists,
|
|
|
|
"documenters", documenters,
|
2008-09-21 05:30:48 +08:00
|
|
|
/* Translators: insert your names here, separated by newline */
|
2005-08-20 00:32:01 +08:00
|
|
|
"translator-credits", _("translator-credits"),
|
2004-03-15 04:55:13 +08:00
|
|
|
NULL);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-20 17:14:26 +08:00
|
|
|
if (pixbuf)
|
|
|
|
g_object_unref (pixbuf);
|
2006-06-19 21:24:44 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->dialog = widget;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (widget), (gpointer) &dialog);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
g_signal_connect (widget, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
2003-12-29 10:57:07 +08:00
|
|
|
NULL);
|
2005-08-20 00:32:01 +08:00
|
|
|
|
|
|
|
g_signal_connect (widget, "map",
|
|
|
|
G_CALLBACK (about_dialog_map),
|
|
|
|
dialog);
|
2003-12-29 10:57:07 +08:00
|
|
|
g_signal_connect (widget, "unmap",
|
|
|
|
G_CALLBACK (about_dialog_unmap),
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
/* kids, don't try this at home! */
|
|
|
|
container = GTK_DIALOG (widget)->vbox;
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (container));
|
2004-03-15 04:55:13 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
if (GTK_IS_VBOX (children->data))
|
2006-08-16 06:21:32 +08:00
|
|
|
{
|
|
|
|
about_dialog_add_animation (children->data, dialog);
|
2006-08-16 18:42:44 +08:00
|
|
|
about_dialog_add_message (children->data);
|
2006-08-16 06:21:32 +08:00
|
|
|
}
|
2005-08-20 00:32:01 +08:00
|
|
|
else
|
|
|
|
g_warning ("%s: ooops, no vbox in this container?", G_STRLOC);
|
2004-01-18 09:29:37 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
g_list_free (children);
|
|
|
|
}
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog->dialog));
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
return dialog->dialog;
|
|
|
|
}
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
static void
|
|
|
|
about_dialog_map (GtkWidget *widget,
|
|
|
|
GimpAboutDialog *dialog)
|
|
|
|
{
|
|
|
|
if (dialog->layout && dialog->timer == 0)
|
|
|
|
{
|
|
|
|
dialog->state = 0;
|
|
|
|
dialog->index = 0;
|
|
|
|
dialog->animstep = 0;
|
|
|
|
dialog->visible = FALSE;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
about_dialog_reshuffle (dialog);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->timer = g_timeout_add (800, about_dialog_timer, dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2005-08-20 00:32:01 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
static void
|
|
|
|
about_dialog_unmap (GtkWidget *widget,
|
|
|
|
GimpAboutDialog *dialog)
|
|
|
|
{
|
|
|
|
if (dialog->timer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
g_source_remove (dialog->timer);
|
|
|
|
dialog->timer = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-08-20 00:32:01 +08:00
|
|
|
about_dialog_load_url (GtkAboutDialog *dialog,
|
|
|
|
const gchar *url,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-04 18:30:58 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
|
|
|
GValueArray *return_vals;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
return_vals = gimp_pdb_execute_procedure_by_name (context->gimp->pdb,
|
2007-12-03 15:44:49 +08:00
|
|
|
context, NULL, NULL,
|
2006-04-26 17:13:47 +08:00
|
|
|
PDB_URL_LOAD,
|
|
|
|
G_TYPE_STRING, url,
|
|
|
|
G_TYPE_NONE);
|
2006-04-04 18:30:58 +08:00
|
|
|
g_value_array_free (return_vals);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
static GdkPixbuf *
|
|
|
|
about_dialog_load_logo (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-06-19 21:24:44 +08:00
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gchar *filename;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
filename = g_build_filename (gimp_data_directory (), "images",
|
2008-10-10 03:16:54 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
|
|
|
"gimp-devel-logo.png",
|
|
|
|
#else
|
2006-06-19 21:24:44 +08:00
|
|
|
"gimp-logo.png",
|
2008-10-10 03:16:54 +08:00
|
|
|
#endif
|
2006-06-19 21:24:44 +08:00
|
|
|
NULL);
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
return pixbuf;
|
|
|
|
}
|
2004-05-06 22:26:31 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
static void
|
|
|
|
about_dialog_add_animation (GtkWidget *vbox,
|
|
|
|
GimpAboutDialog *dialog)
|
|
|
|
{
|
|
|
|
gint height;
|
2004-05-06 22:26:31 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
dialog->anim_area = gtk_drawing_area_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), dialog->anim_area, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (vbox), dialog->anim_area, 4);
|
|
|
|
gtk_widget_show (dialog->anim_area);
|
2004-05-06 22:26:31 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
dialog->layout = gtk_widget_create_pango_layout (dialog->anim_area, NULL);
|
|
|
|
g_object_weak_ref (G_OBJECT (dialog->anim_area),
|
2005-08-20 00:32:01 +08:00
|
|
|
(GWeakNotify) g_object_unref, dialog->layout);
|
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
pango_layout_get_pixel_size (dialog->layout, NULL, &height);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (dialog->anim_area, -1, 2 * height);
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
g_signal_connect (dialog->anim_area, "expose-event",
|
|
|
|
G_CALLBACK (about_dialog_anim_expose),
|
|
|
|
dialog);
|
2004-05-06 22:26:31 +08:00
|
|
|
}
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
static void
|
|
|
|
about_dialog_reshuffle (GimpAboutDialog *dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
GRand *gr = g_rand_new ();
|
|
|
|
gint i;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
for (i = 0; i < dialog->n_authors; i++)
|
|
|
|
dialog->shuffle[i] = i;
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 09:16:41 +08:00
|
|
|
/* here we rely on the authors array having Peter and Spencer first */
|
|
|
|
#define START_INDEX 2
|
|
|
|
|
|
|
|
for (i = START_INDEX; i < dialog->n_authors; i++)
|
2005-08-20 00:32:01 +08:00
|
|
|
{
|
2005-08-20 09:16:41 +08:00
|
|
|
gint j = g_rand_int_range (gr, START_INDEX, dialog->n_authors);
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
if (i != j)
|
|
|
|
{
|
|
|
|
gint t;
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
t = dialog->shuffle[j];
|
|
|
|
dialog->shuffle[j] = dialog->shuffle[i];
|
|
|
|
dialog->shuffle[i] = t;
|
|
|
|
}
|
2003-12-30 01:52:46 +08:00
|
|
|
}
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 09:16:41 +08:00
|
|
|
#undef START_INDEX
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
g_rand_free (gr);
|
|
|
|
}
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
static gboolean
|
2006-06-19 21:24:44 +08:00
|
|
|
about_dialog_anim_expose (GtkWidget *widget,
|
2005-08-20 00:32:01 +08:00
|
|
|
GdkEventExpose *event,
|
|
|
|
GimpAboutDialog *dialog)
|
|
|
|
{
|
2008-06-28 23:12:13 +08:00
|
|
|
GtkStyle *style = gtk_widget_get_style (widget);
|
|
|
|
GdkGC *text_gc;
|
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
if (! dialog->visible)
|
|
|
|
return FALSE;
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2008-06-28 23:12:13 +08:00
|
|
|
text_gc = style->text_gc[GTK_STATE_NORMAL];
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
pango_layout_get_pixel_size (dialog->layout, &width, &height);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
x = (widget->allocation.width - width) / 2;
|
|
|
|
y = (widget->allocation.height - height) / 2;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
if (dialog->textrange[1] > 0)
|
|
|
|
{
|
|
|
|
GdkRegion *covered_region = NULL;
|
|
|
|
GdkRegion *rect_region;
|
2004-02-18 21:43:50 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
covered_region = gdk_pango_layout_get_clip_region (dialog->layout,
|
|
|
|
x, y,
|
|
|
|
dialog->textrange, 1);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
rect_region = gdk_region_rectangle (&event->area);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
gdk_region_intersect (covered_region, rect_region);
|
|
|
|
gdk_region_destroy (rect_region);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
gdk_gc_set_clip_region (text_gc, covered_region);
|
|
|
|
gdk_region_destroy (covered_region);
|
|
|
|
}
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
gdk_draw_layout (widget->window, text_gc, x, y, dialog->layout);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
gdk_gc_set_clip_region (text_gc, NULL);
|
2004-02-18 21:43:50 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
insert_spacers (const gchar *string)
|
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
GString *str = g_string_new (NULL);
|
|
|
|
gchar *normalized;
|
|
|
|
gchar *ptr;
|
|
|
|
gunichar unichr;
|
2000-08-24 08:33:11 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
normalized = g_utf8_normalize (string, -1, G_NORMALIZE_DEFAULT_COMPOSE);
|
|
|
|
ptr = normalized;
|
|
|
|
|
|
|
|
while ((unichr = g_utf8_get_char (ptr)))
|
2000-08-24 08:33:11 +08:00
|
|
|
{
|
2003-12-29 10:57:07 +08:00
|
|
|
g_string_append_unichar (str, unichr);
|
|
|
|
g_string_append_unichar (str, 0x200b); /* ZERO WIDTH SPACE */
|
|
|
|
ptr = g_utf8_next_char (ptr);
|
|
|
|
}
|
2003-11-08 01:29:02 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
g_free (normalized);
|
2003-11-08 01:29:02 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
return g_string_free (str, FALSE);
|
|
|
|
}
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
static void inline
|
2006-06-19 21:24:44 +08:00
|
|
|
mix_colors (const GdkColor *start,
|
|
|
|
const GdkColor *end,
|
|
|
|
GdkColor *target,
|
|
|
|
gdouble pos)
|
2000-07-16 20:49:04 +08:00
|
|
|
{
|
2003-12-29 10:57:07 +08:00
|
|
|
target->red = start->red * (1.0 - pos) + end->red * pos;
|
|
|
|
target->green = start->green * (1.0 - pos) + end->green * pos;
|
|
|
|
target->blue = start->blue * (1.0 - pos) + end->blue * pos;
|
|
|
|
}
|
2001-09-20 03:06:36 +08:00
|
|
|
|
2003-12-30 01:52:46 +08:00
|
|
|
static void
|
2005-08-20 00:32:01 +08:00
|
|
|
decorate_text (GimpAboutDialog *dialog,
|
|
|
|
gint anim_type,
|
|
|
|
gdouble time)
|
2003-12-30 01:52:46 +08:00
|
|
|
{
|
2008-06-28 23:12:13 +08:00
|
|
|
GtkStyle *style = gtk_widget_get_style (dialog->anim_area);
|
2005-08-20 00:32:01 +08:00
|
|
|
const gchar *text;
|
|
|
|
const gchar *ptr;
|
|
|
|
gint letter_count = 0;
|
|
|
|
gint text_length = 0;
|
|
|
|
gint text_bytelen = 0;
|
|
|
|
gint cluster_start, cluster_end;
|
|
|
|
gunichar unichr;
|
|
|
|
PangoAttrList *attrlist = NULL;
|
2003-12-29 10:57:07 +08:00
|
|
|
PangoAttribute *attr;
|
2005-08-20 00:32:01 +08:00
|
|
|
PangoRectangle irect = {0, 0, 0, 0};
|
|
|
|
PangoRectangle lrect = {0, 0, 0, 0};
|
2006-06-19 21:24:44 +08:00
|
|
|
GdkColor mix;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2008-06-28 23:12:13 +08:00
|
|
|
mix_colors (style->bg + GTK_STATE_NORMAL,
|
|
|
|
style->fg + GTK_STATE_NORMAL, &mix, time);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
text = pango_layout_get_text (dialog->layout);
|
|
|
|
g_return_if_fail (text != NULL);
|
2003-12-29 10:57:07 +08:00
|
|
|
|
|
|
|
text_length = g_utf8_strlen (text, -1);
|
|
|
|
text_bytelen = strlen (text);
|
|
|
|
|
|
|
|
attrlist = pango_attr_list_new ();
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->textrange[0] = 0;
|
|
|
|
dialog->textrange[1] = text_bytelen;
|
2003-12-29 10:57:07 +08:00
|
|
|
|
|
|
|
switch (anim_type)
|
2005-08-20 00:32:01 +08:00
|
|
|
{
|
2003-12-29 10:57:07 +08:00
|
|
|
case 0: /* Fade in */
|
|
|
|
attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
|
|
|
|
attr->start_index = 0;
|
|
|
|
attr->end_index = text_bytelen;
|
|
|
|
pango_attr_list_insert (attrlist, attr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Fade in, spread */
|
|
|
|
attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
|
|
|
|
attr->start_index = 0;
|
|
|
|
attr->end_index = text_bytelen;
|
|
|
|
pango_attr_list_change (attrlist, attr);
|
|
|
|
|
|
|
|
ptr = text;
|
|
|
|
|
|
|
|
cluster_start = 0;
|
|
|
|
while ((unichr = g_utf8_get_char (ptr)))
|
|
|
|
{
|
|
|
|
ptr = g_utf8_next_char (ptr);
|
|
|
|
cluster_end = (ptr - text);
|
|
|
|
|
|
|
|
if (unichr == 0x200b)
|
|
|
|
{
|
|
|
|
lrect.width = (1.0 - time) * 15.0 * PANGO_SCALE + 0.5;
|
|
|
|
attr = pango_attr_shape_new (&irect, &lrect);
|
|
|
|
attr->start_index = cluster_start;
|
|
|
|
attr->end_index = cluster_end;
|
|
|
|
pango_attr_list_change (attrlist, attr);
|
|
|
|
}
|
|
|
|
cluster_start = cluster_end;
|
|
|
|
}
|
|
|
|
break;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
case 2: /* Fade in, sinewave */
|
|
|
|
attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
|
|
|
|
attr->start_index = 0;
|
|
|
|
attr->end_index = text_bytelen;
|
|
|
|
pango_attr_list_change (attrlist, attr);
|
|
|
|
|
|
|
|
ptr = text;
|
|
|
|
|
|
|
|
cluster_start = 0;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
while ((unichr = g_utf8_get_char (ptr)))
|
|
|
|
{
|
|
|
|
if (unichr == 0x200b)
|
|
|
|
{
|
|
|
|
cluster_end = ptr - text;
|
|
|
|
attr = pango_attr_rise_new ((1.0 -time) * 18000 *
|
|
|
|
sin (4.0 * time +
|
|
|
|
(float) letter_count * 0.7));
|
|
|
|
attr->start_index = cluster_start;
|
|
|
|
attr->end_index = cluster_end;
|
|
|
|
pango_attr_list_change (attrlist, attr);
|
|
|
|
|
|
|
|
letter_count++;
|
|
|
|
cluster_start = cluster_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = g_utf8_next_char (ptr);
|
|
|
|
}
|
|
|
|
break;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
case 3: /* letterwise Fade in */
|
|
|
|
ptr = text;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
letter_count = 0;
|
2003-12-29 10:57:07 +08:00
|
|
|
cluster_start = 0;
|
2005-08-20 00:32:01 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
while ((unichr = g_utf8_get_char (ptr)))
|
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
gint border = (text_length + 15) * time - 15;
|
2003-12-29 10:57:07 +08:00
|
|
|
gdouble pos;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
if (letter_count < border)
|
|
|
|
pos = 0;
|
|
|
|
else if (letter_count > border + 15)
|
|
|
|
pos = 1;
|
|
|
|
else
|
|
|
|
pos = ((gdouble) (letter_count - border)) / 15;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2008-06-28 23:12:13 +08:00
|
|
|
mix_colors (style->fg + GTK_STATE_NORMAL,
|
|
|
|
style->bg + GTK_STATE_NORMAL,
|
2003-12-29 10:57:07 +08:00
|
|
|
&mix, pos);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
ptr = g_utf8_next_char (ptr);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
cluster_end = ptr - text;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
|
|
|
|
attr->start_index = cluster_start;
|
|
|
|
attr->end_index = cluster_end;
|
|
|
|
pango_attr_list_change (attrlist, attr);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
if (pos < 1.0)
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->textrange[1] = cluster_end;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
letter_count++;
|
|
|
|
cluster_start = cluster_end;
|
|
|
|
}
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
break;
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2003-12-29 10:57:07 +08:00
|
|
|
default:
|
|
|
|
g_printerr ("Unknown animation type %d\n", anim_type);
|
2005-08-20 00:32:01 +08:00
|
|
|
}
|
2004-02-18 21:43:50 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
pango_layout_set_attributes (dialog->layout, attrlist);
|
2003-12-29 10:57:07 +08:00
|
|
|
pango_attr_list_unref (attrlist);
|
2000-07-16 20:49:04 +08:00
|
|
|
}
|
|
|
|
|
2001-09-20 03:06:36 +08:00
|
|
|
static gboolean
|
1997-11-25 06:05:25 +08:00
|
|
|
about_dialog_timer (gpointer data)
|
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
GimpAboutDialog *dialog = data;
|
|
|
|
gint timeout = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
if (dialog->animstep == 0)
|
|
|
|
{
|
2006-06-19 21:24:44 +08:00
|
|
|
gchar *text = NULL;
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->visible = TRUE;
|
2004-01-14 07:19:05 +08:00
|
|
|
|
2005-08-20 09:16:41 +08:00
|
|
|
switch (dialog->state)
|
2004-01-14 07:19:05 +08:00
|
|
|
{
|
2005-08-20 09:16:41 +08:00
|
|
|
case 0:
|
|
|
|
dialog->timer = g_timeout_add (30, about_dialog_timer, dialog);
|
|
|
|
dialog->state += 1;
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
text = insert_spacers (_("GIMP is brought to you by"));
|
|
|
|
dialog->state += 1;
|
|
|
|
break;
|
2004-02-18 21:43:50 +08:00
|
|
|
|
2005-08-20 09:16:41 +08:00
|
|
|
case 2:
|
|
|
|
if (! (dialog->index < dialog->n_authors))
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->index = 0;
|
2003-12-31 04:10:36 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
text = insert_spacers (authors[dialog->shuffle[dialog->index]]);
|
2005-08-20 09:16:41 +08:00
|
|
|
dialog->index += 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (TRUE);
|
|
|
|
break;
|
2003-12-31 04:10:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
g_return_val_if_fail (text != NULL, TRUE);
|
2004-02-18 21:43:50 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
pango_layout_set_text (dialog->layout, text, -1);
|
|
|
|
pango_layout_set_attributes (dialog->layout, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
g_free (text);
|
2003-12-29 10:57:07 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
if (dialog->animstep < 16)
|
2003-12-29 10:57:07 +08:00
|
|
|
{
|
2006-06-19 21:32:04 +08:00
|
|
|
decorate_text (dialog, 2, ((gfloat) dialog->animstep) / 15.0);
|
2003-12-29 10:57:07 +08:00
|
|
|
}
|
2005-08-20 00:32:01 +08:00
|
|
|
else if (dialog->animstep == 16)
|
2003-12-29 10:57:07 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
timeout = 800;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2005-08-20 00:32:01 +08:00
|
|
|
else if (dialog->animstep == 17)
|
2003-12-29 10:57:07 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
timeout = 30;
|
2003-12-29 10:57:07 +08:00
|
|
|
}
|
2005-08-20 00:32:01 +08:00
|
|
|
else if (dialog->animstep < 33)
|
2003-12-29 10:57:07 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
decorate_text (dialog, 1,
|
|
|
|
1.0 - ((gfloat) (dialog->animstep - 17)) / 15.0);
|
2003-12-29 10:57:07 +08:00
|
|
|
}
|
2005-08-20 00:32:01 +08:00
|
|
|
else if (dialog->animstep == 33)
|
2003-12-29 10:57:07 +08:00
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->visible = FALSE;
|
|
|
|
timeout = 300;
|
2003-12-29 10:57:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->visible = FALSE;
|
|
|
|
dialog->animstep = -1;
|
|
|
|
timeout = 30;
|
2003-12-29 10:57:07 +08:00
|
|
|
}
|
|
|
|
|
2005-08-20 00:32:01 +08:00
|
|
|
dialog->animstep++;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-06-19 21:24:44 +08:00
|
|
|
gtk_widget_queue_draw (dialog->anim_area);
|
2005-08-20 00:32:01 +08:00
|
|
|
|
|
|
|
if (timeout > 0)
|
|
|
|
{
|
|
|
|
dialog->timer = g_timeout_add (timeout, about_dialog_timer, dialog);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* else keep the current timeout */
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2006-08-16 06:21:32 +08:00
|
|
|
|
|
|
|
static void
|
2006-08-16 18:42:44 +08:00
|
|
|
about_dialog_add_message (GtkWidget *vbox)
|
2006-08-16 06:21:32 +08:00
|
|
|
{
|
2006-08-16 18:42:44 +08:00
|
|
|
#ifdef GIMP_UNSTABLE
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
label = gtk_label_new (_("This is an unstable development release."));
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
-1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (vbox), label, 2);
|
|
|
|
gtk_widget_show (label);
|
2006-08-16 06:21:32 +08:00
|
|
|
#endif
|
2006-08-16 18:42:44 +08:00
|
|
|
}
|
2006-08-16 06:21:32 +08:00
|
|
|
|