2002-01-30 22:54:27 +08:00
|
|
|
|
1999-08-27 06:29:37 +08:00
|
|
|
#include "config.h"
|
2002-01-30 22:54:27 +08:00
|
|
|
|
1999-08-27 06:29:37 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-01-30 22:54:27 +08:00
|
|
|
|
1999-08-27 06:29:37 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning GTK_DISABLE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
2002-01-30 22:54:27 +08:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
|
|
|
#include <libgimpmath/gimpmath.h>
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
#include <gtk/gtklist.h>
|
2002-01-30 22:54:27 +08:00
|
|
|
#include <gtk/gtkpreview.h>
|
|
|
|
|
|
|
|
#include "gimpressionist.h"
|
|
|
|
#include "ppmtool.h"
|
|
|
|
|
|
|
|
#include <libgimp/stdplugins-intl.h>
|
|
|
|
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
GtkWidget *brushlist = NULL;
|
2002-11-20 04:25:57 +08:00
|
|
|
static GtkWidget *brushprev = NULL;
|
1999-08-27 06:29:37 +08:00
|
|
|
GtkObject *brushreliefadjust = NULL;
|
|
|
|
GtkObject *brushaspectadjust = NULL;
|
|
|
|
GtkObject *brushgammaadjust = NULL;
|
2002-12-18 04:18:16 +08:00
|
|
|
static GtkListStore *brushstore;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
GtkWidget *brushdrawablemenu = NULL;
|
2002-11-20 04:25:57 +08:00
|
|
|
static GtkWidget *brushemptyitem;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
gint32 brushdrawableid;
|
|
|
|
|
|
|
|
int brushfile = 2;
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
ppm_t brushppm = {0,0,NULL};
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
static void updatebrushprev(char *fn);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
static gboolean colorfile(char *fn)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
2002-11-20 04:25:57 +08:00
|
|
|
return fn && strstr(fn, ".ppm");
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
static void brushdmenuselect(gint32 id, gpointer data)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPixelRgn src_rgn;
|
1999-08-27 06:29:37 +08:00
|
|
|
guchar *src_row;
|
|
|
|
guchar *src;
|
|
|
|
gint alpha, has_alpha, bpp;
|
|
|
|
gint x, y;
|
2002-11-20 04:25:57 +08:00
|
|
|
ppm_t *p;
|
1999-08-27 06:29:37 +08:00
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint row, col;
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpDrawable *drawable;
|
1999-08-30 05:06:26 +08:00
|
|
|
int rowstride;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
if(brushfile == 2) return; /* Not finished GUI-building yet */
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
if (brushfile) {
|
|
|
|
/* unselectall(brushlist); */
|
2000-12-15 01:41:10 +08:00
|
|
|
if(GTK_IS_WIDGET(presetsavebutton))
|
|
|
|
gtk_widget_set_sensitive(GTK_WIDGET(presetsavebutton), FALSE);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(brushgammaadjust), 1.0);
|
|
|
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(brushaspectadjust), 0.0);
|
|
|
|
|
|
|
|
drawable = gimp_drawable_get(id);
|
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
|
|
|
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
1999-08-27 06:29:37 +08:00
|
|
|
alpha = (has_alpha) ? bpp - 1 : bpp;
|
|
|
|
|
|
|
|
if(brushppm.col)
|
|
|
|
killppm(&brushppm);
|
|
|
|
newppm(&brushppm, x2-x1, y2-y1);
|
|
|
|
p = &brushppm;
|
|
|
|
|
1999-08-30 05:06:26 +08:00
|
|
|
rowstride = p->width * 3;
|
|
|
|
|
1999-12-31 02:54:17 +08:00
|
|
|
src_row = g_new (guchar, (x2 - x1) * bpp);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
gimp_pixel_rgn_init (&src_rgn, drawable, 0, 0, x2-x1, y2-y1, FALSE, FALSE);
|
|
|
|
|
|
|
|
if(bpp == 3) { /* RGB */
|
|
|
|
int bpr = (x2-x1) * 3;
|
|
|
|
for(row = 0, y = y1; y < y2; row++, y++) {
|
|
|
|
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
|
1999-08-30 05:06:26 +08:00
|
|
|
memcpy(p->col + row*rowstride, src_row, bpr);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
} else if(bpp > 3) { /* RGBA */
|
|
|
|
for(row = 0, y = y1; y < y2; row++, y++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
guchar *tmprow = p->col + row * rowstride;
|
1999-08-27 06:29:37 +08:00
|
|
|
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
|
|
|
|
src = src_row;
|
|
|
|
for (col = 0, x = x1; x < x2; col++, x++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
int k = col * 3;
|
|
|
|
tmprow[k+0] = src[0];
|
|
|
|
tmprow[k+1] = src[1];
|
|
|
|
tmprow[k+2] = src[2];
|
1999-08-27 06:29:37 +08:00
|
|
|
src += src_rgn.bpp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(bpp == 2) { /* GrayA */
|
|
|
|
for(row = 0, y = y1; y < y2; row++, y++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
guchar *tmprow = p->col + row * rowstride;
|
1999-08-27 06:29:37 +08:00
|
|
|
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
|
|
|
|
src = src_row;
|
|
|
|
for (col = 0, x = x1; x < x2; col++, x++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
int k = col * 3;
|
|
|
|
tmprow[k+0] = src[0];
|
|
|
|
tmprow[k+1] = src[0];
|
|
|
|
tmprow[k+2] = src[0];
|
1999-08-27 06:29:37 +08:00
|
|
|
src += src_rgn.bpp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { /* Gray */
|
|
|
|
for(row = 0, y = y1; y < y2; row++, y++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
guchar *tmprow = p->col + row * rowstride;
|
1999-08-27 06:29:37 +08:00
|
|
|
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
|
|
|
|
src = src_row;
|
|
|
|
for (col = 0, x = x1; x < x2; col++, x++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
int k = col * 3;
|
|
|
|
tmprow[k+0] = src[0];
|
|
|
|
tmprow[k+1] = src[0];
|
|
|
|
tmprow[k+2] = src[0];
|
1999-08-27 06:29:37 +08:00
|
|
|
src += src_rgn.bpp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-12-31 02:54:17 +08:00
|
|
|
g_free (src_row);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
if(bpp >= 3) pcvals.colorbrushes = 1;
|
|
|
|
else pcvals.colorbrushes = 0;
|
|
|
|
|
|
|
|
brushfile = 0;
|
|
|
|
updatebrushprev(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dummybrushdmenuselect(GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
if(brushppm.col)
|
|
|
|
killppm(&brushppm);
|
|
|
|
newppm(&brushppm, 10,10);
|
|
|
|
brushfile = 0;
|
|
|
|
updatebrushprev(NULL);
|
|
|
|
}
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
static void destroy_window (GtkWidget *widget, GtkWidget **window)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
|
|
|
*window = NULL;
|
|
|
|
}
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
static void brushlistrefresh(void)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
2002-12-18 04:18:16 +08:00
|
|
|
gtk_list_store_clear (brushstore);
|
|
|
|
readdirintolist("Brushes", brushlist, NULL);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void savebrush_ok(GtkWidget *w, GtkFileSelection *fs, gpointer data)
|
|
|
|
{
|
2001-10-20 00:41:09 +08:00
|
|
|
const gchar *fn;
|
1999-08-27 06:29:37 +08:00
|
|
|
fn = gtk_file_selection_get_filename (GTK_FILE_SELECTION(fs));
|
|
|
|
|
|
|
|
saveppm(&brushppm, fn);
|
|
|
|
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(fs));
|
|
|
|
brushlistrefresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void savebrush(GtkWidget *wg, gpointer data)
|
|
|
|
{
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
GList *thispath = parsepath();
|
|
|
|
char path[200];
|
|
|
|
|
|
|
|
if(!brushppm.col) {
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message( _("Can only save drawables!"));
|
1999-08-27 06:29:37 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(path, "%s/Brushes/", (char *)thispath->data);
|
|
|
|
|
1999-09-26 13:16:19 +08:00
|
|
|
window = gtk_file_selection_new( _("Save brush"));
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), path);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (window, "destroy",
|
|
|
|
G_CALLBACK (destroy_window), &window);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (GTK_FILE_SELECTION (window)->ok_button, "clicked",
|
|
|
|
G_CALLBACK (savebrush_ok), window);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (GTK_FILE_SELECTION (window)->cancel_button,
|
2001-12-29 21:26:29 +08:00
|
|
|
"clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
window);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_widget_show(window);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
static gboolean validdrawable(gint32 imageid, gint32 drawableid, gpointer data)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
|
|
|
if(drawableid == -1) return TRUE;
|
1999-10-25 04:49:09 +08:00
|
|
|
return (gimp_drawable_is_rgb(drawableid) || gimp_drawable_is_gray(drawableid));
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
void reloadbrush(char *fn, ppm_t *p)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
|
|
|
static char lastfn[200] = "";
|
2002-11-20 04:25:57 +08:00
|
|
|
static ppm_t cache = {0,0,NULL};
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
if(strcmp(fn, lastfn)) {
|
|
|
|
strncpy(lastfn, fn, 199);
|
|
|
|
loadppm(fn, &cache);
|
|
|
|
}
|
|
|
|
copyppm(&cache, p);
|
|
|
|
pcvals.colorbrushes = colorfile(fn);
|
|
|
|
}
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
static void padbrush(ppm_t *p, int width, int height)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
1999-08-30 05:06:26 +08:00
|
|
|
guchar black[3] = {0,0,0};
|
1999-08-27 06:29:37 +08:00
|
|
|
int left = (width - p->width) / 2;
|
|
|
|
int right = (width - p->width) - left;
|
|
|
|
int top = (height - p->height) / 2;
|
|
|
|
int bottom = (height - p->height) - top;
|
1999-08-30 05:06:26 +08:00
|
|
|
pad(p, left, right, top, bottom, black);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void updatebrushprev(char *fn)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
char buf[100];
|
|
|
|
|
|
|
|
if(fn)
|
|
|
|
brushfile = 1;
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
if (!fn && brushfile) {
|
1999-08-27 06:29:37 +08:00
|
|
|
memset(buf, 0, 100);
|
|
|
|
for(i = 0; i < 100; i++) {
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (brushprev), buf, 0, i, 100);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
double sc;
|
2002-11-20 04:25:57 +08:00
|
|
|
ppm_t p = {0,0,NULL};
|
1999-08-30 05:06:26 +08:00
|
|
|
guchar gammatable[256];
|
1999-08-27 06:29:37 +08:00
|
|
|
int newheight;
|
|
|
|
|
|
|
|
if(brushfile)
|
|
|
|
reloadbrush(fn, &p);
|
|
|
|
else if(brushppm.col)
|
|
|
|
copyppm(&brushppm, &p);
|
|
|
|
|
|
|
|
pcvals.colorbrushes = colorfile(fn);
|
|
|
|
|
|
|
|
sc = GTK_ADJUSTMENT(brushgammaadjust)->value;
|
|
|
|
if(sc != 1.0)
|
|
|
|
for(i = 0; i < 256; i++)
|
|
|
|
gammatable[i] = pow(i / 255.0, sc) * 255;
|
|
|
|
else
|
|
|
|
for(i = 0; i < 256; i++)
|
|
|
|
gammatable[i] = i;
|
|
|
|
|
|
|
|
newheight = p.height*pow(10,GTK_ADJUSTMENT(brushaspectadjust)->value);
|
|
|
|
sc = p.width > newheight ? p.width : newheight;
|
|
|
|
sc = 100.0 / sc;
|
|
|
|
resize_fast(&p, p.width*sc,newheight*sc);
|
2002-11-20 04:25:57 +08:00
|
|
|
padbrush(&p, 100, 100);
|
1999-08-27 06:29:37 +08:00
|
|
|
for(i = 0; i < 100; i++) {
|
1999-08-30 05:06:26 +08:00
|
|
|
int k = i * p.width * 3;
|
1999-08-27 06:29:37 +08:00
|
|
|
memset(buf,0,100);
|
|
|
|
if(i < p.height)
|
|
|
|
for(j = 0; j < p.width; j++)
|
1999-08-30 05:06:26 +08:00
|
|
|
buf[j] = gammatable[p.col[k + j * 3]];
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (brushprev), buf, 0, i, 100);
|
|
|
|
}
|
|
|
|
killppm(&p);
|
|
|
|
}
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (brushprev);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
static gboolean brushdontupdate = FALSE;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
static void selectbrush(GtkTreeSelection *selection, gpointer data)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
2002-12-18 04:18:16 +08:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
char fname[200];
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
if (brushdontupdate) return;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
if (brushfile == 0) {
|
1999-08-27 06:29:37 +08:00
|
|
|
updatebrushprev(NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
|
|
|
{
|
|
|
|
gchar *brush;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &brush, -1);
|
|
|
|
|
|
|
|
brushdontupdate = TRUE;
|
|
|
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(brushgammaadjust), 1.0);
|
|
|
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(brushaspectadjust), 0.0);
|
|
|
|
brushdontupdate = FALSE;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
sprintf(fname, "Brushes/%s", brush);
|
|
|
|
strcpy(pcvals.selectedbrush, fname);
|
|
|
|
|
|
|
|
updatebrushprev(fname);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
g_free (brush);
|
|
|
|
}
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
static void selectbrushfile(GtkTreeSelection *selection, gpointer data)
|
1999-08-27 06:29:37 +08:00
|
|
|
{
|
|
|
|
brushfile = 1;
|
2002-12-18 04:18:16 +08:00
|
|
|
gtk_widget_set_sensitive (presetsavebutton, TRUE);
|
|
|
|
selectbrush (selection, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void brushaspectadjust_cb(GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
gimp_double_adjustment_update (GTK_ADJUSTMENT(w), data);
|
|
|
|
updatebrushprev (pcvals.selectedbrush);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void create_brushpage(GtkNotebook *notebook)
|
|
|
|
{
|
|
|
|
GtkWidget *box1, *box2, *box3, *thispage;
|
2002-12-18 04:18:16 +08:00
|
|
|
GtkWidget *view;
|
2002-11-20 04:25:57 +08:00
|
|
|
GtkWidget *tmpw, *table;
|
1999-08-27 06:29:37 +08:00
|
|
|
GtkWidget *dmenu;
|
2002-11-20 04:25:57 +08:00
|
|
|
GtkWidget *label;
|
2002-12-18 04:18:16 +08:00
|
|
|
GtkTreeSelection *selection;
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Brush"));
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
thispage = gtk_vbox_new(FALSE, 0);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (thispage), 5);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_widget_show(thispage);
|
|
|
|
|
|
|
|
box1 = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(thispage), box1, TRUE,TRUE,0);
|
|
|
|
gtk_widget_show (box1);
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
view = createonecolumnlist (box1, selectbrushfile);
|
|
|
|
brushlist = view;
|
|
|
|
brushstore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
box2 = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box1), box2,FALSE,FALSE,0);
|
|
|
|
gtk_widget_show (box2);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (box2), 5);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
1999-09-26 13:16:19 +08:00
|
|
|
tmpw = gtk_label_new( _("Brush Preview:"));
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_box_pack_start(GTK_BOX(box2), tmpw,FALSE,FALSE,0);
|
|
|
|
gtk_widget_show (tmpw);
|
|
|
|
|
|
|
|
brushprev = tmpw = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
|
|
|
gtk_preview_size(GTK_PREVIEW (tmpw), 100, 100);
|
|
|
|
gtk_box_pack_start(GTK_BOX (box2), tmpw, FALSE, FALSE, 5);
|
|
|
|
gtk_widget_show(tmpw);
|
|
|
|
|
1999-09-26 13:16:19 +08:00
|
|
|
tmpw = gtk_label_new( _("Gamma:"));
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_box_pack_start(GTK_BOX(box2), tmpw,FALSE,FALSE,0);
|
|
|
|
gtk_widget_show (tmpw);
|
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
brushgammaadjust = gtk_adjustment_new(pcvals.brushgamma, 0.5, 3.0, 0.1,
|
|
|
|
0.1, 1.0);
|
1999-08-27 06:29:37 +08:00
|
|
|
tmpw = gtk_hscale_new(GTK_ADJUSTMENT(brushgammaadjust));
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET(tmpw), 100, 30);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (tmpw), FALSE);
|
|
|
|
gtk_scale_set_digits(GTK_SCALE (tmpw), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box2), tmpw, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (tmpw);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (brushgammaadjust, "value_changed",
|
|
|
|
G_CALLBACK(updatebrushprev), pcvals.selectedbrush);
|
2002-12-18 04:18:16 +08:00
|
|
|
|
1999-09-26 13:16:19 +08:00
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Changes the gamma (brightness) of the selected brush"), NULL);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
|
|
|
box1 = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(thispage), box1,FALSE,FALSE,5);
|
|
|
|
gtk_widget_show (box1);
|
|
|
|
|
|
|
|
box2 = gtk_vbox_new (TRUE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box1), box2,FALSE,FALSE,0);
|
|
|
|
gtk_widget_show (box2);
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
if (!standalone) {
|
|
|
|
GtkWidget *emptyitem;
|
|
|
|
|
1999-08-27 06:29:37 +08:00
|
|
|
box3 = gtk_hbox_new(FALSE,0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box2),box3, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(box3);
|
|
|
|
|
2002-12-10 18:39:23 +08:00
|
|
|
tmpw = gtk_label_new( _("Select:"));
|
|
|
|
gtk_box_pack_start(GTK_BOX(box3), tmpw,FALSE,FALSE,0);
|
|
|
|
gtk_widget_show (tmpw);
|
|
|
|
|
1999-09-26 13:16:19 +08:00
|
|
|
brushemptyitem = emptyitem = gtk_menu_item_new_with_label( _("(None)"));
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (emptyitem, "activate",
|
|
|
|
G_CALLBACK (dummybrushdmenuselect),
|
2001-12-29 21:26:29 +08:00
|
|
|
NULL);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_widget_show(emptyitem);
|
|
|
|
|
|
|
|
tmpw = gtk_option_menu_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(box3),tmpw, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(tmpw);
|
|
|
|
|
|
|
|
brushdrawablemenu = dmenu = gimp_drawable_menu_new(validdrawable, brushdmenuselect, NULL, -1);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (dmenu), emptyitem);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpw), dmenu);
|
2002-11-20 04:25:57 +08:00
|
|
|
tmpw = gtk_button_new_from_stock (GTK_STOCK_SAVE_AS);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_box_pack_start(GTK_BOX(box3),tmpw, FALSE, FALSE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (tmpw, "clicked", G_CALLBACK(savebrush), NULL);
|
1999-08-27 06:29:37 +08:00
|
|
|
gtk_widget_show(tmpw);
|
|
|
|
}
|
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
table = gtk_table_new (2, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE(table), 4);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box2), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
brushaspectadjust =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE(table), 0, 0,
|
|
|
|
_("Aspect ratio:"),
|
|
|
|
150, -1, pcvals.brushaspect,
|
|
|
|
-1.0, 1.0, 0.1, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Specifies the aspect ratio of the brush"),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (brushaspectadjust, "value_changed",
|
2002-12-18 04:18:16 +08:00
|
|
|
G_CALLBACK (brushaspectadjust_cb), &pcvals.brushaspect);
|
2002-11-20 04:25:57 +08:00
|
|
|
|
|
|
|
brushreliefadjust =
|
|
|
|
gimp_scale_entry_new (GTK_TABLE(table), 0, 1,
|
|
|
|
_("Relief:"),
|
|
|
|
150, -1, pcvals.brushrelief,
|
|
|
|
0.0, 100.0, 1.0, 10.0, 1,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
_("Specifies the amount of embossing to apply to the image (in percent)"),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (brushreliefadjust, "value_changed",
|
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&pcvals.brushrelief);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-12-18 04:18:16 +08:00
|
|
|
selectbrush(selection, NULL);
|
|
|
|
readdirintolist("Brushes", view, pcvals.selectedbrush);
|
1999-08-27 06:29:37 +08:00
|
|
|
|
2002-11-20 04:25:57 +08:00
|
|
|
gtk_notebook_append_page_menu (notebook, thispage, label, NULL);
|
1999-08-27 06:29:37 +08:00
|
|
|
}
|