mirror of https://github.com/GNOME/gimp.git
ported to GtkFileChooser.
2004-05-18 Sven Neumann <sven@gimp.org> * plug-ins/gimpressionist/brush.c: ported to GtkFileChooser. * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/ppmtool.[ch]: sprinkled some const qualifiers.
This commit is contained in:
parent
6dded125ee
commit
1dce1705ca
|
@ -1,3 +1,11 @@
|
||||||
|
2004-05-18 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/gimpressionist/brush.c: ported to GtkFileChooser.
|
||||||
|
|
||||||
|
* plug-ins/gimpressionist/gimpressionist.h
|
||||||
|
* plug-ins/gimpressionist/ppmtool.[ch]: sprinkled some const
|
||||||
|
qualifiers.
|
||||||
|
|
||||||
2004-05-18 Sven Neumann <sven@gimp.org>
|
2004-05-18 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/curve_bend.c
|
* plug-ins/common/curve_bend.c
|
||||||
|
|
|
@ -39,9 +39,9 @@ ppm_t brushppm = {0, 0, NULL};
|
||||||
static GtkWidget *brushprev = NULL;
|
static GtkWidget *brushprev = NULL;
|
||||||
static GtkListStore *brushstore = NULL;
|
static GtkListStore *brushstore = NULL;
|
||||||
|
|
||||||
static void updatebrushprev (char *fn);
|
static void updatebrushprev (const char *fn);
|
||||||
|
|
||||||
static gboolean colorfile (char *fn)
|
static gboolean colorfile (const char *fn)
|
||||||
{
|
{
|
||||||
return fn && strstr(fn, ".ppm");
|
return fn && strstr(fn, ".ppm");
|
||||||
}
|
}
|
||||||
|
@ -163,64 +163,69 @@ void dummybrushdmenuselect(GtkWidget *w, gpointer data)
|
||||||
updatebrushprev(NULL);
|
updatebrushprev(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void brushlistrefresh(void)
|
static void
|
||||||
|
brushlistrefresh (void)
|
||||||
{
|
{
|
||||||
gtk_list_store_clear (brushstore);
|
gtk_list_store_clear (brushstore);
|
||||||
readdirintolist("Brushes", brushlist, NULL);
|
readdirintolist("Brushes", brushlist, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
savebrush_response (GtkFileSelection *fs,
|
savebrush_response (GtkWidget *dialog,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
if (response_id == GTK_RESPONSE_OK)
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
const gchar *fn;
|
gchar *name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||||
|
|
||||||
fn = gtk_file_selection_get_filename (fs);
|
saveppm (&brushppm, name);
|
||||||
|
|
||||||
saveppm (&brushppm, fn);
|
|
||||||
brushlistrefresh ();
|
brushlistrefresh ();
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (fs));
|
gtk_widget_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
savebrush (GtkWidget *wg,
|
savebrush (GtkWidget *wg,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
static GtkWidget *window = NULL;
|
static GtkWidget *dialog = NULL;
|
||||||
GList *thispath = parsepath ();
|
GList *thispath = parsepath ();
|
||||||
gchar *path;
|
gchar *path;
|
||||||
|
|
||||||
if(! brushppm.col)
|
if (! brushppm.col)
|
||||||
{
|
{
|
||||||
g_message( _("Can only save drawables!"));
|
g_message( _("Can only save drawables!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window = gtk_file_selection_new (_("Save Brush"));
|
dialog =
|
||||||
|
gtk_file_chooser_dialog_new (_("Save Brush"),
|
||||||
|
GTK_WINDOW (gtk_widget_get_toplevel (wg)),
|
||||||
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
|
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window),
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
GTK_WINDOW (gtk_widget_get_toplevel (wg)));
|
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
||||||
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
|
|
||||||
|
|
||||||
path = g_build_filename ((char *)thispath->data, "Brushes", "", NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), path);
|
path = g_build_filename ((gchar *)thispath->data, "Brushes", NULL);
|
||||||
|
|
||||||
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), path);
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
|
||||||
g_signal_connect (window, "destroy",
|
g_signal_connect (dialog, "destroy",
|
||||||
G_CALLBACK (gtk_widget_destroyed),
|
G_CALLBACK (gtk_widget_destroyed),
|
||||||
&window);
|
&dialog);
|
||||||
g_signal_connect (window, "response",
|
g_signal_connect (dialog, "response",
|
||||||
G_CALLBACK (savebrush_response),
|
G_CALLBACK (savebrush_response),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_widget_show (window);
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -232,12 +237,14 @@ validdrawable (gint32 imageid,
|
||||||
gimp_drawable_is_gray (drawableid));
|
gimp_drawable_is_gray (drawableid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void reloadbrush(char *fn, ppm_t *p)
|
void
|
||||||
|
reloadbrush (const gchar *fn,
|
||||||
|
ppm_t *p)
|
||||||
{
|
{
|
||||||
static char lastfn[256] = "";
|
static char lastfn[256] = "";
|
||||||
static ppm_t cache = {0,0,NULL};
|
static ppm_t cache = {0,0,NULL};
|
||||||
|
|
||||||
if(strcmp(fn, lastfn))
|
if (strcmp(fn, lastfn))
|
||||||
{
|
{
|
||||||
g_strlcpy (lastfn, fn, sizeof (lastfn));
|
g_strlcpy (lastfn, fn, sizeof (lastfn));
|
||||||
loadppm (fn, &cache);
|
loadppm (fn, &cache);
|
||||||
|
@ -246,7 +253,10 @@ void reloadbrush(char *fn, ppm_t *p)
|
||||||
pcvals.colorbrushes = colorfile(fn);
|
pcvals.colorbrushes = colorfile(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void padbrush(ppm_t *p, int width, int height)
|
static void
|
||||||
|
padbrush (ppm_t *p,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
{
|
{
|
||||||
guchar black[3] = {0,0,0};
|
guchar black[3] = {0,0,0};
|
||||||
int left = (width - p->width) / 2;
|
int left = (width - p->width) / 2;
|
||||||
|
@ -256,7 +266,8 @@ static void padbrush(ppm_t *p, int width, int height)
|
||||||
pad(p, left, right, top, bottom, black);
|
pad(p, left, right, top, bottom, black);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updatebrushprev(char *fn)
|
static void
|
||||||
|
updatebrushprev (const gchar *fn)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
guchar buf[100];
|
guchar buf[100];
|
||||||
|
@ -310,7 +321,8 @@ void updatebrushprev(char *fn)
|
||||||
|
|
||||||
static gboolean brushdontupdate = FALSE;
|
static gboolean brushdontupdate = FALSE;
|
||||||
|
|
||||||
static void selectbrush(GtkTreeSelection *selection, gpointer data)
|
static void
|
||||||
|
selectbrush (GtkTreeSelection *selection, gpointer data)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
|
@ -350,20 +362,23 @@ static void selectbrush(GtkTreeSelection *selection, gpointer data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void selectbrushfile(GtkTreeSelection *selection, gpointer data)
|
static void
|
||||||
|
selectbrushfile (GtkTreeSelection *selection, gpointer data)
|
||||||
{
|
{
|
||||||
brushfile = 1;
|
brushfile = 1;
|
||||||
gtk_widget_set_sensitive (presetsavebutton, TRUE);
|
gtk_widget_set_sensitive (presetsavebutton, TRUE);
|
||||||
selectbrush (selection, NULL);
|
selectbrush (selection, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void brushaspectadjust_cb(GtkWidget *w, gpointer data)
|
static void
|
||||||
|
brushaspectadjust_cb (GtkWidget *w, gpointer data)
|
||||||
{
|
{
|
||||||
gimp_double_adjustment_update (GTK_ADJUSTMENT(w), data);
|
gimp_double_adjustment_update (GTK_ADJUSTMENT(w), data);
|
||||||
updatebrushprev (pcvals.selectedbrush);
|
updatebrushprev (pcvals.selectedbrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_brushpage(GtkNotebook *notebook)
|
void
|
||||||
|
create_brushpage(GtkNotebook *notebook)
|
||||||
{
|
{
|
||||||
GtkWidget *box1, *box2, *box3, *thispage;
|
GtkWidget *box1, *box2, *box3, *thispage;
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
|
|
|
@ -173,7 +173,7 @@ GtkWidget *createonecolumnlist(GtkWidget *parent,
|
||||||
void (*changed_cb)
|
void (*changed_cb)
|
||||||
(GtkTreeSelection *selection, gpointer data));
|
(GtkTreeSelection *selection, gpointer data));
|
||||||
|
|
||||||
void reloadbrush(char *fn, struct ppm *p);
|
void reloadbrush(const gchar *fn, struct ppm *p);
|
||||||
|
|
||||||
void create_orientmap_dialog(void);
|
void create_orientmap_dialog(void);
|
||||||
void update_orientmap_dialog(void);
|
void update_orientmap_dialog(void);
|
||||||
|
|
|
@ -229,7 +229,7 @@ void loadgbr(const gchar *fn, ppm_t *p)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadppm(char *fn, ppm_t *p)
|
void loadppm(const char *fn, ppm_t *p)
|
||||||
{
|
{
|
||||||
char line[200];
|
char line[200];
|
||||||
int y, pgm = 0;
|
int y, pgm = 0;
|
||||||
|
|
|
@ -13,7 +13,7 @@ void getrgb(ppm_t *s, float xo, float yo, unsigned char *d);
|
||||||
void resize(ppm_t *p, int nx, int ny);
|
void resize(ppm_t *p, int nx, int ny);
|
||||||
void rescale(ppm_t *p, double scale);
|
void rescale(ppm_t *p, double scale);
|
||||||
void resize_fast(ppm_t *p, int nx, int ny);
|
void resize_fast(ppm_t *p, int nx, int ny);
|
||||||
void loadppm(char *fn, ppm_t *p);
|
void loadppm(const char *fn, ppm_t *p);
|
||||||
void saveppm(ppm_t *p, const char *fn);
|
void saveppm(ppm_t *p, const char *fn);
|
||||||
void copyppm(ppm_t *s, ppm_t *p);
|
void copyppm(ppm_t *s, ppm_t *p);
|
||||||
void fill(ppm_t *p, guchar *c);
|
void fill(ppm_t *p, guchar *c);
|
||||||
|
|
Loading…
Reference in New Issue