gimp/plug-ins/imagemap/imap_settings.c
Manish Singh 5d01581069 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

191 lines
6.3 KiB
C

/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.nl
*
* 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"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#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;
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;
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)));
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);
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(void)
{
SettingsDialog_t *data = g_new(SettingsDialog_t, 1);
GtkWidget *table, *view, *frame, *hbox, *label, *swin;
DefaultDialog_t *dialog;
dialog = data->dialog = make_default_dialog(_("Settings for this Mapfile"));
default_dialog_set_ok_cb(dialog, settings_ok_cb, (gpointer) data);
table = default_dialog_add_table(dialog, 9, 2);
create_label_in_table(table, 0, 0, _("Filename:"));
data->filename = create_label_in_table(table, 0, 1, "");
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,
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:"));
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,
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);
frame = gimp_frame_new(_("Map file format"));
gtk_widget_show(frame);
gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 2, 9, 10);
hbox = gtk_hbox_new(FALSE, 6);
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);
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);
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);
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();
if (!filename)
filename = _("<Untitled>");
gtk_label_set_text(GTK_LABEL(dialog->filename), filename);
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);
}