gimp/plug-ins/gimpressionist/presets.c

705 lines
21 KiB
C
Raw Normal View History

1999-08-26 22:29:37 +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
1999-08-26 22:29:37 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
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 <libgimp/gimp.h>
#include <libgimp/gimpui.h>
1999-08-26 22:29:37 +00:00
#include "gimpressionist.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 "libgimp/stdplugins-intl.h"
1999-08-26 22:29:37 +00:00
GtkWidget *presetnameentry = NULL;
GtkWidget *presetsavebutton = NULL;
static GtkWidget *presetlist = NULL;
1999-08-26 22:29:37 +00:00
GtkWidget *presetdesctext = NULL;
GtkWidget *presetdesclabel = NULL;
static GtkListStore *store;
1999-08-26 22:29:37 +00:00
2002-12-10 10:39:23 +00:00
static char presetdesc[4096] = "";
1999-08-26 22:29:37 +00:00
2002-12-10 10:39:23 +00:00
static char *factory_defaults = "<Factory defaults>";
1999-08-26 22:29:37 +00:00
static void addfactorydefaults(GtkListStore *store)
1999-08-26 22:29:37 +00:00
{
GtkTreeIter iter;
1999-08-26 22:29:37 +00:00
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, factory_defaults, -1);
}
1999-08-26 22:29:37 +00:00
static void presetsrefresh(void)
{
gtk_list_store_clear (store);
addfactorydefaults (store);
readdirintolist ("Presets", presetlist, NULL);
1999-08-26 22:29:37 +00:00
}
#define PRESETMAGIC "Preset"
2002-12-10 10:39:23 +00:00
static int loadoldpreset(char *fname)
1999-08-26 22:29:37 +00:00
{
FILE *f;
int len;
f = fopen(fname, "rb");
if(!f) {
fprintf(stderr, "Error opening file \"%s\" for reading!%c\n", fname, 7);
1999-08-26 22:29:37 +00:00
return -1;
}
len = fread(&pcvals, 1, sizeof(pcvals), f);
fclose(f);
return 0;
}
static void chop(char *buffer)
1999-08-26 22:29:37 +00:00
{
while(strlen(buffer) && buffer[strlen(buffer)-1] <= ' ')
buffer[strlen(buffer)-1] = '\0';
}
static unsigned int hexval(char c)
1999-08-26 22:29:37 +00:00
{
c = g_ascii_tolower (c);
1999-08-26 22:29:37 +00:00
if((c >= 'a') && (c <= 'f')) return c - 'a' + 10;
if((c >= '0') && (c <= '9')) return c - '0';
return 0;
}
static char *parsergbstring(char *s)
1999-08-26 22:29:37 +00:00
{
static char col[3];
col[0] = (hexval(s[0]) << 4) | hexval(s[1]);
col[1] = (hexval(s[2]) << 4) | hexval(s[3]);
col[2] = (hexval(s[4]) << 4) | hexval(s[5]);
return col;
}
static void setorientvector(char *str)
1999-08-26 22:29:37 +00:00
{
char *tmps = str;
int n;
n = atoi(tmps);
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].x = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].y = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].dir = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].dx = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].dy = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].str = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.orientvector[n].type = atoi (++tmps);
1999-08-26 22:29:37 +00:00
}
static void setsizevector(char *str)
1999-08-26 22:29:37 +00:00
{
char *tmps = str;
int n;
n = atoi(tmps);
if(!(tmps = strchr(tmps, ','))) return;
pcvals.sizevector[n].x = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.sizevector[n].y = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.sizevector[n].siz = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
if(!(tmps = strchr(tmps, ','))) return;
pcvals.sizevector[n].str = g_ascii_strtod (++tmps, NULL);
1999-08-26 22:29:37 +00:00
}
static void parsedesc(char *str, char *d, gssize d_len)
1999-08-26 22:29:37 +00:00
{
2002-12-12 20:11:24 +00:00
gchar *dest = g_strcompress (str);
g_strlcpy (d, dest, d_len);
2002-12-12 20:11:24 +00:00
g_free (dest);
1999-08-26 22:29:37 +00:00
}
2002-12-10 10:39:23 +00:00
static void setval(char *key, char *val)
1999-08-26 22:29:37 +00:00
{
if(!strcmp(key, "desc"))
parsedesc(val, presetdesc, sizeof (presetdesc));
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "orientnum"))
pcvals.orientnum = atoi(val);
else if(!strcmp(key, "orientfirst"))
pcvals.orientfirst = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "orientlast"))
pcvals.orientlast = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "orienttype"))
pcvals.orienttype = atoi(val);
else if(!strcmp(key, "sizenum"))
pcvals.sizenum = atoi(val);
else if(!strcmp(key, "sizefirst"))
pcvals.sizefirst = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "sizelast"))
pcvals.sizelast = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "sizetype"))
pcvals.sizetype = atoi(val);
else if(!strcmp(key, "brushrelief"))
pcvals.brushrelief = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "brushscale")) {
/* For compatibility */
pcvals.sizenum = 1;
pcvals.sizefirst = pcvals.sizelast = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
}
else if(!strcmp(key, "brushdensity"))
pcvals.brushdensity = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "brushgamma"))
pcvals.brushgamma = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "brushaspect"))
pcvals.brushaspect = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "generalbgtype"))
pcvals.generalbgtype = atoi(val);
else if(!strcmp(key, "generaldarkedge"))
pcvals.generaldarkedge = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "generalpaintedges"))
pcvals.generalpaintedges = atoi(val);
else if(!strcmp(key, "generaltileable"))
pcvals.generaltileable = atoi(val);
else if(!strcmp(key, "generaldropshadow"))
pcvals.generaldropshadow = atoi(val);
else if(!strcmp(key, "generalshadowdarkness"))
pcvals.generalshadowdarkness = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "generalshadowdepth"))
pcvals.generalshadowdepth = atoi(val);
else if(!strcmp(key, "generalshadowblur"))
pcvals.generalshadowblur = atoi(val);
else if(!strcmp(key, "devthresh"))
pcvals.devthresh = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "paperrelief"))
pcvals.paperrelief = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "paperscale"))
pcvals.paperscale = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "paperinvert"))
pcvals.paperinvert = atoi(val);
else if(!strcmp(key, "paperoverlay"))
pcvals.paperoverlay = atoi(val);
else if(!strcmp(key, "placetype"))
pcvals.placetype = atoi(val);
else if(!strcmp(key, "placecenter"))
pcvals.placecenter = atoi(val);
else if(!strcmp(key, "selectedbrush"))
g_strlcpy (pcvals.selectedbrush, val, sizeof (pcvals.selectedbrush));
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "selectedpaper"))
g_strlcpy (pcvals.selectedpaper, val, sizeof (pcvals.selectedpaper));
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "color")){
char *c = parsergbstring(val);
gimp_rgba_set_uchar(&pcvals.color, c[0], c[1], c[2], 255);
}
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "numorientvector"))
pcvals.numorientvector = atoi(val);
else if(!strcmp(key, "orientvector"))
setorientvector(val);
else if(!strcmp(key, "orientangoff"))
pcvals.orientangoff = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "orientstrexp"))
pcvals.orientstrexp = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "orientvoronoi"))
pcvals.orientvoronoi = atoi(val);
else if(!strcmp(key, "numsizevector"))
pcvals.numsizevector = atoi(val);
else if(!strcmp(key, "sizevector"))
setsizevector(val);
else if(!strcmp(key, "sizestrexp"))
pcvals.sizestrexp = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
else if(!strcmp(key, "sizevoronoi"))
pcvals.sizevoronoi = atoi(val);
else if(!strcmp(key, "colortype"))
pcvals.colortype = atoi(val);
else if(!strcmp(key, "colornoise"))
pcvals.colornoise = g_ascii_strtod (val, NULL);
1999-08-26 22:29:37 +00:00
}
2002-12-10 10:39:23 +00:00
static int loadpreset(char *fn)
1999-08-26 22:29:37 +00:00
{
char line[1024] = "";
FILE *f;
f = fopen(fn, "rt");
if(!f) {
fprintf(stderr, "Error opening file \"%s\" for reading!\n", fn);
1999-08-26 22:29:37 +00:00
return -1;
}
fgets(line,10,f);
if(strncmp(line,PRESETMAGIC,4)) {
fclose(f);
return loadoldpreset(fn);
}
2002-12-10 10:39:23 +00:00
pcvals = defaultpcvals;
1999-08-26 22:29:37 +00:00
while(!feof(f)) {
char *tmps;
if(!fgets(line,1024,f)) break;
chop(line);
tmps = strchr(line, '=');
if(!tmps) continue;
*tmps = '\0';
tmps++;
setval(line, tmps);
}
fclose(f);
return 0;
}
static void applypreset(GtkWidget *w, GtkTreeSelection *selection)
1999-08-26 22:29:37 +00:00
{
GtkTreeIter iter;
GtkTreeModel *model;
1999-08-26 22:29:37 +00:00
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gchar *preset;
1999-08-26 22:29:37 +00:00
gtk_tree_model_get (model, &iter, 0, &preset, -1);
if (strcmp (preset, factory_defaults))
{
gchar *rel = g_build_filename ("Presets", preset, NULL);
gchar *abs = findfile (rel);
g_free (rel);
if (abs)
{
loadpreset (abs);
g_free (abs);
}
}
restorevals ();
g_free (preset);
}
1999-08-26 22:29:37 +00:00
}
static void deletepreset(GtkWidget *w, GtkTreeSelection *selection)
1999-08-26 22:29:37 +00:00
{
GtkTreeIter iter;
GtkTreeModel *model;
1999-08-26 22:29:37 +00:00
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gchar *preset;
1999-08-26 22:29:37 +00:00
gtk_tree_model_get (model, &iter, 0, &preset, -1);
1999-08-26 22:29:37 +00:00
if (preset)
{
gchar *rel = g_build_filename ("Presets", preset, NULL);
gchar *abs = findfile (rel);
g_free (rel);
if (abs)
{
unlink (abs);
g_free (abs);
}
presetsrefresh ();
g_free (preset);
}
}
1999-08-26 22:29:37 +00:00
}
2002-12-12 20:11:24 +00:00
static void savepreset(void);
1999-08-26 22:29:37 +00:00
2002-12-12 20:11:24 +00:00
static void presetdesccallback(GtkTextBuffer *buffer, gpointer data)
1999-08-26 22:29:37 +00:00
{
2002-12-12 20:11:24 +00:00
char *dest, *str;
GtkTextIter start, end;
gtk_text_buffer_get_bounds (buffer, &start, &end);
str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
2002-12-12 20:11:24 +00:00
dest = g_strescape (str, NULL);
g_strlcpy (presetdesc, dest, sizeof (presetdesc));
2002-12-12 20:11:24 +00:00
g_free (dest);
g_free (str);
1999-08-26 22:29:37 +00:00
}
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
static void
savepresetresponse (GtkWidget *widget,
gint response_id,
gpointer data)
1999-08-26 22:29:37 +00:00
{
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
gtk_widget_destroy (widget);
if (response_id == GTK_RESPONSE_OK)
savepreset ();
1999-08-26 22:29:37 +00:00
}
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
static void
create_savepreset (void)
1999-08-26 22:29:37 +00:00
{
static GtkWidget *window = NULL;
GtkWidget *box, *label;
2002-12-12 20:11:24 +00:00
GtkWidget *swin, *text;
GtkTextBuffer *buffer;
1999-08-26 22:29:37 +00:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
if (window)
{
gtk_window_present (GTK_WINDOW (window));
return;
}
window =
2002-12-10 10:39:23 +00:00
gimp_dialog_new (_("Save Current"), "gimpressionist",
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
NULL, 0,
gimp_standard_help_func, HELP_ID,
2002-12-10 10:39:23 +00:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
1999-08-26 22:29:37 +00:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
NULL);
1999-08-26 22:29:37 +00:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
g_signal_connect (window, "response",
G_CALLBACK (savepresetresponse),
NULL);
g_signal_connect (window, "destroy",
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 15:27:05 +00:00
G_CALLBACK (gtk_widget_destroyed),
&window);
2002-12-10 10:39:23 +00:00
box = gtk_vbox_new(FALSE, 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (window)->vbox), box);
gtk_widget_show (box);
1999-08-26 22:29:37 +00:00
label = gtk_label_new( _("Description:"));
2002-12-12 20:11:24 +00:00
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
1999-08-26 22:29:37 +00:00
gtk_widget_show (label);
2002-12-12 20:11:24 +00:00
swin = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(swin),
GTK_SHADOW_IN);
2002-12-12 20:11:24 +00:00
gtk_container_add (GTK_CONTAINER(box), swin);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(swin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show (swin);
1999-08-26 22:29:37 +00:00
2002-12-12 20:11:24 +00:00
buffer = gtk_text_buffer_new (NULL);
g_signal_connect (buffer, "changed",
2002-12-12 20:11:24 +00:00
G_CALLBACK (presetdesccallback), NULL);
gtk_text_buffer_set_text (buffer, presetdesc, -1);
2002-12-12 20:11:24 +00:00
text = gtk_text_view_new_with_buffer (buffer);
gtk_widget_set_size_request (text, -1, 192);
gtk_container_add (GTK_CONTAINER(swin), text);
gtk_widget_show (text);
1999-08-26 22:29:37 +00:00
gtk_widget_show (window);
}
2002-12-12 20:11:24 +00:00
static void savepreset(void)
1999-08-26 22:29:37 +00:00
{
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
const gchar *l;
gchar *fname;
FILE *f;
1999-08-26 22:29:37 +00:00
GList *thispath;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gchar vbuf[6][G_ASCII_DTOSTR_BUF_SIZE];
guchar color[3];
gint i;
1999-08-26 22:29:37 +00:00
l = gtk_entry_get_text (GTK_ENTRY (presetnameentry));
thispath = parsepath ();
storevals ();
1999-08-26 22:29:37 +00:00
if (!thispath)
{
g_printerr ("Internal error: (savepreset) thispath == NULL");
return;
}
1999-08-26 22:29:37 +00:00
fname = g_build_filename ((char *)thispath->data, "Presets", l, NULL);
f = fopen (fname, "wt");
if (!f)
{
g_printerr ("Error opening file \"%s\" for writing!%c\n", fname, 7);
return;
}
1999-08-26 22:29:37 +00:00
fprintf(f, "%s\n", PRESETMAGIC);
fprintf(f, "desc=%s\n", presetdesc);
fprintf(f, "orientnum=%d\n", pcvals.orientnum);
fprintf(f, "orientfirst=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientfirst));
fprintf(f, "orientlast=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientlast));
1999-08-26 22:29:37 +00:00
fprintf(f, "orienttype=%d\n", pcvals.orienttype);
fprintf(f, "sizenum=%d\n", pcvals.sizenum);
fprintf(f, "sizefirst=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizefirst));
fprintf(f, "sizelast=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizelast));
1999-08-26 22:29:37 +00:00
fprintf(f, "sizetype=%d\n", pcvals.sizetype);
fprintf(f, "brushrelief=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brushrelief));
fprintf(f, "brushdensity=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brushdensity));
fprintf(f, "brushgamma=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brushgamma));
fprintf(f, "brushaspect=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.brushaspect));
1999-08-26 22:29:37 +00:00
fprintf(f, "generalbgtype=%d\n", pcvals.generalbgtype);
fprintf(f, "generaldarkedge=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.generaldarkedge));
1999-08-26 22:29:37 +00:00
fprintf(f, "generalpaintedges=%d\n", pcvals.generalpaintedges);
fprintf(f, "generaltileable=%d\n", pcvals.generaltileable);
fprintf(f, "generaldropshadow=%d\n", pcvals.generaldropshadow);
fprintf(f, "generalshadowdarkness=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.generalshadowdarkness));
1999-08-26 22:29:37 +00:00
fprintf(f, "generalshadowdepth=%d\n", pcvals.generalshadowdepth);
fprintf(f, "generalshadowblur=%d\n", pcvals.generalshadowblur);
fprintf(f, "devthresh=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.devthresh));
1999-08-26 22:29:37 +00:00
fprintf(f, "paperrelief=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.paperrelief));
fprintf(f, "paperscale=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.paperscale));
1999-08-26 22:29:37 +00:00
fprintf(f, "paperinvert=%d\n", pcvals.paperinvert);
fprintf(f, "paperoverlay=%d\n", pcvals.paperoverlay);
fprintf(f, "selectedbrush=%s\n", pcvals.selectedbrush);
fprintf(f, "selectedpaper=%s\n", pcvals.selectedpaper);
gimp_rgb_get_uchar(&pcvals.color, &color[0], &color[1], &color[2]);
fprintf(f, "color=%02x%02x%02x\n", color[0], color[1], color[2]);
1999-08-26 22:29:37 +00:00
fprintf(f, "placetype=%d\n", pcvals.placetype);
fprintf(f, "placecenter=%d\n", pcvals.placecenter);
fprintf(f, "numorientvector=%d\n", pcvals.numorientvector);
for(i = 0; i < pcvals.numorientvector; i++)
{
g_ascii_formatd (vbuf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientvector[i].x);
g_ascii_formatd (vbuf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientvector[i].y);
g_ascii_formatd (vbuf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientvector[i].dir);
g_ascii_formatd (vbuf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientvector[i].dx);
g_ascii_formatd (vbuf[4], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientvector[i].dy);
g_ascii_formatd (vbuf[5], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientvector[i].str);
fprintf (f, "orientvector=%d,%s,%s,%s,%s,%s,%s,%d\n", i,
vbuf[0], vbuf[1], vbuf[2], vbuf[3], vbuf[4], vbuf[5],
pcvals.orientvector[i].type);
}
fprintf(f, "orientangoff=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientangoff));
fprintf(f, "orientstrexp=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientstrexp));
1999-08-26 22:29:37 +00:00
fprintf(f, "orientvoronoi=%d\n", pcvals.orientvoronoi);
fprintf(f, "numsizevector=%d\n", pcvals.numsizevector);
for (i = 0; i < pcvals.numsizevector; i++)
{
g_ascii_formatd (vbuf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizevector[i].x);
g_ascii_formatd (vbuf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizevector[i].y);
g_ascii_formatd (vbuf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizevector[i].siz);
g_ascii_formatd (vbuf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizevector[i].str);
fprintf (f, "sizevector=%d,%s,%s,%s,%s\n", i,
vbuf[0], vbuf[1], vbuf[2], vbuf[3]);
}
fprintf(f, "sizestrexp=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.sizestrexp));
1999-08-26 22:29:37 +00:00
fprintf(f, "sizevoronoi=%d\n", pcvals.sizevoronoi);
fprintf(f, "colortype=%d\n", pcvals.colortype);
fprintf(f, "colornoise=%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.colornoise));
fclose (f);
presetsrefresh ();
reselect (presetlist, fname);
g_free (fname);
1999-08-26 22:29:37 +00:00
}
static void readdesc(const char *fn)
1999-08-26 22:29:37 +00:00
{
char *tmp;
char *fname;
1999-08-26 22:29:37 +00:00
FILE *f;
fname = g_build_filename ("Presets", fn, NULL);
tmp = findfile (fname);
g_free (fname);
if (!tmp)
{
gtk_label_set_text (GTK_LABEL (presetdesclabel), "");
return;
}
fname = tmp;
1999-08-26 22:29:37 +00:00
f = fopen(fname, "rt");
if (f)
{
char line[4096];
char tmplabel[4096];
while(!feof(f))
{
fgets(line, 4095, f);
if (!strncmp (line, "desc=", 5))
{
parsedesc (line + 5, tmplabel, sizeof (tmplabel));
gtk_label_set_text (GTK_LABEL (presetdesclabel), tmplabel);
fclose (f);
return;
}
}
fclose (f);
1999-08-26 22:29:37 +00:00
}
gtk_label_set_text (GTK_LABEL (presetdesclabel), "");
1999-08-26 22:29:37 +00:00
}
static void selectpreset(GtkTreeSelection *selection, gpointer data)
1999-08-26 22:29:37 +00:00
{
GtkTreeIter iter;
GtkTreeModel *model;
1999-08-26 22:29:37 +00:00
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gchar *preset;
1999-08-26 22:29:37 +00:00
gtk_tree_model_get (model, &iter, 0, &preset, -1);
if(strcmp(preset, factory_defaults))
gtk_entry_set_text (GTK_ENTRY(presetnameentry), preset);
readdesc (preset);
g_free (preset);
}
1999-08-26 22:29:37 +00:00
}
void create_presetpage(GtkNotebook *notebook)
{
2002-12-12 20:11:24 +00:00
GtkWidget *box1, *box2, *hbox, *vbox, *thispage;
GtkWidget *view;
1999-08-26 22:29:37 +00:00
GtkWidget *tmpw;
GtkWidget *label;
GtkTreeSelection *selection;
1999-08-26 22:29:37 +00:00
label = gtk_label_new_with_mnemonic (_("_Presets"));
1999-08-26 22:29:37 +00:00
thispage = gtk_vbox_new(FALSE, 0);
2000-08-30 08:20:24 +00:00
gtk_container_set_border_width (GTK_CONTAINER (thispage), 5);
1999-08-26 22:29:37 +00:00
gtk_widget_show(thispage);
box1 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start(GTK_BOX(thispage), box1, FALSE, FALSE, 0);
gtk_widget_show (box1);
presetnameentry = tmpw = gtk_entry_new();
gtk_box_pack_start (GTK_BOX (box1), tmpw, FALSE, FALSE, 0);
gtk_widget_set_size_request(tmpw, 150, -1);
1999-08-26 22:29:37 +00:00
gtk_widget_show(tmpw);
presetsavebutton = tmpw = gtk_button_new_with_label( _("Save current..."));
gtk_box_pack_start(GTK_BOX(box1), tmpw, FALSE, FALSE, 5);
1999-08-26 22:29:37 +00:00
gtk_widget_show (tmpw);
g_signal_connect (tmpw, "clicked", G_CALLBACK(create_savepreset), NULL);
gimp_help_set_help_data
(tmpw, _("Save the current settings to the specified file"), NULL);
1999-08-26 22:29:37 +00:00
box1 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start(GTK_BOX(thispage), box1, TRUE, TRUE, 0);
gtk_widget_show (box1);
presetlist = view = createonecolumnlist (box1, selectpreset);
store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
addfactorydefaults (store);
1999-08-26 22:29:37 +00:00
2002-12-12 20:11:24 +00:00
vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start(GTK_BOX(box1), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE,0);
gtk_widget_show (hbox);
1999-08-26 22:29:37 +00:00
box2 = gtk_vbox_new (FALSE, 0);
2002-12-12 20:11:24 +00:00
gtk_box_pack_start(GTK_BOX(hbox), box2, FALSE, FALSE, 5);
1999-08-26 22:29:37 +00:00
gtk_widget_show (box2);
2002-12-10 10:39:23 +00:00
tmpw = gtk_button_new_from_stock (GTK_STOCK_APPLY);
gtk_box_pack_start(GTK_BOX(box2), tmpw, FALSE, FALSE, 0);
1999-08-26 22:29:37 +00:00
gtk_widget_show (tmpw);
g_signal_connect (tmpw, "clicked", G_CALLBACK(applypreset), selection);
gimp_help_set_help_data
(tmpw, _("Reads the selected Preset into memory"), NULL);
1999-08-26 22:29:37 +00:00
2002-12-10 10:39:23 +00:00
tmpw = gtk_button_new_from_stock (GTK_STOCK_DELETE);
1999-08-26 22:29:37 +00:00
gtk_box_pack_start(GTK_BOX(box2), tmpw, FALSE, FALSE,0);
gtk_widget_show (tmpw);
g_signal_connect (tmpw, "clicked", G_CALLBACK(deletepreset), selection);
gimp_help_set_help_data (tmpw, _("Deletes the selected Preset"), NULL);
1999-08-26 22:29:37 +00:00
2002-12-10 10:39:23 +00:00
tmpw = gtk_button_new_from_stock (GTK_STOCK_REFRESH);
1999-08-26 22:29:37 +00:00
gtk_box_pack_start(GTK_BOX(box2), tmpw, FALSE, FALSE,0);
gtk_widget_show (tmpw);
g_signal_connect (tmpw, "clicked", G_CALLBACK(presetsrefresh), NULL);
gimp_help_set_help_data (tmpw, _("Reread the folder of Presets"), NULL);
1999-08-26 22:29:37 +00:00
2002-12-12 20:11:24 +00:00
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE,0);
gtk_widget_show (hbox);
presetdesclabel = tmpw = gtk_label_new( _("(Desc)"));
2002-12-12 20:11:24 +00:00
gtk_box_pack_start(GTK_BOX(hbox), tmpw, FALSE, FALSE, 0);
1999-08-26 22:29:37 +00:00
gtk_widget_show(tmpw);
tmpw = gtk_label_new( _("\nIf you come up with some nice Presets,\n\
1999-08-26 22:29:37 +00:00
(or Brushes and Papers for that matter)\n\
feel free to send them to me <vidar@prosalg.no>\n\
for inclusion into the next release!\n"));
1999-08-26 22:29:37 +00:00
gtk_box_pack_start(GTK_BOX(thispage), tmpw, FALSE, FALSE, 0);
gtk_widget_show(tmpw);
readdirintolist("Presets", view, NULL);
gtk_notebook_append_page_menu (notebook, thispage, label, NULL);
1999-08-26 22:29:37 +00:00
}