2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-06-26 20:09:43 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-06-26 20:09:43 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-06-26 20:09:43 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-06-26 20:09:43 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2001-06-26 20:09:43 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2014-07-07 06:46:25 +08:00
|
|
|
#include "libgimpbase/gimpbase.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"
|
2014-07-07 06:46:25 +08:00
|
|
|
#include "core/gimpimagefile.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
|
|
|
|
2016-01-04 03:05:27 +08:00
|
|
|
#include "plug-in/gimppluginmanager-file.h"
|
2006-04-29 06:26:51 +08:00
|
|
|
|
2001-10-25 21:30:01 +08:00
|
|
|
#include "file/file-open.h"
|
|
|
|
#include "file/file-save.h"
|
2009-05-01 15:03:13 +08:00
|
|
|
#include "file/gimp-file.h"
|
2001-10-25 21:30:01 +08:00
|
|
|
|
2005-10-29 09:43:14 +08:00
|
|
|
#include "widgets/gimpactiongroup.h"
|
2015-02-17 20:33:10 +08:00
|
|
|
#include "widgets/gimpclipboard.h"
|
2004-09-09 17:47:33 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2015-09-01 02:57:37 +08:00
|
|
|
#include "widgets/gimpexportdialog.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"
|
2015-09-01 02:57:37 +08:00
|
|
|
#include "widgets/gimpopendialog.h"
|
|
|
|
#include "widgets/gimpsavedialog.h"
|
2014-05-02 09:01:23 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.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
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
2009-05-02 21:58:32 +08:00
|
|
|
#include "dialogs/file-save-dialog.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
|
|
|
/* local function prototypes */
|
|
|
|
|
2013-08-24 02:35:24 +08:00
|
|
|
static void file_open_dialog_show (Gimp *gimp,
|
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
|
|
|
GimpImage *image,
|
2014-07-07 06:46:25 +08:00
|
|
|
GFile *file,
|
2013-08-24 02:35:24 +08:00
|
|
|
gboolean open_as_layers);
|
|
|
|
static GtkWidget * file_save_dialog_show (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
|
|
|
gboolean save_a_copy,
|
|
|
|
gboolean close_after_saving,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static GtkWidget * file_export_dialog_show (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
2021-01-30 17:44:36 +08:00
|
|
|
GtkWidget *parent,
|
|
|
|
GimpDisplay *display);
|
2013-08-24 02:35:24 +08:00
|
|
|
static void file_save_dialog_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data);
|
|
|
|
static void file_export_dialog_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data);
|
|
|
|
static void file_new_template_callback (GtkWidget *widget,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer data);
|
|
|
|
static void file_revert_confirm_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpDisplay *display);
|
2009-04-26 23:22:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2007-01-16 03:48:36 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_open_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2008-07-30 22:53:09 +08:00
|
|
|
Gimp *gimp;
|
2005-01-14 01:41:48 +08:00
|
|
|
GtkWidget *widget;
|
2008-10-05 23:21:02 +08:00
|
|
|
GimpImage *image;
|
2008-07-30 22:53:09 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
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);
|
|
|
|
|
2008-10-05 23:21:02 +08:00
|
|
|
file_open_dialog_show (gimp, widget,
|
|
|
|
_("Open Image"),
|
|
|
|
image, NULL, FALSE);
|
2004-09-21 20:08:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_open_as_layers_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-09-21 20:08:30 +08:00
|
|
|
{
|
2008-07-30 22:53:09 +08:00
|
|
|
Gimp *gimp;
|
2004-09-21 20:08:30 +08:00
|
|
|
GtkWidget *widget;
|
2008-10-05 23:21:02 +08:00
|
|
|
GimpDisplay *display;
|
|
|
|
GimpImage *image = NULL;
|
2008-07-30 22:53:09 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2004-09-21 20:08:30 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2008-10-05 23:21:02 +08:00
|
|
|
display = action_data_get_display (data);
|
|
|
|
|
|
|
|
if (display)
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (display);
|
2005-02-25 01:18:11 +08:00
|
|
|
|
2008-10-05 23:21:02 +08:00
|
|
|
file_open_dialog_show (gimp, widget,
|
|
|
|
_("Open Image as Layers"),
|
|
|
|
image, NULL, TRUE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2004-05-31 22:40:10 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_open_location_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-05-31 22:40:10 +08:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (widget),
|
2010-05-16 18:19:18 +08:00
|
|
|
NULL /*ui_manager*/,
|
2018-05-03 06:55:44 +08:00
|
|
|
widget,
|
2004-09-09 17:47:33 +08:00
|
|
|
"gimp-file-open-location-dialog", -1, TRUE);
|
2004-05-31 22:40:10 +08:00
|
|
|
}
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_open_recent_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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;
|
2019-07-04 07:11:48 +08:00
|
|
|
gint index;
|
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
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
index = g_variant_get_int32 (value);
|
|
|
|
|
2008-11-21 06:45:19 +08:00
|
|
|
num_entries = gimp_container_get_n_children (gimp->documents);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
if (index >= num_entries)
|
2001-06-30 03:25:03 +08:00
|
|
|
return;
|
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
imagefile = (GimpImagefile *)
|
2019-07-04 07:11:48 +08:00
|
|
|
gimp_container_get_child_by_index (gimp->documents, index);
|
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
|
|
|
{
|
2014-07-07 06:46:25 +08:00
|
|
|
GFile *file;
|
2008-03-25 17:33:28 +08:00
|
|
|
GimpDisplay *display;
|
2014-05-03 02:20:46 +08:00
|
|
|
GtkWidget *widget;
|
2008-03-25 17:33:28 +08:00
|
|
|
GimpProgress *progress;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2003-03-05 19:25:59 +08:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
GError *error = NULL;
|
2008-03-25 17:33:28 +08:00
|
|
|
return_if_no_display (display, data);
|
2014-05-03 02:20:46 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2008-03-25 17:33:28 +08:00
|
|
|
|
2008-10-21 15:51:08 +08:00
|
|
|
g_object_ref (display);
|
|
|
|
g_object_ref (imagefile);
|
|
|
|
|
2014-07-07 06:46:25 +08:00
|
|
|
file = gimp_imagefile_get_file (imagefile);
|
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
progress = gimp_display_get_image (display) ?
|
|
|
|
NULL : GIMP_PROGRESS (display);
|
2003-03-05 19:25:59 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = file_open_with_display (gimp, action_data_get_context (data),
|
2008-03-25 17:33:28 +08:00
|
|
|
progress,
|
2014-07-07 06:46:25 +08:00
|
|
|
file, FALSE,
|
2018-04-29 23:27:47 +08:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)),
|
2006-07-12 14:10:52 +08:00
|
|
|
&status, &error);
|
2003-03-05 19:25:59 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! image && status != GIMP_PDB_CANCEL)
|
2003-03-05 19:25:59 +08:00
|
|
|
{
|
2008-03-25 17:33:28 +08:00
|
|
|
gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
|
2006-10-09 16:17:22 +08:00
|
|
|
_("Opening '%s' failed:\n\n%s"),
|
2014-07-07 06:46:25 +08:00
|
|
|
gimp_file_get_utf8_name (file), error->message);
|
2003-03-05 19:25:59 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2008-10-21 15:51:08 +08:00
|
|
|
|
|
|
|
g_object_unref (imagefile);
|
|
|
|
g_object_unref (display);
|
2001-06-30 03:25:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_save_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2009-05-01 18:22:41 +08:00
|
|
|
Gimp *gimp;
|
2007-01-21 03:38:09 +08:00
|
|
|
GimpDisplay *display;
|
|
|
|
GimpImage *image;
|
2020-04-14 17:46:17 +08:00
|
|
|
GList *drawables;
|
2007-01-21 03:38:09 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GimpSaveMode save_mode;
|
2014-07-07 06:46:25 +08:00
|
|
|
GFile *file = NULL;
|
2007-01-21 03:38:09 +08:00
|
|
|
gboolean saved = FALSE;
|
2009-05-01 18:22:41 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2006-03-29 01:55:52 +08:00
|
|
|
return_if_no_display (display, data);
|
2007-01-21 03:38:09 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (display);
|
2005-02-14 02:05:43 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
save_mode = (GimpSaveMode) g_variant_get_int32 (value);
|
2007-01-21 03:38:09 +08:00
|
|
|
|
2020-04-14 17:46:17 +08:00
|
|
|
drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
if (! drawables)
|
|
|
|
{
|
|
|
|
g_list_free (drawables);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_list_free (drawables);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
file = gimp_image_get_file (image);
|
2014-07-07 06:46:25 +08:00
|
|
|
|
2007-01-21 03:38:09 +08:00
|
|
|
switch (save_mode)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2007-01-21 03:38:09 +08:00
|
|
|
case GIMP_SAVE_MODE_SAVE:
|
|
|
|
case GIMP_SAVE_MODE_SAVE_AND_CLOSE:
|
2008-08-15 15:38:32 +08:00
|
|
|
/* Only save if the image has been modified, or if it is new. */
|
2009-07-04 03:11:21 +08:00
|
|
|
if ((gimp_image_is_dirty (image) ||
|
2008-08-15 15:38:32 +08:00
|
|
|
! GIMP_GUI_CONFIG (image->gimp->config)->trust_dirty_flag) ||
|
2014-07-07 06:46:25 +08:00
|
|
|
file == NULL)
|
2004-07-01 00:01:05 +08:00
|
|
|
{
|
2023-02-14 05:57:09 +08:00
|
|
|
GimpPlugInProcedure *save_proc = gimp_image_get_save_proc (image);
|
|
|
|
gboolean valid_file = FALSE;
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2023-02-14 05:57:09 +08:00
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
gchar *uri = g_file_get_uri (file);
|
|
|
|
|
|
|
|
/* Non-valid URI (such as "Untitled.xcd" without a scheme) are
|
|
|
|
* considered non-native by GLib and will trigger remote file code
|
|
|
|
* path in file_save_dialog_save_image(), eventually failing with
|
|
|
|
* a weird error. When we encounter such non-valid URI, we just
|
|
|
|
* consider that the file was entered manually with a bogus name
|
|
|
|
* (possibly by some script or plug-in) and we fall through
|
|
|
|
* directly to showing the file dialog. The file name will still
|
|
|
|
* be useful as default file name.
|
|
|
|
*/
|
|
|
|
valid_file = g_uri_is_valid (uri, G_URI_FLAGS_NONE, NULL);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (valid_file && ! save_proc)
|
2008-08-15 15:38:32 +08:00
|
|
|
{
|
|
|
|
save_proc =
|
2016-01-04 03:05:27 +08:00
|
|
|
gimp_plug_in_manager_file_procedure_find (image->gimp->plug_in_manager,
|
|
|
|
GIMP_FILE_PROCEDURE_GROUP_SAVE,
|
|
|
|
file, NULL);
|
2008-08-15 15:38:32 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2023-02-14 05:57:09 +08:00
|
|
|
if (valid_file && save_proc)
|
2006-10-09 16:17:22 +08:00
|
|
|
{
|
2009-05-02 21:58:32 +08:00
|
|
|
saved = file_save_dialog_save_image (GIMP_PROGRESS (display),
|
2014-07-07 06:46:25 +08:00
|
|
|
gimp, image, file,
|
2009-05-02 21:58:32 +08:00
|
|
|
save_proc,
|
|
|
|
GIMP_RUN_WITH_LAST_VALS,
|
2014-10-04 08:26:36 +08:00
|
|
|
TRUE, FALSE, FALSE,
|
2017-03-24 01:03:27 +08:00
|
|
|
gimp_image_get_xcf_compression (image),
|
2015-09-01 21:17:44 +08:00
|
|
|
TRUE);
|
2006-10-09 16:17:22 +08:00
|
|
|
break;
|
2004-07-01 00:01:05 +08:00
|
|
|
}
|
2005-10-29 09:43:14 +08:00
|
|
|
|
2007-01-21 03:38:09 +08:00
|
|
|
/* fall thru */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (display), GIMP_MESSAGE_INFO,
|
|
|
|
_("No changes need to be saved"));
|
2007-01-21 03:38:09 +08:00
|
|
|
saved = TRUE;
|
|
|
|
break;
|
2004-07-01 00:01:05 +08:00
|
|
|
}
|
2006-12-12 04:33:01 +08:00
|
|
|
|
2007-01-21 03:38:09 +08:00
|
|
|
case GIMP_SAVE_MODE_SAVE_AS:
|
2009-10-07 01:20:44 +08:00
|
|
|
file_save_dialog_show (gimp, image, widget,
|
2007-01-21 03:38:09 +08:00
|
|
|
_("Save Image"), FALSE,
|
2012-11-25 22:13:35 +08:00
|
|
|
save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE, display);
|
2007-01-21 03:38:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_SAVE_MODE_SAVE_A_COPY:
|
2009-10-07 01:20:44 +08:00
|
|
|
file_save_dialog_show (gimp, image, widget,
|
2007-01-21 03:38:09 +08:00
|
|
|
_("Save a Copy of the Image"), TRUE,
|
2012-11-25 22:13:35 +08:00
|
|
|
FALSE, display);
|
2007-01-21 03:38:09 +08:00
|
|
|
break;
|
2009-04-24 00:59:40 +08:00
|
|
|
|
2013-11-13 10:15:45 +08:00
|
|
|
case GIMP_SAVE_MODE_EXPORT_AS:
|
2021-01-30 17:44:36 +08:00
|
|
|
file_export_dialog_show (gimp, image, widget, display);
|
2009-04-25 16:54:56 +08:00
|
|
|
break;
|
|
|
|
|
2013-11-13 10:15:45 +08:00
|
|
|
case GIMP_SAVE_MODE_EXPORT:
|
2011-07-01 05:44:50 +08:00
|
|
|
case GIMP_SAVE_MODE_OVERWRITE:
|
2009-04-26 23:44:10 +08:00
|
|
|
{
|
2014-07-07 06:46:25 +08:00
|
|
|
GFile *file = NULL;
|
2014-07-02 20:24:02 +08:00
|
|
|
GimpPlugInProcedure *export_proc = NULL;
|
|
|
|
gboolean overwrite = FALSE;
|
2009-04-26 23:44:10 +08:00
|
|
|
|
2013-11-13 10:15:45 +08:00
|
|
|
if (save_mode == GIMP_SAVE_MODE_EXPORT)
|
2011-07-01 05:44:50 +08:00
|
|
|
{
|
2014-07-08 05:56:56 +08:00
|
|
|
file = gimp_image_get_exported_file (image);
|
2014-07-02 20:24:02 +08:00
|
|
|
export_proc = gimp_image_get_export_proc (image);
|
2011-07-01 05:44:50 +08:00
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
if (! file)
|
2011-07-01 05:44:50 +08:00
|
|
|
{
|
2013-11-13 10:15:45 +08:00
|
|
|
/* Behave as if Export As... was invoked */
|
2021-01-30 17:44:36 +08:00
|
|
|
file_export_dialog_show (gimp, image, widget, display);
|
2011-07-01 05:44:50 +08:00
|
|
|
break;
|
|
|
|
}
|
2012-05-19 00:48:51 +08:00
|
|
|
|
|
|
|
overwrite = FALSE;
|
2011-07-01 05:44:50 +08:00
|
|
|
}
|
|
|
|
else if (save_mode == GIMP_SAVE_MODE_OVERWRITE)
|
|
|
|
{
|
2014-07-08 05:56:56 +08:00
|
|
|
file = gimp_image_get_imported_file (image);
|
2012-05-19 00:48:51 +08:00
|
|
|
|
|
|
|
overwrite = TRUE;
|
2011-07-01 05:44:50 +08:00
|
|
|
}
|
2009-07-05 15:09:12 +08:00
|
|
|
|
2014-07-07 06:46:25 +08:00
|
|
|
if (file && ! export_proc)
|
2009-04-26 23:44:10 +08:00
|
|
|
{
|
|
|
|
export_proc =
|
2016-01-04 03:05:27 +08:00
|
|
|
gimp_plug_in_manager_file_procedure_find (image->gimp->plug_in_manager,
|
|
|
|
GIMP_FILE_PROCEDURE_GROUP_EXPORT,
|
|
|
|
file, NULL);
|
2009-04-26 23:44:10 +08:00
|
|
|
}
|
|
|
|
|
2014-07-07 06:46:25 +08:00
|
|
|
if (file && export_proc)
|
2009-04-26 23:44:10 +08:00
|
|
|
{
|
|
|
|
saved = file_save_dialog_save_image (GIMP_PROGRESS (display),
|
2014-07-07 06:46:25 +08:00
|
|
|
gimp, image, file,
|
2009-04-26 23:44:10 +08:00
|
|
|
export_proc,
|
|
|
|
GIMP_RUN_WITH_LAST_VALS,
|
2012-05-19 00:48:51 +08:00
|
|
|
FALSE,
|
|
|
|
overwrite, ! overwrite,
|
2014-10-04 08:26:36 +08:00
|
|
|
FALSE, TRUE);
|
2009-04-26 23:44:10 +08:00
|
|
|
}
|
|
|
|
}
|
2009-04-24 00:59:40 +08:00
|
|
|
break;
|
2007-01-21 03:38:09 +08:00
|
|
|
}
|
2006-12-12 04:33:01 +08:00
|
|
|
|
2007-01-21 03:38:09 +08:00
|
|
|
if (save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE &&
|
2009-07-04 03:11:21 +08:00
|
|
|
saved &&
|
2009-10-07 01:20:44 +08:00
|
|
|
! gimp_image_is_dirty (image))
|
2007-01-21 03:38:09 +08:00
|
|
|
{
|
2008-04-06 04:32:24 +08:00
|
|
|
gimp_display_close (display);
|
2007-01-21 03:38:09 +08:00
|
|
|
}
|
2006-12-12 04:33:01 +08:00
|
|
|
}
|
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_create_template_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2003-04-04 01:50:56 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display;
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image;
|
2004-10-19 22:08:44 +08:00
|
|
|
GtkWidget *dialog;
|
2006-03-29 01:55:52 +08:00
|
|
|
return_if_no_display (display, data);
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
dialog = gimp_query_string_box (_("Create New Template"),
|
2009-10-06 01:58:03 +08:00
|
|
|
GTK_WIDGET (gimp_display_get_shell (display)),
|
2004-10-19 22:08:44 +08:00
|
|
|
gimp_standard_help_func,
|
2009-04-26 14:24:02 +08:00
|
|
|
GIMP_HELP_FILE_CREATE_TEMPLATE,
|
2004-10-19 22:08:44 +08:00
|
|
|
_("Enter a name for this template"),
|
|
|
|
NULL,
|
2009-10-07 01:20:44 +08:00
|
|
|
G_OBJECT (image), "disconnect",
|
2019-08-08 04:48:06 +08:00
|
|
|
file_new_template_callback,
|
|
|
|
image, NULL);
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_show (dialog);
|
2003-04-04 01:50:56 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_revert_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display;
|
2006-08-09 05:06:36 +08:00
|
|
|
GimpImage *image;
|
2004-10-13 23:27:00 +08:00
|
|
|
GtkWidget *dialog;
|
2014-07-08 05:56:56 +08:00
|
|
|
GFile *file;
|
2006-03-29 01:55:52 +08:00
|
|
|
return_if_no_display (display, data);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (display);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
file = gimp_image_get_file (image);
|
2006-08-09 05:06:36 +08:00
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
if (! file)
|
|
|
|
file = gimp_image_get_imported_file (image);
|
2009-04-26 19:00:25 +08:00
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
if (! file)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (display), GIMP_MESSAGE_ERROR,
|
|
|
|
_("Revert failed. "
|
|
|
|
"No file name associated with this image."));
|
2016-09-12 06:03:22 +08:00
|
|
|
return;
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
2016-09-12 06:03:22 +08:00
|
|
|
|
|
|
|
#define REVERT_DIALOG_KEY "gimp-revert-confirm-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), REVERT_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2004-10-13 23:27:00 +08:00
|
|
|
dialog =
|
2017-03-05 23:01:59 +08:00
|
|
|
gimp_message_dialog_new (_("Revert Image"), GIMP_ICON_DOCUMENT_REVERT,
|
2009-10-06 01:58:03 +08:00
|
|
|
GTK_WIDGET (gimp_display_get_shell (display)),
|
|
|
|
0,
|
2004-10-13 23:27:00 +08:00
|
|
|
gimp_standard_help_func, GIMP_HELP_FILE_REVERT,
|
2001-08-30 01:48:28 +08:00
|
|
|
|
2017-02-12 23:06:34 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Revert"), 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
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-09-28 02:51:44 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-10 19:00:46 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
g_signal_connect_object (display, "disconnect",
|
2004-10-13 23:27:00 +08:00
|
|
|
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),
|
2006-03-29 01:55:52 +08:00
|
|
|
display);
|
2004-07-01 00:01:05 +08:00
|
|
|
|
2004-10-13 23:27:00 +08:00
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("Revert '%s' to '%s'?"),
|
2012-07-18 04:52:49 +08:00
|
|
|
gimp_image_get_display_name (image),
|
2014-07-08 05:56:56 +08:00
|
|
|
gimp_file_get_utf8_name (file));
|
2004-10-13 23:27:00 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), REVERT_DIALOG_KEY, dialog);
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
2016-09-12 06:03:22 +08:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2005-09-25 03:30:08 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_close_all_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2005-09-25 03:30:08 +08:00
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
return_if_no_gimp (gimp, data);
|
|
|
|
|
|
|
|
if (! gimp_displays_dirty (gimp))
|
|
|
|
{
|
2008-04-06 04:32:24 +08:00
|
|
|
gimp_displays_close (gimp);
|
2005-09-25 03:30:08 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (widget),
|
2018-05-03 06:55:44 +08:00
|
|
|
widget,
|
2005-09-25 03:30:08 +08:00
|
|
|
"gimp-close-all-dialog", -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-17 20:33:10 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_copy_location_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2015-02-17 20:33:10 +08:00
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
GimpDisplay *display;
|
|
|
|
GimpImage *image;
|
|
|
|
GFile *file;
|
|
|
|
return_if_no_gimp (gimp, data);
|
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
|
|
file = gimp_image_get_any_file (image);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
gchar *uri = g_file_get_uri (file);
|
|
|
|
|
|
|
|
gimp_clipboard_set_text (gimp, uri);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-17 01:40:26 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_show_in_file_manager_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2015-02-17 01:40:26 +08:00
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
GimpDisplay *display;
|
|
|
|
GimpImage *image;
|
|
|
|
GFile *file;
|
|
|
|
return_if_no_gimp (gimp, data);
|
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
|
|
file = gimp_image_get_any_file (image);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (! gimp_file_show_in_file_manager (file, &error))
|
|
|
|
{
|
|
|
|
gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
|
|
|
|
_("Can't show file in file manager: %s"),
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
file_quit_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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
|
2014-07-07 06:46:25 +08:00
|
|
|
file_file_open_dialog (Gimp *gimp,
|
|
|
|
GFile *file,
|
|
|
|
GtkWidget *parent)
|
2004-09-14 03:33:07 +08:00
|
|
|
{
|
2008-10-05 23:21:02 +08:00
|
|
|
file_open_dialog_show (gimp, parent,
|
|
|
|
_("Open Image"),
|
2014-07-07 06:46:25 +08:00
|
|
|
NULL, file, FALSE);
|
2004-09-14 03:33:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2008-10-05 23:21:02 +08:00
|
|
|
file_open_dialog_show (Gimp *gimp,
|
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image,
|
2014-07-07 06:46:25 +08:00
|
|
|
GFile *file,
|
2006-11-05 19:35:57 +08:00
|
|
|
gboolean open_as_layers)
|
2003-01-11 01:55:53 +08:00
|
|
|
{
|
2004-09-14 00:01:52 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (parent),
|
2010-05-16 18:19:18 +08:00
|
|
|
NULL /*ui_manager*/,
|
2018-05-03 06:55:44 +08:00
|
|
|
parent,
|
2004-09-14 00:01:52 +08:00
|
|
|
"gimp-file-open-dialog", -1, FALSE);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
2014-07-07 06:46:25 +08:00
|
|
|
if (! file && image)
|
2014-07-08 05:56:56 +08:00
|
|
|
file = gimp_image_get_file (image);
|
2008-10-05 23:21:02 +08:00
|
|
|
|
2014-07-07 06:46:25 +08:00
|
|
|
if (! file)
|
2014-07-08 05:56:56 +08:00
|
|
|
file = g_object_get_data (G_OBJECT (gimp),
|
|
|
|
GIMP_FILE_OPEN_LAST_FILE_KEY);
|
2008-07-30 22:53:09 +08:00
|
|
|
|
2014-07-07 06:46:25 +08:00
|
|
|
if (file)
|
2016-01-06 12:12:03 +08:00
|
|
|
{
|
|
|
|
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), file, NULL);
|
|
|
|
}
|
2012-12-15 07:34:15 +08:00
|
|
|
else if (gimp->default_folder)
|
2016-01-06 12:12:03 +08:00
|
|
|
{
|
|
|
|
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog),
|
|
|
|
gimp->default_folder, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
2004-09-14 00:01:52 +08:00
|
|
|
|
2015-09-01 02:57:37 +08:00
|
|
|
gimp_open_dialog_set_image (GIMP_OPEN_DIALOG (dialog),
|
|
|
|
image, open_as_layers);
|
2004-09-21 20:08:30 +08:00
|
|
|
|
2012-11-14 23:43:06 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
|
|
|
GTK_WINDOW (gtk_widget_get_toplevel (parent)));
|
2005-05-19 05:01:51 +08:00
|
|
|
|
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
|
|
|
|
2013-08-24 02:35:24 +08:00
|
|
|
static GtkWidget *
|
2009-05-01 18:22:41 +08:00
|
|
|
file_save_dialog_show (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
2004-09-14 03:33:07 +08:00
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
2007-01-21 03:38:09 +08:00
|
|
|
gboolean save_a_copy,
|
2012-11-25 22:13:35 +08:00
|
|
|
gboolean close_after_saving,
|
|
|
|
GimpDisplay *display)
|
2004-09-14 03:33:07 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
#define SAVE_DIALOG_KEY "gimp-file-save-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), SAVE_DIALOG_KEY);
|
2004-09-14 03:33:07 +08:00
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
2010-03-01 06:20:57 +08:00
|
|
|
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (parent),
|
2010-05-16 18:19:18 +08:00
|
|
|
NULL /*ui_manager*/,
|
2018-05-03 06:55:44 +08:00
|
|
|
parent,
|
2004-09-14 03:33:07 +08:00
|
|
|
"gimp-file-save-dialog",
|
|
|
|
-1, FALSE);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
2005-05-19 05:01:51 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
2012-11-14 23:42:05 +08:00
|
|
|
GTK_WINDOW (gtk_widget_get_toplevel (parent)));
|
2005-05-19 05:01:51 +08:00
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), SAVE_DIALOG_KEY, dialog);
|
|
|
|
g_signal_connect_object (image, "disconnect",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
|
|
|
|
2013-08-24 02:35:24 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (file_save_dialog_response),
|
|
|
|
image);
|
2004-09-14 03:33:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
|
|
|
|
2015-09-01 02:57:37 +08:00
|
|
|
gimp_save_dialog_set_image (GIMP_SAVE_DIALOG (dialog),
|
2016-01-06 21:10:36 +08:00
|
|
|
image, save_a_copy,
|
2015-09-01 02:57:37 +08:00
|
|
|
close_after_saving, GIMP_OBJECT (display));
|
2004-09-14 03:33:07 +08:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
2013-08-24 02:35:24 +08:00
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_save_dialog_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (response_id == FILE_SAVE_RESPONSE_OTHER_DIALOG)
|
|
|
|
{
|
|
|
|
GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
|
|
|
|
GtkWindow *parent;
|
|
|
|
GtkWidget *other;
|
2014-07-08 07:19:39 +08:00
|
|
|
GFile *file;
|
2017-10-11 18:34:16 +08:00
|
|
|
gchar *folder;
|
2014-07-08 07:19:39 +08:00
|
|
|
gchar *basename;
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2014-07-08 07:19:39 +08:00
|
|
|
parent = gtk_window_get_transient_for (GTK_WINDOW (dialog));
|
|
|
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
2017-10-11 18:34:16 +08:00
|
|
|
folder = g_path_get_dirname (gimp_file_get_utf8_name (file));
|
2014-07-08 07:19:39 +08:00
|
|
|
basename = g_path_get_basename (gimp_file_get_utf8_name (file));
|
|
|
|
g_object_unref (file);
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2015-09-01 02:57:37 +08:00
|
|
|
other = file_export_dialog_show (GIMP_FILE_DIALOG (file_dialog)->image->gimp,
|
|
|
|
GIMP_FILE_DIALOG (file_dialog)->image,
|
2021-01-30 17:44:36 +08:00
|
|
|
GTK_WIDGET (parent), NULL);
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2017-10-11 18:34:16 +08:00
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (other), folder);
|
2014-07-08 07:19:39 +08:00
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), basename);
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2017-10-11 18:34:16 +08:00
|
|
|
g_free (folder);
|
2014-07-08 07:19:39 +08:00
|
|
|
g_free (basename);
|
2013-08-24 02:35:24 +08:00
|
|
|
}
|
2004-09-14 03:33:07 +08:00
|
|
|
}
|
|
|
|
|
2013-08-24 02:35:24 +08:00
|
|
|
static GtkWidget *
|
2021-01-30 17:44:36 +08:00
|
|
|
file_export_dialog_show (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
|
|
|
GtkWidget *parent,
|
|
|
|
GimpDisplay *display)
|
2009-04-25 16:54:56 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
#define EXPORT_DIALOG_KEY "gimp-file-export-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY);
|
2009-04-25 16:54:56 +08:00
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
2010-03-01 06:20:57 +08:00
|
|
|
dialog = gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (parent),
|
2010-05-16 18:19:18 +08:00
|
|
|
NULL /*ui_manager*/,
|
2018-05-03 06:55:44 +08:00
|
|
|
parent,
|
2009-04-25 16:54:56 +08:00
|
|
|
"gimp-file-export-dialog",
|
|
|
|
-1, FALSE);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
2012-11-14 23:42:05 +08:00
|
|
|
GTK_WINDOW (gtk_widget_get_toplevel (parent)));
|
2009-04-25 16:54:56 +08:00
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY, dialog);
|
|
|
|
g_signal_connect_object (image, "disconnect",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
dialog, G_CONNECT_SWAPPED);
|
|
|
|
|
2013-08-24 02:35:24 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (file_export_dialog_response),
|
|
|
|
image);
|
2009-04-25 16:54:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
2021-01-30 17:44:36 +08:00
|
|
|
gimp_export_dialog_set_image (GIMP_EXPORT_DIALOG (dialog), image,
|
|
|
|
GIMP_OBJECT (display));
|
2009-04-25 16:54:56 +08:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
2013-08-24 02:35:24 +08:00
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_export_dialog_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (response_id == FILE_SAVE_RESPONSE_OTHER_DIALOG)
|
|
|
|
{
|
|
|
|
GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
|
|
|
|
GtkWindow *parent;
|
|
|
|
GtkWidget *other;
|
2014-07-08 07:19:39 +08:00
|
|
|
GFile *file;
|
2017-10-11 18:34:16 +08:00
|
|
|
gchar *folder;
|
2014-07-08 07:19:39 +08:00
|
|
|
gchar *basename;
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2014-07-08 07:19:39 +08:00
|
|
|
parent = gtk_window_get_transient_for (GTK_WINDOW (dialog));
|
|
|
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
2017-10-11 18:34:16 +08:00
|
|
|
folder = g_path_get_dirname (gimp_file_get_utf8_name (file));
|
2014-07-08 07:19:39 +08:00
|
|
|
basename = g_path_get_basename (gimp_file_get_utf8_name (file));
|
|
|
|
g_object_unref (file);
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2015-09-01 02:57:37 +08:00
|
|
|
other = file_save_dialog_show (GIMP_FILE_DIALOG (file_dialog)->image->gimp,
|
|
|
|
GIMP_FILE_DIALOG (file_dialog)->image,
|
2013-08-24 02:35:24 +08:00
|
|
|
GTK_WIDGET (parent),
|
|
|
|
_("Save Image"),
|
|
|
|
FALSE, FALSE, NULL);
|
|
|
|
|
2017-10-11 18:34:16 +08:00
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (other), folder);
|
2014-07-08 07:19:39 +08:00
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), basename);
|
2013-08-24 02:35:24 +08:00
|
|
|
|
2017-10-11 18:34:16 +08:00
|
|
|
g_free (folder);
|
2014-07-08 07:19:39 +08:00
|
|
|
g_free (basename);
|
2013-08-24 02:35:24 +08:00
|
|
|
}
|
2009-04-25 16:54: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;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = (GimpImage *) data;
|
2003-04-04 01:50:56 +08:00
|
|
|
|
|
|
|
if (! (name && strlen (name)))
|
|
|
|
name = _("(Unnamed Template)");
|
|
|
|
|
|
|
|
template = gimp_template_new (name);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_template_set_from_image (template, image);
|
|
|
|
gimp_container_add (image->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,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2001-07-10 01:58:56 +08:00
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *old_image = gimp_display_get_image (display);
|
2004-10-13 23:27:00 +08:00
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
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
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
Gimp *gimp = old_image->gimp;
|
|
|
|
GimpImage *new_image;
|
2014-07-07 06:46:25 +08:00
|
|
|
GFile *file;
|
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
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
file = gimp_image_get_file (old_image);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
if (! file)
|
|
|
|
file = gimp_image_get_imported_file (old_image);
|
2014-07-07 06:46:25 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
new_image = file_open_image (gimp, gimp_get_user_context (gimp),
|
2006-07-12 14:10:52 +08:00
|
|
|
GIMP_PROGRESS (display),
|
2024-04-26 07:07:59 +08:00
|
|
|
file, 0, 0, FALSE, NULL,
|
2006-07-12 14:10:52 +08:00
|
|
|
GIMP_RUN_INTERACTIVE,
|
|
|
|
&status, NULL, &error);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (new_image)
|
2004-07-01 00:01:05 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_displays_reconnect (gimp, old_image, new_image);
|
|
|
|
gimp_image_flush (new_image);
|
2003-05-18 00:34:30 +08:00
|
|
|
|
|
|
|
/* the displays own the image now */
|
2006-03-29 01:08:36 +08:00
|
|
|
g_object_unref (new_image);
|
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
|
|
|
{
|
2006-10-09 16:17:22 +08:00
|
|
|
gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
|
2006-08-09 05:06:36 +08:00
|
|
|
_("Reverting to '%s' failed:\n\n%s"),
|
2014-07-07 06:46:25 +08:00
|
|
|
gimp_file_get_utf8_name (file), error->message);
|
2003-03-05 19:25:59 +08:00
|
|
|
g_clear_error (&error);
|
2004-07-01 00:01:05 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
}
|
|
|
|
}
|