2001-02-11 09:39:24 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-04-22 08:38:56 +08:00
|
|
|
* gimpdata.c
|
|
|
|
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2001-02-11 09:39:24 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2003-02-27 02:08:26 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2003-03-04 02:14:31 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include <io.h>
|
|
|
|
#define F_OK 0
|
|
|
|
#define W_OK 2
|
|
|
|
#define R_OK 4
|
|
|
|
#define X_OK 0 /* not really */
|
|
|
|
#define access(f,p) _access(f,p)
|
|
|
|
#endif
|
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
|
|
|
|
#include "core-types.h"
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
#include "gimpdata.h"
|
2001-02-14 03:53:07 +08:00
|
|
|
#include "gimpmarshal.h"
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-10-31 02:46:29 +08:00
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
DIRTY,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-01-31 00:14:26 +08:00
|
|
|
static void gimp_data_class_init (GimpDataClass *klass);
|
|
|
|
static void gimp_data_init (GimpData *data);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2002-01-31 00:14:26 +08:00
|
|
|
static void gimp_data_finalize (GObject *object);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2002-01-31 00:14:26 +08:00
|
|
|
static void gimp_data_name_changed (GimpObject *object);
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64 gimp_data_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
|
|
static void gimp_data_real_dirty (GimpData *data);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
static guint data_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static GimpViewableClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
GType
|
2001-02-11 09:39:24 +08:00
|
|
|
gimp_data_get_type (void)
|
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
static GType data_type = 0;
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
if (! data_type)
|
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
static const GTypeInfo data_info =
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpDataClass),
|
2001-08-11 22:39:19 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_data_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpData),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_data_init,
|
2001-02-11 09:39:24 +08:00
|
|
|
};
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
data_type = g_type_register_static (GIMP_TYPE_VIEWABLE,
|
|
|
|
"GimpData",
|
|
|
|
&data_info, 0);
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return data_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_class_init (GimpDataClass *klass)
|
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
GObjectClass *object_class;
|
2001-02-12 11:27:28 +08:00
|
|
|
GimpObjectClass *gimp_object_class;
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
data_signals[DIRTY] =
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_signal_new ("dirty",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDataClass, dirty),
|
|
|
|
NULL, NULL,
|
2001-11-23 07:46:13 +08:00
|
|
|
gimp_marshal_VOID__VOID,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_TYPE_NONE, 0);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class->finalize = gimp_data_finalize;
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_object_class->name_changed = gimp_data_name_changed;
|
2002-01-31 00:14:26 +08:00
|
|
|
gimp_object_class->get_memsize = gimp_data_get_memsize;
|
2001-02-12 11:27:28 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
klass->dirty = gimp_data_real_dirty;
|
|
|
|
klass->save = NULL;
|
|
|
|
klass->get_extension = NULL;
|
|
|
|
klass->duplicate = NULL;
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_init (GimpData *data)
|
|
|
|
{
|
2003-02-27 02:08:26 +08:00
|
|
|
data->filename = NULL;
|
|
|
|
data->writeable = TRUE;
|
|
|
|
data->dirty = FALSE;
|
|
|
|
data->internal = FALSE;
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-08-11 22:39:19 +08:00
|
|
|
gimp_data_finalize (GObject *object)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GimpData *data = GIMP_DATA (object);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
if (data->filename)
|
|
|
|
{
|
|
|
|
g_free (data->filename);
|
|
|
|
data->filename = NULL;
|
|
|
|
}
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
static void
|
|
|
|
gimp_data_name_changed (GimpObject *object)
|
|
|
|
{
|
|
|
|
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
|
|
|
|
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
|
|
|
|
|
|
|
|
gimp_data_dirty (GIMP_DATA (object));
|
|
|
|
}
|
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64
|
2003-08-25 18:49:33 +08:00
|
|
|
gimp_data_get_memsize (GimpObject *object,
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 *gui_size)
|
2002-01-31 00:14:26 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GimpData *data = GIMP_DATA (object);
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 memsize = 0;
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
|
|
if (data->filename)
|
|
|
|
memsize += strlen (data->filename) + 1;
|
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
}
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
gboolean
|
2002-12-02 21:39:09 +08:00
|
|
|
gimp_data_save (GimpData *data,
|
|
|
|
GError **error)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
|
2002-12-02 21:39:09 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2002-06-12 21:48:47 +08:00
|
|
|
if (data->internal)
|
|
|
|
{
|
|
|
|
data->dirty = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-03 06:41:44 +08:00
|
|
|
g_return_val_if_fail (data->filename != NULL, FALSE);
|
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
if (GIMP_DATA_GET_CLASS (data)->save)
|
|
|
|
success = GIMP_DATA_GET_CLASS (data)->save (data, error);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
data->dirty = FALSE;
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_data_dirty (GimpData *data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DATA (data));
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (data, data_signals[DIRTY], 0);
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_real_dirty (GimpData *data)
|
|
|
|
{
|
|
|
|
data->dirty = TRUE;
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (data));
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2002-10-31 02:46:29 +08:00
|
|
|
gimp_data_delete_from_disk (GimpData *data,
|
|
|
|
GError **error)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
|
|
|
|
g_return_val_if_fail (data->filename != NULL, FALSE);
|
2002-10-31 02:46:29 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2002-06-12 21:48:47 +08:00
|
|
|
if (data->internal)
|
|
|
|
return TRUE;
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
if (unlink (data->filename) == -1)
|
|
|
|
{
|
2002-12-02 21:39:09 +08:00
|
|
|
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_DELETE,
|
2002-10-31 02:46:29 +08:00
|
|
|
_("Could not delete '%s': %s"),
|
2004-01-24 01:24:44 +08:00
|
|
|
gimp_filename_to_utf8 (data->filename), g_strerror (errno));
|
2001-02-11 09:39:24 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-02-14 03:53:07 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_data_get_extension (GimpData *data)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DATA (data), NULL);
|
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
if (GIMP_DATA_GET_CLASS (data)->get_extension)
|
|
|
|
return GIMP_DATA_GET_CLASS (data)->get_extension (data);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
return NULL;
|
2001-02-14 03:53:07 +08:00
|
|
|
}
|
|
|
|
|
2001-02-11 09:39:24 +08:00
|
|
|
void
|
|
|
|
gimp_data_set_filename (GimpData *data,
|
2004-01-29 05:53:50 +08:00
|
|
|
const gchar *filename,
|
|
|
|
gboolean writable)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DATA (data));
|
2004-01-29 05:53:50 +08:00
|
|
|
g_return_if_fail (filename != NULL);
|
|
|
|
g_return_if_fail (g_path_is_absolute (filename));
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2002-06-12 21:48:47 +08:00
|
|
|
if (data->internal)
|
|
|
|
return;
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
if (data->filename)
|
|
|
|
{
|
|
|
|
g_free (data->filename);
|
|
|
|
data->filename = NULL;
|
|
|
|
}
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
data->filename = g_strdup (filename);
|
|
|
|
data->writeable = FALSE;
|
2003-02-27 02:08:26 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
/* if the data is supposed to be writable, still check if it really is */
|
|
|
|
if (writable)
|
2003-02-27 02:08:26 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
gchar *dirname = g_path_get_dirname (filename);
|
2003-02-27 02:08:26 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
if ((access (filename, F_OK) == 0 && /* check if the file exists */
|
|
|
|
access (filename, W_OK) == 0) || /* and is writeable */
|
|
|
|
(access (filename, F_OK) != 0 && /* OR doesn't exist */
|
|
|
|
access (dirname, W_OK) == 0)) /* and we can write to its dir */
|
2003-02-27 02:08:26 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
data->writeable = TRUE;
|
2003-02-27 02:08:26 +08:00
|
|
|
}
|
2004-01-29 05:53:50 +08:00
|
|
|
|
|
|
|
g_free (dirname);
|
2003-02-27 02:08:26 +08:00
|
|
|
}
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_data_create_filename (GimpData *data,
|
|
|
|
const gchar *basename,
|
2004-01-29 05:53:50 +08:00
|
|
|
const gchar *dest_dir)
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
|
|
|
gchar *filename;
|
2001-10-24 23:56:33 +08:00
|
|
|
gchar *fullpath;
|
2001-02-11 09:39:24 +08:00
|
|
|
gchar *safe_name;
|
|
|
|
gint i;
|
|
|
|
gint unum = 1;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DATA (data));
|
|
|
|
g_return_if_fail (basename != NULL);
|
2004-01-29 05:53:50 +08:00
|
|
|
g_return_if_fail (dest_dir != NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
|
|
|
safe_name = g_strdup (basename);
|
|
|
|
if (safe_name[0] == '.')
|
2004-01-29 05:53:50 +08:00
|
|
|
safe_name[0] = '-';
|
2001-02-11 09:39:24 +08:00
|
|
|
for (i = 0; safe_name[i]; i++)
|
2002-02-11 03:51:20 +08:00
|
|
|
if (safe_name[i] == G_DIR_SEPARATOR || g_ascii_isspace (safe_name[i]))
|
2004-01-29 05:53:50 +08:00
|
|
|
safe_name[i] = '-';
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
filename = g_strconcat (safe_name, gimp_data_get_extension (data), NULL);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
fullpath = g_build_filename (dest_dir, filename, NULL);
|
2001-10-24 23:56:33 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
while (g_file_test (fullpath, G_FILE_TEST_EXISTS))
|
2001-02-11 09:39:24 +08:00
|
|
|
{
|
2001-10-24 23:56:33 +08:00
|
|
|
g_free (fullpath);
|
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
filename = g_strdup_printf ("%s-%d%s",
|
2001-10-24 23:56:33 +08:00
|
|
|
safe_name,
|
2002-12-02 21:39:09 +08:00
|
|
|
unum++,
|
2001-02-14 03:53:07 +08:00
|
|
|
gimp_data_get_extension (data));
|
2001-10-24 23:56:33 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
fullpath = g_build_filename (dest_dir, filename, NULL);
|
2001-10-24 23:56:33 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (safe_name);
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_data_set_filename (data, fullpath, TRUE);
|
2001-02-11 09:39:24 +08:00
|
|
|
|
2001-10-24 23:56:33 +08:00
|
|
|
g_free (fullpath);
|
2001-02-11 09:39:24 +08:00
|
|
|
}
|
2001-02-14 22:57:14 +08:00
|
|
|
|
|
|
|
GimpData *
|
2002-12-01 00:31:39 +08:00
|
|
|
gimp_data_duplicate (GimpData *data,
|
|
|
|
gboolean stingy_memory_use)
|
2001-02-14 22:57:14 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GimpData *new = NULL;
|
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DATA (data), NULL);
|
|
|
|
|
|
|
|
if (GIMP_DATA_GET_CLASS (data)->duplicate)
|
2004-01-29 05:53:50 +08:00
|
|
|
{
|
|
|
|
new = GIMP_DATA_GET_CLASS (data)->duplicate (data, stingy_memory_use);
|
2001-02-14 22:57:14 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
if (new)
|
|
|
|
new->dirty = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new;
|
2002-12-02 21:39:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GQuark
|
|
|
|
gimp_data_error_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark q = 0;
|
|
|
|
if (q == 0)
|
|
|
|
q = g_quark_from_static_string ("gimp-data-error-quark");
|
2001-02-14 22:57:14 +08:00
|
|
|
|
2002-12-02 21:39:09 +08:00
|
|
|
return q;
|
2001-02-14 22:57:14 +08:00
|
|
|
}
|