gimp/plug-ins/imagemap/imap_settings.c

187 lines
6.3 KiB
C
Raw Normal View History

1999-09-07 00:03:20 +00:00
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl
1999-09-07 00:03:20 +00: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-02-17 08:36:46 +00:00
#include "config.h"
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 13:26:29 +00:00
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
1999-09-07 00:03:20 +00:00
#include "imap_browse.h"
#include "imap_main.h"
#include "imap_settings.h"
#include "imap_string.h"
#include "imap_table.h"
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 13:26:29 +00:00
#ifdef __GNUC__
#warning GTK_ENABLE_BROKEN
#endif
updated for GTK2 build 2001-07-28 Hans Breuer <hans@breuer.org> * */*/makefile.msc : updated for GTK2 build * app/widgets/makefile.msc : (new file) forgot this one last time * plug-ins/common/animationplay.c : reflect that GTK2 has its gdk<x|win32|fb>.h files in the back-end sub directories * plug-ins/common/gif.c : * plug-ins/common/jpeg.c : * plug-ins/dbbrowser/dbbrowser_utils.c : * plug-ins/gap/gap_dbbrowser_utils.c : * plug-ims/gimpressionist/presets.c : * plug-ims/gimpressionist/imap_setting.c : * plug-ims/gimpressionist/imap_source.c : * plug-ims/script-fu/script-fu-console.c : * plug-ims/script-fu/script-fu-scripts.c : #define GTK_ENABLE_BROKEN and include <gtk/gtktext.h> to make them compile/work again * plug-ins/common/spheredesigner.c : gtk_color_selction_set_opacity renamed to gtk_color_selction_set_current_alpha * plug-ins/gflare/gtkmultioptionmenu.c : ported ny removing the virtual draw function and style->xthickness and ythickness via direct access, klass field isn't available anymore * plug-ins/common/nlfilt.c : * plug-ims/gap/gap_movdialog.c : * plug-ims/gimpressionist/gimpressionist.c : gtk_widget_set_default_visible is neither available nor needed anymore * plug-ins/common/plugindetails.c : ported to GtkTextBuffer and reflect gtk_paned api changes * plug-ims/gimpressionist/imap_preview.c : replace GTK_WIDGET(a)->klass access by GTK_WIDGET_GET_CLASS(a) * plug-ims/gimpressionist/imap_selection.c : * plug-ims/gimpressionist/imap_toolbar.c : * plug-ims/gimpressionist/imap_tools.c : gtk_toolbar api changes
2001-07-28 19:40:07 +00:00
#define GTK_ENABLE_BROKEN
#include <gtk/gtktext.h>
1999-09-07 00:03:20 +00:00
#include "libgimp/stdplugins-intl.h"
typedef struct {
DefaultDialog_t *dialog;
BrowseWidget_t *imagename;
GtkWidget *filename;
GtkWidget *title;
GtkWidget *author;
GtkWidget *default_url;
GtkWidget *description;
GtkWidget *ncsa;
GtkWidget *cern;
GtkWidget *csim;
} SettingsDialog_t;
1999-09-07 00:03:20 +00:00
static MapFormat_t _map_format = CSIM;
static void
settings_ok_cb(gpointer data)
{
SettingsDialog_t *param = (SettingsDialog_t*) data;
MapInfo_t *info = get_map_info();
g_strreplace(&info->image_name, gtk_entry_get_text(
GTK_ENTRY(param->imagename->file)));
g_strreplace(&info->title, gtk_entry_get_text(GTK_ENTRY(param->title)));
g_strreplace(&info->author, gtk_entry_get_text(GTK_ENTRY(param->author)));
g_strreplace(&info->default_url,
gtk_entry_get_text(GTK_ENTRY(param->default_url)));
g_strreplace(&info->description,
gtk_editable_get_chars(GTK_EDITABLE(param->description),
0, -1));
info->map_format = _map_format;
}
static void
type_toggled_cb(GtkWidget *widget, gpointer data)
{
if (GTK_WIDGET_STATE(widget) & GTK_STATE_SELECTED)
_map_format = (MapFormat_t) data;
}
static SettingsDialog_t*
create_settings_dialog()
1999-09-07 00:03:20 +00:00
{
SettingsDialog_t *data = g_new(SettingsDialog_t, 1);
GtkWidget *table, *vscrollbar, *frame, *hbox, *label;
1999-09-07 00:03:20 +00:00
DefaultDialog_t *dialog;
1999-10-24 20:57:17 +00:00
dialog = data->dialog = make_default_dialog(_("Settings for this Mapfile"));
1999-09-07 00:03:20 +00:00
default_dialog_set_ok_cb(dialog, settings_ok_cb, (gpointer) data);
table = default_dialog_add_table(dialog, 9, 3);
1999-09-07 00:03:20 +00:00
1999-10-24 20:57:17 +00:00
create_label_in_table(table, 0, 0, _("Filename:"));
1999-09-07 00:03:20 +00:00
data->filename = create_label_in_table(table, 0, 1, "");
1999-10-24 20:57:17 +00:00
create_label_in_table(table, 1, 0, _("Image name:"));
data->imagename = browse_widget_new(_("Select Image File"));
1999-09-07 00:03:20 +00:00
gtk_table_attach_defaults(GTK_TABLE(table), data->imagename->hbox, 1, 2,
1, 2);
label = create_label_in_table(table, 2, 0, _("_Title:"));
data->title = create_entry_in_table(table, label, 2, 1);
label = create_label_in_table(table, 3, 0, _("Aut_hor:"));
data->author = create_entry_in_table(table, label, 3, 1);
label = create_label_in_table(table, 4, 0, _("Default _URL:"));
data->default_url = create_entry_in_table(table, label, 4, 1);
label = create_label_in_table(table, 5, 0, _("_Description:"));
1999-09-07 00:03:20 +00:00
data->description = gtk_text_new(NULL, NULL);
gtk_text_set_editable(GTK_TEXT(data->description), TRUE);
gtk_table_attach(GTK_TABLE(table), data->description, 1, 2, 5, 8,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show(data->description);
/* Add a vertical scrollbar to the GtkText widget */
vscrollbar = gtk_vscrollbar_new(GTK_TEXT(data->description)->vadj);
gtk_table_attach(GTK_TABLE(table), vscrollbar, 2, 3, 5, 8,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show(vscrollbar);
1999-10-24 20:57:17 +00:00
frame = gtk_frame_new(_("Map file format"));
1999-09-07 00:03:20 +00:00
gtk_widget_show(frame);
gtk_table_attach_defaults(GTK_TABLE(table), frame, 1, 2, 9, 10);
hbox = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
data->ncsa = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_NCSA");
g_signal_connect(G_OBJECT(data->ncsa), "toggled",
G_CALLBACK(type_toggled_cb), (gpointer) NCSA);
1999-09-07 00:03:20 +00:00
gtk_box_pack_start(GTK_BOX(hbox), data->ncsa, TRUE, TRUE, 10);
gtk_widget_show(data->ncsa);
data->cern = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(data->ncsa), "C_ERN");
g_signal_connect(G_OBJECT(data->cern), "toggled",
G_CALLBACK(type_toggled_cb), (gpointer) CERN);
1999-09-07 00:03:20 +00:00
gtk_box_pack_start(GTK_BOX(hbox), data->cern, TRUE, TRUE, 10);
gtk_widget_show(data->cern);
data->csim = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(data->cern), "C_SIM");
g_signal_connect(G_OBJECT(data->csim), "toggled",
G_CALLBACK(type_toggled_cb), (gpointer) CSIM);
1999-09-07 00:03:20 +00:00
gtk_box_pack_start(GTK_BOX(hbox), data->csim, TRUE, TRUE, 10);
gtk_widget_show(data->csim);
return data;
}
void
do_settings_dialog(void)
{
static SettingsDialog_t *dialog;
const char *filename = get_filename();
MapInfo_t *info = get_map_info();
if (!dialog)
dialog = create_settings_dialog();
1999-09-07 00:03:20 +00:00
gtk_label_set_text(GTK_LABEL(dialog->filename), filename);
1999-09-07 00:03:20 +00:00
browse_widget_set_filename(dialog->imagename, info->image_name);
gtk_entry_set_text(GTK_ENTRY(dialog->title), info->title);
gtk_entry_set_text(GTK_ENTRY(dialog->author), info->author);
gtk_entry_set_text(GTK_ENTRY(dialog->default_url), info->default_url);
if (info->map_format == NCSA)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->ncsa), TRUE);
else if (info->map_format == CERN)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->cern), TRUE);
else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->csim), TRUE);
gtk_widget_grab_focus(dialog->imagename->file);
default_dialog_show(dialog->dialog);
gtk_editable_delete_text(GTK_EDITABLE(dialog->description), 0, -1);
gtk_text_insert(GTK_TEXT(dialog->description), NULL, NULL, NULL,
info->description, -1);
}