gimp/plug-ins/imagemap/imap_settings.c

191 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-2004 Maurits Rijk m.rijk@chello.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
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.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"
#include "libgimp/stdplugins-intl.h"
typedef struct {
DefaultDialog_t *dialog;
BrowseWidget_t *imagename;
GtkWidget *filename;
GtkWidget *title;
GtkWidget *author;
GtkWidget *default_url;
GtkWidget *ncsa;
GtkWidget *cern;
GtkWidget *csim;
GtkTextBuffer *description;
} 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();
gchar *description;
GtkTextIter start, end;
1999-09-07 00:03:20 +00:00
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,
1999-09-07 00:03:20 +00:00
gtk_entry_get_text(GTK_ENTRY(param->default_url)));
gtk_text_buffer_get_bounds(param->description, &start, &end);
description = gtk_text_buffer_get_text(param->description, &start, &end,
FALSE);
g_strreplace(&info->description, description);
g_free(description);
1999-09-07 00:03:20 +00:00
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*
Fix a bunch of warnings from Sparse: 2004-11-13 Manish Singh <yosh@gimp.org> Fix a bunch of warnings from Sparse: * app/actions/dockable-commands.c * app/actions/layers-actions.c * app/actions/view-commands.c * app/base/pixel-surround.c * app/config/gimpconfig-utils.c * app/config/gimpscanner.c * app/core/gimpbrushgenerated.c * app/core/gimpcontainer.c * app/core/gimpimage.c * app/dialogs/palette-import-dialog.c * app/file/gimprecentlist.c * app/plug-in/plug-in-params.c * app/text/gimptext-compat.c * app/text/gimptext-parasite.c * app/vectors/gimpbezierstroke.c * app/vectors/gimpstroke.c * app/widgets/gimpcellrendereraccel.c * app/widgets/gimpselectiondata.c * app/xcf/xcf.c * libgimp/gimp.c * libgimpthumb/gimpthumb-utils.c * libgimpthumb/gimpthumbnail.c * modules/cdisplay_proof.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/csource.c * plug-ins/common/glasstile.c * plug-ins/common/nova.c * plug-ins/common/pcx.c * plug-ins/common/pnm.c * plug-ins/common/randomize.c * plug-ins/common/screenshot.c * plug-ins/common/sel_gauss.c * plug-ins/common/spheredesigner.c * plug-ins/common/wind.c * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-dobject.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/ifscompose/ifscompose.c * plug-ins/print/gimp_main_window.c * plug-ins/print/print.c: Cleanup integer vs. pointer confusion. * app/base/temp-buf.c * app/dialogs/about-dialog.c * plug-ins/common/bumpmap.c * plug-ins/common/jigsaw.c * plug-ins/gfig/gfig-dobject.c: Cosmetic cleanups. * app/config/gimpconfig-deserialize.c * app/config/gimpconfig-path.c * app/config/gimpconfigwriter.c * app/core/gimpgradient.c * app/tools/gimpdrawtool.c * plug-ins/common/nlfilt.c * plug-ins/common/unsharp.c * plug-ins/common/zealouscrop.c: Define inline functions before they are used. * app/core/gimpdrawable-blend.c: PixelRegion definition was changed some time ago, but the initialization here didn't change. Fix it. * app/plug-in/plug-in-rc.c (plug_in_extra_deserialize): No need to assign token twice in a row. * libgimpbase/gimpdatafiles.c (gimp_datafiles_read_directories): No need to initialize file_data, since the code fills out all the fields. * plug-ins/common/CML_explorer.c * plug-ins/common/vpropagate.c: Declare function pointers fully. * plug-ins/common/grid.c (pix_composite): G_INLINE_FUNC isn't needed, we assume we can use the "inline" keyword always. * plug-ins/common/psd_save.c * plug-ins/common/vinvert.c * plug-ins/gfig/gfig-arc.c * plug-ins/gfig/gfig-bezier.c * plug-ins/gfig/gfig-circle.c * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-dobject.c * plug-ins/gfig/gfig-ellipse.c * plug-ins/gfig/gfig-line.c * plug-ins/gfig/gfig-poly.c * plug-ins/gfig/gfig-spiral.c * plug-ins/gfig/gfig-star.c * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/orientmap.c * plug-ins/gimpressionist/placement.c * plug-ins/gimpressionist/sizemap.c * plug-ins/imagemap/imap_grid.c * plug-ins/imagemap/imap_main.c * plug-ins/imagemap/imap_preferences.c * plug-ins/imagemap/imap_settings.c * plug-ins/maze/maze.c * plug-ins/sel2path/curve.c * plug-ins/sel2path/fit.c * plug-ins/sel2path/pxl-outline.c * plug-ins/sel2path/spline.c * plug-ins/xjt/xjt.c: Functions with no args should be declared with (void). * plug-ins/common/retinex.c (MSRCR): Initialize max_preview to quiet the compiler.
2004-11-14 02:50:33 +00:00
create_settings_dialog(void)
1999-09-07 00:03:20 +00:00
{
SettingsDialog_t *data = g_new(SettingsDialog_t, 1);
GtkWidget *table, *view, *frame, *hbox, *label, *swin;
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, 2);
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"));
gtk_table_attach_defaults(GTK_TABLE(table), data->imagename->hbox, 1, 2,
1999-09-07 00:03:20 +00:00
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_buffer_new(NULL);
view = gtk_text_view_new_with_buffer(data->description);
gtk_widget_set_size_request(view, -1, 128);
gtk_widget_show(view);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), view);
swin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin),
GTK_SHADOW_IN);
gtk_table_attach(GTK_TABLE(table), swin, 1, 2, 5, 8,
1999-09-07 00:03:20 +00:00
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_widget_show(swin);
gtk_container_add(GTK_CONTAINER(swin), view);
1999-09-07 00:03:20 +00:00
frame = gimp_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, 0, 2, 9, 10);
hbox = gtk_hbox_new(FALSE, 6);
1999-09-07 00:03:20 +00:00
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(data->ncsa, "toggled",
G_CALLBACK(type_toggled_cb), (gpointer) NCSA);
gtk_box_pack_start(GTK_BOX(hbox), data->ncsa, FALSE, FALSE, 0);
1999-09-07 00:03:20 +00:00
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(data->cern, "toggled",
G_CALLBACK(type_toggled_cb), (gpointer) CERN);
gtk_box_pack_start(GTK_BOX(hbox), data->cern, FALSE, FALSE, 0);
1999-09-07 00:03:20 +00:00
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(data->csim, "toggled",
G_CALLBACK(type_toggled_cb), (gpointer) CSIM);
gtk_box_pack_start(GTK_BOX(hbox), data->csim, FALSE, FALSE, 0);
1999-09-07 00:03:20 +00:00
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
if (!filename)
filename = _("<Untitled>");
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_text_buffer_set_text (dialog->description, info->description, -1);
1999-09-07 00:03:20 +00:00
}