gimp/app/dialogs/file-save-dialog.c

861 lines
28 KiB
C
Raw Normal View History

/* GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
configure.in added new directory app/dialogs and link libappdialogs.c into 2004-09-13 Michael Natterer <mitch@gimp.org> * configure.in * app/Makefile.am: added new directory app/dialogs and link libappdialogs.c into the gimp binary. * app/gui/Makefile.am * app/gui/gui-types.h * app/gui/gui-vtable.c * app/gui/gui.c * app/gui/about-dialog.[ch] * app/gui/authors.h * app/gui/color-notebook.[ch] * app/gui/convert-dialog.[ch] * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.[ch] * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-open-location-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/grid-dialog.[ch] * app/gui/info-dialog.[ch] * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/offset-dialog.[ch] * app/gui/palette-import-dialog.[ch] * app/gui/preferences-dialog.[ch] * app/gui/quit-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/resolution-calibrate-dialog.[ch] * app/gui/stroke-dialog.[ch] * app/gui/tips-dialog.[ch] * app/gui/tips-parser.[ch] * app/gui/user-install-dialog.[ch]: removed these files... * app/dialogs/Makefile.am * app/dialogs/dialogs-types.h * app/dialogs/*.[ch]: ...and added them here. Changed some filenames like module-browser -> module-dialog. * app/app_procs.c * app/actions/actions-types.h * app/actions/actions.c * app/actions/dialogs-actions.c * app/actions/dialogs-commands.c * app/actions/dockable-commands.c * app/actions/drawable-commands.c * app/actions/edit-commands.c * app/actions/file-commands.c * app/actions/gradient-editor-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/palettes-commands.c * app/actions/select-commands.c * app/actions/templates-commands.c * app/actions/templates-commands.h * app/actions/vectors-commands.c * app/actions/view-commands.c * app/display/gimpdisplayshell-cursor.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell.[ch] * app/tools/gimpcroptool.c * app/tools/gimpperspectivetool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptransformtool.[ch] * app/tools/gimpvectortool.c * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcolorpanel.c * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimppaletteeditor.[ch] * app/widgets/gimptoolbox-color-area.c * menus/toolbox-menu.xml.in * tools/authorsgen/authorsgen.pl: changed accordingly.
2004-09-13 23:15:23 +08:00
#include "dialogs-types.h"
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 19:47:11 +08:00
#include "core/gimp.h"
#include "core/gimpimage.h"
Redid the whole internal progress stuff: don't pass around 2004-08-10 Michael Natterer <mitch@gimp.org> Redid the whole internal progress stuff: don't pass around progress_callback and progress_data; instead, provide a pointer to a GimpProgressInterface which can be implemented by a variety of backends. Addresses (but not yet fixes) bugs #6010, #97266 and #135185. * app/display/Makefile.am * app/display/gimpprogress.[ch]: removed the old progress hack. * app/core/Makefile.am * app/core/core-types.h * app/core/gimpprogress.[ch]: implement GimpProgressInterface. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressdialog.[ch]: the standalone progress dialog as widget implementing GimpProgressInterface. * app/display/gimpdisplay.c * app/display/gimpstatusbar.[ch] * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpthumbbox.[ch]: added GimpProgressInterface implementation to these classes. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: replaced the old progress vtable entries by two new to create and destroy a GimpProgressDialog in case no other progress is available. * app/pdb/procedural_db.[ch] * app/plug-in/plug-in-run.[ch] * tools/pdbgen/app.pl: pass a GimpProgress to all PDB wrappers and all plug-ins. * app/plug-in/plug-in.[ch] * app/plug-in/plug-ins.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c: handle the case there the plug-in was crated with a progress as well as the case where it wasn't. * app/app_procs.c * app/batch.c * app/xcf/xcf.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/widgets/gimphelp.c * app/widgets/gimpbrushselect.c * app/widgets/gimpfontselect.c * app/widgets/gimpgradientselect.c * app/widgets/gimppaletteselect.c * app/widgets/gimppatternselect.c: changed accordingly. * app/core/gimpimagefile.[ch] * app/display/gimpdisplayshell-dnd.c * app/gui/file-open-dialog.c * app/gui/file-open-location-dialog.c * app/gui/file-save-dialog.c * app/widgets/gimplayertreeview.c * app/widgets/gimptoolbox-dnd.c: pass a GimpProgress to all file related functions. Embed the progress in the file dialog where possible. * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-convert.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage-scale.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/core/gimplayer.c * app/core/gimpselection.c * app/vectors/gimpvectors.c: replaced callback/data by GimpProgress. * app/tools/gimpblendtool.c * app/tools/gimptransformtool.c * app/gui/convert-dialog.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/plug-in-commands.c * app/actions/vectors-commands.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb: changed callers accordingly. * app/pdb/*_cmds.c: regenerated.
2004-08-11 02:47:21 +08:00
#include "core/gimpprogress.h"
#include "plug-in/gimppluginmanager-file.h"
#include "plug-in/gimppluginprocedure.h"
app/plug-in/Makefile.am app/plug-in/plug-in-types.h new object which keeps 2006-04-29 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/gimppluginmanager.[ch]: new object which keeps all plug-in related stuff that was kept in the Gimp instance. Has "menu-branch-added" and "last-plug-in-changed" signals. * app/plug-in/plug-ins.[ch]: removed, all its functions are in GimpPlugInManager now. * app/core/gimpmarshal.list: new marshaller for the new object. * app/core/gimp.[ch]: removed all plug-in related stuff and keep a GimpPlugInManager around. * app/plug-in/plug-in-data.[ch] * app/plug-in/plug-in-file.[ch] * app/plug-in/plug-in-help-domain.[ch] * app/plug-in/plug-in-locale-domain.[ch] * app/plug-in/plug-in-menu-branch.[ch] * app/plug-in/plug-ins-query.[ch]: removed... * app/plug-in/gimppluginmanager-data.[ch] * app/plug-in/gimppluginmanager-file.[ch] * app/plug-in/gimppluginmanager-help-domain.[ch] * app/plug-in/gimppluginmanager-locale-domain.[ch] * app/plug-in/gimppluginmanager-menu-branch.[ch] * app/plug-in/gimppluginmanager-query.[ch]: ...and added as methods of GimpPlugInManager. * app/plug-in/plug-in-debug.[ch] * app/plug-in/plug-in-shm.[ch]: removed... * app/plug-in/gimpplugindebug.[ch] * app/plug-in/gimppluginshm.[ch]: ...and added as properly namespeced structs with constructors and destructors. * app/core/Makefile.am * app/core/gimpenvirontable.[ch] * app/core/gimpinterpreterdb.[ch]: removed... * app/plug-in/gimpenvirontable.[ch] * app/plug-in/gimpinterpreterdb.[ch]: ...and added here unchanged. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: remove gimp_menus_create_branch() and all related stuff. * app/actions/plug-in-actions.[ch]: connect to the plug-in-manager's "menu-path-added" signal and create menu branch actions accordingly. * app/plug-in/plug-in-context.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/plug-in/plug-in.[ch] * app/app_procs.c * app/actions/file-commands.c * app/actions/plug-in-commands.c * app/core/gimpimage.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/gui/gui.c * app/menus/plug-in-menus.c * app/pdb/gimppluginprocedure.c * app/pdb/gimptemporaryprocedure.c * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimphelp.c * app/widgets/gimpthumbbox.c * app/xcf/xcf.c * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/progress.pdb * tools/pdbgen/pdb/undo.pdb: follow above refactoring. * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/fileops_cmds.c * app/pdb/help_cmds.c * app/pdb/message_cmds.c * app/pdb/plug_in_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/progress_cmds.c * app/pdb/undo_cmds.c: regenerated.
2006-04-29 06:26:51 +08:00
generate app/file/Makefile 2001-10-25 Michael Natterer <mitch@gimp.org> * configure.in: generate app/file/Makefile * app/Makefile.am * app/file-open.[ch] * app/file-save.[ch] * app/file-utils.[ch]: removed... * app/file/Makefile.am * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch]: ...and added here. * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * tools/pdbgen/pdb/fileops.pdb: changed includes accordingly. * app/app_procs.[ch]: removed app_exit_finish() and app_exit_finish_done() from the public API, call gtk_main() here, pass "no_data" to gimp_new() and "restore_session" to gui_restore(). * app/main.c: removed global variable "double_speed", don't call gtk_main() in main.c. Added some missing log domains. * app/appenv.h: removed "double_speed". * app/core/gimp.[ch]: added "gboolean no_data" property which must be passed to gimp_new(). * app/display/gimpdisplay-foreach.[ch]: added gdisplays_set_busy() and gdisplays_unset_busy(). * app/gui/about-dialog.c: don't include "appenv.h", declare "double_speed" extern. * app/gui/brush-select.[ch] * app/gui/gradient-select.[ch] * app/gui/palette-select.[ch] * app/gui/pattern-select.[ch]: made the list of dialogs and the global selection dialogs private. Added functions which get a dialog by PDB callback_name. Pass a "Gimp" and the callback_name to the constructors. Don't include "app_procs.h" for "the_gimp" and "appenv.h" for "no_data" any more. Use the passed "Gimp" instead and look at gimp->no_data. * app/gui/toolbox.[ch]: pass a "Gimp" to the constructor. * app/gui/gui.[ch]: use the new gdisplays_[un]set_busy() functions, use the passed "Gimp" all over the place, don't include "appenv.h" and "app_procs.h". gui_really_quit_dialog() takes a "quit_func" callback now and calls it instead of calling app_exit_finish() (which is now private) directly. * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/palette-import-dialog.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb: changed accordingly. * app/pdb/brush_select_cmds.c * app/pdb/fileops_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c: regenerated. 2001-10-25 Michael Natterer <mitch@gimp.org> * POTFILES.in: app/file-*.c -> app/file/file-*.c
2001-10-25 21:30:01 +08:00
#include "file/file-save.h"
#include "file/gimp-file.h"
generate app/file/Makefile 2001-10-25 Michael Natterer <mitch@gimp.org> * configure.in: generate app/file/Makefile * app/Makefile.am * app/file-open.[ch] * app/file-save.[ch] * app/file-utils.[ch]: removed... * app/file/Makefile.am * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch]: ...and added here. * app/gui/file-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * tools/pdbgen/pdb/fileops.pdb: changed includes accordingly. * app/app_procs.[ch]: removed app_exit_finish() and app_exit_finish_done() from the public API, call gtk_main() here, pass "no_data" to gimp_new() and "restore_session" to gui_restore(). * app/main.c: removed global variable "double_speed", don't call gtk_main() in main.c. Added some missing log domains. * app/appenv.h: removed "double_speed". * app/core/gimp.[ch]: added "gboolean no_data" property which must be passed to gimp_new(). * app/display/gimpdisplay-foreach.[ch]: added gdisplays_set_busy() and gdisplays_unset_busy(). * app/gui/about-dialog.c: don't include "appenv.h", declare "double_speed" extern. * app/gui/brush-select.[ch] * app/gui/gradient-select.[ch] * app/gui/palette-select.[ch] * app/gui/pattern-select.[ch]: made the list of dialogs and the global selection dialogs private. Added functions which get a dialog by PDB callback_name. Pass a "Gimp" and the callback_name to the constructors. Don't include "app_procs.h" for "the_gimp" and "appenv.h" for "no_data" any more. Use the passed "Gimp" instead and look at gimp->no_data. * app/gui/toolbox.[ch]: pass a "Gimp" to the constructor. * app/gui/gui.[ch]: use the new gdisplays_[un]set_busy() functions, use the passed "Gimp" all over the place, don't include "appenv.h" and "app_procs.h". gui_really_quit_dialog() takes a "quit_func" callback now and calls it instead of calling app_exit_finish() (which is now private) directly. * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/palette-import-dialog.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb: changed accordingly. * app/pdb/brush_select_cmds.c * app/pdb/fileops_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c: regenerated. 2001-10-25 Michael Natterer <mitch@gimp.org> * POTFILES.in: app/file-*.c -> app/file/file-*.c
2001-10-25 21:30:01 +08:00
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpexportdialog.h"
app/widgets/Makefile.am new file defining the available help topics. Work 2003-08-21 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/gimphelp-ids.h: new file defining the available help topics. Work in progress and totally unusable for matching to the help system. Stay tuned... * app/gui/about-dialog.c * app/gui/brushes-menu.c * app/gui/buffers-menu.c * app/gui/channels-commands.[ch] * app/gui/channels-menu.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradients-commands.c * app/gui/gradients-menu.c * app/gui/image-menu.c * app/gui/layers-commands.[ch] * app/gui/layers-menu.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palettes-menu.c * app/gui/patterns-menu.c * app/gui/resize-dialog.c * app/gui/select-commands.c * app/gui/templates-menu.c * app/gui/tips-dialog.c * app/gui/toolbox-menu.c * app/gui/vectors-commands.[ch] * app/gui/vectors-menu.c: replaced literal HTML file paths by help IDs from gimphelp-ids.h. Renamed some menu callbacks to be consistent with similar ones. This is just an intermediate commit and not finished. While browsing all the menus, I noticed that our "x to selection" functions are not consistent at all. They should all offer the REPLACE,ADD,SUBTRACT,INTERSECT options: * app/core/gimpchannel.[ch]: added new function gimp_channel_new_from_alpha(). Removed gimp_channel_layer_alpha() and gimp_channel_layer_mask(). * app/core/gimpimage-mask.[ch]: added gimp_image_mask_select_alpha() and gimp_image_mask_select_component() which offer the full set of operation, feather and feather_radius parameters as the other selection functions. * app/core/gimpimage-mask-select.[ch]: removed gimp_image_mask_layer_alpha() and gimp_image_mask_layer_mask(). * app/gui/channels-commands.c (channels_channel_to_selection): use gimp_image_mask_select_component() instead of implementing it here. * app/gui/image-menu.c * app/gui/layers-commands.[ch]: offer the full choice of REPLACE,ADD,SUBTRACT,INTERSECT with "Alpha to Selection" and "Mask to Selection". * tools/pdbgen/pdb/selection.pdb: changed accordingly. * app/pdb/selection_cmds.c: regenerated.
2003-08-21 23:54:47 +08:00
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
#include "widgets/gimpsavedialog.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "file-save-dialog.h"
#include "gimp-log.h"
#include "gimp-intl.h"
typedef enum
{
CHECK_URI_FAIL,
CHECK_URI_OK,
CHECK_URI_SWITCH_DIALOGS
} CheckUriResult;
/* local function prototypes */
static GtkFileChooserConfirmation
file_save_dialog_confirm_overwrite (GtkWidget *dialog,
Gimp *gimp);
static void file_save_dialog_response (GtkWidget *dialog,
gint response_id,
Gimp *gimp);
static CheckUriResult file_save_dialog_check_file (GtkWidget *save_dialog,
Gimp *gimp,
GFile **ret_file,
gchar **ret_basename,
GimpPlugInProcedure **ret_save_proc);
static gboolean file_save_dialog_no_overwrite_confirmation (GimpFileDialog *dialog,
Gimp *gimp);
static GimpPlugInProcedure *
file_save_dialog_find_procedure (GimpFileDialog *dialog,
GFile *file);
static gboolean file_save_dialog_switch_dialogs (GimpFileDialog *file_dialog,
Gimp *gimp,
const gchar *basename);
static gboolean file_save_dialog_use_extension (GtkWidget *save_dialog,
GFile *file);
/* public functions */
GtkWidget *
file_save_dialog_new (Gimp *gimp,
gboolean export)
{
GtkWidget *dialog;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (! export)
{
dialog = gimp_save_dialog_new (gimp);
gimp_file_dialog_load_state (GIMP_FILE_DIALOG (dialog),
"gimp-file-save-dialog-state");
}
else
{
dialog = gimp_export_dialog_new (gimp);
gimp_file_dialog_load_state (GIMP_FILE_DIALOG (dialog),
"gimp-file-export-dialog-state");
}
g_signal_connect (dialog, "confirm-overwrite",
G_CALLBACK (file_save_dialog_confirm_overwrite),
gimp);
g_signal_connect (dialog, "response",
G_CALLBACK (file_save_dialog_response),
gimp);
return dialog;
}
/* private functions */
static GtkFileChooserConfirmation
file_save_dialog_confirm_overwrite (GtkWidget *dialog,
Gimp *gimp)
{
GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
if (file_save_dialog_no_overwrite_confirmation (file_dialog, gimp))
/* The URI will not be accepted whatever happens, so don't
* bother asking the user about overwriting files
*/
return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
else
return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
}
static void
file_save_dialog_response (GtkWidget *dialog,
gint response_id,
Gimp *gimp)
{
GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
GFile *file;
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
gchar *basename;
GimpPlugInProcedure *save_proc;
if (GIMP_IS_SAVE_DIALOG (dialog))
{
gimp_file_dialog_save_state (file_dialog, "gimp-file-save-dialog-state");
}
else /* GIMP_IS_EXPORT_DIALOG (dialog) */
{
gimp_file_dialog_save_state (file_dialog, "gimp-file-export-dialog-state");
}
if (response_id != GTK_RESPONSE_OK)
{
if (! file_dialog->busy && response_id != GTK_RESPONSE_HELP)
gtk_widget_destroy (dialog);
return;
}
g_object_ref (file_dialog);
g_object_ref (file_dialog->image);
switch (file_save_dialog_check_file (dialog, gimp,
&file, &basename, &save_proc))
{
case CHECK_URI_FAIL:
break;
case CHECK_URI_OK:
{
GimpImage *image = file_dialog->image;
GimpProgress *progress = GIMP_PROGRESS (dialog);
GimpDisplay *display_to_close = NULL;
gboolean xcf_compression = FALSE;
gboolean is_save_dialog = GIMP_IS_SAVE_DIALOG (dialog);
gboolean close_after_saving = FALSE;
gboolean save_a_copy = FALSE;
if (is_save_dialog)
{
close_after_saving = GIMP_SAVE_DIALOG (dialog)->close_after_saving;
display_to_close = GIMP_DISPLAY (GIMP_SAVE_DIALOG (dialog)->display_to_close);
save_a_copy = GIMP_SAVE_DIALOG (dialog)->save_a_copy;
}
gimp_file_dialog_set_sensitive (file_dialog, FALSE);
if (GIMP_IS_SAVE_DIALOG (dialog))
{
xcf_compression = GIMP_SAVE_DIALOG (dialog)->compression;
}
/* Hide the file dialog while exporting, avoid dialogs piling
* up, even more as some formats have preview features, so the
* file dialog is just blocking the view.
*/
if (GIMP_IS_EXPORT_DIALOG (dialog))
{
gtk_widget_hide (dialog);
progress = GIMP_PROGRESS (GIMP_EXPORT_DIALOG (dialog)->display);
}
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
if (file_save_dialog_save_image (progress,
gimp,
image,
file,
save_proc,
GIMP_RUN_INTERACTIVE,
is_save_dialog && ! save_a_copy,
FALSE,
GIMP_IS_EXPORT_DIALOG (dialog),
xcf_compression,
FALSE))
{
/* Save was successful, now store the URI in a couple of
* places that depend on it being the user that made a
* save. Lower-level URI management is handled in
* file_save()
*/
if (is_save_dialog)
{
if (save_a_copy)
gimp_image_set_save_a_copy_file (image, file);
g_object_set_data_full (G_OBJECT (image->gimp),
GIMP_FILE_SAVE_LAST_FILE_KEY,
g_object_ref (file),
(GDestroyNotify) g_object_unref);
}
else
{
g_object_set_data_full (G_OBJECT (image->gimp),
GIMP_FILE_EXPORT_LAST_FILE_KEY,
g_object_ref (file),
(GDestroyNotify) g_object_unref);
}
/* make sure the menus are updated with the keys we've just set */
gimp_image_flush (image);
/* Handle close-after-saving */
if (close_after_saving && display_to_close &&
! gimp_image_is_dirty (gimp_display_get_image (display_to_close)))
{
gimp_display_close (display_to_close);
}
if (dialog)
gtk_widget_destroy (dialog);
}
else
{
if (dialog)
{
GFile *parent_dir = g_file_get_parent (file);
/* XXX Not sure why, but after reshowing the file
* chooser dialog, the displayed name is correct, but
* the parent directory is the current working dir.
* Force it to be the expected folder.
*/
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog),
parent_dir, NULL);
gtk_widget_show (dialog);
g_object_unref (parent_dir);
}
}
g_object_unref (file);
g_free (basename);
if (dialog)
{
gimp_file_dialog_set_sensitive (file_dialog, TRUE);
g_signal_handlers_disconnect_by_func (dialog,
G_CALLBACK (gtk_widget_destroyed),
&dialog);
}
}
break;
case CHECK_URI_SWITCH_DIALOGS:
file_dialog->busy = TRUE; /* prevent destruction */
gtk_dialog_response (GTK_DIALOG (dialog), FILE_SAVE_RESPONSE_OTHER_DIALOG);
file_dialog->busy = FALSE;
gtk_widget_destroy (dialog);
break;
}
g_object_unref (file_dialog->image);
g_object_unref (file_dialog);
}
/* IMPORTANT: When changing this function, keep
* file_save_dialog_no_overwrite_confirmation() up to date. It is
* difficult to move logic to a common place due to how the dialog is
* implemented in GTK+ in combination with how we use it.
*/
static CheckUriResult
file_save_dialog_check_file (GtkWidget *dialog,
Gimp *gimp,
GFile **ret_file,
gchar **ret_basename,
GimpPlugInProcedure **ret_save_proc)
{
GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
GFile *file;
gchar *uri;
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
gchar *basename;
GFile *basename_file;
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
GimpPlugInProcedure *save_proc;
GimpPlugInProcedure *uri_proc;
GimpPlugInProcedure *basename_proc;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) 2001-07-24 Michael Natterer <mitch@gimp.org> Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) * configure.in: require glib/gtk+ >= 1.3.7, commented out the gtkxmhtml stuff. From now on, you will need glib, pango, atk and gtk+ HEAD from CVS to hack or use GIMP HEAD. Beware, it crashes randomly :) * app/core/Makefile.am * app/core/gimpmarshal.list: new file plus rules to generate gimpmarshal.[ch] from it. * app/core/* * app/tools/* * app/widgets/* * libgimpwidgets/*: started to use the glib object system. All core/ objects are still gtk objects however. All signals are created using g_signal_new(). There are many gtk+ artefacts left. Finally, we will _not_ use the gtk_signal_foo() wrappers and friends any more. * app/colormaps.c * app/devices.[ch] * app/disp_callbacks.c * app/errorconsole.c * app/file-save.[ch] * app/interface.c * app/module_db.c * app/nav_window.c * app/ops_buttons.c * app/scroll.c * app/user_install.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/brushes-commands.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.[ch] * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimp/gimpui.c * libgimpbase/gimpenv.c: tons and tons of changes like "const gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete and currently disables), lots of s/gtk_signal/g_signal/, removal/replacement of deprecated stuff, s/GtkSignalFunc/GCallback/ and lots of small changes and fixes while I was on it, zillions of warnings left... * modules/Makefile.am: disabled the water color selector temporarily (XInput issues). * plug-ins/Makefile.am * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl: simply excluded all plug-ins which did not build (including Script-Fu). They are trivial to fix.
2001-07-25 05:27:11 +08:00
if (! file)
return CHECK_URI_FAIL;
basename = g_path_get_basename (gimp_file_get_utf8_name (file));
basename_file = g_file_new_for_uri (basename);
save_proc = file_dialog->file_proc;
uri_proc = file_save_dialog_find_procedure (file_dialog, file);
basename_proc = file_save_dialog_find_procedure (file_dialog, basename_file);
g_object_unref (basename_file);
uri = g_file_get_uri (file);
GIMP_LOG (SAVE_DIALOG, "URI = %s", uri);
GIMP_LOG (SAVE_DIALOG, "basename = %s", basename);
GIMP_LOG (SAVE_DIALOG, "selected save_proc: %s",
save_proc ?
gimp_procedure_get_label (GIMP_PROCEDURE (save_proc)) : "NULL");
GIMP_LOG (SAVE_DIALOG, "URI save_proc: %s",
uri_proc ?
gimp_procedure_get_label (GIMP_PROCEDURE (uri_proc)) : "NULL");
GIMP_LOG (SAVE_DIALOG, "basename save_proc: %s",
basename_proc ?
gimp_procedure_get_label (GIMP_PROCEDURE (basename_proc)) : "NULL");
g_free (uri);
/* first check if the user entered an extension at all */
if (! basename_proc)
{
GIMP_LOG (SAVE_DIALOG, "basename has no valid extension");
if (! strchr (basename, '.'))
{
const gchar *ext = NULL;
GIMP_LOG (SAVE_DIALOG, "basename has no '.', trying to add extension");
if (! save_proc && GIMP_IS_SAVE_DIALOG (dialog))
{
ext = "xcf";
}
else if (save_proc && save_proc->extensions_list)
{
ext = save_proc->extensions_list->data;
}
if (ext)
{
gchar *ext_basename;
gchar *dirname;
gchar *filename;
gchar *utf8;
GIMP_LOG (SAVE_DIALOG, "appending .%s to basename", ext);
ext_basename = g_strconcat (basename, ".", ext, NULL);
g_free (basename);
basename = ext_basename;
dirname = g_path_get_dirname (gimp_file_get_utf8_name (file));
filename = g_build_filename (dirname, basename, NULL);
g_free (dirname);
utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
utf8);
g_free (utf8);
g_free (filename);
GIMP_LOG (SAVE_DIALOG,
"set basename to %s, rerunning response and bailing out",
basename);
/* call the response callback again, so the
* overwrite-confirm logic can check the changed uri
*/
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
goto fail;
}
else
{
GIMP_LOG (SAVE_DIALOG,
"save_proc has no extensions, continuing without");
/* there may be file formats with no extension at all, use
* the selected proc in this case.
*/
basename_proc = save_proc;
if (! uri_proc)
uri_proc = basename_proc;
}
if (! basename_proc)
{
GIMP_LOG (SAVE_DIALOG,
"unable to figure save_proc, bailing out");
if (file_save_dialog_switch_dialogs (file_dialog, gimp, basename))
{
goto switch_dialogs;
}
goto fail;
}
}
else if (save_proc && ! save_proc->extensions_list)
{
GIMP_LOG (SAVE_DIALOG,
"basename has '.', but save_proc has no extensions, "
"accepting random extension");
/* accept any random extension if the file format has
* no extensions at all
*/
basename_proc = save_proc;
if (! uri_proc)
uri_proc = basename_proc;
}
}
/* then check if the selected format matches the entered extension */
if (! save_proc)
{
GIMP_LOG (SAVE_DIALOG, "no save_proc was selected from the list");
if (! basename_proc)
{
GIMP_LOG (SAVE_DIALOG,
"basename has no useful extension, bailing out");
if (file_save_dialog_switch_dialogs (file_dialog, gimp, basename))
{
goto switch_dialogs;
}
goto fail;
}
GIMP_LOG (SAVE_DIALOG, "use URI's proc '%s' so indirect saving works",
gimp_procedure_get_label (GIMP_PROCEDURE (uri_proc)));
/* use the URI's proc if no save proc was selected */
save_proc = uri_proc;
}
else
{
GIMP_LOG (SAVE_DIALOG, "save_proc '%s' was selected from the list",
gimp_procedure_get_label (GIMP_PROCEDURE (save_proc)));
if (save_proc != basename_proc)
{
GIMP_LOG (SAVE_DIALOG, "however the basename's proc is '%s'",
gimp_procedure_get_label (GIMP_PROCEDURE (basename_proc)));
if (uri_proc != basename_proc)
{
GIMP_LOG (SAVE_DIALOG,
"that's impossible for remote URIs, bailing out");
/* remote URI */
gimp_message (gimp, G_OBJECT (dialog), GIMP_MESSAGE_WARNING,
_("Saving remote files needs to determine the "
"file format from the file extension. "
"Please enter a file extension that matches "
"the selected file format or enter no file "
"extension at all."));
goto fail;
}
else
{
GIMP_LOG (SAVE_DIALOG,
"ask the user if she really wants that filename");
/* local URI */
if (! file_save_dialog_use_extension (dialog, file))
{
goto fail;
}
}
}
else if (save_proc != uri_proc)
{
GIMP_LOG (SAVE_DIALOG,
"use URI's proc '%s' so indirect saving works",
gimp_procedure_get_label (GIMP_PROCEDURE (uri_proc)));
/* need to use the URI's proc for saving because e.g.
* the GIF plug-in can't save a GIF to sftp://
*/
save_proc = uri_proc;
}
}
if (! save_proc)
{
g_warning ("%s: EEEEEEK", G_STRFUNC);
return CHECK_URI_FAIL;
}
*ret_file = file;
*ret_basename = basename;
*ret_save_proc = save_proc;
return CHECK_URI_OK;
fail:
g_object_unref (file);
g_free (basename);
return CHECK_URI_FAIL;
switch_dialogs:
g_object_unref (file);
g_free (basename);
return CHECK_URI_SWITCH_DIALOGS;
}
/*
* IMPORTANT: Keep this up to date with file_save_dialog_check_uri().
*/
static gboolean
file_save_dialog_no_overwrite_confirmation (GimpFileDialog *file_dialog,
Gimp *gimp)
{
GFile *file;
gchar *basename;
GFile *basename_file;
GimpPlugInProcedure *basename_proc;
GimpPlugInProcedure *save_proc;
gboolean uri_will_change;
gboolean unknown_ext;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (file_dialog));
if (! file)
return FALSE;
basename = g_path_get_basename (gimp_file_get_utf8_name (file));
basename_file = g_file_new_for_uri (basename);
save_proc = file_dialog->file_proc;
basename_proc = file_save_dialog_find_procedure (file_dialog, basename_file);
g_object_unref (basename_file);
uri_will_change = (! basename_proc &&
! strchr (basename, '.') &&
(! save_proc || save_proc->extensions_list));
unknown_ext = (! save_proc &&
! basename_proc);
g_free (basename);
g_object_unref (file);
return uri_will_change || unknown_ext;
}
static GimpPlugInProcedure *
file_save_dialog_find_procedure (GimpFileDialog *file_dialog,
GFile *file)
{
GimpPlugInManager *manager = file_dialog->gimp->plug_in_manager;
GimpFileProcedureGroup group;
if (GIMP_IS_SAVE_DIALOG (file_dialog))
group = GIMP_FILE_PROCEDURE_GROUP_SAVE;
else
group = GIMP_FILE_PROCEDURE_GROUP_EXPORT;
return gimp_plug_in_manager_file_procedure_find (manager, group, file, NULL);
}
static gboolean
file_save_other_dialog_activated (GtkWidget *label,
const gchar *uri,
GtkDialog *dialog)
{
gtk_dialog_response (dialog, FILE_SAVE_RESPONSE_OTHER_DIALOG);
return TRUE;
}
static gboolean
file_save_dialog_switch_dialogs (GimpFileDialog *file_dialog,
Gimp *gimp,
const gchar *basename)
{
GimpPlugInProcedure *proc_in_other_group;
GimpFileProcedureGroup other_group;
GFile *file;
gboolean switch_dialogs = FALSE;
file = g_file_new_for_uri (basename);
if (GIMP_IS_EXPORT_DIALOG (file_dialog))
other_group = GIMP_FILE_PROCEDURE_GROUP_SAVE;
else
other_group = GIMP_FILE_PROCEDURE_GROUP_EXPORT;
proc_in_other_group =
gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
other_group, file, NULL);
g_object_unref (file);
if (proc_in_other_group)
{
GtkWidget *dialog;
const gchar *primary;
const gchar *message;
const gchar *link;
if (GIMP_IS_EXPORT_DIALOG (file_dialog))
{
primary = _("The given filename cannot be used for exporting");
message = _("You can use this dialog to export to various file formats. "
"If you want to save the image to the GIMP XCF format, use "
"File→Save instead.");
link = _("Take me to the Save dialog");
}
else
{
primary = _("The given filename cannot be used for saving");
message = _("You can use this dialog to save to the GIMP XCF "
"format. Use File→Export to export to other file formats.");
link = _("Take me to the Export dialog");
}
dialog = gimp_message_dialog_new (_("Extension Mismatch"),
GIMP_ICON_DIALOG_WARNING,
GTK_WIDGET (file_dialog),
GTK_DIALOG_DESTROY_WITH_PARENT,
gimp_standard_help_func, NULL,
_("_OK"), GTK_RESPONSE_OK,
NULL);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
"%s", primary);
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
"%s", message);
if (GIMP_IS_EXPORT_DIALOG (file_dialog) ||
(! GIMP_SAVE_DIALOG (file_dialog)->save_a_copy &&
! GIMP_SAVE_DIALOG (file_dialog)->close_after_saving))
{
GtkWidget *label;
gchar *markup;
markup = g_strdup_printf ("<a href=\"other-dialog\">%s</a>", link);
label = gtk_label_new (markup);
g_free (markup);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_box_pack_start (GTK_BOX (GIMP_MESSAGE_DIALOG (dialog)->box), label,
FALSE, FALSE, 0);
gtk_widget_show (label);
g_signal_connect (label, "activate-link",
G_CALLBACK (file_save_other_dialog_activated),
dialog);
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (file_dialog),
GTK_RESPONSE_CANCEL, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (file_dialog),
GTK_RESPONSE_OK, FALSE);
g_object_ref (dialog);
if (gimp_dialog_run (GIMP_DIALOG (dialog)) == FILE_SAVE_RESPONSE_OTHER_DIALOG)
{
switch_dialogs = TRUE;
}
gtk_widget_destroy (dialog);
g_object_unref (dialog);
gtk_dialog_set_response_sensitive (GTK_DIALOG (file_dialog),
GTK_RESPONSE_CANCEL, TRUE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (file_dialog),
GTK_RESPONSE_OK, TRUE);
}
else
{
gimp_message (gimp, G_OBJECT (file_dialog), GIMP_MESSAGE_WARNING,
_("The given filename does not have any known "
"file extension. Please enter a known file "
"extension or select a file format from the "
"file format list."));
}
return switch_dialogs;
}
static gboolean
file_save_dialog_use_extension (GtkWidget *save_dialog,
GFile *file)
{
GtkWidget *dialog;
gboolean use_name = FALSE;
dialog = gimp_message_dialog_new (_("Extension Mismatch"),
GIMP_ICON_DIALOG_QUESTION,
save_dialog, GTK_DIALOG_DESTROY_WITH_PARENT,
gimp_standard_help_func, NULL,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Save"), GTK_RESPONSE_OK,
NULL);
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("The given file extension does "
"not match the chosen file type."));
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("Do you want to save the image using this "
"name anyway?"));
gtk_dialog_set_response_sensitive (GTK_DIALOG (save_dialog),
GTK_RESPONSE_CANCEL, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (save_dialog),
GTK_RESPONSE_OK, FALSE);
g_object_ref (dialog);
use_name = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
gtk_widget_destroy (dialog);
g_object_unref (dialog);
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 19:47:11 +08:00
gtk_dialog_set_response_sensitive (GTK_DIALOG (save_dialog),
GTK_RESPONSE_CANCEL, TRUE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (save_dialog),
GTK_RESPONSE_OK, TRUE);
return use_name;
}
gboolean
file_save_dialog_save_image (GimpProgress *progress,
Gimp *gimp,
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
GimpImage *image,
GFile *file,
app/plug-in/plug-in-types.h renamed to GimpPlugInProcedure and made a 2006-04-05 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-types.h * app/plug-in/plug-in-proc-def.[ch]: renamed to GimpPlugInProcedure and made a GObject derived from GimpProcedure (instead of having a pointer to a GimpProcedure). Added image_types and file_magic utility functions taken from plug-ins.[ch]. Still lives in the same crappy files because I am undecided where to put it... * app/pdb/gimpprocedure.c (gimp_procedure_real_execute): removed switch() statement and always call the internal marshaller because GimpProcedure::execute() is properly overridden by GimpPlugInProcedure now. * app/plug-in/plug-ins.[ch]: removed the mime_type and file_magic utilities added to GimpPlugInProcedure. * app/actions/file-commands.c * app/actions/plug-in-actions.[ch] * app/actions/plug-in-commands.[ch] * app/core/gimp-gui.[ch] * app/core/gimp.[ch] * app/core/gimpimage.[ch] * app/dialogs/file-open-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/print-size-dialog.c * app/file/file-open.[ch] * app/file/file-save.[ch] * app/file/file-utils.[ch] * app/gui/gui-vtable.c * app/menus/plug-in-menus.[ch] * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-message.c * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-run.c * app/plug-in/plug-in.c * app/plug-in/plug-ins-query.c * app/widgets/gimpactiongroup.[ch] * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.[ch] * app/widgets/gimpfileprocview.[ch] * app/widgets/gimppluginaction.[ch] * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/plug_in.pdb: changed addordingly. * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2006-04-05 16:38:33 +08:00
GimpPlugInProcedure *save_proc,
GimpRunMode run_mode,
gboolean change_saved_state,
gboolean export_backward,
gboolean export_forward,
gboolean xcf_compression,
gboolean verbose_cancel)
{
GimpPDBStatusType status;
GError *error = NULL;
GList *list;
gboolean success = FALSE;
for (list = gimp_action_groups_from_name ("file");
list;
list = g_list_next (list))
{
gimp_action_group_set_action_sensitive (list->data, "file-quit", FALSE, NULL);
}
gimp_image_set_xcf_compression (image, xcf_compression);
status = file_save (gimp, image, progress, file,
save_proc, run_mode,
change_saved_state, export_backward, export_forward,
&error);
switch (status)
{
case GIMP_PDB_SUCCESS:
success = TRUE;
break;
case GIMP_PDB_CANCEL:
if (verbose_cancel)
gimp_message_literal (gimp,
G_OBJECT (progress), GIMP_MESSAGE_INFO,
_("Saving canceled"));
break;
default:
{
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
_("Saving '%s' failed:\n\n%s"),
gimp_file_get_utf8_name (file),
error ? error->message : _("Unknown error"));
g_clear_error (&error);
}
break;
}
for (list = gimp_action_groups_from_name ("file");
list;
list = g_list_next (list))
{
gimp_action_group_set_action_sensitive (list->data, "file-quit", TRUE, NULL);
}
return success;
}