mirror of https://github.com/GNOME/gimp.git
applied patch from Shlomi Fish that fixes a number of bugs in the
2004-07-05 Sven Neumann <sven@gimp.org> * plug-ins/gimpressionist: applied patch from Shlomi Fish that fixes a number of bugs in the gimpressionst plug-in (bug #145309). Also added some const qualifiers, cleaned up includes and removed degtorad() and radtodeg() functions that used to duplicate functionality from libgimpmath.
This commit is contained in:
parent
49a46c76a0
commit
afe4ff8290
|
@ -1,3 +1,12 @@
|
|||
2004-07-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/gimpressionist: applied patch from Shlomi Fish that
|
||||
fixes a number of bugs in the gimpressionst plug-in (bug #145309).
|
||||
|
||||
Also added some const qualifiers, cleaned up includes and removed
|
||||
degtorad() and radtodeg() functions that used to duplicate
|
||||
functionality from libgimpmath.
|
||||
|
||||
2004-07-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimptemplateview.c
|
||||
|
|
|
@ -28,10 +28,11 @@ libexec_PROGRAMS = gimpressionist
|
|||
|
||||
gimpressionist_sources = \
|
||||
brush.c \
|
||||
color.h \
|
||||
brush.h \
|
||||
color.c \
|
||||
general.h \
|
||||
color.h \
|
||||
general.c \
|
||||
general.h \
|
||||
gimp.c \
|
||||
gimpressionist.c \
|
||||
gimpressionist.h \
|
||||
|
@ -39,8 +40,8 @@ gimpressionist_sources = \
|
|||
orientation.c \
|
||||
orientmap.c \
|
||||
paper.c \
|
||||
placement.h \
|
||||
placement.c \
|
||||
placement.h \
|
||||
plasma.c \
|
||||
ppmtool.c \
|
||||
ppmtool.h \
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
|
@ -24,6 +18,7 @@
|
|||
|
||||
#include "gimpressionist.h"
|
||||
#include "ppmtool.h"
|
||||
#include "brush.h"
|
||||
|
||||
#include <libgimp/stdplugins-intl.h>
|
||||
|
||||
|
@ -38,6 +33,8 @@ static GtkObject *brushreliefadjust = NULL;
|
|||
static GtkObject *brushaspectadjust = NULL;
|
||||
static GtkObject *brushgammaadjust = NULL;
|
||||
|
||||
static gchar *last_selected_brush = NULL;
|
||||
|
||||
void brush_restore(void)
|
||||
{
|
||||
reselect (brushlist, pcvals.selectedbrush);
|
||||
|
@ -51,6 +48,11 @@ void brush_store(void)
|
|||
pcvals.brushgamma = GTK_ADJUSTMENT(brushgammaadjust)->value;
|
||||
}
|
||||
|
||||
void brush_free(void)
|
||||
{
|
||||
g_free (last_selected_brush);
|
||||
}
|
||||
|
||||
static void updatebrushprev (const char *fn);
|
||||
|
||||
static gboolean file_is_color (const char *fn)
|
||||
|
@ -339,22 +341,41 @@ selectbrush (GtkTreeSelection *selection, gpointer data)
|
|||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
gchar *fname = NULL;
|
||||
gchar *brush = NULL;
|
||||
|
||||
if (brushdontupdate)
|
||||
return;
|
||||
goto cleanup;
|
||||
|
||||
if (brushfile == 0)
|
||||
{
|
||||
updatebrushprev (NULL);
|
||||
return;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
{
|
||||
gchar *brush;
|
||||
|
||||
gtk_tree_model_get (model, &iter, 0, &brush, -1);
|
||||
|
||||
/* Check if the same brush was selected twice, and if so
|
||||
* break. Otherwise, the brush gamma and stuff would have been
|
||||
* reset.
|
||||
* */
|
||||
if (last_selected_brush == NULL)
|
||||
{
|
||||
last_selected_brush = g_strdup(brush);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strcmp (last_selected_brush, brush))
|
||||
goto cleanup;
|
||||
else
|
||||
{
|
||||
g_free (last_selected_brush);
|
||||
last_selected_brush = g_strdup(brush);
|
||||
}
|
||||
}
|
||||
|
||||
brushdontupdate = TRUE;
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(brushgammaadjust), 1.0);
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(brushaspectadjust), 0.0);
|
||||
|
@ -362,17 +383,20 @@ selectbrush (GtkTreeSelection *selection, gpointer data)
|
|||
|
||||
if (brush)
|
||||
{
|
||||
gchar *fname = g_build_filename ("Brushes", brush, NULL);
|
||||
fname = g_build_filename ("Brushes", brush, NULL);
|
||||
|
||||
g_strlcpy (pcvals.selectedbrush,
|
||||
fname, sizeof (pcvals.selectedbrush));
|
||||
|
||||
updatebrushprev (fname);
|
||||
|
||||
g_free (fname);
|
||||
g_free (brush);
|
||||
}
|
||||
}
|
||||
cleanup:
|
||||
g_free (fname);
|
||||
g_free (brush);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -517,5 +541,11 @@ create_brushpage(GtkNotebook *notebook)
|
|||
selectbrush(selection, NULL);
|
||||
readdirintolist("Brushes", view, pcvals.selectedbrush);
|
||||
|
||||
/*
|
||||
* This is so the "changed signal won't get sent to the brushes' list
|
||||
* and reset the gamma and stuff.
|
||||
* */
|
||||
gtk_widget_grab_focus (brushlist);
|
||||
|
||||
gtk_notebook_append_page_menu (notebook, thispage, label, NULL);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef __BRUSH_H
|
||||
#define __BRUSH_H
|
||||
|
||||
void brush_store(void);
|
||||
void brush_restore(void);
|
||||
void brush_free(void);
|
||||
|
||||
#endif /* #ifndef __BRUSH_H */
|
|
@ -1,9 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -22,10 +18,8 @@ static GtkWidget *colorradio[NUMCOLORRADIO];
|
|||
|
||||
void color_type_restore(void)
|
||||
{
|
||||
gtk_toggle_button_set_active (
|
||||
GTK_TOGGLE_BUTTON(colorradio[pcvals.colortype]),
|
||||
TRUE
|
||||
);
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON(colorradio[pcvals.colortype]), TRUE);
|
||||
}
|
||||
|
||||
void create_colorpage(GtkNotebook *notebook)
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -12,6 +9,7 @@
|
|||
#include "ppmtool.h"
|
||||
#include "gimpressionist.h"
|
||||
#include "preview.h"
|
||||
#include "brush.h"
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
@ -80,7 +78,7 @@ run (const gchar *name,
|
|||
GimpRunMode run_mode;
|
||||
GimpPDBStatusType status;
|
||||
gboolean with_specified_preset;
|
||||
gchar *preset_name;
|
||||
gchar *preset_name = NULL;
|
||||
|
||||
status = GIMP_PDB_SUCCESS;
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
@ -119,7 +117,7 @@ run (const gchar *name,
|
|||
* */
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
gimpressionist_get_data();
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
{
|
||||
|
@ -178,6 +176,7 @@ run (const gchar *name,
|
|||
free_parsepath_cache();
|
||||
reloadbrush(NULL, NULL);
|
||||
preview_free_resources();
|
||||
brush_free();
|
||||
|
||||
values[0].data.d_status = status;
|
||||
|
||||
|
@ -201,7 +200,7 @@ void grabarea(void)
|
|||
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
alpha = (has_alpha) ? bpp - 1 : bpp;
|
||||
|
||||
|
||||
newppm(&infile, x2-x1, y2-y1);
|
||||
p = &infile;
|
||||
if(has_alpha) {
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
|
||||
#include "gimpressionist.h"
|
||||
/*
|
||||
* The Page Specific Imports
|
||||
* The Page Specific Imports
|
||||
* */
|
||||
#include "brush.h"
|
||||
#include "color.h"
|
||||
#include "general.h"
|
||||
#include "placement.h"
|
||||
|
@ -52,7 +45,7 @@ void restorevals(void)
|
|||
|
||||
place_restore();
|
||||
general_restore();
|
||||
|
||||
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(devthreshadjust), pcvals.devthresh);
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(colornoiseadjust), pcvals.colornoise);
|
||||
color_type_restore();
|
||||
|
@ -242,6 +235,12 @@ create_dialog (void)
|
|||
|
||||
updatepreview (NULL, 0);
|
||||
|
||||
/*
|
||||
* This is to make sure the values from the pcvals will be reflected
|
||||
* in the GUI here. Otherwise they will be set to the defaults.
|
||||
* */
|
||||
restorevals ();
|
||||
|
||||
gtk_widget_show (dlg);
|
||||
|
||||
return dlg;
|
||||
|
|
|
@ -160,8 +160,6 @@ void readdirintolist(char *subdir, GtkWidget *view, char *selected);
|
|||
void orientation_restore(void);
|
||||
void paper_store(void);
|
||||
void paper_restore(void);
|
||||
void brush_store(void);
|
||||
void brush_restore(void);
|
||||
|
||||
GtkWidget *createonecolumnlist(GtkWidget *parent,
|
||||
void (*changed_cb)
|
||||
|
@ -184,12 +182,10 @@ enum SELECT_PRESET_RETURN_VALUES
|
|||
SELECT_PRESET_LOAD_FAILED = -2,
|
||||
};
|
||||
|
||||
int select_preset(char * preset);
|
||||
int select_preset(const gchar *preset);
|
||||
void set_colorbrushes (const gchar *fn);
|
||||
int create_gimpressionist (void);
|
||||
|
||||
double degtorad(double d);
|
||||
double radtodeg(double d);
|
||||
double dist(double x, double y, double dx, double dy);
|
||||
|
||||
void restore_default_values(void);
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -31,19 +23,19 @@ static void orientation_store(GtkWidget *wg, void *d)
|
|||
void orientation_restore(void)
|
||||
{
|
||||
gtk_toggle_button_set_active (
|
||||
GTK_TOGGLE_BUTTON(orientradio[pcvals.orienttype]),
|
||||
GTK_TOGGLE_BUTTON(orientradio[pcvals.orienttype]),
|
||||
TRUE
|
||||
);
|
||||
gtk_adjustment_set_value (
|
||||
GTK_ADJUSTMENT(orientnumadjust),
|
||||
GTK_ADJUSTMENT(orientnumadjust),
|
||||
pcvals.orientnum
|
||||
);
|
||||
gtk_adjustment_set_value(
|
||||
GTK_ADJUSTMENT(orientfirstadjust),
|
||||
GTK_ADJUSTMENT(orientfirstadjust),
|
||||
pcvals.orientfirst
|
||||
);
|
||||
gtk_adjustment_set_value(
|
||||
GTK_ADJUSTMENT(orientlastadjust),
|
||||
GTK_ADJUSTMENT(orientlastadjust),
|
||||
pcvals.orientlast
|
||||
);
|
||||
}
|
||||
|
@ -56,12 +48,12 @@ static void create_orientmap_dialog_helper(void)
|
|||
}
|
||||
|
||||
|
||||
static void create_orientradio_button (GtkWidget *box, int orienttype,
|
||||
static void create_orientradio_button (GtkWidget *box, int orienttype,
|
||||
gchar *label, gchar *help_string,
|
||||
GSList **radio_group
|
||||
)
|
||||
{
|
||||
create_radio_button (box, orienttype, orientation_store, label,
|
||||
create_radio_button (box, orienttype, orientation_store, label,
|
||||
help_string, radio_group, orientradio);
|
||||
return;
|
||||
}
|
||||
|
@ -141,22 +133,22 @@ create_orientationpage (GtkNotebook *notebook)
|
|||
_("Let the value (brightness) of the region determine the direction of the stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
create_orientradio_button(box3, ORIENTATION_RADIUS, _("Radius"),
|
||||
_("The distance from the center of the image determines the direction of the stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
create_orientradio_button(box3, ORIENTATION_RANDOM, _("Random"),
|
||||
_("Selects a random direction of each stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
create_orientradio_button(box3, ORIENTATION_RADIAL, _("Radial"),
|
||||
_("Let the direction from the center determine the direction of the stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
box3 = gtk_vbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box3);
|
||||
|
@ -175,7 +167,7 @@ create_orientationpage (GtkNotebook *notebook)
|
|||
_("The direction that matches the original image the closest is selected"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
box4 = gtk_hbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (box3), box4, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box4);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
|
@ -125,7 +120,7 @@ double getdir(double x, double y, int from)
|
|||
}
|
||||
dx = dx / sum;
|
||||
dy = dy / sum;
|
||||
return 90-(radtodeg(atan2(dy,dx))+angoff);
|
||||
return 90-(gimp_rad_to_deg(atan2(dy,dx))+angoff);
|
||||
}
|
||||
|
||||
static void updateompreviewprev(void)
|
||||
|
@ -143,7 +138,7 @@ static void updateompreviewprev(void)
|
|||
|
||||
for(y = 6; y < OMHEIGHT-4; y += 10)
|
||||
for(x = 6; x < OMWIDTH-4; x += 10) {
|
||||
double dir = degtorad(getdir(x/(double)OMWIDTH,y/(double)OMHEIGHT,0));
|
||||
double dir = gimp_deg_to_rad(getdir(x/(double)OMWIDTH,y/(double)OMHEIGHT,0));
|
||||
double xo = sin(dir)*4.0;
|
||||
double yo = cos(dir)*4.0;
|
||||
drawline(&nbuffer, x-xo, y-yo, x+xo, y+yo, gray);
|
||||
|
@ -193,8 +188,8 @@ static void updatevectorprev(void)
|
|||
double s;
|
||||
x = vector[i].x * OMWIDTH;
|
||||
y = vector[i].y * OMHEIGHT;
|
||||
dir = degtorad(vector[i].dir);
|
||||
s = degtorad(vector[i].str);
|
||||
dir = gimp_deg_to_rad(vector[i].dir);
|
||||
s = gimp_deg_to_rad(vector[i].str);
|
||||
xo = sin(dir)*(6.0+100*s);
|
||||
yo = cos(dir)*(6.0+100*s);
|
||||
if(i == selectedvector)
|
||||
|
@ -246,8 +241,8 @@ static void add_new_vector (gdouble x, gdouble y)
|
|||
vector[numvect].x = x;
|
||||
vector[numvect].y = y;
|
||||
vector[numvect].dir = 0.0;
|
||||
vector[numvect].dx = sin(degtorad(0.0));
|
||||
vector[numvect].dy = cos(degtorad(0.0));
|
||||
vector[numvect].dx = sin(gimp_deg_to_rad(0.0));
|
||||
vector[numvect].dy = cos(gimp_deg_to_rad(0.0));
|
||||
vector[numvect].str = 1.0;
|
||||
vector[numvect].type = 0;
|
||||
selectedvector = numvect;
|
||||
|
@ -292,7 +287,7 @@ static void mapclick(GtkWidget *w, GdkEventButton *event)
|
|||
double d;
|
||||
d = atan2(OMWIDTH * vector[selectedvector].x - event->x,
|
||||
OMHEIGHT * vector[selectedvector].y - event->y);
|
||||
vector[selectedvector].dir = radtodeg(d);
|
||||
vector[selectedvector].dir = gimp_rad_to_deg(d);
|
||||
vector[selectedvector].dx = sin(d);
|
||||
vector[selectedvector].dy = cos(d);
|
||||
updatesliders();
|
||||
|
@ -305,8 +300,8 @@ static void angadjmove(GtkWidget *w, gpointer data)
|
|||
{
|
||||
if (adjignore) return;
|
||||
vector[selectedvector].dir = GTK_ADJUSTMENT(angadjust)->value;
|
||||
vector[selectedvector].dx = sin(degtorad(vector[selectedvector].dir));
|
||||
vector[selectedvector].dy = cos(degtorad(vector[selectedvector].dir));
|
||||
vector[selectedvector].dx = sin(gimp_deg_to_rad(vector[selectedvector].dir));
|
||||
vector[selectedvector].dy = cos(gimp_deg_to_rad(vector[selectedvector].dir));
|
||||
updatevectorprev();
|
||||
updateompreviewprev();
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimpmath/gimpmath.h>
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include "gimpressionist.h"
|
||||
|
|
|
@ -3,14 +3,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimpmath/gimpmath.h>
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include "ppmtool.h"
|
||||
|
@ -20,7 +17,7 @@
|
|||
|
||||
int readline(FILE *f, char *buffer, int len)
|
||||
{
|
||||
do
|
||||
do
|
||||
{
|
||||
if(!fgets(buffer, len, f))
|
||||
return -1;
|
||||
|
@ -73,24 +70,24 @@ void getrgb(ppm_t *s, float xo, float yo, guchar *d)
|
|||
int bail = 0;
|
||||
int rowstride = s->width * 3;
|
||||
|
||||
if (xo < 0.0)
|
||||
if (xo < 0.0)
|
||||
bail=1;
|
||||
else if (xo >= s->width-1)
|
||||
{
|
||||
xo = s->width-1;
|
||||
else if (xo >= s->width-1)
|
||||
{
|
||||
xo = s->width-1;
|
||||
#if 0
|
||||
bail=1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(yo < 0.0)
|
||||
}
|
||||
|
||||
if(yo < 0.0)
|
||||
bail=1;
|
||||
else if (yo >= s->height-1)
|
||||
{
|
||||
yo= s->height-1;
|
||||
else if (yo >= s->height-1)
|
||||
{
|
||||
yo= s->height-1;
|
||||
#if 0
|
||||
bail=1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if(bail) {
|
||||
|
@ -533,7 +530,7 @@ void saveppm(ppm_t *p, const char *fn)
|
|||
|
||||
if (!f)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* gimp_filename_to_utf8() and g_strerror() return temporary strings
|
||||
* that need not and should not be freed. So this call is OK.
|
||||
* */
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -16,16 +18,25 @@
|
|||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
static GtkWidget *presetnameentry = NULL;
|
||||
static GtkWidget *presetlist = NULL;
|
||||
static GtkWidget *presetdesclabel = NULL;
|
||||
#ifdef G_OS_WIN32
|
||||
#include "libgimpbase/gimpwin32-io.h"
|
||||
#endif
|
||||
|
||||
static GtkWidget *presetnameentry = NULL;
|
||||
static GtkWidget *presetlist = NULL;
|
||||
static GtkWidget *presetdesclabel = NULL;
|
||||
static GtkListStore *store;
|
||||
|
||||
static void set_preset_description_text (const gchar *text)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (presetdesclabel), text);
|
||||
}
|
||||
|
||||
static char presetdesc[4096] = "";
|
||||
|
||||
static char *factory_defaults = "<Factory defaults>";
|
||||
|
||||
static void addfactorydefaults(void)
|
||||
static void addfactorydefaults (void)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
|
@ -42,7 +53,7 @@ static void presetsrefresh(void)
|
|||
|
||||
#define PRESETMAGIC "Preset"
|
||||
|
||||
static int loadoldpreset(char *fname)
|
||||
static int loadoldpreset (const gchar *fname)
|
||||
{
|
||||
FILE *f;
|
||||
int len;
|
||||
|
@ -58,7 +69,7 @@ static int loadoldpreset(char *fname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int hexval(char c)
|
||||
static unsigned int hexval (char c)
|
||||
{
|
||||
c = g_ascii_tolower (c);
|
||||
if((c >= 'a') && (c <= 'f')) return c - 'a' + 10;
|
||||
|
@ -66,7 +77,7 @@ static unsigned int hexval(char c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *parsergbstring(char *s)
|
||||
static char *parsergbstring (const gchar *s)
|
||||
{
|
||||
static char col[3];
|
||||
col[0] = (hexval(s[0]) << 4) | hexval(s[1]);
|
||||
|
@ -75,9 +86,9 @@ static char *parsergbstring(char *s)
|
|||
return col;
|
||||
}
|
||||
|
||||
static void setorientvector(char *str)
|
||||
static void setorientvector (const gchar *str)
|
||||
{
|
||||
char *tmps = str;
|
||||
const gchar *tmps = str;
|
||||
int n;
|
||||
|
||||
n = atoi(tmps);
|
||||
|
@ -105,9 +116,9 @@ static void setorientvector(char *str)
|
|||
|
||||
}
|
||||
|
||||
static void setsizevector(char *str)
|
||||
static void setsizevector (const gchar *str)
|
||||
{
|
||||
char *tmps = str;
|
||||
const gchar *tmps = str;
|
||||
int n;
|
||||
|
||||
n = atoi(tmps);
|
||||
|
@ -126,7 +137,7 @@ static void setsizevector(char *str)
|
|||
|
||||
}
|
||||
|
||||
static void parsedesc(char *str, char *d, gssize d_len)
|
||||
static void parsedesc (const gchar *str, gchar *d, gssize d_len)
|
||||
{
|
||||
gchar *dest = g_strcompress (str);
|
||||
|
||||
|
@ -135,7 +146,7 @@ static void parsedesc(char *str, char *d, gssize d_len)
|
|||
g_free (dest);
|
||||
}
|
||||
|
||||
static void setval(char *key, char *val)
|
||||
static void setval (const gchar *key, const gchar *val)
|
||||
{
|
||||
if(!strcmp(key, "desc"))
|
||||
parsedesc(val, presetdesc, sizeof (presetdesc));
|
||||
|
@ -240,7 +251,7 @@ static void setval(char *key, char *val)
|
|||
pcvals.colornoise = g_ascii_strtod (val, NULL);
|
||||
}
|
||||
|
||||
static int loadpreset(char *fn)
|
||||
static int loadpreset(const gchar *fn)
|
||||
{
|
||||
char line[1024] = "";
|
||||
FILE *f;
|
||||
|
@ -258,11 +269,11 @@ static int loadpreset(char *fn)
|
|||
restore_default_values();
|
||||
while(!feof(f)) {
|
||||
char *tmps;
|
||||
if(!fgets(line,1024,f))
|
||||
if(!fgets(line,1024,f))
|
||||
break;
|
||||
remove_trailing_whitespace(line);
|
||||
tmps = strchr(line, '=');
|
||||
if(!tmps)
|
||||
if(!tmps)
|
||||
continue;
|
||||
*tmps = '\0';
|
||||
tmps++;
|
||||
|
@ -272,7 +283,7 @@ static int loadpreset(char *fn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int select_preset(char * preset)
|
||||
int select_preset(const gchar *preset)
|
||||
{
|
||||
int ret = SELECT_PRESET_OK;
|
||||
/* I'm copying this behavior as is. As it seems applying the
|
||||
|
@ -307,6 +318,7 @@ int select_preset(char * preset)
|
|||
* */
|
||||
set_colorbrushes (pcvals.selectedbrush);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -364,14 +376,12 @@ static void savepreset(void);
|
|||
|
||||
static void presetdesccallback(GtkTextBuffer *buffer, gpointer data)
|
||||
{
|
||||
char *dest, *str;
|
||||
char *str;
|
||||
GtkTextIter start, end;
|
||||
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
dest = g_strescape (str, NULL);
|
||||
g_strlcpy (presetdesc, dest, sizeof (presetdesc));
|
||||
g_free (dest);
|
||||
g_strlcpy (presetdesc, str, sizeof (presetdesc));
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
|
@ -451,13 +461,14 @@ create_savepreset (void)
|
|||
static void savepreset(void)
|
||||
{
|
||||
const gchar *l;
|
||||
gchar *fname;
|
||||
gchar *fname, *presets_dir_path;
|
||||
FILE *f;
|
||||
GList *thispath;
|
||||
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
gchar vbuf[6][G_ASCII_DTOSTR_BUF_SIZE];
|
||||
guchar color[3];
|
||||
gint i;
|
||||
gchar *desc_escaped;
|
||||
|
||||
l = gtk_entry_get_text (GTK_ENTRY (presetnameentry));
|
||||
thispath = parsepath ();
|
||||
|
@ -469,17 +480,39 @@ static void savepreset(void)
|
|||
return;
|
||||
}
|
||||
|
||||
fname = g_build_filename ((char *)thispath->data, "Presets", l, NULL);
|
||||
/* Create the ~/.gimp-$VER/gimpressionist/Presets directory if
|
||||
* it doesn't already exists.
|
||||
* */
|
||||
presets_dir_path = g_build_filename ((char *)thispath->data, "Presets", NULL);
|
||||
|
||||
if (!g_file_test (presets_dir_path, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
if (mkdir (presets_dir_path,
|
||||
S_IRUSR | S_IWUSR | S_IXUSR |
|
||||
S_IRGRP | S_IXGRP |
|
||||
S_IROTH | S_IXOTH) == -1)
|
||||
{
|
||||
g_printerr ("Error creating folder \"%s\"!\n", presets_dir_path);
|
||||
g_free (presets_dir_path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fname = g_build_filename (presets_dir_path, l, NULL);
|
||||
g_free (presets_dir_path);
|
||||
|
||||
f = fopen (fname, "wt");
|
||||
if (!f)
|
||||
{
|
||||
g_printerr ("Error opening file \"%s\" for writing!%c\n", fname, 7);
|
||||
g_free (fname);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(f, "%s\n", PRESETMAGIC);
|
||||
fprintf(f, "desc=%s\n", presetdesc);
|
||||
desc_escaped = g_strescape (presetdesc, NULL);
|
||||
fprintf(f, "desc=%s\n", desc_escaped);
|
||||
g_free (desc_escaped);
|
||||
fprintf(f, "orientnum=%d\n", pcvals.orientnum);
|
||||
fprintf(f, "orientfirst=%s\n",
|
||||
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", pcvals.orientfirst));
|
||||
|
@ -590,7 +623,7 @@ static void readdesc(const char *fn)
|
|||
|
||||
if (!fname)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (presetdesclabel), "");
|
||||
set_preset_description_text("");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -606,7 +639,7 @@ static void readdesc(const char *fn)
|
|||
if (!strncmp (line, "desc=", 5))
|
||||
{
|
||||
parsedesc (line + 5, tmplabel, sizeof (tmplabel));
|
||||
gtk_label_set_text (GTK_LABEL (presetdesclabel), tmplabel);
|
||||
set_preset_description_text (tmplabel);
|
||||
fclose (f);
|
||||
return;
|
||||
}
|
||||
|
@ -614,7 +647,7 @@ static void readdesc(const char *fn)
|
|||
fclose (f);
|
||||
}
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (presetdesclabel), "");
|
||||
set_preset_description_text ("");
|
||||
}
|
||||
|
||||
static void selectpreset(GtkTreeSelection *selection, gpointer data)
|
||||
|
@ -705,6 +738,13 @@ void create_presetpage(GtkNotebook *notebook)
|
|||
gimp_help_set_help_data (tmpw, _("Reread the folder of Presets"), NULL);
|
||||
|
||||
presetdesclabel = tmpw = gtk_label_new (NULL);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (tmpw), TRUE);
|
||||
/*
|
||||
* Make sure the label's width is reasonable and it won't stretch
|
||||
* the dialog more than its width.
|
||||
* */
|
||||
gtk_widget_set_size_request (tmpw, 200, -1);
|
||||
|
||||
gtk_misc_set_alignment (GTK_MISC (tmpw), 0.0, 0.0);
|
||||
gtk_box_pack_start(GTK_BOX (vbox), tmpw, TRUE, TRUE, 0);
|
||||
gtk_widget_show(tmpw);
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#else
|
||||
#define HAVE_DIRENT_H
|
||||
#define HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -27,7 +18,7 @@ static gimpressionist_vals_t runningvals;
|
|||
|
||||
static double get_siz_from_pcvals(double x, double y)
|
||||
{
|
||||
return getsiz_proto(x,y, pcvals.numsizevector, pcvals.sizevector,
|
||||
return getsiz_proto(x,y, pcvals.numsizevector, pcvals.sizevector,
|
||||
pcvals.sizestrexp, pcvals.sizevoronoi);
|
||||
}
|
||||
|
||||
|
@ -71,7 +62,7 @@ static double sumbrush(ppm_t *p)
|
|||
static int gethue(guchar *rgb)
|
||||
{
|
||||
double h, v, temp, diff;
|
||||
/* TODO : There seems to be some typoes in the comments here.
|
||||
/* TODO : There seems to be some typoes in the comments here.
|
||||
* Ask vidar what he meant.
|
||||
* */
|
||||
if((rgb[0] == rgb[1]) && (rgb[0] == rgb[2])) /* Gray */
|
||||
|
@ -155,7 +146,7 @@ static int bestbrush(ppm_t *p, ppm_t *a, int tx, int ty,
|
|||
g_list_free(brlist);
|
||||
brlist = NULL;
|
||||
}
|
||||
|
||||
|
||||
if(dev <= bestdev || best < 0) {
|
||||
best = i;
|
||||
bestdev = dev;
|
||||
|
@ -165,7 +156,7 @@ static int bestbrush(ppm_t *p, ppm_t *a, int tx, int ty,
|
|||
}
|
||||
|
||||
if(!brlist) {
|
||||
fprintf(stderr, "What!? No brushes?!\n");
|
||||
g_printerr("What!? No brushes?!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -299,7 +290,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
/* Shouldn't be necessary, but... */
|
||||
if(img_has_alpha)
|
||||
if((p->width != a->width) || (p->height != a->height)) {
|
||||
fprintf(stderr, "Huh? Image size != alpha size?\n");
|
||||
g_printerr("Huh? Image size != alpha size?\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -309,7 +300,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
|
||||
density = runningvals.brushdensity;
|
||||
|
||||
if(runningvals.placetype == PLACEMENT_TYPE_EVEN_DIST)
|
||||
if(runningvals.placetype == PLACEMENT_TYPE_EVEN_DIST)
|
||||
density /= 3.0;
|
||||
|
||||
bgamma = runningvals.brushgamma;
|
||||
|
@ -333,13 +324,13 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
|
||||
if(bgamma != 1.0)
|
||||
ppmgamma(&brushes[0], 1.0/bgamma, 1,1,1);
|
||||
|
||||
|
||||
resize(&brushes[0], brushes[0].width * scale, brushes[0].height * scale);
|
||||
i = 1 + sqrt(brushes[0].width * brushes[0].width +
|
||||
brushes[0].height * brushes[0].height);
|
||||
ppm_pad(&brushes[0], i-brushes[0].width, i-brushes[0].width,
|
||||
i-brushes[0].height, i-brushes[0].height, back);
|
||||
|
||||
|
||||
for(i = 1; i < numbrush; i++) {
|
||||
brushes[i].col = NULL;
|
||||
copyppm(&brushes[0], &brushes[i]);
|
||||
|
@ -356,14 +347,14 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
startangle + j * anglespan / runningvals.orientnum);
|
||||
rescale(&brushes[h], (sv * runningvals.sizefirst + (1.0-sv) * runningvals.sizelast) / runningvals.sizelast);
|
||||
autocrop(&brushes[h],1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Brush-debugging */
|
||||
#if 0
|
||||
for(i = 0; i < numbrush; i++) {
|
||||
char tmp[1000];
|
||||
sprintf(tmp, "/tmp/_brush%03d.ppm", i);
|
||||
g_snprintf (tmp, sizeof (tmp), "/tmp/_brush%03d.ppm", i);
|
||||
saveppm(&brushes[i], tmp);
|
||||
}
|
||||
#endif
|
||||
|
@ -382,7 +373,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
if(brushes[i].width > maxbrushwidth) maxbrushwidth = brushes[i].width;
|
||||
if(brushes[i].height > maxbrushheight) maxbrushheight = brushes[i].height;
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < numbrush; i++) {
|
||||
int xp, yp;
|
||||
guchar blk[3] = {0,0,0};
|
||||
|
@ -398,7 +389,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
shadows[i].col = NULL;
|
||||
copyppm(&brushes[i], &shadows[i]);
|
||||
ppmgamma(&shadows[i], 0, 1,1,0);
|
||||
ppm_pad(&shadows[i], shadowblur*2, shadowblur*2,
|
||||
ppm_pad(&shadows[i], shadowblur*2, shadowblur*2,
|
||||
shadowblur*2, shadowblur*2, back);
|
||||
for(j = 0; j < shadowblur; j++)
|
||||
blur(&shadows[i], 2, 2);
|
||||
|
@ -411,7 +402,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
maxbrushheight += shadowdepth*3;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* For extra annoying debugging :-) */
|
||||
#if 0
|
||||
saveppm(brushes, "/tmp/__brush.ppm");
|
||||
|
@ -465,7 +456,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
|
||||
switch(runningvals.orienttype)
|
||||
{
|
||||
case ORIENTATION_VALUE:
|
||||
case ORIENTATION_VALUE:
|
||||
newppm(&dirmap, p->width, p->height);
|
||||
for(y = 0; y < dirmap.height; y++) {
|
||||
guchar *dstrow = &dirmap.col[y*dirmap.width*3];
|
||||
|
@ -534,7 +525,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
break;
|
||||
}
|
||||
|
||||
if(runningvals.sizetype == SIZE_TYPE_VALUE)
|
||||
if(runningvals.sizetype == SIZE_TYPE_VALUE)
|
||||
{
|
||||
newppm(&sizmap, p->width, p->height);
|
||||
for(y = 0; y < sizmap.height; y++) {
|
||||
|
@ -545,7 +536,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(runningvals.sizetype == SIZE_TYPE_RADIUS)
|
||||
else if(runningvals.sizetype == SIZE_TYPE_RADIUS)
|
||||
{
|
||||
newppm(&sizmap, p->width, p->height);
|
||||
for(y = 0; y < sizmap.height; y++) {
|
||||
|
@ -556,7 +547,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(runningvals.sizetype == SIZE_TYPE_RADIAL)
|
||||
else if(runningvals.sizetype == SIZE_TYPE_RADIAL)
|
||||
{
|
||||
newppm(&sizmap, p->width, p->height);
|
||||
for(y = 0; y < sizmap.height; y++) {
|
||||
|
@ -566,7 +557,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(runningvals.sizetype == SIZE_TYPE_FLOWING)
|
||||
else if(runningvals.sizetype == SIZE_TYPE_FLOWING)
|
||||
{
|
||||
newppm(&sizmap, p->width / 6 + 5, p->height / 6 + 5);
|
||||
mkgrayplasma(&sizmap, 15);
|
||||
|
@ -577,7 +568,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
if(runningvals.generalpaintedges)
|
||||
edgepad(&sizmap, maxbrushwidth, maxbrushheight,maxbrushwidth, maxbrushheight);
|
||||
}
|
||||
else if(runningvals.sizetype == SIZE_TYPE_HUE)
|
||||
else if(runningvals.sizetype == SIZE_TYPE_HUE)
|
||||
{
|
||||
newppm(&sizmap, p->width, p->height);
|
||||
for(y = 0; y < sizmap.height; y++) {
|
||||
|
@ -594,8 +585,8 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
newppm(&sizmap, p->width, p->height);
|
||||
fill(&sizmap, tmpcol);
|
||||
|
||||
}
|
||||
else if(runningvals.sizetype == SIZE_TYPE_MANUAL)
|
||||
}
|
||||
else if(runningvals.sizetype == SIZE_TYPE_MANUAL)
|
||||
{
|
||||
newppm(&sizmap, p->width-maxbrushwidth*2, p->height-maxbrushheight*2);
|
||||
for(y = 0; y < sizmap.height; y++) {
|
||||
|
@ -618,7 +609,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
(int)(tmp.height * density / maxbrushheight);
|
||||
step = i;
|
||||
#if 0
|
||||
fprintf(stderr, "step=%d i=%d\n", step, i);
|
||||
g_printerr("step=%d i=%d\n", step, i);
|
||||
#endif
|
||||
}
|
||||
if(i < 1) i = 1;
|
||||
|
@ -651,7 +642,8 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
gimp_progress_update(0.8 - 0.8*((double)i / max_progress));
|
||||
} else {
|
||||
char tmps[40];
|
||||
sprintf(tmps, "%.1f %%", 100 * (1.0 - ((double)i / max_progress)));
|
||||
g_snprintf (tmps, sizeof (tmps),
|
||||
"%.1f %%", 100 * (1.0 - ((double)i / max_progress)));
|
||||
gtk_label_set_text(GTK_LABEL(GTK_BIN(previewbutton)->child), tmps);
|
||||
while(gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
|
@ -659,9 +651,9 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
}
|
||||
|
||||
if(runningvals.placetype == PLACEMENT_TYPE_RANDOM) {
|
||||
tx = g_rand_int_range (gr, maxbrushwidth/2,
|
||||
tx = g_rand_int_range (gr, maxbrushwidth/2,
|
||||
tmp.width - maxbrushwidth/2);
|
||||
ty = g_rand_int_range (gr, maxbrushheight/2,
|
||||
ty = g_rand_int_range (gr, maxbrushheight/2,
|
||||
tmp.height - maxbrushheight/2);
|
||||
} else if(runningvals.placetype == PLACEMENT_TYPE_EVEN_DIST) {
|
||||
tx = xpos[i-1];
|
||||
|
@ -677,7 +669,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
(tx + maxbrushwidth/2 >= p->width) ||
|
||||
(ty + maxbrushheight/2 >= p->height)) {
|
||||
#if 0
|
||||
fprintf(stderr, "Internal Error; invalid coords: (%d,%d) i=%d\n", tx, ty, i);
|
||||
g_printerr("Internal Error; invalid coords: (%d,%d) i=%d\n", tx, ty, i);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
@ -690,7 +682,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
n = sn = on = 0;
|
||||
|
||||
switch(runningvals.orienttype) {
|
||||
case ORIENTATION_RANDOM:
|
||||
case ORIENTATION_RANDOM:
|
||||
on = g_rand_int_range (gr, 0, runningvals.orientnum);
|
||||
break;
|
||||
case ORIENTATION_VALUE:
|
||||
|
@ -704,7 +696,7 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
case ORIENTATION_ADAPTIVE:
|
||||
break; /* Handled below */
|
||||
default:
|
||||
fprintf(stderr, "Internal error; Unknown orientationtype\n");
|
||||
g_printerr("Internal error; Unknown orientationtype\n");
|
||||
on = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -724,15 +716,15 @@ void repaint(ppm_t *p, ppm_t *a)
|
|||
case SIZE_TYPE_ADAPTIVE:
|
||||
break; /* Handled below */
|
||||
default:
|
||||
fprintf(stderr, "Internal error; Unknown sizetype\n");
|
||||
g_printerr("Internal error; Unknown sizetype\n");
|
||||
sn = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle Adaptive selections */
|
||||
/* TODO : Nest the ifs here. */
|
||||
if((runningvals.orienttype == ORIENTATION_ADAPTIVE) &&
|
||||
(runningvals.sizetype == SIZE_TYPE_ADAPTIVE))
|
||||
if((runningvals.orienttype == ORIENTATION_ADAPTIVE) &&
|
||||
(runningvals.sizetype == SIZE_TYPE_ADAPTIVE))
|
||||
{
|
||||
n = bestbrush(p, a, tx-maxbrushwidth/2, ty-maxbrushheight/2,
|
||||
brushes, numbrush, brushsum, 0, 1);
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -31,16 +24,16 @@ static void size_store(GtkWidget *wg, void *d)
|
|||
static void size_type_restore(void)
|
||||
{
|
||||
gtk_toggle_button_set_active (
|
||||
GTK_TOGGLE_BUTTON(sizeradio[pcvals.sizetype]),
|
||||
GTK_TOGGLE_BUTTON(sizeradio[pcvals.sizetype]),
|
||||
TRUE
|
||||
);
|
||||
);
|
||||
}
|
||||
void size_restore(void)
|
||||
{
|
||||
size_type_restore();
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(sizenumadjust), pcvals.sizenum);
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(sizefirstadjust), pcvals.sizefirst);
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(sizelastadjust), pcvals.sizelast);
|
||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(sizelastadjust), pcvals.sizelast);
|
||||
}
|
||||
|
||||
static void create_sizemap_dialog_helper(void)
|
||||
|
@ -49,12 +42,12 @@ static void create_sizemap_dialog_helper(void)
|
|||
create_sizemap_dialog();
|
||||
}
|
||||
|
||||
static void create_size_radio_button (GtkWidget *box, int orienttype,
|
||||
static void create_size_radio_button (GtkWidget *box, int orienttype,
|
||||
gchar *label, gchar *help_string,
|
||||
GSList **radio_group
|
||||
)
|
||||
{
|
||||
create_radio_button (box, orienttype, size_store, label,
|
||||
create_radio_button (box, orienttype, size_store, label,
|
||||
help_string, radio_group, sizeradio);
|
||||
}
|
||||
|
||||
|
@ -129,16 +122,16 @@ void create_sizepage(GtkNotebook *notebook)
|
|||
gtk_box_pack_start(GTK_BOX(box2), box3, FALSE, FALSE, 0);
|
||||
gtk_widget_show(box3);
|
||||
|
||||
create_size_radio_button (box3, SIZE_TYPE_VALUE, _("Value"),
|
||||
create_size_radio_button (box3, SIZE_TYPE_VALUE, _("Value"),
|
||||
_("Let the value (brightness) of the region determine the size of the stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
create_size_radio_button (box3, SIZE_TYPE_RADIUS, _("Radius"),
|
||||
_("The distance from the center of the image determines the size of the stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
create_size_radio_button (box3, SIZE_TYPE_RANDOM, _("Random"),
|
||||
_("Selects a random size for each stroke"),
|
||||
&radio_group
|
||||
|
@ -148,7 +141,7 @@ void create_sizepage(GtkNotebook *notebook)
|
|||
_("Let the direction from the center determine the size of the stroke"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
box3 = gtk_vbox_new(FALSE, 6);
|
||||
gtk_box_pack_start(GTK_BOX(box2), box3,FALSE,FALSE, 0);
|
||||
gtk_widget_show(box3);
|
||||
|
@ -157,7 +150,7 @@ void create_sizepage(GtkNotebook *notebook)
|
|||
_("The strokes follow a \"flowing\" pattern"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
create_size_radio_button (box3, SIZE_TYPE_HUE, _("Hue"),
|
||||
_("The hue of the region determines the size of the stroke"),
|
||||
&radio_group
|
||||
|
@ -177,7 +170,7 @@ void create_sizepage(GtkNotebook *notebook)
|
|||
_("Manually specify the stroke size"),
|
||||
&radio_group
|
||||
);
|
||||
|
||||
|
||||
size_type_restore();
|
||||
|
||||
tmpw = gtk_button_new_from_stock (GIMP_STOCK_EDIT);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
|
|
|
@ -2,27 +2,20 @@
|
|||
* utils.c - various utility routines that don't fit anywhere else. Usually
|
||||
* these routines don't affect the state of the program.
|
||||
* */
|
||||
#include <math.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <libgimpmath/gimpmath.h>
|
||||
|
||||
#include "gimpressionist.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
/* Mathematical Utilities */
|
||||
|
||||
double degtorad(double d)
|
||||
{
|
||||
return d/180.0*G_PI;
|
||||
}
|
||||
|
||||
double radtodeg(double d)
|
||||
{
|
||||
double v = d/G_PI*180.0;
|
||||
if(v < 0.0) v += 360;
|
||||
return v;
|
||||
}
|
||||
|
||||
double dist(double x, double y, double end_x, double end_y)
|
||||
{
|
||||
double dx = end_x - x;
|
||||
|
@ -37,7 +30,8 @@ double getsiz_proto (double x, double y, int n, smvector_t *vec,
|
|||
double sum, ssum, dst;
|
||||
int first = 0, last;
|
||||
|
||||
if((x < 0.0) || (x > 1.0)) printf("HUH? x = %f\n",x);
|
||||
if ((x < 0.0) || (x > 1.0))
|
||||
g_warning ("HUH? x = %f\n",x);
|
||||
|
||||
#if 0
|
||||
if (from == 0)
|
||||
|
@ -101,7 +95,7 @@ void remove_trailing_whitespace(char *buffer)
|
|||
{
|
||||
char * ptr;
|
||||
/*
|
||||
* Note: there is some reliance on the ASCII character code
|
||||
* Note: there is some reliance on the ASCII character code
|
||||
* characteristics here.
|
||||
* */
|
||||
ptr = buffer + strlen(buffer)-1;
|
||||
|
@ -113,13 +107,13 @@ void remove_trailing_whitespace(char *buffer)
|
|||
static GList *parsepath_cached_path = NULL;
|
||||
|
||||
/* This function is memoized. Once it finds the value it permanently
|
||||
* caches it
|
||||
* caches it
|
||||
* */
|
||||
GList * parsepath (void)
|
||||
{
|
||||
gchar *gimpdatasubdir, *defaultpath, *tmps;
|
||||
|
||||
|
||||
|
||||
if (parsepath_cached_path)
|
||||
return parsepath_cached_path;
|
||||
|
||||
|
@ -327,7 +321,7 @@ void readdirintolist(char *subdir, GtkWidget *view, char *selected)
|
|||
* box - the containing box.
|
||||
* orienttype - The orientation ID
|
||||
* label, help_string - self-describing
|
||||
* radio_group -
|
||||
* radio_group -
|
||||
* A pointer to a radio group. The function assigns its value
|
||||
* as the radio group of the radio button. Afterwards, it assigns it
|
||||
* a new value of the new radio group of the button.
|
||||
|
@ -342,7 +336,7 @@ GtkWidget *create_radio_button (GtkWidget *box, int orienttype,
|
|||
)
|
||||
{
|
||||
GtkWidget *tmpw;
|
||||
buttons_array[orienttype] = tmpw =
|
||||
buttons_array[orienttype] = tmpw =
|
||||
gtk_radio_button_new_with_label ((*radio_group), label);
|
||||
gtk_box_pack_start (GTK_BOX (box), tmpw, FALSE, FALSE, 0);
|
||||
gtk_widget_show (tmpw);
|
||||
|
|
Loading…
Reference in New Issue