2001-06-26 20:09:43 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "gui-types.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimp.h"
|
2001-10-24 00:23:32 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2003-04-06 19:21:56 +08:00
|
|
|
#include "core/gimplist.h"
|
2001-07-10 01:58:56 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-02-13 01:11:34 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2003-04-04 01:50:56 +08:00
|
|
|
#include "core/gimptemplate.h"
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2001-10-25 21:30:01 +08:00
|
|
|
#include "file/file-open.h"
|
|
|
|
#include "file/file-save.h"
|
2002-04-19 22:09:53 +08:00
|
|
|
#include "file/file-utils.h"
|
2001-10-25 21:30:01 +08:00
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2003-05-03 02:43:15 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "display/gimpdisplay-foreach.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
#include "dialogs.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "file-commands.h"
|
|
|
|
#include "file-new-dialog.h"
|
|
|
|
#include "file-open-dialog.h"
|
|
|
|
#include "file-save-dialog.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "menus.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
#define REVERT_DATA_KEY "revert-confirm-dialog"
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
|
|
|
|
#define return_if_no_gimp(gimp,data) \
|
|
|
|
if (GIMP_IS_DISPLAY (data)) \
|
|
|
|
gimp = ((GimpDisplay *) data)->gimage->gimp; \
|
|
|
|
else if (GIMP_IS_GIMP (data)) \
|
|
|
|
gimp = data; \
|
|
|
|
else \
|
|
|
|
gimp = NULL; \
|
|
|
|
if (! gimp) \
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
#define return_if_no_display(gdisp,data) \
|
2002-12-11 00:38:16 +08:00
|
|
|
if (GIMP_IS_DISPLAY (data)) \
|
|
|
|
gdisp = data; \
|
|
|
|
else if (GIMP_IS_GIMP (data)) \
|
|
|
|
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
|
|
|
|
else \
|
|
|
|
gdisp = NULL; \
|
|
|
|
if (! gdisp) \
|
|
|
|
return
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2003-09-05 09:40:29 +08:00
|
|
|
static void file_new_template_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data);
|
|
|
|
static void file_revert_confirm_callback (GtkWidget *widget,
|
|
|
|
gboolean revert,
|
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
|
|
|
file_new_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
Gimp *gimp;
|
2002-12-11 00:38:16 +08:00
|
|
|
GimpImage *gimage;
|
2003-05-03 02:43:15 +08:00
|
|
|
GtkWidget *dialog;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
/* if called from the image menu */
|
2001-06-26 20:09:43 +08:00
|
|
|
if (action)
|
2002-11-02 00:20:13 +08:00
|
|
|
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
|
2003-11-08 23:29:47 +08:00
|
|
|
else
|
2002-12-11 00:38:16 +08:00
|
|
|
gimage = NULL;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
|
2003-11-08 23:29:47 +08:00
|
|
|
gtk_widget_get_screen (widget),
|
2003-05-03 02:43:15 +08:00
|
|
|
"gimp-file-new-dialog", -1);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
file_new_dialog_set (dialog, gimage, NULL);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
void
|
|
|
|
file_open_by_extension_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
file_open_dialog_set_type (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_open_type_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
|
|
|
file_open_dialog_set_type ((PlugInProcDef *) data);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
|
|
|
file_open_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2002-11-02 00:20:13 +08:00
|
|
|
Gimp *gimp;
|
2002-12-11 00:38:16 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_gimp (gimp, data);
|
2002-11-02 00:20:13 +08:00
|
|
|
|
|
|
|
/* if called from the image menu */
|
|
|
|
if (action)
|
|
|
|
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
|
2002-12-11 00:38:16 +08:00
|
|
|
else
|
|
|
|
gimage = NULL;
|
2002-11-02 00:20:13 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
file_open_dialog_show (gimp, gimage, NULL, global_menu_factory);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
void
|
|
|
|
file_last_opened_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
Gimp *gimp;
|
2001-10-24 00:23:32 +08:00
|
|
|
GimpImagefile *imagefile;
|
|
|
|
guint num_entries;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
num_entries = gimp_container_num_children (gimp->documents);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
|
|
|
if (action >= num_entries)
|
|
|
|
return;
|
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
imagefile = (GimpImagefile *)
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_container_get_child_by_index (gimp->documents, action);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
if (imagefile)
|
2001-06-30 03:25:03 +08:00
|
|
|
{
|
2003-03-05 19:25:59 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpPDBStatusType status;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
gimage = file_open_with_display (gimp, GIMP_OBJECT (imagefile)->name,
|
|
|
|
&status, &error);
|
|
|
|
|
|
|
|
if (! gimage && status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
2002-04-19 22:09:53 +08:00
|
|
|
|
2003-03-05 19:25:59 +08:00
|
|
|
filename =
|
|
|
|
file_utils_uri_to_utf8_filename (GIMP_OBJECT (imagefile)->name);
|
|
|
|
|
|
|
|
g_message (_("Opening '%s' failed:\n\n%s"),
|
|
|
|
filename, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2001-06-30 03:25:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
void
|
|
|
|
file_save_by_extension_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_dialog_set_type (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_save_type_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
|
|
|
file_save_dialog_set_type ((PlugInProcDef *) data);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
|
|
|
file_save_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-07-08 16:34:18 +08:00
|
|
|
g_return_if_fail (gimp_image_active_drawable (gdisp->gimage));
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
/* Only save if the gimage has been modified */
|
2002-11-19 04:50:31 +08:00
|
|
|
if (gdisp->gimage->dirty ||
|
|
|
|
! GIMP_GUI_CONFIG (gdisp->gimage->gimp->config)->trust_dirty_flag)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2002-04-14 22:38:55 +08:00
|
|
|
const gchar *uri;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (gdisp->gimage));
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
if (! uri)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2002-11-02 00:20:13 +08:00
|
|
|
file_save_as_cmd_callback (widget, data, action);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-03-05 19:25:59 +08:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
GError *error = NULL;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-03-05 19:25:59 +08:00
|
|
|
status = file_save (gdisp->gimage, GIMP_RUN_WITH_LAST_VALS, &error);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
if (status != GIMP_PDB_SUCCESS &&
|
|
|
|
status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
2003-03-04 18:32:35 +08:00
|
|
|
gchar *filename;
|
|
|
|
|
2003-03-05 19:25:59 +08:00
|
|
|
filename = file_utils_uri_to_utf8_filename (uri);
|
2003-03-04 18:32:35 +08:00
|
|
|
|
2003-03-05 19:25:59 +08:00
|
|
|
g_message (_("Saving '%s' failed:\n\n%s"),
|
|
|
|
filename, error->message);
|
|
|
|
g_clear_error (&error);
|
2003-03-04 18:32:35 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_save_as_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_dialog_show (gdisp->gimage, global_menu_factory);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-09-01 15:44:29 +08:00
|
|
|
file_save_a_copy_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
file_save_a_copy_dialog_show (gdisp->gimage, global_menu_factory);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
void
|
|
|
|
file_save_template_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GtkWidget *qbox;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
qbox = gimp_query_string_box (_("Create New Template"),
|
2003-11-08 23:29:47 +08:00
|
|
|
gdisp->shell,
|
2003-04-04 01:50:56 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_FILE_SAVE_AS_TEMPLATE,
|
2003-04-04 01:50:56 +08:00
|
|
|
_("Enter a name for this template"),
|
|
|
|
NULL,
|
|
|
|
G_OBJECT (gdisp->gimage), "disconnect",
|
|
|
|
file_new_template_callback, gdisp->gimage);
|
|
|
|
gtk_widget_show (qbox);
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
|
|
|
file_revert_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-07-10 01:58:56 +08:00
|
|
|
GtkWidget *query_box;
|
2002-04-14 22:38:55 +08:00
|
|
|
const gchar *uri;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (gdisp->gimage));
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
query_box = g_object_get_data (G_OBJECT (gdisp->gimage), REVERT_DATA_KEY);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
if (! uri)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
|
|
|
g_message (_("Revert failed.\n"
|
2001-11-27 01:12:29 +08:00
|
|
|
"No file name associated with this image."));
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
else if (query_box)
|
|
|
|
{
|
2002-10-25 09:11:24 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (query_box->window));
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
gchar *basename;
|
2001-07-10 01:58:56 +08:00
|
|
|
gchar *text;
|
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
basename = g_path_get_basename (uri);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2001-11-27 01:12:29 +08:00
|
|
|
text = g_strdup_printf (_("Revert '%s' to\n"
|
2002-02-28 18:36:06 +08:00
|
|
|
"'%s'?\n\n"
|
2003-03-20 22:34:16 +08:00
|
|
|
"You will lose all your changes, "
|
|
|
|
"including all undo information."),
|
2002-04-14 22:38:55 +08:00
|
|
|
basename, uri);
|
2001-08-30 01:48:28 +08:00
|
|
|
|
|
|
|
g_free (basename);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2001-11-27 01:12:29 +08:00
|
|
|
query_box = gimp_query_boolean_box (_("Revert Image"),
|
2003-11-08 23:29:47 +08:00
|
|
|
gdisp->shell,
|
2001-07-10 01:58:56 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_FILE_REVERT,
|
2003-03-07 00:47:34 +08:00
|
|
|
GIMP_STOCK_QUESTION,
|
2001-07-10 01:58:56 +08:00
|
|
|
text,
|
2001-07-31 01:17:36 +08:00
|
|
|
GTK_STOCK_YES, GTK_STOCK_NO,
|
2001-08-12 05:10:44 +08:00
|
|
|
G_OBJECT (gdisp->gimage),
|
|
|
|
"disconnect",
|
2001-07-10 01:58:56 +08:00
|
|
|
file_revert_confirm_callback,
|
|
|
|
gdisp->gimage);
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
g_object_set_data (G_OBJECT (gdisp->gimage), REVERT_DATA_KEY,
|
|
|
|
query_box);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-03-20 22:34:16 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (query_box),
|
|
|
|
GTK_WINDOW (gdisp->shell));
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_show (query_box);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_close_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_close (GIMP_DISPLAY_SHELL (gdisp->shell), FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_quit_cmd_callback (GtkWidget *widget,
|
2002-11-02 00:20:13 +08:00
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2002-12-11 00:38:16 +08:00
|
|
|
Gimp *gimp;
|
|
|
|
return_if_no_gimp (gimp, data);
|
|
|
|
|
|
|
|
gimp_exit (gimp, FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
void
|
|
|
|
file_file_open_dialog (Gimp *gimp,
|
|
|
|
const gchar *uri)
|
|
|
|
{
|
|
|
|
file_open_dialog_show (gimp, NULL, uri, global_menu_factory);
|
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
/* private functions */
|
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
static void
|
2003-09-05 09:40:29 +08:00
|
|
|
file_new_template_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data)
|
2003-04-04 01:50:56 +08:00
|
|
|
{
|
|
|
|
GimpTemplate *template;
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
|
|
|
gimage = (GimpImage *) data;
|
|
|
|
|
|
|
|
if (! (name && strlen (name)))
|
|
|
|
name = _("(Unnamed Template)");
|
|
|
|
|
|
|
|
template = gimp_template_new (name);
|
|
|
|
gimp_template_set_from_image (template, gimage);
|
|
|
|
|
2003-04-06 19:21:56 +08:00
|
|
|
gimp_list_uniquefy_name (GIMP_LIST (gimage->gimp->templates),
|
|
|
|
GIMP_OBJECT (template), TRUE);
|
2003-04-04 01:50:56 +08:00
|
|
|
gimp_container_add (gimage->gimp->templates,
|
|
|
|
GIMP_OBJECT (template));
|
|
|
|
g_object_unref (template);
|
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
static void
|
|
|
|
file_revert_confirm_callback (GtkWidget *widget,
|
|
|
|
gboolean revert,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *old_gimage;
|
|
|
|
|
|
|
|
old_gimage = (GimpImage *) data;
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
g_object_set_data (G_OBJECT (old_gimage), REVERT_DATA_KEY, NULL);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
if (revert)
|
|
|
|
{
|
2003-05-18 00:34:30 +08:00
|
|
|
Gimp *gimp;
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *new_gimage;
|
2002-04-14 22:38:55 +08:00
|
|
|
const gchar *uri;
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpPDBStatusType status;
|
2002-04-19 22:09:53 +08:00
|
|
|
GError *error = NULL;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-05-18 00:34:30 +08:00
|
|
|
gimp = old_gimage->gimp;
|
|
|
|
|
2002-04-14 22:38:55 +08:00
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (old_gimage));
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2003-05-18 00:34:30 +08:00
|
|
|
new_gimage = file_open_image (gimp, uri, uri, NULL,
|
2001-12-19 08:13:16 +08:00
|
|
|
GIMP_RUN_INTERACTIVE,
|
2003-05-18 00:34:30 +08:00
|
|
|
&status, &error);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2002-04-19 22:09:53 +08:00
|
|
|
if (new_gimage)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2003-05-18 00:34:30 +08:00
|
|
|
GList *contexts = NULL;
|
|
|
|
GList *list;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-05-18 00:34:30 +08:00
|
|
|
/* remember which contexts refer to old_gimage */
|
|
|
|
for (list = gimp->context_list; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpContext *context = list->data;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-05-18 00:34:30 +08:00
|
|
|
if (gimp_context_get_image (context) == old_gimage)
|
|
|
|
contexts = g_list_prepend (contexts, list->data);
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-05-18 00:34:30 +08:00
|
|
|
gimp_image_undo_free (new_gimage);
|
|
|
|
gimp_displays_reconnect (gimp, old_gimage, new_gimage);
|
|
|
|
gimp_image_clean_all (new_gimage);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (new_gimage);
|
2003-05-18 00:34:30 +08:00
|
|
|
|
|
|
|
/* set the new_gimage on the remembered contexts (in reverse
|
|
|
|
* order, since older contexts are usually the parents of
|
|
|
|
* newer ones)
|
|
|
|
*/
|
|
|
|
g_list_foreach (contexts, (GFunc) gimp_context_set_image, new_gimage);
|
|
|
|
g_list_free (contexts);
|
|
|
|
|
|
|
|
/* the displays own the image now */
|
|
|
|
g_object_unref (new_gimage);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
else if (status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
2002-04-19 22:09:53 +08:00
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
filename = file_utils_uri_to_utf8_filename (uri);
|
|
|
|
|
2003-03-05 19:25:59 +08:00
|
|
|
g_message (_("Reverting to '%s' failed:\n\n%s"),
|
2002-04-19 22:09:53 +08:00
|
|
|
filename, error->message);
|
2003-03-05 19:25:59 +08:00
|
|
|
g_clear_error (&error);
|
2002-04-19 22:09:53 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|