1999-09-07 08:03:20 +08:00
|
|
|
/*
|
|
|
|
* This is a plug-in for the GIMP.
|
|
|
|
*
|
|
|
|
* Generates clickable image maps.
|
|
|
|
*
|
2003-01-01 21:23:47 +08:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2000-08-21 02:05:04 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-08-21 02:05:04 +08:00
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
#include "imap_default_dialog.h"
|
|
|
|
#include "imap_file.h"
|
|
|
|
#include "imap_main.h"
|
2003-01-01 21:23:47 +08:00
|
|
|
#include "imap_misc.h"
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
static void
|
2003-11-19 22:51:52 +08:00
|
|
|
open_cb (GtkFileSelection *fs,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2003-11-19 22:51:52 +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
|
2003-11-19 22:51:52 +08:00
|
|
|
do_file_open_dialog (void)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
|
|
|
static GtkWidget *dialog;
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
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
|
2003-11-19 22:51:52 +08:00
|
|
|
save_cb (GtkFileSelection *fs,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2003-11-19 22:51:52 +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
|
2003-11-19 22:51:52 +08:00
|
|
|
do_file_save_as_dialog (void)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
|
|
|
static GtkWidget *dialog;
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2002-09-07 00:59:51 +08:00
|
|
|
static Alert_t *alert;
|
|
|
|
|
|
|
|
if (!alert)
|
|
|
|
alert = create_alert(GTK_STOCK_DIALOG_ERROR);
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2004-04-13 21:01:08 +08:00
|
|
|
alert_set_text(alert, error, gimp_filename_to_utf8 (filename));
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2002-09-07 00:59:51 +08:00
|
|
|
default_dialog_show(alert->dialog);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|