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"
|
|
|
|
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "plug-in/plug-in.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in/plug-in-proc.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"
|
|
|
|
|
2001-11-28 03:27:55 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
#include "file-dialog-utils.h"
|
|
|
|
#include "file-save-dialog.h"
|
|
|
|
|
|
|
|
#include "gimprc.h"
|
|
|
|
#include "undo.h"
|
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _OverwriteData OverwriteData;
|
|
|
|
|
|
|
|
struct _OverwriteData
|
|
|
|
{
|
2002-04-14 22:38:55 +08:00
|
|
|
gchar *uri;
|
2001-04-28 23:11:29 +08:00
|
|
|
gchar *raw_filename;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void file_save_dialog_create (void);
|
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
static void file_overwrite (const gchar *uri,
|
2001-10-29 19:47:11 +08:00
|
|
|
const gchar *raw_filename);
|
2001-04-28 23:11:29 +08:00
|
|
|
static void file_overwrite_callback (GtkWidget *widget,
|
|
|
|
gboolean overwrite,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void file_save_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void file_save_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *filesave = NULL;
|
|
|
|
static GtkWidget *save_options = NULL;
|
|
|
|
|
|
|
|
static PlugInProcDef *save_file_proc = NULL;
|
|
|
|
|
|
|
|
static GimpImage *the_gimage = NULL;
|
2002-04-14 22:38:55 +08:00
|
|
|
static gboolean set_uri = TRUE;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2002-03-21 01:46:13 +08:00
|
|
|
file_save_dialog_menu_init (Gimp *gimp,
|
|
|
|
GimpItemFactory *item_factory)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
GimpItemFactoryEntry entry;
|
|
|
|
PlugInProcDef *file_proc;
|
|
|
|
GSList *list;
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2002-03-21 01:46:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_ITEM_FACTORY (item_factory));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp->save_procs = g_slist_reverse (gimp->save_procs);
|
|
|
|
|
|
|
|
for (list = gimp->save_procs; list; list = g_slist_next (list))
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
gchar *basename;
|
2001-10-24 23:56:33 +08:00
|
|
|
gchar *filename;
|
2001-08-30 01:48:28 +08:00
|
|
|
gchar *page;
|
|
|
|
gchar *lowercase_page;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
file_proc = (PlugInProcDef *) list->data;
|
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
basename = g_path_get_basename (file_proc->prog);
|
|
|
|
|
2001-10-24 23:56:33 +08:00
|
|
|
filename = g_strconcat (basename, ".html", NULL);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
|
|
|
g_free (basename);
|
|
|
|
|
2001-10-24 23:56:33 +08:00
|
|
|
page = g_build_filename ("filters", filename, NULL);
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
|
2001-09-26 20:52:12 +08:00
|
|
|
lowercase_page = g_ascii_strdown (page, -1);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
|
|
|
g_free (page);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
entry.entry.path = strstr (file_proc->menu_path, "/");
|
2001-04-28 23:11:29 +08:00
|
|
|
entry.entry.accelerator = NULL;
|
|
|
|
entry.entry.callback = file_save_type_callback;
|
|
|
|
entry.entry.callback_action = 0;
|
|
|
|
entry.entry.item_type = NULL;
|
2001-07-10 01:58:56 +08:00
|
|
|
entry.quark_string = NULL;
|
2001-08-30 01:48:28 +08:00
|
|
|
entry.help_page = lowercase_page;
|
2001-04-28 23:11:29 +08:00
|
|
|
entry.description = NULL;
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
gimp_item_factory_create_item (item_factory,
|
|
|
|
&entry,
|
|
|
|
file_proc, 2,
|
|
|
|
TRUE, FALSE);
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-10 01:58:56 +08:00
|
|
|
file_save_dialog_menu_reset (void)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
save_file_proc = NULL;
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-10 01:58:56 +08:00
|
|
|
file_save_dialog_show (GimpImage *gimage)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2002-04-14 22:38:55 +08:00
|
|
|
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));
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! gimp_image_active_drawable (gimage))
|
2001-04-28 23:11:29 +08:00
|
|
|
return;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
the_gimage = gimage;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
set_uri = TRUE;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (gimage));
|
|
|
|
|
|
|
|
if (uri)
|
|
|
|
filename = g_filename_from_uri (uri, NULL, NULL);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
if (! filesave)
|
|
|
|
file_save_dialog_create ();
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
|
|
|
|
if (GTK_WIDGET_VISIBLE (filesave))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image"));
|
|
|
|
|
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
|
|
|
|
filename ?
|
|
|
|
filename :
|
|
|
|
"." G_DIR_SEPARATOR_S);
|
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
file_dialog_update_menus (gimage->gimp->save_procs,
|
|
|
|
gimp_drawable_type (gimp_image_active_drawable (gimage)));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
file_dialog_show (filesave);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-10 01:58:56 +08:00
|
|
|
file_save_a_copy_dialog_show (GimpImage *gimage)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2002-04-14 22:38:55 +08:00
|
|
|
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));
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! gimp_image_active_drawable (gimage))
|
2001-04-28 23:11:29 +08:00
|
|
|
return;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
the_gimage = gimage;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
set_uri = FALSE;
|
|
|
|
|
|
|
|
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)
|
2001-04-28 23:11:29 +08:00
|
|
|
file_save_dialog_create ();
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
|
|
|
|
if (GTK_WIDGET_VISIBLE (filesave))
|
|
|
|
return;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
file_dialog_update_menus (gimage->gimp->save_procs,
|
|
|
|
gimp_drawable_type (gimp_image_active_drawable (gimage)));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
file_dialog_show (filesave);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_dialog_create (void)
|
|
|
|
{
|
2001-08-15 00:33:28 +08:00
|
|
|
GtkFileSelection *file_sel;
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
filesave = gtk_file_selection_new (_("Save Image"));
|
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (filesave), "save_image", "Gimp");
|
|
|
|
gtk_window_set_position (GTK_WINDOW (filesave), GTK_WIN_POS_MOUSE);
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
file_sel = GTK_FILE_SELECTION (filesave);
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filesave), 2);
|
2001-08-15 00:33:28 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (file_sel->button_area), 2);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (G_OBJECT (file_sel->cancel_button), "clicked",
|
|
|
|
G_CALLBACK (file_dialog_hide),
|
|
|
|
filesave);
|
|
|
|
g_signal_connect (G_OBJECT (filesave), "delete_event",
|
|
|
|
G_CALLBACK (file_dialog_hide),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (file_sel->ok_button), "clicked",
|
|
|
|
G_CALLBACK (file_save_ok_callback),
|
|
|
|
filesave);
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
/* Connect the "F1" help key */
|
2001-08-01 07:28:56 +08:00
|
|
|
gimp_help_connect (filesave,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"save/dialogs/file_save.html");
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
{
|
2002-01-26 02:34:33 +08:00
|
|
|
GimpItemFactory *item_factory;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *option_menu;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
save_options = gtk_hbox_new (TRUE, 1);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (_("Save Options"));
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (save_options), frame, TRUE, TRUE, 4);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Determine File Type:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
option_menu = gtk_option_menu_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), option_menu, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (option_menu);
|
|
|
|
|
2002-01-26 02:34:33 +08:00
|
|
|
item_factory = gimp_item_factory_from_path ("<Save>");
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu),
|
2002-01-26 02:34:33 +08:00
|
|
|
GTK_ITEM_FACTORY (item_factory)->widget);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
/* pack the containing save_options hbox into the save-dialog */
|
|
|
|
gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (filesave)->main_vbox),
|
|
|
|
save_options, FALSE, FALSE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show (save_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PlugInProcDef *proc = (PlugInProcDef *) data;
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
file_dialog_update_name (proc, GTK_FILE_SELECTION (filesave));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
save_file_proc = proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
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
|
|
|
gchar *dot;
|
|
|
|
gint x;
|
|
|
|
struct stat buf;
|
|
|
|
gint err;
|
|
|
|
|
|
|
|
fs = GTK_FILE_SELECTION (data);
|
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);
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
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 *the_drawable;
|
|
|
|
|
|
|
|
the_drawable = gimp_image_active_drawable (the_gimage);
|
|
|
|
if (!the_drawable)
|
|
|
|
return;
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
proc_rec = procedural_db_lookup (the_gimage->gimp,
|
|
|
|
"plug_in_the_slimy_egg");
|
2001-04-28 23:11:29 +08:00
|
|
|
if (!proc_rec)
|
|
|
|
break;
|
|
|
|
|
|
|
|
file_dialog_hide (filesave);
|
|
|
|
|
|
|
|
args = g_new (Argument, 3);
|
2001-05-21 21:58:46 +08:00
|
|
|
args[0].arg_type = GIMP_PDB_INT32;
|
2001-12-19 08:13:16 +08:00
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
2001-05-21 21:58:46 +08:00
|
|
|
args[1].arg_type = GIMP_PDB_IMAGE;
|
2001-04-28 23:11:29 +08:00
|
|
|
args[1].value.pdb_int = gimp_image_get_ID (the_gimage);
|
2001-05-21 21:58:46 +08:00
|
|
|
args[2].arg_type = GIMP_PDB_DRAWABLE;
|
2002-02-26 01:58:50 +08:00
|
|
|
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (the_drawable));
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_in_run (the_gimage->gimp, proc_rec, args, 3, FALSE, TRUE, 0);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
g_free (args);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = stat (filename, &buf);
|
|
|
|
|
|
|
|
if (err == 0)
|
|
|
|
{
|
|
|
|
if (buf.st_mode & S_IFDIR)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), FALSE);
|
2002-04-14 22:38:55 +08:00
|
|
|
file_overwrite (uri, raw_filename);
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
|
2001-04-28 23:11:29 +08:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), FALSE);
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
status = file_save (the_gimage,
|
2002-04-14 22:38:55 +08:00
|
|
|
uri,
|
2001-10-29 19:47:11 +08:00
|
|
|
raw_filename,
|
|
|
|
save_file_proc,
|
2001-12-19 08:13:16 +08:00
|
|
|
GIMP_RUN_INTERACTIVE,
|
2002-04-14 22:38:55 +08:00
|
|
|
set_uri);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
if (status != GIMP_PDB_SUCCESS &&
|
|
|
|
status != GIMP_PDB_CANCEL)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
2001-11-27 01:12:29 +08:00
|
|
|
/* Please add error. (: %s) --bex */
|
2002-04-14 22:38:55 +08:00
|
|
|
g_message (_("Saving %s failed."), uri);
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
2001-10-29 19:47:11 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
file_dialog_hide (GTK_WIDGET (fs));
|
|
|
|
}
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-14 22:38:55 +08:00
|
|
|
file_overwrite (const gchar *uri,
|
2001-10-29 19:47:11 +08:00
|
|
|
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;
|
|
|
|
gchar *overwrite_text;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
overwrite_data = g_new0 (OverwriteData, 1);
|
|
|
|
|
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
|
|
|
|
2002-03-02 19:20:21 +08:00
|
|
|
overwrite_text = g_strdup_printf (_("File '%s' exists.\n"
|
2002-04-14 22:38:55 +08:00
|
|
|
"Overwrite it?"), uri);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
query_box = gimp_query_boolean_box (_("File Exists!"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"save/file_exists.html",
|
2002-01-10 04:39:49 +08:00
|
|
|
GTK_STOCK_DIALOG_QUESTION,
|
2001-04-28 23:11:29 +08:00
|
|
|
overwrite_text,
|
2001-07-31 01:17:36 +08:00
|
|
|
GTK_STOCK_YES, GTK_STOCK_NO,
|
2001-04-28 23:11:29 +08:00
|
|
|
NULL, NULL,
|
|
|
|
file_overwrite_callback,
|
|
|
|
overwrite_data);
|
|
|
|
|
|
|
|
g_free (overwrite_text);
|
|
|
|
|
|
|
|
gtk_widget_show (query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_overwrite_callback (GtkWidget *widget,
|
|
|
|
gboolean overwrite,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
OverwriteData *overwrite_data;
|
|
|
|
|
|
|
|
overwrite_data = (OverwriteData *) data;
|
|
|
|
|
|
|
|
if (overwrite)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
|
|
|
|
status = file_save (the_gimage,
|
2002-04-14 22:38:55 +08:00
|
|
|
overwrite_data->uri,
|
2001-10-29 19:47:11 +08:00
|
|
|
overwrite_data->raw_filename,
|
|
|
|
save_file_proc,
|
2001-12-19 08:13:16 +08:00
|
|
|
GIMP_RUN_INTERACTIVE,
|
2002-04-14 22:38:55 +08:00
|
|
|
set_uri);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
if (status != GIMP_PDB_SUCCESS &&
|
|
|
|
status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
2001-11-27 01:12:29 +08:00
|
|
|
/* Another error required. --bex */
|
2002-04-14 22:38:55 +08:00
|
|
|
g_message (_("Saving '%s' failed."), overwrite_data->uri);
|
2001-10-29 19:47:11 +08:00
|
|
|
}
|
|
|
|
else
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
file_dialog_hide (GTK_WIDGET (filesave));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always make file save dialog sensitive */
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
|
|
|
|
|
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);
|
|
|
|
}
|