2001-04-28 23:11:29 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis
|
|
|
|
* Copyright (C) 1997 Josh MacDonald
|
|
|
|
*
|
|
|
|
* 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 <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
#include "gui-types.h"
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in/plug-in-proc.h"
|
2003-01-30 19:20:12 +08:00
|
|
|
#include "plug-in/plug-in-run.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
2001-10-25 21:30:01 +08:00
|
|
|
#include "file/file-save.h"
|
|
|
|
#include "file/file-utils.h"
|
|
|
|
|
2003-01-31 19:54:16 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
2001-11-28 03:27:55 +08:00
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
#include "file-dialog-utils.h"
|
|
|
|
#include "file-save-dialog.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
static GtkWidget * file_save_dialog_create (Gimp *gimp,
|
|
|
|
GimpMenuFactory *menu_factory);
|
|
|
|
static void file_save_ok_callback (GtkWidget *widget,
|
|
|
|
GtkWidget *save_dialog);
|
|
|
|
static void file_save_overwrite (GtkWidget *save_dialog,
|
|
|
|
const gchar *uri,
|
|
|
|
const gchar *raw_filename);
|
|
|
|
static void file_save_overwrite_callback (GtkWidget *widget,
|
|
|
|
gboolean overwrite,
|
|
|
|
gpointer data);
|
|
|
|
static void file_save_dialog_save_image (GtkWidget *save_dialog,
|
|
|
|
GimpImage *gimage,
|
|
|
|
const gchar *uri,
|
|
|
|
const gchar *raw_filename,
|
|
|
|
PlugInProcDef *save_proc,
|
2003-03-04 18:32:35 +08:00
|
|
|
gboolean set_uri_and_proc);
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
static GtkWidget *filesave = NULL;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
static PlugInProcDef *save_file_proc = NULL;
|
|
|
|
static GimpImage *the_gimage = NULL;
|
|
|
|
static gboolean set_uri_and_proc = TRUE;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_dialog_set_type (PlugInProcDef *proc)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
if (proc)
|
|
|
|
file_dialog_update_name (proc, GTK_FILE_SELECTION (filesave));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
save_file_proc = proc;
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_dialog_show (GimpImage *gimage,
|
|
|
|
GimpMenuFactory *menu_factory)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2003-01-31 19:54:16 +08:00
|
|
|
GimpItemFactory *item_factory;
|
|
|
|
gchar *filename;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! gimp_image_active_drawable (gimage))
|
2001-04-28 23:11:29 +08:00
|
|
|
return;
|
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
the_gimage = gimage;
|
|
|
|
set_uri_and_proc = TRUE;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
if (! filesave)
|
2003-01-11 01:55:53 +08:00
|
|
|
filesave = file_save_dialog_create (gimage->gimp, menu_factory);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
|
2002-11-02 00:20:13 +08:00
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (filesave))
|
2002-11-02 00:20:13 +08:00
|
|
|
{
|
|
|
|
gtk_window_present (GTK_WINDOW (filesave));
|
|
|
|
return;
|
|
|
|
}
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image"));
|
|
|
|
|
2002-11-02 00:20:13 +08:00
|
|
|
filename = gimp_image_get_filename (gimage);
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
|
|
|
|
filename ?
|
|
|
|
filename :
|
|
|
|
"." G_DIR_SEPARATOR_S);
|
|
|
|
|
2002-11-02 00:20:13 +08:00
|
|
|
g_free (filename);
|
|
|
|
|
2003-01-31 19:54:16 +08:00
|
|
|
item_factory = g_object_get_data (G_OBJECT (filesave), "gimp-item-factory");
|
|
|
|
|
|
|
|
gimp_item_factory_update (item_factory,
|
|
|
|
gimp_image_active_drawable (gimage));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
file_dialog_show (filesave);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_a_copy_dialog_show (GimpImage *gimage,
|
|
|
|
GimpMenuFactory *menu_factory)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2003-01-31 19:54:16 +08:00
|
|
|
GimpItemFactory *item_factory;
|
|
|
|
const gchar *uri;
|
|
|
|
gchar *filename = NULL;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! gimp_image_active_drawable (gimage))
|
2001-04-28 23:11:29 +08:00
|
|
|
return;
|
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
the_gimage = gimage;
|
|
|
|
set_uri_and_proc = FALSE;
|
2002-04-14 22:38:55 +08:00
|
|
|
|
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (gimage));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
if (uri)
|
|
|
|
filename = g_filename_from_uri (uri, NULL, NULL);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! filesave)
|
2003-01-11 01:55:53 +08:00
|
|
|
filesave = file_save_dialog_create (gimage->gimp, menu_factory);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
|
2002-11-02 00:20:13 +08:00
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (filesave))
|
2002-11-02 00:20:13 +08:00
|
|
|
{
|
|
|
|
gtk_window_present (GTK_WINDOW (filesave));
|
|
|
|
return;
|
|
|
|
}
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (filesave), _("Save a Copy of the Image"));
|
|
|
|
|
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
|
|
|
|
filename ?
|
|
|
|
filename :
|
|
|
|
"." G_DIR_SEPARATOR_S);
|
|
|
|
|
2003-01-31 19:54:16 +08:00
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
item_factory = g_object_get_data (G_OBJECT (filesave), "gimp-item-factory");
|
|
|
|
|
|
|
|
gimp_item_factory_update (item_factory,
|
|
|
|
gimp_image_active_drawable (gimage));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
file_dialog_show (filesave);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
static GtkWidget *
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_dialog_create (Gimp *gimp,
|
|
|
|
GimpMenuFactory *menu_factory)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2002-04-18 09:18:24 +08:00
|
|
|
return file_dialog_new (gimp,
|
2003-01-11 01:55:53 +08:00
|
|
|
menu_factory, "<Save>",
|
2002-04-18 09:18:24 +08:00
|
|
|
_("Save Image"), "save_image",
|
|
|
|
"save/dialogs/file_save.html",
|
|
|
|
G_CALLBACK (file_save_ok_callback));
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_ok_callback (GtkWidget *widget,
|
2002-04-18 09:18:24 +08:00
|
|
|
GtkWidget *save_dialog)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
GtkFileSelection *fs;
|
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
|
|
|
const gchar *filename;
|
|
|
|
const gchar *raw_filename;
|
2002-04-14 22:38:55 +08:00
|
|
|
gchar *uri;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
fs = GTK_FILE_SELECTION (save_dialog);
|
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
|
|
|
|
|
|
|
filename = gtk_file_selection_get_filename (fs);
|
2001-04-28 23:11:29 +08:00
|
|
|
raw_filename = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
|
|
|
|
|
|
|
|
g_assert (filename && raw_filename);
|
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
uri = g_filename_to_uri (filename, NULL, NULL);
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
{
|
|
|
|
gchar *dot;
|
|
|
|
gint x;
|
|
|
|
|
|
|
|
for (dot = strrchr (filename, '.'), x = 0; dot && *(++dot);)
|
|
|
|
{
|
|
|
|
if (*dot != 'e' || ++x < 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (x > 3 && !strcmp (dot + 1, "k"))
|
|
|
|
{
|
|
|
|
ProcRecord *proc_rec;
|
|
|
|
Argument *args;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
file_dialog_hide (save_dialog);
|
|
|
|
|
|
|
|
drawable = gimp_image_active_drawable (the_gimage);
|
|
|
|
if (! drawable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
proc_rec = procedural_db_lookup (the_gimage->gimp,
|
|
|
|
"plug_in_the_slimy_egg");
|
|
|
|
if (! proc_rec)
|
|
|
|
return;
|
|
|
|
|
|
|
|
args = g_new (Argument, 3);
|
|
|
|
args[0].arg_type = GIMP_PDB_INT32;
|
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
|
|
|
args[1].arg_type = GIMP_PDB_IMAGE;
|
|
|
|
args[1].value.pdb_int = gimp_image_get_ID (the_gimage);
|
|
|
|
args[2].arg_type = GIMP_PDB_DRAWABLE;
|
|
|
|
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
|
|
|
|
|
2003-01-30 19:20:12 +08:00
|
|
|
plug_in_run (the_gimage->gimp, proc_rec, args, 3, FALSE, TRUE, -1);
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
g_free (args);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
if (g_file_test (filename, G_FILE_TEST_EXISTS))
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2002-04-18 09:18:24 +08:00
|
|
|
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
if (filename[strlen (filename) - 1] != G_DIR_SEPARATOR)
|
|
|
|
{
|
|
|
|
gchar *s = g_strconcat (filename, G_DIR_SEPARATOR_S, NULL);
|
|
|
|
gtk_file_selection_set_filename (fs, s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
else
|
2001-10-24 23:56:33 +08:00
|
|
|
{
|
|
|
|
gtk_file_selection_set_filename (fs, filename);
|
|
|
|
}
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-18 09:18:24 +08:00
|
|
|
file_save_overwrite (save_dialog, uri, raw_filename);
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), FALSE);
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
file_save_dialog_save_image (save_dialog,
|
|
|
|
the_gimage,
|
|
|
|
uri,
|
|
|
|
raw_filename,
|
|
|
|
save_file_proc,
|
2003-03-04 18:32:35 +08:00
|
|
|
set_uri_and_proc);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
typedef struct _OverwriteData OverwriteData;
|
|
|
|
|
|
|
|
struct _OverwriteData
|
|
|
|
{
|
|
|
|
GtkWidget *save_dialog;
|
|
|
|
gchar *uri;
|
|
|
|
gchar *raw_filename;
|
|
|
|
};
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
static void
|
2002-04-18 09:18:24 +08:00
|
|
|
file_save_overwrite (GtkWidget *save_dialog,
|
|
|
|
const gchar *uri,
|
|
|
|
const gchar *raw_filename)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
OverwriteData *overwrite_data;
|
2001-07-10 01:58:56 +08:00
|
|
|
GtkWidget *query_box;
|
2003-03-04 18:32:35 +08:00
|
|
|
gchar *filename;
|
|
|
|
gchar *message;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
overwrite_data = g_new0 (OverwriteData, 1);
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
overwrite_data->save_dialog = save_dialog;
|
2002-04-14 22:38:55 +08:00
|
|
|
overwrite_data->uri = g_strdup (uri);
|
|
|
|
overwrite_data->raw_filename = g_strdup (raw_filename);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
filename = file_utils_uri_to_utf8_filename (uri);
|
|
|
|
|
|
|
|
message = g_strdup_printf (_("File '%s' exists.\n"
|
|
|
|
"Overwrite it?"), filename);
|
|
|
|
|
|
|
|
g_free (filename);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
query_box = gimp_query_boolean_box (_("File Exists!"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"save/file_exists.html",
|
2003-03-07 00:47:34 +08:00
|
|
|
GIMP_STOCK_QUESTION,
|
2003-03-04 18:32:35 +08:00
|
|
|
message,
|
2001-07-31 01:17:36 +08:00
|
|
|
GTK_STOCK_YES, GTK_STOCK_NO,
|
2001-04-28 23:11:29 +08:00
|
|
|
NULL, NULL,
|
2002-04-18 09:18:24 +08:00
|
|
|
file_save_overwrite_callback,
|
2001-04-28 23:11:29 +08:00
|
|
|
overwrite_data);
|
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
g_free (message);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2003-03-17 01:51:52 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (query_box),
|
|
|
|
GTK_WINDOW (save_dialog));
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
gtk_widget_set_sensitive (save_dialog, FALSE);
|
2003-03-20 22:34:16 +08:00
|
|
|
|
|
|
|
gtk_widget_show (query_box);
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-18 09:18:24 +08:00
|
|
|
file_save_overwrite_callback (GtkWidget *widget,
|
|
|
|
gboolean overwrite,
|
|
|
|
gpointer data)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
OverwriteData *overwrite_data;
|
|
|
|
|
|
|
|
overwrite_data = (OverwriteData *) data;
|
|
|
|
|
|
|
|
if (overwrite)
|
|
|
|
{
|
2002-04-18 09:18:24 +08:00
|
|
|
file_save_dialog_save_image (overwrite_data->save_dialog,
|
|
|
|
the_gimage,
|
|
|
|
overwrite_data->uri,
|
|
|
|
overwrite_data->raw_filename,
|
|
|
|
save_file_proc,
|
2003-03-04 18:32:35 +08:00
|
|
|
set_uri_and_proc);
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
gtk_widget_set_sensitive (overwrite_data->save_dialog, TRUE);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
g_free (overwrite_data->uri);
|
2001-04-28 23:11:29 +08:00
|
|
|
g_free (overwrite_data->raw_filename);
|
|
|
|
g_free (overwrite_data);
|
|
|
|
}
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_dialog_save_image (GtkWidget *save_dialog,
|
|
|
|
GimpImage *gimage,
|
|
|
|
const gchar *uri,
|
|
|
|
const gchar *raw_filename,
|
|
|
|
PlugInProcDef *save_proc,
|
2003-03-04 18:32:35 +08:00
|
|
|
gboolean set_uri_and_proc)
|
2002-04-18 09:18:24 +08:00
|
|
|
{
|
2003-03-05 19:25:59 +08:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
GError *error = NULL;
|
2002-04-18 09:18:24 +08:00
|
|
|
|
2003-03-04 18:32:35 +08:00
|
|
|
status = file_save_as (gimage,
|
|
|
|
uri,
|
|
|
|
raw_filename,
|
|
|
|
save_proc,
|
|
|
|
GIMP_RUN_INTERACTIVE,
|
2003-03-05 19:25:59 +08:00
|
|
|
set_uri_and_proc,
|
|
|
|
&error);
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
if (status != GIMP_PDB_SUCCESS &&
|
|
|
|
status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
2003-03-05 19:25:59 +08:00
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
filename = file_utils_uri_to_utf8_filename (uri);
|
|
|
|
|
|
|
|
g_message (_("Saving '%s' failed:\n\n%s"),
|
|
|
|
filename, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
g_free (filename);
|
2002-04-18 09:18:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file_dialog_hide (save_dialog);
|
|
|
|
}
|
|
|
|
}
|