gimp/plug-ins/imagemap/imap_preferences.c

627 lines
20 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-1999 Maurits Rijk lpeek.mrijk@consunet.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"
1999-09-07 00:03:20 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
1999-10-24 20:57:17 +00:00
#include "imap_command.h"
1999-09-07 00:03:20 +00:00
#include "imap_file.h"
#include "imap_main.h"
1999-10-24 20:57:17 +00:00
#include "imap_menu.h"
1999-09-07 00:03:20 +00:00
#include "imap_misc.h"
1999-10-24 20:57:17 +00:00
#include "imap_mru.h"
1999-09-07 00:03:20 +00:00
#include "imap_preferences.h"
#include "imap_table.h"
#include "libgimp/gimp.h"
#include "libgimp/stdplugins-intl.h"
1999-09-07 00:03:20 +00:00
static gint
parse_map_type(void)
{
char *token = strtok(NULL, " )");
if (!strcmp(token, "ncsa"))
return NCSA;
else if (!strcmp(token, "cern"))
return CERN;
return CSIM;
}
static gint
parse_yes_no(void)
{
char *token = strtok(NULL, " )");
return (gint) strcmp(token, "no");
}
static gint
parse_int(void)
{
char *token = strtok(NULL, " )");
return (gint) atoi(token);
}
static void
parse_color(GdkColor *gdk_color)
{
gint color[3];
color[0] = parse_int();
color[1] = parse_int();
color[2] = parse_int();
gdk_color->red = (guint16) color[0];
gdk_color->green = (guint16) color[1];
gdk_color->blue = (guint16) color[2];
}
static void
parse_mru_entry(void)
{
char *filename = strtok(NULL, " )");
mru_add(get_mru(), filename);
}
static void
parse_line(PreferencesData_t *data, char *line)
{
char *token;
ColorSelData_t *colors = &data->colors;
line++; /* Skip '(' */
token = strtok(line, " ");
if (!strcmp(token, "default-map-type")) {
data->default_map_type = parse_map_type();
}else if (!strcmp(token, "prompt-for-area-info")) {
data->prompt_for_area_info = parse_yes_no();
} else if (!strcmp(token, "require-default-url")) {
data->require_default_url = parse_yes_no();
} else if (!strcmp(token, "show-area-handle")) {
data->show_area_handle = parse_yes_no();
} else if (!strcmp(token, "keep-circles-round")) {
data->keep_circles_round = parse_yes_no();
} else if (!strcmp(token, "show-url-tip")) {
data->show_url_tip = parse_yes_no();
} else if (!strcmp(token, "use-doublesized")) {
data->use_doublesized = parse_yes_no();
1999-10-24 20:57:17 +00:00
} else if (!strcmp(token, "mru-size")) {
data->mru_size = parse_int();
} else if (!strcmp(token, "undo-levels")) {
data->undo_levels = parse_int();
1999-09-07 00:03:20 +00:00
} else if (!strcmp(token, "normal-fg-color")) {
parse_color(&colors->normal_fg);
} else if (!strcmp(token, "normal-bg-color")) {
parse_color(&colors->normal_bg);
} else if (!strcmp(token, "selected-fg-color")) {
parse_color(&colors->selected_fg);
} else if (!strcmp(token, "selected-bg-color")) {
parse_color(&colors->selected_bg);
} else if (!strcmp(token, "mru-entry")) {
parse_mru_entry();
} else {
/* Unrecognized, just ignore rest of line */
}
}
gboolean
preferences_load(PreferencesData_t *data)
{
FILE *in;
char buf[256];
gchar *filename;
filename = g_build_filename (gimp_directory (), "imagemaprc", NULL);
1999-09-07 00:03:20 +00:00
in = fopen(filename, "r");
g_free(filename);
if (in) {
while (fgets(buf, sizeof(buf), in)) {
if (*buf != '\n' && *buf != '#') {
parse_line(data, buf);
}
}
fclose(in);
return TRUE;
}
return FALSE;
}
void
preferences_save(PreferencesData_t *data)
{
FILE *out;
gchar *filename;
ColorSelData_t *colors = &data->colors;
filename = g_build_filename (gimp_directory (), "imagemaprc", NULL);
1999-09-07 00:03:20 +00:00
out = fopen(filename, "w");
if (out) {
fprintf(out, "# Imagemap plug-in resource file\n\n");
if (data->default_map_type == NCSA)
fprintf(out, "(default-map-type ncsa)\n");
else if (data->default_map_type == CERN)
fprintf(out, "(default-map-type cern)\n");
else
fprintf(out, "(default-map-type csim)\n");
fprintf(out, "(prompt-for-area-info %s)\n",
(data->prompt_for_area_info) ? "yes" : "no");
fprintf(out, "(require-default-url %s)\n",
(data->require_default_url) ? "yes" : "no");
fprintf(out, "(show-area-handle %s)\n",
(data->show_area_handle) ? "yes" : "no");
fprintf(out, "(keep-circles-round %s)\n",
(data->keep_circles_round) ? "yes" : "no");
fprintf(out, "(show-url-tip %s)\n",
(data->show_url_tip) ? "yes" : "no");
fprintf(out, "(use-doublesized %s)\n",
(data->use_doublesized) ? "yes" : "no");
1999-10-24 20:57:17 +00:00
fprintf(out, "(undo-levels %d)\n", data->undo_levels);
fprintf(out, "(mru-size %d)\n", data->mru_size);
1999-09-07 00:03:20 +00:00
fprintf(out, "(normal-fg-color %d %d %d)\n",
colors->normal_fg.red, colors->normal_fg.green,
colors->normal_fg.blue);
fprintf(out, "(normal-bg-color %d %d %d)\n",
colors->normal_bg.red, colors->normal_bg.green,
colors->normal_bg.blue);
fprintf(out, "(selected-fg-color %d %d %d)\n",
colors->selected_fg.red, colors->selected_fg.green,
colors->selected_fg.blue);
fprintf(out, "(selected-bg-color %d %d %d)\n",
colors->selected_bg.red, colors->selected_bg.green,
colors->selected_bg.blue);
mru_write(get_mru(), out);
fclose(out);
} else {
2000-02-17 08:36:46 +00:00
do_file_error_dialog( _("Couldn't save resource file:"), filename);
1999-09-07 00:03:20 +00:00
}
g_free(filename);
}
static void
preferences_ok_cb(gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
PreferencesData_t *old_data = param->old_data;
ColorSelData_t *colors = &old_data->colors;
1999-10-24 20:57:17 +00:00
MRU_t *mru = get_mru();
1999-09-07 00:03:20 +00:00
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->cern)))
old_data->default_map_type = CERN;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->ncsa)))
old_data->default_map_type = NCSA;
else
old_data->default_map_type = CSIM;
old_data->prompt_for_area_info = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->prompt_for_area_info));
old_data->require_default_url = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->require_default_url));
old_data->show_area_handle = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->show_area_handle));
old_data->keep_circles_round = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->keep_circles_round));
old_data->show_url_tip = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->show_url_tip));
old_data->use_doublesized = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->use_doublesized));
1999-10-24 20:57:17 +00:00
old_data->mru_size =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->mru_size));
old_data->undo_levels =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->undo_levels));
mru_set_size(mru, old_data->mru_size);
menu_build_mru_items(mru);
command_list_set_undo_level(old_data->undo_levels);
1999-09-07 00:03:20 +00:00
*colors = param->new_colors;
gdk_gc_set_foreground(old_data->normal_gc, &colors->normal_fg);
gdk_gc_set_background(old_data->normal_gc, &colors->normal_bg);
gdk_gc_set_foreground(old_data->selected_gc, &colors->selected_fg);
gdk_gc_set_background(old_data->selected_gc, &colors->selected_bg);
set_sash_size(old_data->use_doublesized);
redraw_preview();
}
static void
set_button_colors(PreferencesDialog_t *dialog, ColorSelData_t *colors)
{
gdk_window_set_background(dialog->normal_fg->window,
&colors->normal_fg);
gdk_window_clear(dialog->normal_fg->window);
gdk_window_set_background(dialog->normal_bg->window,
&colors->normal_bg);
gdk_window_clear(dialog->normal_bg->window);
gdk_window_set_background(dialog->selected_fg->window,
&colors->selected_fg);
gdk_window_clear(dialog->selected_fg->window);
gdk_window_set_background(dialog->selected_bg->window,
&colors->selected_bg);
gdk_window_clear(dialog->selected_bg->window);
}
static void
select_color_cancel(GtkWidget *widget, gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
gtk_widget_hide(param->color_sel_dlg);
set_button_colors(param, &param->old_colors);
}
static void
select_color_ok(GtkWidget *widget, gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
param->old_colors = param->new_colors;
gtk_widget_hide(param->color_sel_dlg);
}
static void (*_color_changed_func)(GtkWidget *widget, gpointer data);
static void
color_changed(GtkWidget *widget, gpointer data)
{
(*_color_changed_func)(widget, data);
}
static void
change_color(PreferencesDialog_t *param, GtkWidget *button,
GdkColor *gdk_color)
{
gdouble color[3];
GdkColormap *colormap;
GtkColorSelection *colorsel = GTK_COLOR_SELECTION(param->color_sel);
gtk_color_selection_get_color(colorsel, color);
gdk_color->red = (guint16)(color[0]*65535.0);
gdk_color->green = (guint16)(color[1]*65535.0);
gdk_color->blue = (guint16)(color[2]*65535.0);
colormap = gdk_drawable_get_colormap(button->window);
link the app in a different order as some init functions are called from 2001-10-19 Michael Natterer <mitch@gimp.org> * app/Makefile.am: link the app in a different order as some init functions are called from core/gimp.c instead of app_procs.c now. * app/app_procs.[ch]: made app_init_update_status() private and pass it as callback to various init functions. * app/plug_in.[ch]: plug_in_init() take "gimp" and "status_callback" parameters. * app/undo.c: use "gimage->gimp" instead of "the_gimp", don't include "app_procs.h". * app/core/core-types.h: added "GimpInitStatusFunc" typedef. * app/core/gimp.[ch]: gimp_initialize() and gimp_restore() now take a "status_callback" as parameter. Don't include "app_procs.h". * app/core/gimpmodules.c: putting the modules in a strong container was a bad idea because it may be impossible to finalize a GimpModuleInfo object belonging to a stalled module. * app/gui/color-area.c: use G_N_ELEMENTS(). * app/gui/session.c: don't call app_init_update_status() and don't include "app_procs.h" because this happens after the splash is hidden. * tools/pdbgen/app.pl * app/pdb/internal_procs.[ch]: pass a "status_callback" to internal_procs_init(), don't include "app_procs.h". * plug-ins/Makefile.am: build gfig, gimpressionist and imagemap again. * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_ui.c: s/gdk_image_unref/g_object_unref/ * plug-ins/gfig/gfig.c * plug-ins/gimpressionist/brush.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/ppmtool.[ch] * plug-ins/gimpressionist/presets.c * plug-ins/imagemap/imap_browse.[ch] * plug-ins/imagemap/imap_csim.y * plug-ins/imagemap/imap_edit_area_info.c * plug-ins/imagemap/imap_file.c * plug-ins/imagemap/imap_main.c * plug-ins/imagemap/imap_menu.c * plug-ins/imagemap/imap_polygon.c * plug-ins/imagemap/imap_popup.c * plug-ins/imagemap/imap_preferences.c * plug-ins/imagemap/imap_taglist.c * plug-ins/imagemap/imap_tools.c: ported to current GLib/Gtk+. * plug-ins/gap/gap_arr_dialog.c * plug-ins/gap/gap_decode_xanim.c * plug-ins/gap/gap_filter_foreach.c * plug-ins/gap/gap_filter_main.c * plug-ins/gap/gap_frontends_main.c * plug-ins/gap/gap_lib.c * plug-ins/gap/gap_main.c * plug-ins/gap/gap_mod_layer.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gap/gap_navigator_dialog.c * plug-ins/gap/resize.c: half-way fixed this one too but I'm not willing to fix tons of duplicated and deprecated app/ code...
2001-10-19 16:41:09 +00:00
gdk_colormap_alloc_color(colormap, gdk_color, FALSE, TRUE);
1999-09-07 00:03:20 +00:00
gdk_window_set_background(button->window, gdk_color);
gdk_window_clear(button->window);
}
static void
normal_fg_color_changed(GtkWidget *widget, gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
change_color(param, param->normal_fg, &param->new_colors.normal_fg);
}
static void
normal_bg_color_changed(GtkWidget *widget, gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
change_color(param, param->normal_bg, &param->new_colors.normal_bg);
}
static void
selected_fg_color_changed(GtkWidget *widget, gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
change_color(param, param->selected_fg, &param->new_colors.selected_fg);
}
static void
selected_bg_color_changed(GtkWidget *widget, gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
change_color(param, param->selected_bg, &param->new_colors.selected_bg);
}
static gint
area_event(GtkWidget *widget, GdkEvent *event, PreferencesDialog_t *param,
GdkColor *gdk_color,
void (*color_changed_func)(GtkWidget *widget, gpointer data))
{
gdouble color[3];
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
if (!param->color_sel_dlg) {
2000-02-17 08:36:46 +00:00
GtkWidget *dialog = gtk_color_selection_dialog_new( _("Select Color"));
1999-09-07 00:03:20 +00:00
param->color_sel_dlg = dialog;
param->color_sel = GTK_COLOR_SELECTION_DIALOG(
param->color_sel_dlg)->colorsel;
gtk_signal_connect(GTK_OBJECT(param->color_sel), "color_changed",
(GtkSignalFunc)color_changed, (gpointer) param);
gtk_signal_connect(
GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(dialog)->ok_button),
"clicked", GTK_SIGNAL_FUNC(select_color_ok), (gpointer) param);
gtk_signal_connect(
GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(dialog)->cancel_button),
"clicked", GTK_SIGNAL_FUNC(select_color_cancel), (gpointer) param);
}
_color_changed_func = color_changed_func;
color[0] = (gdouble) gdk_color->red / 65535.0;
color[1] = (gdouble) gdk_color->green / 65535.0;
color[2] = (gdouble) gdk_color->blue / 65535.0;
gtk_color_selection_set_color(GTK_COLOR_SELECTION(param->color_sel), color);
gtk_widget_show(param->color_sel_dlg);
return TRUE;
}
static gint
edit_normal_fg(GtkWidget *widget, GdkEvent *event, PreferencesDialog_t *param)
{
return area_event(widget, event, param, &param->old_data->colors.normal_fg,
normal_fg_color_changed);
}
static gint
edit_normal_bg(GtkWidget *widget, GdkEvent *event, PreferencesDialog_t *param)
{
return area_event(widget, event, param, &param->old_data->colors.normal_bg,
normal_bg_color_changed);
}
static gint
edit_selected_fg(GtkWidget *widget, GdkEvent *event,
PreferencesDialog_t *param)
{
return area_event(widget, event, param,
&param->old_data->colors.selected_fg,
selected_fg_color_changed);
}
static gint
edit_selected_bg(GtkWidget *widget, GdkEvent *event,
PreferencesDialog_t *param)
{
return area_event(widget, event, param,
&param->old_data->colors.selected_bg,
selected_bg_color_changed);
}
static void
create_general_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *table;
GtkWidget *frame;
GtkWidget *hbox;
GSList *group;
GtkWidget *label;
table = gtk_table_new(7, 2, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_widget_show(table);
2000-02-17 08:36:46 +00:00
frame = gtk_frame_new( _("Default Map Type"));
1999-09-07 00:03:20 +00:00
gtk_widget_show(frame);
gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 2, 0, 1);
hbox = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
data->ncsa = gtk_radio_button_new_with_label(NULL, "NCSA");
gtk_box_pack_start(GTK_BOX(hbox), data->ncsa, TRUE, TRUE, 10);
gtk_widget_show(data->ncsa);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(data->ncsa));
data->cern = gtk_radio_button_new_with_label(group, "CERN");
gtk_box_pack_start(GTK_BOX(hbox), data->cern, TRUE, TRUE, 10);
gtk_widget_show(data->cern);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(data->cern));
data->csim = gtk_radio_button_new_with_label(group, "CSIM");
gtk_box_pack_start(GTK_BOX(hbox), data->csim, TRUE, TRUE, 10);
gtk_widget_show(data->csim);
data->prompt_for_area_info =
2000-02-17 08:36:46 +00:00
create_check_button_in_table(table, 1, 0, _("Prompt for area info"));
1999-09-07 00:03:20 +00:00
data->require_default_url =
2000-02-17 08:36:46 +00:00
create_check_button_in_table(table, 2, 0, _("Require default URL"));
1999-09-07 00:03:20 +00:00
data->show_area_handle =
2000-02-17 08:36:46 +00:00
create_check_button_in_table(table, 3, 0, _("Show area handles"));
1999-09-07 00:03:20 +00:00
data->keep_circles_round =
2000-02-17 08:36:46 +00:00
create_check_button_in_table(table, 4, 0, _("Keep NCSA circles true"));
1999-09-07 00:03:20 +00:00
data->show_url_tip =
2000-02-17 08:36:46 +00:00
create_check_button_in_table(table, 5, 0, _("Show area URL tip"));
1999-09-07 00:03:20 +00:00
data->use_doublesized =
create_check_button_in_table(table, 6, 0,
2000-02-17 08:36:46 +00:00
_("Use double-sized grab handles"));
1999-09-07 00:03:20 +00:00
gtk_widget_show(frame);
2000-02-17 08:36:46 +00:00
label = gtk_label_new( _("General"));
1999-09-07 00:03:20 +00:00
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
}
1999-10-24 20:57:17 +00:00
static void
create_menu_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *table;
GtkWidget *label;
GtkWidget *vbox;
vbox = gtk_vbox_new(FALSE, 1);
gtk_widget_show(vbox);
table = gtk_table_new(2, 2, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_widget_show(table);
2000-02-17 08:36:46 +00:00
create_label_in_table(table, 0, 0, _("Number of Undo levels (1 - 99):"));
1999-10-24 20:57:17 +00:00
data->undo_levels = create_spin_button_in_table(table, 0, 1, 1, 1, 99);
2000-02-17 08:36:46 +00:00
create_label_in_table(table, 1, 0, _("Number of MRU entries (1 - 16):"));
1999-10-24 20:57:17 +00:00
data->mru_size = create_spin_button_in_table(table, 1, 1, 1, 1, 16);
2000-02-17 08:36:46 +00:00
label = gtk_label_new( _("Menu"));
1999-10-24 20:57:17 +00:00
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
}
1999-09-07 00:03:20 +00:00
static GtkWidget*
create_color_field(PreferencesDialog_t *data, GtkWidget *table, gint row,
gint col, GtkSignalFunc func)
{
GtkWidget *area = gtk_drawing_area_new();
gtk_drawing_area_size(GTK_DRAWING_AREA(area), 16, 8);
gtk_widget_set_events(area, GDK_BUTTON_PRESS_MASK);
gtk_table_attach_defaults(GTK_TABLE(table), area, col, col + 1, row,
row + 1);
gtk_signal_connect(GTK_OBJECT(area), "event", func, (gpointer) data);
gtk_widget_show(area);
return area;
}
static void
create_colors_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *table, *label;
GtkWidget *vbox;
vbox = gtk_vbox_new(FALSE, 1);
gtk_widget_show(vbox);
table = gtk_table_new(2, 3, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_widget_show(table);
2000-02-17 08:36:46 +00:00
create_label_in_table(table, 0, 0, _("Normal:"));
1999-09-07 00:03:20 +00:00
data->normal_fg = create_color_field(data, table, 0, 1,
(GtkSignalFunc) edit_normal_fg);
data->normal_bg = create_color_field(data, table, 0, 2,
(GtkSignalFunc) edit_normal_bg);
2000-02-17 08:36:46 +00:00
create_label_in_table(table, 1, 0, _("Selected:"));
1999-09-07 00:03:20 +00:00
data->selected_fg = create_color_field(data, table, 1, 1,
(GtkSignalFunc) edit_selected_fg);
data->selected_bg = create_color_field(data, table, 1, 2,
(GtkSignalFunc) edit_selected_bg);
2000-02-17 08:36:46 +00:00
label = gtk_label_new( _("Colors"));
1999-09-07 00:03:20 +00:00
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
}
static void
switch_page(GtkWidget *widget, GtkNotebookPage *page, gint page_num,
gpointer data)
{
1999-10-24 20:57:17 +00:00
if (page_num == 2) {
1999-09-07 00:03:20 +00:00
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
set_button_colors(param, &param->old_colors);
}
}
static PreferencesDialog_t*
create_preferences_dialog()
{
PreferencesDialog_t *data = g_new(PreferencesDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *notebook;
data->color_sel_dlg = NULL;
2000-02-17 08:36:46 +00:00
data->dialog = dialog = make_default_dialog( _("General Preferences"));
1999-09-07 00:03:20 +00:00
default_dialog_set_ok_cb(dialog, preferences_ok_cb, (gpointer) data);
data->notebook = notebook = gtk_notebook_new();
gtk_container_set_border_width(GTK_CONTAINER(notebook), 10);
gtk_signal_connect_after(GTK_OBJECT(notebook), "switch_page",
GTK_SIGNAL_FUNC(switch_page), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox),
notebook, TRUE, TRUE, 10);
create_general_tab(data, notebook);
1999-10-24 20:57:17 +00:00
create_menu_tab(data, notebook);
1999-09-07 00:03:20 +00:00
create_colors_tab(data, notebook);
gtk_widget_show(notebook);
return data;
}
void
do_preferences_dialog(void)
{
static PreferencesDialog_t *dialog;
PreferencesData_t *old_data;
GtkWidget *map_type;
if (!dialog) {
dialog = create_preferences_dialog();
}
need to link with pangof2 2001-09-22 Hans Breuer <hans@breuer.org> * app/makefile.msc : need to link with pangof2 * app/display/display-funcs.h : new file to provide prototype gdisplays_selection_visibility () * app/core/gimpimage-mask.c : * app/core/gimplayer.c : use it * app/core/makefile.msc : generate gimpmarshal.[hc] * app/gui/makefile.msc : add error-console-dialog.obj, also more trying for building as dll * app/tools/gimpinktool.c(965) : avoid "fatal error C1021: invalid preprocessor command 'warning'", by wrapping it in #ifdef __GNUC__ * app/tools/makefile.msc : add FREETYPE2_CFLAGS * app/widgets/gimpfontselction-dialog.c : use g_strcasecmp () * app/tools/makefile.msc : add FREETYPE2_CFLAGS and gimpfontselction* * libgimp/gimp.def : * libgimpwidgets/gimpwidgets.def : updated externals * libgimpwidgets/makefile.msc : add gimpstock * plug-ins/makefile.msc : gflare doesn't require EXTRA_gflare anymore * plug-ins/common/spheredesigner.c : * plug-ins/helpbrowser/helpbrowser.c : * plug-ins/imagemap/imap_main.c : remove _help_accel from gimp_help_connect () * plug-ins/gap/gap_mov_dialog.c : * plug-ins/gap/gap_navigator_dialog.c : remove references to use_xshm and gimp_color_cube () * plug-ins/gfig/gfig.c : don't access ->klass, but use G_OBJECT_GET_CLASS * plug-ins/gimpressionist/repaint.c : the GtkButton::child field is moved to the parent GtkBin. * plug-ins/ifscompose/ifscompose.c : the GtkStyle::font field isn't public anymore, use accessor gtk_style_get_font () * plug-ins/imagemap/imap_preferences.c : reflect GTK2 API change gtk_notebook_set_current_page ()
2001-09-22 19:47:27 +00:00
gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog->notebook), 0);
1999-09-07 00:03:20 +00:00
dialog->old_data = old_data = get_preferences();
dialog->new_colors = dialog->old_colors = old_data->colors;
if (old_data->default_map_type == CERN)
map_type = dialog->cern;
else if (old_data->default_map_type == NCSA)
map_type = dialog->ncsa;
else
map_type = dialog->csim;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(map_type), TRUE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(dialog->prompt_for_area_info),
old_data->prompt_for_area_info);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->require_default_url),
old_data->require_default_url);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->show_area_handle),
old_data->show_area_handle);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->keep_circles_round),
old_data->keep_circles_round);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->show_url_tip),
old_data->show_url_tip);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->use_doublesized),
old_data->use_doublesized);
1999-10-24 20:57:17 +00:00
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->undo_levels),
old_data->undo_levels);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->mru_size),
old_data->mru_size);
1999-09-07 00:03:20 +00:00
default_dialog_show(dialog->dialog);
}