1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
2000-09-25 09:27:47 +08:00
|
|
|
* Copyright (C) 2000 Michael Natterer and Sven Neumann
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-12-31 02:51:57 +08:00
|
|
|
#include <errno.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2001-02-04 12:51:17 +08:00
|
|
|
#include <string.h>
|
2002-12-31 02:51:57 +08:00
|
|
|
#include <sys/types.h>
|
2005-02-07 09:24:22 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-07 09:24:22 +08:00
|
|
|
#include <glib/gstdio.h>
|
2001-02-04 12:51:17 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2003-01-01 21:33:27 +08:00
|
|
|
#ifdef G_OS_WIN32
|
2005-02-19 08:50:36 +08:00
|
|
|
#include <libgimpbase/gimpwin32-io.h>
|
2003-01-01 21:33:27 +08:00
|
|
|
#endif
|
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2004-01-19 09:54:11 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +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
|
|
|
|
2005-01-25 06:41:24 +08:00
|
|
|
#include "config/gimpconfig-file.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimprc.h"
|
2001-05-15 19:25:25 +08:00
|
|
|
|
2004-11-24 05:00:15 +08:00
|
|
|
#include "core/gimp-templates.h"
|
|
|
|
|
2001-11-11 03:35:21 +08:00
|
|
|
#include "user-install-dialog.h"
|
2001-05-23 05:12:43 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2002-12-31 01:27:58 +08:00
|
|
|
|
2002-12-31 02:51:57 +08:00
|
|
|
enum
|
|
|
|
{
|
2006-04-21 21:32:29 +08:00
|
|
|
WELCOME_PAGE,
|
|
|
|
INSTALLATION_PAGE,
|
2002-12-31 02:51:57 +08:00
|
|
|
NUM_PAGES
|
|
|
|
};
|
2002-12-31 01:27:58 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2002-03-28 10:05:10 +08:00
|
|
|
DIRENT_COLUMN,
|
|
|
|
PIXBUF_COLUMN,
|
|
|
|
DESC_COLUMN,
|
|
|
|
NUM_COLUMNS
|
|
|
|
};
|
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
static void user_install_response (GtkWidget *dialog,
|
2004-11-05 04:10:57 +08:00
|
|
|
gint response_id,
|
|
|
|
GimpRc *gimprc);
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-24 23:26:08 +08:00
|
|
|
static gboolean user_install_run (GtkWidget *dialog,
|
2006-04-21 19:07:25 +08:00
|
|
|
const gchar *oldgimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
/* private stuff */
|
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
static GtkWidget *notebook = NULL;
|
2000-03-16 00:00:24 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
static GtkWidget *title_label = NULL;
|
|
|
|
static GtkWidget *footer_label = NULL;
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
static gchar *oldgimp = NULL;
|
|
|
|
static gint oldgimp_major = 0;
|
|
|
|
static gint oldgimp_minor = 0;
|
|
|
|
static gboolean migrate = FALSE;
|
2004-10-31 09:20:56 +08:00
|
|
|
|
|
|
|
|
2002-12-26 09:51:25 +08:00
|
|
|
typedef enum
|
2002-12-30 04:59:42 +08:00
|
|
|
{
|
2006-04-21 21:32:29 +08:00
|
|
|
USER_INSTALL_DO_NOTHING, /* Don't pre-create */
|
|
|
|
USER_INSTALL_MKDIR, /* Create the directory */
|
|
|
|
USER_INSTALL_FROM_SYSCONF_DIR /* Copy from sysconf directory */
|
|
|
|
} UserInstallAction;
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-19 22:28:10 +08:00
|
|
|
static const struct
|
2000-03-15 07:06:21 +08:00
|
|
|
{
|
2006-04-21 21:32:29 +08:00
|
|
|
const gchar *name;
|
|
|
|
UserInstallAction action;
|
2000-03-15 07:06:21 +08:00
|
|
|
}
|
2006-04-21 21:32:29 +08:00
|
|
|
user_install_items[] =
|
2000-03-15 07:06:21 +08:00
|
|
|
{
|
2006-04-21 21:32:29 +08:00
|
|
|
{ "gimprc", USER_INSTALL_DO_NOTHING },
|
|
|
|
{ "gtkrc", USER_INSTALL_FROM_SYSCONF_DIR },
|
|
|
|
{ "pluginrc", USER_INSTALL_DO_NOTHING },
|
|
|
|
{ "menurc", USER_INSTALL_DO_NOTHING },
|
|
|
|
{ "sessionrc", USER_INSTALL_DO_NOTHING },
|
|
|
|
{ "templaterc", USER_INSTALL_DO_NOTHING },
|
|
|
|
{ "unitrc", USER_INSTALL_DO_NOTHING },
|
|
|
|
{ "brushes", USER_INSTALL_MKDIR },
|
|
|
|
{ "fonts", USER_INSTALL_MKDIR },
|
|
|
|
{ "gradients", USER_INSTALL_MKDIR },
|
|
|
|
{ "palettes", USER_INSTALL_MKDIR },
|
|
|
|
{ "patterns", USER_INSTALL_MKDIR },
|
|
|
|
{ "plug-ins", USER_INSTALL_MKDIR },
|
|
|
|
{ "modules", USER_INSTALL_MKDIR },
|
|
|
|
{ "interpreters", USER_INSTALL_MKDIR },
|
|
|
|
{ "environ", USER_INSTALL_MKDIR },
|
|
|
|
{ "scripts", USER_INSTALL_MKDIR },
|
|
|
|
{ "templates", USER_INSTALL_MKDIR },
|
|
|
|
{ "themes", USER_INSTALL_MKDIR },
|
|
|
|
{ "tmp", USER_INSTALL_MKDIR },
|
|
|
|
{ "tool-options", USER_INSTALL_MKDIR },
|
|
|
|
{ "curves", USER_INSTALL_MKDIR },
|
|
|
|
{ "levels", USER_INSTALL_MKDIR },
|
|
|
|
{ "fractalexplorer", USER_INSTALL_MKDIR },
|
|
|
|
{ "gfig", USER_INSTALL_MKDIR },
|
|
|
|
{ "gflare", USER_INSTALL_MKDIR },
|
|
|
|
{ "gimpressionist", USER_INSTALL_MKDIR }
|
2000-03-15 07:06:21 +08:00
|
|
|
};
|
2002-11-21 08:36:45 +08:00
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
static GtkWidget *
|
2000-04-08 04:04:00 +08:00
|
|
|
user_install_notebook_set_page (GtkNotebook *notebook,
|
2003-12-23 03:47:05 +08:00
|
|
|
gint index)
|
2000-03-16 00:00:24 +08:00
|
|
|
{
|
2006-04-19 22:28:10 +08:00
|
|
|
GtkWidget *page;
|
|
|
|
const gchar *title;
|
|
|
|
const gchar *footer;
|
2002-12-31 02:51:57 +08:00
|
|
|
|
2000-03-16 00:00:24 +08:00
|
|
|
page = gtk_notebook_get_nth_page (notebook, index);
|
2002-12-31 02:51:57 +08:00
|
|
|
|
2001-07-25 08:27:41 +08:00
|
|
|
title = g_object_get_data (G_OBJECT (page), "title");
|
|
|
|
footer = g_object_get_data (G_OBJECT (page), "footer");
|
2000-03-16 00:00:24 +08:00
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (title_label), title);
|
|
|
|
gtk_label_set_text (GTK_LABEL (footer_label), footer);
|
|
|
|
|
2001-08-01 08:35:59 +08:00
|
|
|
gtk_notebook_set_current_page (notebook, index);
|
2006-04-21 19:07:25 +08:00
|
|
|
|
|
|
|
return page;
|
2000-03-16 00:00:24 +08:00
|
|
|
}
|
2000-03-15 07:06:21 +08:00
|
|
|
|
|
|
|
static void
|
2006-04-21 19:07:25 +08:00
|
|
|
user_install_response (GtkWidget *dialog,
|
2003-11-06 23:27:05 +08:00
|
|
|
gint response_id,
|
|
|
|
GimpRc *gimprc)
|
2000-03-15 07:06:21 +08:00
|
|
|
{
|
2006-04-21 19:07:25 +08:00
|
|
|
gint index = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id != GTK_RESPONSE_OK)
|
2006-04-21 19:07:25 +08:00
|
|
|
exit (EXIT_SUCCESS);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-11-24 05:00:15 +08:00
|
|
|
switch (index)
|
2000-03-15 07:06:21 +08:00
|
|
|
{
|
2006-04-21 21:32:29 +08:00
|
|
|
case WELCOME_PAGE:
|
2006-04-21 19:07:25 +08:00
|
|
|
{
|
|
|
|
GtkWidget *page;
|
|
|
|
|
|
|
|
page = user_install_notebook_set_page (GTK_NOTEBOOK (notebook),
|
|
|
|
++index);
|
|
|
|
|
|
|
|
/* Creating the directories can take some time on NFS, so inform
|
|
|
|
* the user and set the buttons insensitive
|
|
|
|
*/
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_CANCEL, FALSE);
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK, TRUE);
|
|
|
|
|
2006-04-24 23:26:08 +08:00
|
|
|
if (user_install_run (dialog, migrate ? oldgimp : NULL))
|
2006-04-21 19:07:25 +08:00
|
|
|
{
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK, TRUE);
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (footer_label),
|
2006-04-24 23:26:08 +08:00
|
|
|
_("Installation successful."));
|
2006-04-21 19:07:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_label_set_text (GTK_LABEL (footer_label),
|
2006-04-24 23:26:08 +08:00
|
|
|
_("Installation failed!"));
|
2006-04-21 19:07:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_CANCEL, TRUE);
|
|
|
|
}
|
2000-03-15 07:06:21 +08:00
|
|
|
break;
|
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
case INSTALLATION_PAGE:
|
2004-11-05 04:10:57 +08:00
|
|
|
if (! migrate)
|
|
|
|
gimp_rc_save (gimprc);
|
2003-07-11 19:30:41 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
2000-03-15 07:06:21 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gtk_main_quit ();
|
2004-10-31 09:20:56 +08:00
|
|
|
break;
|
2000-03-15 09:38:14 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2004-06-10 07:51:06 +08:00
|
|
|
break;
|
2000-03-15 07:06:21 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
static GtkWidget *
|
2000-04-08 04:04:00 +08:00
|
|
|
user_install_notebook_append_page (GtkNotebook *notebook,
|
2006-04-19 22:28:10 +08:00
|
|
|
const gchar *title,
|
|
|
|
const gchar *footer,
|
2003-07-11 19:30:41 +08:00
|
|
|
gint vbox_spacing)
|
2000-03-15 07:06:21 +08:00
|
|
|
{
|
2006-04-21 19:07:25 +08:00
|
|
|
GtkWidget *page = gtk_vbox_new (FALSE, vbox_spacing);
|
2002-12-31 02:51:57 +08:00
|
|
|
|
2006-04-19 22:28:10 +08:00
|
|
|
g_object_set_data (G_OBJECT (page), "title", (gpointer) title);
|
|
|
|
g_object_set_data (G_OBJECT (page), "footer", (gpointer) footer);
|
2006-04-21 19:07:25 +08:00
|
|
|
|
2000-03-16 00:00:24 +08:00
|
|
|
gtk_notebook_append_page (notebook, page, NULL);
|
2000-03-15 07:06:21 +08:00
|
|
|
gtk_widget_show (page);
|
|
|
|
|
2000-03-16 00:00:24 +08:00
|
|
|
return page;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-24 23:26:08 +08:00
|
|
|
static void
|
|
|
|
user_install_details_expand (GtkExpander *expander)
|
|
|
|
{
|
|
|
|
gtk_expander_set_label (expander,
|
|
|
|
gtk_expander_get_expanded (expander) ?
|
|
|
|
_("Hide _details") : _("Show _details"));
|
|
|
|
gtk_expander_set_use_underline (expander, TRUE);
|
|
|
|
}
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
void
|
2003-10-02 19:26:26 +08:00
|
|
|
user_install_dialog_run (const gchar *alternate_system_gimprc,
|
|
|
|
const gchar *alternate_gimprc,
|
|
|
|
gboolean verbose)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-11-21 04:39:23 +08:00
|
|
|
GimpRc *gimprc;
|
2000-03-15 07:06:21 +08:00
|
|
|
GtkWidget *dialog;
|
2000-03-16 00:00:24 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
2000-03-15 07:06:21 +08:00
|
|
|
GtkWidget *page;
|
2006-04-21 21:32:29 +08:00
|
|
|
GtkWidget *widget;
|
2002-02-07 19:50:16 +08:00
|
|
|
GdkPixbuf *wilber;
|
|
|
|
gchar *filename;
|
2004-10-31 09:20:56 +08:00
|
|
|
gchar *version;
|
2001-11-13 11:59:47 +08:00
|
|
|
|
2004-10-31 09:20:56 +08:00
|
|
|
oldgimp = g_strdup (gimp_directory ());
|
|
|
|
|
|
|
|
/* FIXME */
|
2005-02-20 07:38:59 +08:00
|
|
|
version = strstr (oldgimp, "2.3");
|
2004-10-31 09:20:56 +08:00
|
|
|
|
2005-02-20 07:38:59 +08:00
|
|
|
if (version)
|
2005-10-30 00:41:51 +08:00
|
|
|
{
|
|
|
|
version[2] = '2';
|
|
|
|
oldgimp_major = 2;
|
|
|
|
oldgimp_minor = 2;
|
|
|
|
}
|
2006-04-21 19:07:25 +08:00
|
|
|
|
2004-10-31 23:14:59 +08:00
|
|
|
migrate = (version && g_file_test (oldgimp, G_FILE_TEST_IS_DIR));
|
|
|
|
|
2005-02-20 07:38:59 +08:00
|
|
|
if (! migrate)
|
|
|
|
{
|
|
|
|
if (version)
|
2005-10-30 00:41:51 +08:00
|
|
|
{
|
|
|
|
version[2] = '0';
|
|
|
|
oldgimp_major = 2;
|
|
|
|
oldgimp_minor = 0;
|
|
|
|
}
|
2006-04-21 19:07:25 +08:00
|
|
|
|
2005-02-20 07:38:59 +08:00
|
|
|
migrate = (version && g_file_test (oldgimp, G_FILE_TEST_IS_DIR));
|
|
|
|
}
|
|
|
|
|
2004-10-31 23:14:59 +08:00
|
|
|
if (! migrate)
|
2004-10-31 09:20:56 +08:00
|
|
|
{
|
|
|
|
g_free (oldgimp);
|
|
|
|
oldgimp = NULL;
|
2005-10-30 00:41:51 +08:00
|
|
|
oldgimp_major = 0;
|
|
|
|
oldgimp_minor = 0;
|
2004-10-31 09:20:56 +08:00
|
|
|
}
|
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
dialog = gimp_dialog_new (_("GIMP User Installation"),
|
|
|
|
"gimp-user-installation",
|
|
|
|
NULL, 0,
|
|
|
|
NULL, NULL,
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
_("Continue"), GTK_RESPONSE_OK,
|
2001-11-24 07:04:49 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
NULL);
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2005-02-09 04:40:33 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
gimprc = gimp_rc_new (alternate_system_gimprc, alternate_gimprc, verbose);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (user_install_response),
|
|
|
|
gimprc);
|
2002-11-21 04:39:23 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, gimprc);
|
2001-11-13 11:59:47 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
2000-03-16 00:00:24 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
|
2006-04-21 19:07:25 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
|
|
|
gtk_widget_show (vbox);
|
2000-03-16 00:00:24 +08:00
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
2000-03-16 00:00:24 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-02-07 19:50:16 +08:00
|
|
|
filename = g_build_filename (gimp_data_directory(),
|
|
|
|
"images", "wilber-wizard.png", NULL);
|
|
|
|
wilber = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
if (wilber)
|
|
|
|
{
|
2006-04-21 19:07:25 +08:00
|
|
|
GtkWidget *image = gtk_image_new_from_pixbuf (wilber);
|
|
|
|
|
2002-02-07 19:50:16 +08:00
|
|
|
g_object_unref (wilber);
|
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
2006-04-21 19:07:25 +08:00
|
|
|
gtk_widget_show (image);
|
2002-02-07 19:50:16 +08:00
|
|
|
}
|
2000-03-16 00:00:24 +08:00
|
|
|
|
|
|
|
title_label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_justify (GTK_LABEL (title_label), GTK_JUSTIFY_LEFT);
|
2004-01-09 05:39:13 +08:00
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (title_label), TRUE);
|
2006-04-24 23:26:08 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (title_label), 0.0, 0.5);
|
2006-04-21 19:07:25 +08:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (title_label),
|
2006-04-21 21:32:29 +08:00
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_X_LARGE,
|
2006-04-21 19:07:25 +08:00
|
|
|
-1);
|
2000-03-16 00:00:24 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), title_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (title_label);
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
notebook = gtk_notebook_new ();
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
2006-04-21 19:07:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
|
2000-03-15 07:06:21 +08:00
|
|
|
gtk_widget_show (notebook);
|
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
footer_label = gtk_label_new (NULL);
|
2006-04-24 23:26:08 +08:00
|
|
|
gtk_label_set_justify (GTK_LABEL (footer_label), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (footer_label), TRUE);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (footer_label), 0.0, 0.5);
|
2006-04-21 21:32:29 +08:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (footer_label),
|
2006-04-24 23:26:08 +08:00
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
2006-04-21 21:32:29 +08:00
|
|
|
-1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), footer_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (footer_label);
|
|
|
|
|
|
|
|
/* WELCOME_PAGE */
|
|
|
|
page = user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
|
|
|
|
_("Welcome to the GNU Image "
|
|
|
|
"Manipulation Program"),
|
|
|
|
NULL,
|
|
|
|
12);
|
|
|
|
|
2006-04-21 19:07:25 +08:00
|
|
|
if (migrate)
|
2006-04-21 21:32:29 +08:00
|
|
|
{
|
|
|
|
gchar *title;
|
|
|
|
gchar *label;
|
2002-03-28 10:05:10 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
title = g_strdup_printf (_("It seems you have used GIMP %s before."),
|
|
|
|
version);
|
|
|
|
label = g_strdup_printf (_("_Migrate GIMP %s user settings"), version);
|
2002-03-28 10:05:10 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
widget = gimp_int_radio_group_new (TRUE, title,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&migrate, migrate,
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
label,
|
|
|
|
TRUE, NULL,
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
_("Do a _fresh user installation"),
|
|
|
|
FALSE, NULL,
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
NULL);
|
2003-07-11 19:30:41 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
g_free (label);
|
|
|
|
g_free (title);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
text = g_strdup_printf (_("It appears that you are using GIMP for the "
|
|
|
|
"first time. GIMP will now create a folder "
|
|
|
|
"named '<b>%s</b>' and copy some files to it."),
|
|
|
|
gimp_filename_to_utf8 (gimp_directory ()));
|
|
|
|
|
|
|
|
widget = g_object_new (GTK_TYPE_LABEL,
|
|
|
|
"use-markup", TRUE,
|
|
|
|
"label", text,
|
|
|
|
"wrap", TRUE,
|
|
|
|
"xalign", 0.0,
|
|
|
|
NULL);
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
/* INSTALLATION_PAGE */
|
2006-04-21 19:07:25 +08:00
|
|
|
page = user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
|
2006-04-24 23:26:08 +08:00
|
|
|
_("User Installation"),
|
|
|
|
_("Your personal GIMP folder is "
|
2006-04-21 19:07:25 +08:00
|
|
|
"being created..."),
|
|
|
|
0);
|
2006-04-24 23:26:08 +08:00
|
|
|
{
|
|
|
|
GtkWidget *expander;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkTextBuffer *log_buffer;
|
|
|
|
GtkWidget *log_view;
|
|
|
|
|
|
|
|
expander = gtk_expander_new (NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (page), expander, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (expander);
|
|
|
|
|
|
|
|
g_signal_connect (expander, "notify::expanded",
|
|
|
|
G_CALLBACK (user_install_details_expand),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
user_install_details_expand (GTK_EXPANDER (expander));
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_widget_set_size_request (scrolled_window, -1, 300);
|
|
|
|
gtk_container_add (GTK_CONTAINER (expander), scrolled_window);
|
|
|
|
gtk_widget_show (scrolled_window);
|
|
|
|
|
|
|
|
log_buffer = gtk_text_buffer_new (NULL);
|
|
|
|
|
|
|
|
gtk_text_buffer_create_tag (log_buffer, "bold",
|
|
|
|
"weight", PANGO_WEIGHT_BOLD,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
log_view = gtk_text_view_new_with_buffer (log_buffer);
|
|
|
|
g_object_unref (log_buffer);
|
|
|
|
|
|
|
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (log_view), FALSE);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), log_view);
|
|
|
|
gtk_widget_show (log_view);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (dialog), "log-view", log_view);
|
|
|
|
g_object_set_data (G_OBJECT (dialog), "log-buffer", log_buffer);
|
|
|
|
}
|
2006-04-21 19:07:25 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
user_install_notebook_set_page (GTK_NOTEBOOK (notebook), WELCOME_PAGE);
|
2000-03-15 09:38:14 +08:00
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
gtk_widget_show (dialog);
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
gtk_main ();
|
2004-10-31 23:14:59 +08:00
|
|
|
|
|
|
|
g_free (oldgimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
|
|
|
|
/*********************/
|
|
|
|
/* Local functions */
|
|
|
|
|
2003-07-11 19:30:41 +08:00
|
|
|
static void
|
|
|
|
print_log (GtkWidget *view,
|
|
|
|
GtkTextBuffer *buffer,
|
|
|
|
GError *error)
|
|
|
|
{
|
|
|
|
GtkTextIter cursor;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, error ? "\n" : " ", -1);
|
|
|
|
|
|
|
|
gtk_text_buffer_get_end_iter (buffer, &cursor);
|
|
|
|
|
|
|
|
pixbuf =
|
|
|
|
gtk_widget_render_icon (view,
|
|
|
|
error ? GIMP_STOCK_ERROR : GTK_STOCK_APPLY,
|
|
|
|
error ? GTK_ICON_SIZE_DIALOG : GTK_ICON_SIZE_MENU,
|
|
|
|
NULL);
|
|
|
|
gtk_text_buffer_insert_pixbuf (buffer, &cursor, pixbuf);
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
gtk_text_buffer_insert (buffer, &cursor, "\n", -1);
|
|
|
|
gtk_text_buffer_insert_with_tags_by_name (buffer, &cursor,
|
|
|
|
error->message, -1,
|
|
|
|
"bold",
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_text_buffer_insert (buffer, &cursor, "\n", -1);
|
|
|
|
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
}
|
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
static gboolean
|
|
|
|
user_install_file_copy (GtkTextBuffer *log_buffer,
|
|
|
|
const gchar *source,
|
|
|
|
const gchar *dest,
|
|
|
|
GError **error)
|
|
|
|
{
|
2004-11-01 02:32:26 +08:00
|
|
|
gchar *msg;
|
2004-11-01 01:51:00 +08:00
|
|
|
|
2004-11-01 02:32:26 +08:00
|
|
|
msg = g_strdup_printf (_("Copying file '%s' from '%s'..."),
|
|
|
|
gimp_filename_to_utf8 (dest),
|
|
|
|
gimp_filename_to_utf8 (source));
|
|
|
|
gtk_text_buffer_insert_at_cursor (log_buffer, msg, -1);
|
|
|
|
g_free (msg);
|
2004-11-01 01:51:00 +08:00
|
|
|
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
|
|
|
|
return gimp_config_file_copy (source, dest, error);
|
|
|
|
}
|
|
|
|
|
2004-11-01 02:32:26 +08:00
|
|
|
static gboolean
|
|
|
|
user_install_mkdir (GtkTextBuffer *log_buffer,
|
|
|
|
const gchar *dirname,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
gchar *msg;
|
|
|
|
|
|
|
|
msg = g_strdup_printf (_("Creating folder '%s'..."),
|
|
|
|
gimp_filename_to_utf8 (dirname));
|
|
|
|
gtk_text_buffer_insert_at_cursor (log_buffer, msg, -1);
|
|
|
|
g_free (msg);
|
|
|
|
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
|
2005-02-07 09:24:22 +08:00
|
|
|
if (g_mkdir (dirname,
|
|
|
|
S_IRUSR | S_IWUSR | S_IXUSR |
|
|
|
|
S_IRGRP | S_IXGRP |
|
|
|
|
S_IROTH | S_IXOTH) == -1)
|
2004-11-01 02:32:26 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
|
|
|
_("Cannot create folder '%s': %s"),
|
|
|
|
gimp_filename_to_utf8 (dirname), g_strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
static gboolean
|
|
|
|
user_install_dir_copy (GtkWidget *log_view,
|
|
|
|
GtkTextBuffer *log_buffer,
|
|
|
|
const gchar *source,
|
|
|
|
const gchar *base,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GDir *source_dir = NULL;
|
|
|
|
GDir *dest_dir = NULL;
|
|
|
|
gchar dest[1024];
|
|
|
|
gchar *basename;
|
|
|
|
gchar *dirname;
|
|
|
|
|
|
|
|
basename = g_path_get_basename (source);
|
|
|
|
dirname = g_build_filename (base, basename, NULL);
|
|
|
|
g_free (basename);
|
|
|
|
|
2004-11-01 02:32:26 +08:00
|
|
|
if (! user_install_mkdir (log_buffer, dirname, error))
|
2004-11-01 01:51:00 +08:00
|
|
|
{
|
|
|
|
g_free (dirname);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_log (log_view, log_buffer, NULL);
|
|
|
|
|
|
|
|
dest_dir = g_dir_open (dirname, 0, error);
|
|
|
|
if (dest_dir)
|
|
|
|
{
|
|
|
|
source_dir = g_dir_open (source, 0, error);
|
|
|
|
if (source_dir)
|
|
|
|
{
|
|
|
|
const gchar *basename;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
while ((basename = g_dir_read_name (source_dir)) != NULL)
|
|
|
|
{
|
|
|
|
name = g_build_filename (source, basename, NULL);
|
|
|
|
|
|
|
|
if (g_file_test (name, G_FILE_TEST_IS_REGULAR))
|
|
|
|
{
|
|
|
|
g_snprintf (dest, sizeof (dest), "%s%c%s",
|
|
|
|
dirname, G_DIR_SEPARATOR, basename);
|
|
|
|
|
|
|
|
if (! user_install_file_copy (log_buffer, name, dest, error))
|
|
|
|
{
|
|
|
|
g_free (name);
|
|
|
|
goto break_out_of_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_log (log_view, log_buffer, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break_out_of_loop:
|
|
|
|
g_free (dirname);
|
|
|
|
|
|
|
|
if (source_dir)
|
|
|
|
g_dir_close (source_dir);
|
|
|
|
if (dest_dir)
|
|
|
|
g_dir_close (dest_dir);
|
|
|
|
|
|
|
|
return (*error == NULL);
|
|
|
|
}
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
static gboolean
|
2004-10-31 23:14:59 +08:00
|
|
|
user_install_create_files (GtkWidget *log_view,
|
|
|
|
GtkTextBuffer *log_buffer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-10-31 23:14:59 +08:00
|
|
|
gchar dest[1024];
|
|
|
|
gchar source[1024];
|
|
|
|
gint i;
|
|
|
|
GError *error = NULL;
|
2002-12-31 01:27:58 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (user_install_items); i++)
|
2002-12-31 02:51:57 +08:00
|
|
|
{
|
2002-12-26 09:51:25 +08:00
|
|
|
g_snprintf (dest, sizeof (dest), "%s%c%s",
|
2006-04-21 21:32:29 +08:00
|
|
|
gimp_directory (),
|
|
|
|
G_DIR_SEPARATOR,
|
|
|
|
user_install_items[i].name);
|
2002-12-31 01:27:58 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
switch (user_install_items[i].action)
|
2003-12-23 03:47:05 +08:00
|
|
|
{
|
2006-04-21 21:32:29 +08:00
|
|
|
case USER_INSTALL_DO_NOTHING:
|
2003-12-23 03:47:05 +08:00
|
|
|
break;
|
2002-12-26 09:51:25 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
case USER_INSTALL_MKDIR:
|
2004-11-01 02:32:26 +08:00
|
|
|
if (! user_install_mkdir (log_buffer, dest, &error))
|
2003-12-23 03:47:05 +08:00
|
|
|
goto break_out_of_loop;
|
|
|
|
break;
|
2002-12-26 09:51:25 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
case USER_INSTALL_FROM_SYSCONF_DIR:
|
2003-12-23 03:47:05 +08:00
|
|
|
g_snprintf (source, sizeof (source), "%s%c%s",
|
|
|
|
gimp_sysconf_directory (), G_DIR_SEPARATOR,
|
2006-04-21 21:32:29 +08:00
|
|
|
user_install_items[i].name);
|
2002-12-31 01:27:58 +08:00
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
if (! user_install_file_copy (log_buffer, source, dest, &error))
|
2002-12-31 02:51:57 +08:00
|
|
|
goto break_out_of_loop;
|
2003-12-23 03:47:05 +08:00
|
|
|
break;
|
2002-12-26 09:51:25 +08:00
|
|
|
|
2003-12-23 03:47:05 +08:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2002-12-31 01:27:58 +08:00
|
|
|
break;
|
2003-12-23 03:47:05 +08:00
|
|
|
}
|
2002-12-31 01:27:58 +08:00
|
|
|
|
2006-04-21 21:32:29 +08:00
|
|
|
if (user_install_items[i].action != USER_INSTALL_DO_NOTHING)
|
2003-07-11 19:30:41 +08:00
|
|
|
print_log (log_view, log_buffer, NULL);
|
2002-12-26 09:51:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
break_out_of_loop:
|
2002-12-31 01:27:58 +08:00
|
|
|
if (error)
|
2002-12-26 09:51:25 +08:00
|
|
|
{
|
2003-07-11 19:30:41 +08:00
|
|
|
print_log (log_view, log_buffer, error);
|
2002-12-31 02:51:57 +08:00
|
|
|
g_clear_error (&error);
|
2003-07-11 19:30:41 +08:00
|
|
|
|
2002-12-26 09:51:25 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-10-31 23:14:59 +08:00
|
|
|
static gboolean
|
|
|
|
user_install_migrate_files (const gchar *oldgimp,
|
2005-10-30 00:41:51 +08:00
|
|
|
gint oldgimp_major,
|
|
|
|
gint oldgimp_minor,
|
2004-10-31 23:14:59 +08:00
|
|
|
GtkWidget *log_view,
|
|
|
|
GtkTextBuffer *log_buffer)
|
|
|
|
{
|
2004-11-01 01:51:00 +08:00
|
|
|
GDir *dir;
|
|
|
|
GError *error = NULL;
|
2004-10-31 23:14:59 +08:00
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
dir = g_dir_open (oldgimp, 0, &error);
|
|
|
|
if (dir)
|
|
|
|
{
|
|
|
|
const gchar *basename;
|
2004-11-01 02:32:26 +08:00
|
|
|
gchar *source = NULL;
|
2004-11-01 01:51:00 +08:00
|
|
|
gchar dest[1024];
|
|
|
|
|
|
|
|
while ((basename = g_dir_read_name (dir)) != NULL)
|
|
|
|
{
|
|
|
|
source = g_build_filename (oldgimp, basename, NULL);
|
|
|
|
|
2005-10-30 00:41:51 +08:00
|
|
|
if (g_file_test (source, G_FILE_TEST_IS_REGULAR))
|
2004-11-01 01:51:00 +08:00
|
|
|
{
|
2005-10-30 00:41:51 +08:00
|
|
|
/* skip these for all old versions */
|
|
|
|
if ((strncmp (basename, "gimpswap.", 9) == 0) ||
|
|
|
|
(strncmp (basename, "pluginrc", 8) == 0) ||
|
|
|
|
(strncmp (basename, "themerc", 7) == 0))
|
|
|
|
{
|
|
|
|
goto next_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip menurc for gimp 2.0 since the format has changed */
|
|
|
|
if (oldgimp_minor == 0 &&
|
|
|
|
(strncmp (basename, "menurc", 6) == 0))
|
|
|
|
{
|
|
|
|
goto next_file;
|
|
|
|
}
|
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
g_snprintf (dest, sizeof (dest), "%s%c%s",
|
|
|
|
gimp_directory (), G_DIR_SEPARATOR, basename);
|
2004-10-31 23:14:59 +08:00
|
|
|
|
2004-11-01 02:32:26 +08:00
|
|
|
user_install_file_copy (log_buffer, source, dest, &error);
|
2004-10-31 23:14:59 +08:00
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
print_log (log_view, log_buffer, error);
|
2004-11-01 02:32:26 +08:00
|
|
|
g_clear_error (&error);
|
2004-11-01 01:51:00 +08:00
|
|
|
}
|
|
|
|
else if (g_file_test (source, G_FILE_TEST_IS_DIR) &&
|
|
|
|
strcmp (basename, "tmp") != 0)
|
|
|
|
{
|
|
|
|
if (! user_install_dir_copy (log_view, log_buffer,
|
|
|
|
source, gimp_directory (), &error))
|
2004-11-01 02:32:26 +08:00
|
|
|
{
|
|
|
|
print_log (log_view, log_buffer, error);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2004-11-01 01:51:00 +08:00
|
|
|
}
|
|
|
|
|
2005-10-30 00:41:51 +08:00
|
|
|
next_file:
|
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
g_free (source);
|
|
|
|
source = NULL;
|
|
|
|
}
|
|
|
|
|
2004-11-01 02:32:26 +08:00
|
|
|
/* create the tmp directory that was explicitely not copied */
|
2004-11-01 01:51:00 +08:00
|
|
|
|
2004-11-01 02:32:26 +08:00
|
|
|
g_snprintf (dest, sizeof (dest), "%s%c%s",
|
|
|
|
gimp_directory (), G_DIR_SEPARATOR, "tmp");
|
|
|
|
|
|
|
|
if (user_install_mkdir (log_buffer, dest, &error))
|
|
|
|
print_log (log_view, log_buffer, NULL);
|
|
|
|
|
|
|
|
g_dir_close (dir);
|
|
|
|
}
|
2004-11-01 01:51:00 +08:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
print_log (log_view, log_buffer, error);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-02-20 07:38:59 +08:00
|
|
|
gimp_templates_migrate (oldgimp);
|
2004-11-24 05:00:15 +08:00
|
|
|
|
2004-11-01 01:51:00 +08:00
|
|
|
return TRUE;
|
2004-10-31 23:14:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2006-04-24 23:26:08 +08:00
|
|
|
user_install_run (GtkWidget *dialog,
|
2006-04-21 19:07:25 +08:00
|
|
|
const gchar *oldgimp)
|
2004-10-31 23:14:59 +08:00
|
|
|
{
|
2006-04-24 23:26:08 +08:00
|
|
|
GtkWidget *view = g_object_get_data (G_OBJECT (dialog), "log-view");
|
|
|
|
GtkTextBuffer *buffer = g_object_get_data (G_OBJECT (dialog), "log-buffer");
|
|
|
|
GError *error = NULL;
|
2004-10-31 23:14:59 +08:00
|
|
|
|
2006-04-24 23:26:08 +08:00
|
|
|
if (! user_install_mkdir (buffer, gimp_directory (), &error))
|
2004-10-31 23:14:59 +08:00
|
|
|
{
|
2006-04-24 23:26:08 +08:00
|
|
|
print_log (view, buffer, error);
|
2004-10-31 23:14:59 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-04-24 23:26:08 +08:00
|
|
|
print_log (view, buffer, NULL);
|
2004-10-31 23:14:59 +08:00
|
|
|
|
|
|
|
if (oldgimp)
|
2005-10-30 00:41:51 +08:00
|
|
|
return user_install_migrate_files (oldgimp, oldgimp_major, oldgimp_minor,
|
2006-04-24 23:26:08 +08:00
|
|
|
view, buffer);
|
2004-10-31 23:14:59 +08:00
|
|
|
else
|
2006-04-24 23:26:08 +08:00
|
|
|
return user_install_create_files (view, buffer);
|
2004-10-31 23:14:59 +08:00
|
|
|
}
|