gimp/plug-ins/imagemap/imap_file.c

159 lines
3.7 KiB
C
Raw Normal View History

1999-09-07 08:03:20 +08:00
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
1999-09-07 08:03:20 +08:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
1999-09-07 08:03:20 +08:00
#include "imap_default_dialog.h"
#include "imap_file.h"
#include "imap_main.h"
#include "imap_misc.h"
1999-09-07 08:03:20 +08:00
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "libgimp/stdplugins-intl.h"
1999-09-07 08:03:20 +08:00
static void
open_cb (GtkFileSelection *fs,
gint response_id,
gpointer data)
1999-09-07 08:03:20 +08:00
{
if (response_id == GTK_RESPONSE_OK)
{
const gchar *filename;
filename = gtk_file_selection_get_filename (fs);
if (! g_file_test (filename, G_FILE_TEST_IS_REGULAR))
{
do_file_error_dialog (_("Error opening file"), filename);
return;
}
load (filename);
}
gtk_widget_hide (GTK_WIDGET (fs));
1999-09-07 08:03:20 +08:00
}
void
do_file_open_dialog (void)
1999-09-07 08:03:20 +08:00
{
static GtkWidget *dialog;
if (! dialog)
{
dialog = gtk_file_selection_new (_("Load Imagemap"));
g_signal_connect (dialog, "delete_event",
G_CALLBACK (gtk_true),
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (open_cb),
NULL);
}
gtk_window_present (GTK_WINDOW (dialog));
1999-09-07 08:03:20 +08:00
}
static void
really_overwrite(gpointer data)
{
gtk_widget_hide((GtkWidget*) data);
save_as(gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)));
}
static void
do_file_exists_dialog(gpointer data)
{
static DefaultDialog_t *dialog;
if (!dialog) {
1999-10-25 04:57:17 +08:00
dialog = make_default_dialog(_("File exists!"));
1999-09-07 08:03:20 +08:00
default_dialog_hide_apply_button(dialog);
default_dialog_set_ok_cb(dialog, really_overwrite, data);
default_dialog_set_label(
dialog,
1999-10-25 04:57:17 +08:00
_("File already exists.\n"
" Do you really want to overwrite? "));
1999-09-07 08:03:20 +08:00
}
default_dialog_show(dialog);
}
static void
save_cb (GtkFileSelection *fs,
gint response_id,
gpointer data)
1999-09-07 08:03:20 +08:00
{
if (response_id == GTK_RESPONSE_OK)
{
const gchar *filename;
filename = gtk_file_selection_get_filename (fs);
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
{
do_file_exists_dialog (fs);
return;
}
save_as (filename);
}
gtk_widget_hide (GTK_WIDGET (fs));
1999-09-07 08:03:20 +08:00
}
void
do_file_save_as_dialog (void)
1999-09-07 08:03:20 +08:00
{
static GtkWidget *dialog;
if (! dialog)
{
dialog = gtk_file_selection_new (_("Save Imagemap"));
g_signal_connect (dialog, "delete_event",
G_CALLBACK (gtk_true),
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (save_cb),
NULL);
}
gtk_window_present (GTK_WINDOW (dialog));
1999-09-07 08:03:20 +08:00
}
void
do_file_error_dialog(const char *error, const char *filename)
{
static Alert_t *alert;
if (!alert)
alert = create_alert(GTK_STOCK_DIALOG_ERROR);
1999-09-07 08:03:20 +08:00
alert_set_text(alert, error, gimp_filename_to_utf8 (filename));
1999-09-07 08:03:20 +08:00
default_dialog_show(alert->dialog);
1999-09-07 08:03:20 +08:00
}