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"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-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-07-10 01:58:56 +08:00
|
|
|
#include "core/gimpimage.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.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
|
|
|
|
2004-09-09 17:47:33 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2004-09-14 00:01:52 +08:00
|
|
|
#include "widgets/gimpfiledialog.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-10-13 23:27:00 +08:00
|
|
|
#include "widgets/gimpmessagebox.h"
|
|
|
|
#include "widgets/gimpmessagedialog.h"
|
2003-05-03 02:43:15 +08:00
|
|
|
|
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-09-26 07:23:09 +08:00
|
|
|
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "file-commands.h"
|
|
|
|
|
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
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2004-09-14 03:33:07 +08:00
|
|
|
static void file_open_dialog_show (GtkWidget *parent,
|
|
|
|
GimpImage *gimage,
|
2004-09-21 20:08:30 +08:00
|
|
|
const gchar *uri,
|
|
|
|
gboolean open_as_layer);
|
2004-09-14 03:33:07 +08:00
|
|
|
static void file_save_dialog_show (GimpImage *gimage,
|
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
2004-11-16 21:37:36 +08:00
|
|
|
gboolean save_a_copy);
|
2004-09-14 03:33:07 +08:00
|
|
|
static void file_save_dialog_destroyed (GtkWidget *dialog,
|
|
|
|
GimpImage *gimage);
|
2003-09-05 09:40:29 +08:00
|
|
|
static void file_new_template_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data);
|
2004-10-13 23:27:00 +08:00
|
|
|
static void file_revert_confirm_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpDisplay *gdisp);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-05-25 20:02:54 +08:00
|
|
|
file_open_cmd_callback (GtkAction *action,
|
2004-07-01 00:01:05 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-09-21 20:08:30 +08:00
|
|
|
file_open_dialog_show (widget, NULL, NULL, FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 20:02:54 +08:00
|
|
|
file_open_from_image_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2005-01-14 01:41:48 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
const gchar *uri = NULL;
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-11-02 00:20:13 +08:00
|
|
|
|
2005-01-14 01:41:48 +08:00
|
|
|
image = action_data_get_image (data);
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (image));
|
|
|
|
|
|
|
|
file_open_dialog_show (widget, NULL, uri, FALSE);
|
2004-09-21 20:08:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_open_as_layer_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GtkWidget *widget;
|
2005-02-25 01:18:11 +08:00
|
|
|
GimpImage *image;
|
|
|
|
const gchar *uri;
|
2004-09-21 20:08:30 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2005-02-25 01:18:11 +08:00
|
|
|
image = gdisp->gimage;
|
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (image));
|
|
|
|
|
|
|
|
file_open_dialog_show (widget, image, uri, TRUE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2004-05-31 22:40:10 +08:00
|
|
|
void
|
|
|
|
file_open_location_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2004-09-09 17:47:33 +08:00
|
|
|
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
|
|
|
gtk_widget_get_screen (widget),
|
|
|
|
"gimp-file-open-location-dialog", -1, TRUE);
|
2004-05-31 22:40:10 +08:00
|
|
|
}
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_last_opened_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
2004-07-01 00:01:05 +08:00
|
|
|
gpointer data)
|
2001-06-30 03:25:03 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
Gimp *gimp;
|
2001-10-24 00:23:32 +08:00
|
|
|
GimpImagefile *imagefile;
|
2004-04-29 20:52:29 +08:00
|
|
|
gint 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
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
if (value >= num_entries)
|
2001-06-30 03:25:03 +08:00
|
|
|
return;
|
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
imagefile = (GimpImagefile *)
|
2004-04-29 20:52:29 +08:00
|
|
|
gimp_container_get_child_by_index (gimp->documents, value);
|
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;
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimage = file_open_with_display (gimp, action_data_get_context (data),
|
2004-08-11 02:47:21 +08:00
|
|
|
NULL,
|
2004-04-15 07:37:34 +08:00
|
|
|
GIMP_OBJECT (imagefile)->name,
|
2003-03-05 19:25:59 +08:00
|
|
|
&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-06-26 20:09:43 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_save_cmd_callback (GtkAction *action,
|
2004-07-01 00:01:05 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2005-02-14 02:05:43 +08:00
|
|
|
GimpImage *gimage;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2005-02-14 02:05:43 +08:00
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
|
|
|
if (! gimp_image_active_drawable (gimage))
|
2004-10-24 03:13:17 +08:00
|
|
|
return;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
/* Only save if the gimage has been modified */
|
2005-02-14 02:05:43 +08:00
|
|
|
if (gimage->dirty ||
|
|
|
|
! GIMP_GUI_CONFIG (gimage->gimp->config)->trust_dirty_flag)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2005-02-14 02:05:43 +08:00
|
|
|
const gchar *uri;
|
|
|
|
PlugInProcDef *save_proc = NULL;
|
|
|
|
|
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (gimage));
|
|
|
|
save_proc = gimp_image_get_save_proc (gimage);
|
|
|
|
|
|
|
|
if (uri && ! save_proc)
|
|
|
|
save_proc = file_utils_find_proc (gimage->gimp->save_procs, uri);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2005-02-14 02:05:43 +08:00
|
|
|
if (! (uri && save_proc))
|
2004-07-01 00:01:05 +08:00
|
|
|
{
|
|
|
|
file_save_as_cmd_callback (action, data);
|
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
else
|
2004-07-01 00:01:05 +08:00
|
|
|
{
|
|
|
|
GimpPDBStatusType status;
|
2003-03-05 19:25:59 +08:00
|
|
|
GError *error = NULL;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2005-02-14 02:05:43 +08:00
|
|
|
status = file_save (gimage, action_data_get_context (data),
|
2004-08-11 02:47:21 +08:00
|
|
|
GIMP_PROGRESS (gdisp),
|
2005-02-14 02:05:43 +08:00
|
|
|
uri, save_proc,
|
|
|
|
GIMP_RUN_WITH_LAST_VALS, FALSE, &error);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2004-07-01 00:01:05 +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
|
|
|
|
2004-07-01 00:01:05 +08:00
|
|
|
g_message (_("Saving '%s' failed:\n\n%s"),
|
2003-03-05 19:25:59 +08:00
|
|
|
filename, error->message);
|
|
|
|
g_clear_error (&error);
|
2003-03-04 18:32:35 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
2004-07-01 00:01:05 +08:00
|
|
|
}
|
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_save_as_cmd_callback (GtkAction *action,
|
2004-07-01 00:01:05 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-09-14 00:37:01 +08:00
|
|
|
GtkWidget *widget;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2004-09-14 00:37:01 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
if (! gimp_image_active_drawable (gdisp->gimage))
|
|
|
|
return;
|
|
|
|
|
2004-11-16 21:37:36 +08:00
|
|
|
file_save_dialog_show (gdisp->gimage, widget,
|
|
|
|
_("Save Image"), FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_save_a_copy_cmd_callback (GtkAction *action,
|
2004-04-20 00:00:54 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-09-14 00:37:01 +08:00
|
|
|
GtkWidget *widget;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2004-09-14 00:37:01 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
if (! gimp_image_active_drawable (gdisp->gimage))
|
|
|
|
return;
|
|
|
|
|
2004-11-16 21:37:36 +08:00
|
|
|
file_save_dialog_show (gdisp->gimage, widget,
|
|
|
|
_("Save a Copy of the Image"), TRUE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_save_template_cmd_callback (GtkAction *action,
|
2004-04-20 00:00:54 +08:00
|
|
|
gpointer data)
|
2003-04-04 01:50:56 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
2004-10-19 22:08:44 +08:00
|
|
|
GtkWidget *dialog;
|
2003-04-04 01:50:56 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
dialog = gimp_query_string_box (_("Create New Template"),
|
|
|
|
gdisp->shell,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_FILE_SAVE_AS_TEMPLATE,
|
|
|
|
_("Enter a name for this template"),
|
|
|
|
NULL,
|
|
|
|
G_OBJECT (gdisp->gimage), "disconnect",
|
|
|
|
file_new_template_callback, gdisp->gimage);
|
|
|
|
gtk_widget_show (dialog);
|
2003-04-04 01:50:56 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_revert_cmd_callback (GtkAction *action,
|
2004-07-01 00:01:05 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-10-13 23:27:00 +08:00
|
|
|
GtkWidget *dialog;
|
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
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
dialog = 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
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Revert failed. No file name associated with this image."));
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
2004-10-13 23:27:00 +08:00
|
|
|
else if (dialog)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2004-10-13 23:27:00 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
gchar *basename;
|
2004-10-14 07:03:12 +08:00
|
|
|
gchar *filename;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
dialog =
|
|
|
|
gimp_message_dialog_new (_("Revert Image"), GIMP_STOCK_QUESTION,
|
|
|
|
gdisp->shell, 0,
|
|
|
|
gimp_standard_help_func, GIMP_HELP_FILE_REVERT,
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_REVERT_TO_SAVED, GTK_RESPONSE_OK,
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
NULL);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2005-02-10 19:00:46 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
g_signal_connect_object (gdisp, "disconnect",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
2004-07-17 05:24:39 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (file_revert_confirm_response),
|
|
|
|
gdisp);
|
2004-07-01 00:01:05 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
basename = g_path_get_basename (uri);
|
2004-10-14 07:03:12 +08:00
|
|
|
filename = file_utils_uri_to_utf8_filename (uri);
|
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("Revert '%s' to '%s'?"),
|
2004-10-14 07:03:12 +08:00
|
|
|
basename, filename);
|
|
|
|
g_free (filename);
|
2004-10-13 23:27:00 +08:00
|
|
|
g_free (basename);
|
|
|
|
|
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("By reverting the image to the state saved "
|
|
|
|
"on disk, you will lose all changes, "
|
|
|
|
"including all undo information."));
|
2004-07-17 05:24:39 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
g_object_set_data (G_OBJECT (gdisp->gimage), REVERT_DATA_KEY, dialog);
|
2004-07-17 05:24:39 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2005-09-25 03:30:08 +08:00
|
|
|
void
|
|
|
|
file_close_all_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
return_if_no_gimp (gimp, data);
|
|
|
|
|
|
|
|
if (! gimp_displays_dirty (gimp))
|
|
|
|
{
|
|
|
|
gimp_displays_delete (gimp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
gimp_dialog_factory_dialog_raise (global_dialog_factory,
|
|
|
|
gtk_widget_get_screen (widget),
|
|
|
|
"gimp-close-all-dialog", -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
file_quit_cmd_callback (GtkAction *action,
|
2004-07-01 00:01:05 +08:00
|
|
|
gpointer data)
|
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,
|
2003-11-10 06:05:37 +08:00
|
|
|
const gchar *uri,
|
|
|
|
GtkWidget *parent)
|
2004-09-14 03:33:07 +08:00
|
|
|
{
|
2004-09-21 20:08:30 +08:00
|
|
|
file_open_dialog_show (parent, NULL, uri, FALSE);
|
2004-09-14 03:33:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_open_dialog_show (GtkWidget *parent,
|
|
|
|
GimpImage *gimage,
|
2004-09-21 20:08:30 +08:00
|
|
|
const gchar *uri,
|
|
|
|
gboolean open_as_layer)
|
2003-01-11 01:55:53 +08:00
|
|
|
{
|
2004-09-14 00:01:52 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
|
|
|
|
gtk_widget_get_screen (parent),
|
|
|
|
"gimp-file-open-dialog", -1, FALSE);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
2005-01-14 01:41:48 +08:00
|
|
|
if (uri)
|
|
|
|
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
|
2004-09-14 00:01:52 +08:00
|
|
|
|
2004-09-21 20:08:30 +08:00
|
|
|
if (open_as_layer)
|
|
|
|
{
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), _("Open Image as Layer"));
|
|
|
|
GIMP_FILE_DIALOG (dialog)->gimage = gimage;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), _("Open Image"));
|
|
|
|
GIMP_FILE_DIALOG (dialog)->gimage = NULL;
|
|
|
|
}
|
|
|
|
|
2005-05-19 05:01:51 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
|
|
|
|
|
2004-09-14 00:01:52 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
2003-01-11 01:55:53 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2004-09-14 03:33:07 +08:00
|
|
|
static void
|
|
|
|
file_save_dialog_show (GimpImage *gimage,
|
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
2004-11-16 21:37:36 +08:00
|
|
|
gboolean save_a_copy)
|
2004-09-14 03:33:07 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2004-09-14 03:33:07 +08:00
|
|
|
dialog = g_object_get_data (G_OBJECT (gimage), "gimp-file-save-dialog");
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
|
|
|
|
gtk_widget_get_screen (parent),
|
|
|
|
"gimp-file-save-dialog",
|
|
|
|
-1, FALSE);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
2005-05-19 05:01:51 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
|
|
|
GTK_WINDOW (parent));
|
|
|
|
|
2004-09-14 03:33:07 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (gimage),
|
|
|
|
"gimp-file-save-dialog", dialog,
|
|
|
|
(GDestroyNotify) gtk_widget_destroy);
|
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (file_save_dialog_destroyed),
|
|
|
|
gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
|
|
|
|
2004-11-16 21:37:36 +08:00
|
|
|
gimp_file_dialog_set_image (GIMP_FILE_DIALOG (dialog),
|
|
|
|
gimage, save_a_copy);
|
2004-09-14 03:33:07 +08:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_dialog_destroyed (GtkWidget *dialog,
|
|
|
|
GimpImage *gimage)
|
|
|
|
{
|
|
|
|
if (GIMP_FILE_DIALOG (dialog)->gimage == gimage)
|
|
|
|
g_object_set_data (G_OBJECT (gimage), "gimp-file-save-dialog", NULL);
|
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
|
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);
|
2004-05-24 18:49:34 +08:00
|
|
|
gimp_container_add (gimage->gimp->templates, GIMP_OBJECT (template));
|
2003-04-04 01:50:56 +08:00
|
|
|
g_object_unref (template);
|
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
static void
|
2004-10-13 23:27:00 +08:00
|
|
|
file_revert_confirm_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpDisplay *gdisp)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2004-10-13 23:27:00 +08:00
|
|
|
GimpImage *old_gimage = gdisp->gimage;
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
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
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2004-10-13 23:27:00 +08:00
|
|
|
Gimp *gimp = old_gimage->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
|
|
|
|
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
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
new_gimage = file_open_image (gimp, gimp_get_user_context (gimp),
|
2004-08-11 02:47:21 +08:00
|
|
|
GIMP_PROGRESS (gdisp),
|
2004-04-15 07:37:34 +08:00
|
|
|
uri, uri, NULL,
|
2004-07-01 00:01:05 +08:00
|
|
|
GIMP_RUN_INTERACTIVE,
|
|
|
|
&status, NULL, &error);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2002-04-19 22:09:53 +08:00
|
|
|
if (new_gimage)
|
2004-07-01 00:01:05 +08:00
|
|
|
{
|
|
|
|
gimp_displays_reconnect (gimp, old_gimage, new_gimage);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (new_gimage);
|
2003-05-18 00:34:30 +08:00
|
|
|
|
|
|
|
/* the displays own the image now */
|
|
|
|
g_object_unref (new_gimage);
|
2004-07-01 00:01:05 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
else if (status != GIMP_PDB_CANCEL)
|
2004-07-01 00:01:05 +08:00
|
|
|
{
|
2002-04-19 22:09:53 +08:00
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
filename = file_utils_uri_to_utf8_filename (uri);
|
|
|
|
|
2004-07-01 00:01:05 +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);
|
2004-07-01 00:01:05 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
}
|