mirror of https://github.com/GNOME/gimp.git
app/Makefile.am new object.
2001-02-04 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimppattern.[ch]: new object. * app/apptypes.h: added GimpPattern, removed GPattern. * app/patterns.[ch]: contains only the "patterns_()" functions for the global pattern list, s/pattern_list/global_pattern_list/g * app/brushes.[ch]: s/brush_list/global_brush_list/g * app/pattern_select.[ch] * app/gimpcontext.[ch]: connect to the Patterns' and the pattern list's signals. * app/brush_select.[ch] * app/devices.c * app/disp_callbacks.[ch] * app/gimpbrush.c * app/gimpbrushgenerated.[ch] * app/gimpcontextpreview.[ch] * app/gimpdnd.[ch] * app/indicator_area.c * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * app/tools/bucket_fill.c * app/tools/clone.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * po/POTFILES.in: changed accordingly.
This commit is contained in:
parent
1994facc9e
commit
78a8bb4c70
38
ChangeLog
38
ChangeLog
|
@ -1,3 +1,39 @@
|
|||
2001-02-04 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/Makefile.am
|
||||
* app/gimppattern.[ch]: new object.
|
||||
|
||||
* app/apptypes.h: added GimpPattern, removed GPattern.
|
||||
|
||||
* app/patterns.[ch]: contains only the "patterns_()" functions for
|
||||
the global pattern list, s/pattern_list/global_pattern_list/g
|
||||
|
||||
* app/brushes.[ch]: s/brush_list/global_brush_list/g
|
||||
|
||||
* app/pattern_select.[ch]
|
||||
* app/gimpcontext.[ch]: connect to the Patterns' and the pattern
|
||||
list's signals.
|
||||
|
||||
* app/brush_select.[ch]
|
||||
* app/devices.c
|
||||
* app/disp_callbacks.[ch]
|
||||
* app/gimpbrush.c
|
||||
* app/gimpbrushgenerated.[ch]
|
||||
* app/gimpcontextpreview.[ch]
|
||||
* app/gimpdnd.[ch]
|
||||
* app/indicator_area.c
|
||||
* app/pdb/brush_select_cmds.c
|
||||
* app/pdb/brushes_cmds.c
|
||||
* app/pdb/pattern_select_cmds.c
|
||||
* app/pdb/patterns_cmds.c
|
||||
* app/tools/bucket_fill.c
|
||||
* app/tools/clone.c
|
||||
* tools/pdbgen/pdb/brush_select.pdb
|
||||
* tools/pdbgen/pdb/brushes.pdb
|
||||
* tools/pdbgen/pdb/pattern_select.pdb
|
||||
* tools/pdbgen/pdb/patterns.pdb
|
||||
* po/POTFILES.in: changed accordingly.
|
||||
|
||||
2001-02-04 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpcontainer.[ch]: renamed gimp_container_lookup() back
|
||||
|
@ -13,7 +49,7 @@
|
|||
* app/gimpbrushlist.[ch]: removed. It's job is done by the
|
||||
GimpDataList now.
|
||||
|
||||
* app/brushes.[ch]: new files. Contain the "brushes_()" functions
|
||||
* app/brushes.[ch]: new files. Contains the "brushes_()" functions
|
||||
for the global brush list.
|
||||
|
||||
* app/app_procs.c
|
||||
|
|
|
@ -142,6 +142,8 @@ gimp_SOURCES = \
|
|||
gimpmarshal.h \
|
||||
gimpobject.c \
|
||||
gimpobject.h \
|
||||
gimppattern.c \
|
||||
gimppattern.h \
|
||||
gimppalette.c \
|
||||
gimppalette.h \
|
||||
gimpparasite.c \
|
||||
|
|
|
@ -60,6 +60,8 @@ typedef struct _GimpBrush GimpBrush;
|
|||
typedef struct _GimpBrushGenerated GimpBrushGenerated;
|
||||
typedef struct _GimpBrushPipe GimpBrushPipe;
|
||||
|
||||
typedef struct _GimpPattern GimpPattern;
|
||||
|
||||
typedef struct _GimpPalette GimpPalette;
|
||||
|
||||
|
||||
|
@ -95,8 +97,6 @@ typedef struct _GimpParasite GimpParasite;
|
|||
|
||||
typedef struct _GimpProgress GimpProgress;
|
||||
|
||||
typedef struct _GPattern GPattern;
|
||||
|
||||
typedef struct _gradient_t gradient_t;
|
||||
|
||||
typedef struct _Guide Guide;
|
||||
|
|
|
@ -310,7 +310,8 @@ brush_select_new (gchar *title,
|
|||
|
||||
if (title && init_name && strlen (init_name))
|
||||
{
|
||||
active = (GimpBrush *) gimp_list_get_child_by_name (brush_list, init_name);
|
||||
active = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
init_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -526,20 +527,20 @@ brush_select_new (gchar *title,
|
|||
/* add callbacks to keep the display area current */
|
||||
bsp->name_changed_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "name_changed",
|
||||
(GIMP_CONTAINER (global_brush_list), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
bsp->dirty_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "dirty",
|
||||
(GIMP_CONTAINER (global_brush_list), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
|
||||
gtk_signal_connect (GTK_OBJECT (global_brush_list), "add",
|
||||
GTK_SIGNAL_FUNC (brush_added_callback),
|
||||
bsp);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
|
||||
gtk_signal_connect (GTK_OBJECT (global_brush_list), "remove",
|
||||
GTK_SIGNAL_FUNC (brush_removed_callback),
|
||||
bsp);
|
||||
|
||||
|
@ -599,12 +600,12 @@ brush_select_free (BrushSelect *bsp)
|
|||
gtk_object_unref (GTK_OBJECT (bsp->context));
|
||||
}
|
||||
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (global_brush_list),
|
||||
bsp->name_changed_handler_id);
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (global_brush_list),
|
||||
bsp->dirty_handler_id);
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), bsp);
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (global_brush_list), bsp);
|
||||
|
||||
g_free (bsp);
|
||||
}
|
||||
|
@ -613,7 +614,7 @@ void
|
|||
brush_select_freeze_all (void)
|
||||
{
|
||||
BrushSelect *bsp;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
for (list = brush_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
|
@ -627,7 +628,7 @@ void
|
|||
brush_select_thaw_all (void)
|
||||
{
|
||||
BrushSelect *bsp;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
for (list = brush_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
|
@ -835,7 +836,7 @@ brush_select_select (BrushSelect *bsp,
|
|||
gint row, col;
|
||||
gint scroll_offset = 0;
|
||||
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
@ -885,7 +886,7 @@ brush_select_brush_dirty_callback (GimpBrush *brush,
|
|||
if (!bsp || bsp->freeze)
|
||||
return;
|
||||
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush));
|
||||
redraw = (brush != gimp_context_get_brush (bsp->context));
|
||||
|
||||
clear_brush (bsp, brush,
|
||||
|
@ -1351,8 +1352,8 @@ do_display_brush (GimpBrush *brush,
|
|||
static void
|
||||
display_brushes (BrushSelect *bsp)
|
||||
{
|
||||
if (brush_list == NULL ||
|
||||
gimp_container_num_children (GIMP_CONTAINER (brush_list)) == 0)
|
||||
if (global_brush_list == NULL ||
|
||||
gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) == 0)
|
||||
{
|
||||
gtk_widget_set_sensitive (bsp->options_box, FALSE);
|
||||
return;
|
||||
|
@ -1366,7 +1367,7 @@ display_brushes (BrushSelect *bsp)
|
|||
display_setup (bsp);
|
||||
|
||||
brush_counter = 0;
|
||||
gimp_container_foreach (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_foreach (GIMP_CONTAINER (global_brush_list),
|
||||
(GFunc) do_display_brush,
|
||||
bsp);
|
||||
}
|
||||
|
@ -1492,7 +1493,7 @@ preview_calc_scrollbar (BrushSelect *bsp)
|
|||
gint max;
|
||||
|
||||
bsp->scroll_offset = 0;
|
||||
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) +
|
||||
(bsp->NUM_BRUSH_COLUMNS) - 1)
|
||||
/ (bsp->NUM_BRUSH_COLUMNS));
|
||||
max = num_rows * bsp->cell_width;
|
||||
|
@ -1533,7 +1534,7 @@ brush_select_resize (GtkWidget *widget,
|
|||
bsp->NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid / cell_size);
|
||||
bsp->NUM_BRUSH_ROWS =
|
||||
(gint) ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
(gint) ((gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) +
|
||||
bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
bsp->NUM_BRUSH_COLUMNS);
|
||||
|
||||
|
@ -1567,7 +1568,8 @@ brush_select_events (GtkWidget *widget,
|
|||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
/* Get the brush and check if it is editable */
|
||||
brush = GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, index));
|
||||
brush = GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list,
|
||||
index));
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
brush_select_edit_brush_callback (NULL, bsp);
|
||||
break;
|
||||
|
@ -1579,7 +1581,8 @@ brush_select_events (GtkWidget *widget,
|
|||
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
|
||||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_index (brush_list, index);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_index (global_brush_list,
|
||||
index);
|
||||
|
||||
if (brush)
|
||||
bsp->dnd_brush = brush;
|
||||
|
@ -1706,7 +1709,8 @@ brush_select_scroll_update (GtkAdjustment *adjustment,
|
|||
|
||||
if (active)
|
||||
{
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (active));
|
||||
index = gimp_list_get_child_index (global_brush_list,
|
||||
GIMP_OBJECT (active));
|
||||
if (index < 0)
|
||||
return;
|
||||
row = index / bsp->NUM_BRUSH_COLUMNS;
|
||||
|
@ -1810,7 +1814,7 @@ brush_select_new_brush_callback (GtkWidget *widget,
|
|||
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
||||
if (brush)
|
||||
{
|
||||
gimp_container_add (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_add (GIMP_CONTAINER (global_brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
|
||||
gimp_context_set_brush (bsp->context, brush);
|
||||
|
@ -1870,7 +1874,7 @@ brush_select_delete_brush_callback (GtkWidget *widget,
|
|||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
gimp_container_remove (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove (GIMP_CONTAINER (global_brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
gimp_context_refresh_brushes ();
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ extern GSList *brush_active_dialogs;
|
|||
/* the main brush dialog */
|
||||
extern BrushSelect *brush_select_dialog;
|
||||
|
||||
|
||||
BrushSelect * brush_select_new (gchar *title,
|
||||
/* These are the required initial vals
|
||||
* If init_name == NULL then use
|
||||
|
|
|
@ -18,21 +18,12 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brushes.h"
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "gimpbrushpipe.h"
|
||||
|
@ -51,7 +42,7 @@
|
|||
|
||||
|
||||
/* global variables */
|
||||
GimpList *brush_list = NULL;
|
||||
GimpList *global_brush_list = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
@ -62,10 +53,10 @@ static void brushes_brush_load (const gchar *filename);
|
|||
void
|
||||
brushes_init (gboolean no_data)
|
||||
{
|
||||
if (brush_list)
|
||||
if (global_brush_list)
|
||||
brushes_free ();
|
||||
else
|
||||
brush_list = GIMP_LIST (gimp_data_list_new (GIMP_TYPE_BRUSH));
|
||||
global_brush_list = GIMP_LIST (gimp_data_list_new (GIMP_TYPE_BRUSH));
|
||||
|
||||
if (brush_path != NULL && !no_data)
|
||||
{
|
||||
|
@ -130,7 +121,7 @@ brushes_brush_load (const gchar *filename)
|
|||
}
|
||||
|
||||
if (brush != NULL)
|
||||
gimp_container_add (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_add (GIMP_CONTAINER (global_brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
}
|
||||
|
||||
|
@ -140,7 +131,7 @@ brushes_free (void)
|
|||
GList *vbr_path;
|
||||
gchar *vbr_dir;
|
||||
|
||||
if (!brush_list)
|
||||
if (! global_brush_list)
|
||||
return;
|
||||
|
||||
vbr_path = gimp_path_parse (brush_vbr_path, 16, TRUE, NULL);
|
||||
|
@ -149,66 +140,14 @@ brushes_free (void)
|
|||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
while (GIMP_LIST (brush_list)->list)
|
||||
while (GIMP_LIST (global_brush_list)->list)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (GIMP_LIST (brush_list)->list->data);
|
||||
GimpBrush *brush = GIMP_BRUSH (GIMP_LIST (global_brush_list)->list->data);
|
||||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush) && vbr_dir)
|
||||
{
|
||||
gchar *filename = NULL;
|
||||
if (!brush->filename)
|
||||
{
|
||||
FILE *tmp_fp;
|
||||
gint unum = 0;
|
||||
gimp_brush_generated_save (GIMP_BRUSH_GENERATED (brush), vbr_dir);
|
||||
|
||||
if (vbr_dir)
|
||||
{
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace(safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
vbr_dir,
|
||||
safe_name);
|
||||
while ((tmp_fp = fopen (filename, "r")))
|
||||
{ /* make sure we don't overite an existing brush */
|
||||
fclose (tmp_fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
vbr_dir, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (brush->filename);
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{ /* we only want to save .vbr files, so set filename to null
|
||||
if this isn't a .vbr file */
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if (filename)
|
||||
{
|
||||
gimp_brush_generated_save (GIMP_BRUSH_GENERATED (brush),
|
||||
filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
gimp_container_remove (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove (GIMP_CONTAINER (global_brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
#define __BRUSHES_H__
|
||||
|
||||
|
||||
extern GimpList *brush_list;
|
||||
extern GimpList *global_brush_list;
|
||||
|
||||
|
||||
void brushes_init (gboolean no_data);
|
||||
void brushes_free (void);
|
||||
|
||||
GimpBrush * brushes_get_standard_brush (void);
|
||||
|
||||
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
#include "brush_header.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
/* this needs to go away */
|
||||
|
@ -135,7 +133,7 @@ gimp_brush_get_type (void)
|
|||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
if (! type)
|
||||
{
|
||||
static const GtkTypeInfo info =
|
||||
{
|
||||
|
@ -149,7 +147,7 @@ gimp_brush_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (gimp_object_get_type (), &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_OBJECT, &info);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
@ -237,7 +235,6 @@ gimp_brush_load_brush (gint fd,
|
|||
const gchar *filename)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
GPattern *pattern;
|
||||
gint bn_size;
|
||||
BrushHeader header;
|
||||
gchar *name;
|
||||
|
@ -310,32 +307,6 @@ gimp_brush_load_brush (gint fd,
|
|||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For backwards-compatibility, check if a pattern follows.
|
||||
The obsolete .gpb format did it this way. */
|
||||
pattern = pattern_load (fd, filename);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
if (pattern->mask && pattern->mask->bytes == 3)
|
||||
{
|
||||
brush->pixmap = pattern->mask;
|
||||
pattern->mask = NULL;
|
||||
}
|
||||
pattern_free (pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rewind to make brush pipe loader happy */
|
||||
if (lseek (fd, - ((off_t) sizeof (PatternHeader)), SEEK_CUR) < 0)
|
||||
{
|
||||
g_message (_("GIMP brush file appears to be corrupted: \"%s\"."),
|
||||
filename);
|
||||
g_free (name);
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
@ -359,7 +330,9 @@ gimp_brush_load_brush (gint fd,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_message ("Unsupported brush depth: %d\n in file \"%s\"\nGIMP Brushes must be GRAY or RGBA\n",
|
||||
g_message ("Unsupported brush depth: %d\n"
|
||||
"in file \"%s\"\n"
|
||||
"GIMP Brushes must be GRAY or RGBA",
|
||||
header.bytes, filename);
|
||||
g_free (name);
|
||||
return NULL;
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
#include "brush_header.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
/* this needs to go away */
|
||||
|
@ -135,7 +133,7 @@ gimp_brush_get_type (void)
|
|||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
if (! type)
|
||||
{
|
||||
static const GtkTypeInfo info =
|
||||
{
|
||||
|
@ -149,7 +147,7 @@ gimp_brush_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (gimp_object_get_type (), &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_OBJECT, &info);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
@ -237,7 +235,6 @@ gimp_brush_load_brush (gint fd,
|
|||
const gchar *filename)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
GPattern *pattern;
|
||||
gint bn_size;
|
||||
BrushHeader header;
|
||||
gchar *name;
|
||||
|
@ -310,32 +307,6 @@ gimp_brush_load_brush (gint fd,
|
|||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For backwards-compatibility, check if a pattern follows.
|
||||
The obsolete .gpb format did it this way. */
|
||||
pattern = pattern_load (fd, filename);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
if (pattern->mask && pattern->mask->bytes == 3)
|
||||
{
|
||||
brush->pixmap = pattern->mask;
|
||||
pattern->mask = NULL;
|
||||
}
|
||||
pattern_free (pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rewind to make brush pipe loader happy */
|
||||
if (lseek (fd, - ((off_t) sizeof (PatternHeader)), SEEK_CUR) < 0)
|
||||
{
|
||||
g_message (_("GIMP brush file appears to be corrupted: \"%s\"."),
|
||||
filename);
|
||||
g_free (name);
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
@ -359,7 +330,9 @@ gimp_brush_load_brush (gint fd,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_message ("Unsupported brush depth: %d\n in file \"%s\"\nGIMP Brushes must be GRAY or RGBA\n",
|
||||
g_message ("Unsupported brush depth: %d\n"
|
||||
"in file \"%s\"\n"
|
||||
"GIMP Brushes must be GRAY or RGBA",
|
||||
header.bytes, filename);
|
||||
g_free (name);
|
||||
return NULL;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -201,14 +202,66 @@ gimp_brush_generated_load (const gchar *file_name)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *file_name)
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *directory)
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
gchar *filename = NULL;
|
||||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
g_return_if_fail (directory != NULL);
|
||||
|
||||
if (! GIMP_BRUSH (brush)->filename)
|
||||
{
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
gint unum = 1;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace (safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
directory, safe_name);
|
||||
|
||||
while ((fp = fopen (filename, "r")))
|
||||
{
|
||||
/* make sure we don't overite an existing brush */
|
||||
fclose (fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
directory, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (GIMP_BRUSH (brush)->filename);
|
||||
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{
|
||||
/* we only want to save .vbr files, so set filename to null
|
||||
* if this isn't a .vbr file
|
||||
*/
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! filename)
|
||||
return;
|
||||
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if ((fp = fopen (filename, "wb")) == NULL)
|
||||
{
|
||||
g_warning ("Unable to save file %s", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -201,14 +202,66 @@ gimp_brush_generated_load (const gchar *file_name)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *file_name)
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *directory)
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
gchar *filename = NULL;
|
||||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
g_return_if_fail (directory != NULL);
|
||||
|
||||
if (! GIMP_BRUSH (brush)->filename)
|
||||
{
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
gint unum = 1;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace (safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
directory, safe_name);
|
||||
|
||||
while ((fp = fopen (filename, "r")))
|
||||
{
|
||||
/* make sure we don't overite an existing brush */
|
||||
fclose (fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
directory, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (GIMP_BRUSH (brush)->filename);
|
||||
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{
|
||||
/* we only want to save .vbr files, so set filename to null
|
||||
* if this isn't a .vbr file
|
||||
*/
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! filename)
|
||||
return;
|
||||
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if ((fp = fopen (filename, "wb")) == NULL)
|
||||
{
|
||||
g_warning ("Unable to save file %s", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -201,14 +202,66 @@ gimp_brush_generated_load (const gchar *file_name)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *file_name)
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *directory)
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
gchar *filename = NULL;
|
||||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
g_return_if_fail (directory != NULL);
|
||||
|
||||
if (! GIMP_BRUSH (brush)->filename)
|
||||
{
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
gint unum = 1;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace (safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
directory, safe_name);
|
||||
|
||||
while ((fp = fopen (filename, "r")))
|
||||
{
|
||||
/* make sure we don't overite an existing brush */
|
||||
fclose (fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
directory, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (GIMP_BRUSH (brush)->filename);
|
||||
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{
|
||||
/* we only want to save .vbr files, so set filename to null
|
||||
* if this isn't a .vbr file
|
||||
*/
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! filename)
|
||||
return;
|
||||
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if ((fp = fopen (filename, "wb")) == NULL)
|
||||
{
|
||||
g_warning ("Unable to save file %s", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,16 +53,15 @@ struct _GimpBrushGeneratedClass
|
|||
};
|
||||
|
||||
|
||||
GtkType gimp_brush_generated_get_type (void);
|
||||
|
||||
GimpBrush * gimp_brush_generated_new (gfloat radius,
|
||||
gfloat hardness,
|
||||
gfloat angle,
|
||||
gfloat aspect_ratio);
|
||||
GimpBrush * gimp_brush_generated_load (const gchar *file_name);
|
||||
GtkType gimp_brush_generated_get_type (void);
|
||||
GimpBrush * gimp_brush_generated_new (gfloat radius,
|
||||
gfloat hardness,
|
||||
gfloat angle,
|
||||
gfloat aspect_ratio);
|
||||
GimpBrush * gimp_brush_generated_load (const gchar *file_name);
|
||||
|
||||
void gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *file_name);
|
||||
const gchar *directory);
|
||||
void gimp_brush_generated_delete (GimpBrushGenerated *brush);
|
||||
|
||||
void gimp_brush_generated_freeze (GimpBrushGenerated *brush);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient_header.h"
|
||||
#include "gradient.h"
|
||||
|
@ -102,14 +103,24 @@ static void gimp_context_copy_paint_mode (GimpContext *src,
|
|||
GimpContext *dest);
|
||||
|
||||
/* brush */
|
||||
static void gimp_context_brush_dirty (GimpBrush *brush,
|
||||
GimpContext *context);
|
||||
static void gimp_context_brush_removed (GimpContainer *brush_list,
|
||||
GimpBrush *brush,
|
||||
GimpContext *context);
|
||||
static void gimp_context_real_set_brush (GimpContext *context,
|
||||
GimpBrush *brush);
|
||||
static void gimp_context_copy_brush (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
/* pattern */
|
||||
static void gimp_context_pattern_dirty (GimpPattern *pattern,
|
||||
GimpContext *context);
|
||||
static void gimp_context_pattern_removed (GimpContainer *brush_list,
|
||||
GimpPattern *pattern,
|
||||
GimpContext *context);
|
||||
static void gimp_context_real_set_pattern (GimpContext *context,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
static void gimp_context_copy_pattern (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
|
@ -343,8 +354,13 @@ gimp_context_destroy (GtkObject *object)
|
|||
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->brush), context);
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
}
|
||||
|
||||
if (context->brush_name)
|
||||
|
@ -353,6 +369,17 @@ gimp_context_destroy (GtkObject *object)
|
|||
context->brush_name = NULL;
|
||||
}
|
||||
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
}
|
||||
|
||||
if (context->pattern_name)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
|
@ -1355,8 +1382,12 @@ gimp_context_brush_removed (GimpContainer *brush_list,
|
|||
{
|
||||
context->brush = NULL;
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), context);
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
}
|
||||
}
|
||||
|
@ -1388,20 +1419,24 @@ gimp_context_real_set_brush (GimpContext *context,
|
|||
/* disconnect from the old brush's signals */
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->brush), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
|
||||
/* if we don't get a new brush, also disconnect from the brush list */
|
||||
if (! brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
}
|
||||
}
|
||||
/* if we get a new brush but didn't have one before... */
|
||||
else if (brush)
|
||||
{
|
||||
/* ...connect to the brush list */
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
|
||||
gtk_signal_connect (GTK_OBJECT (global_brush_list), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_context_brush_removed),
|
||||
context);
|
||||
}
|
||||
|
@ -1455,16 +1490,17 @@ gimp_context_refresh_brush (GimpContext *context,
|
|||
if (! context->brush_name)
|
||||
context->brush_name = g_strdup (default_brush);
|
||||
|
||||
if ((brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list,
|
||||
if ((brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
context->brush_name)))
|
||||
{
|
||||
gimp_context_real_set_brush (context, brush);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (brush_list)))
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (global_brush_list)))
|
||||
gimp_context_real_set_brush
|
||||
(context, GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, 0)));
|
||||
(context, GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list,
|
||||
0)));
|
||||
else
|
||||
gimp_context_real_set_brush (context, brushes_get_standard_brush ());
|
||||
}
|
||||
|
@ -1472,15 +1508,17 @@ gimp_context_refresh_brush (GimpContext *context,
|
|||
void
|
||||
gimp_context_refresh_brushes (void)
|
||||
{
|
||||
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_brush, NULL);
|
||||
g_slist_foreach (context_list,
|
||||
(GFunc) gimp_context_refresh_brush,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* pattern *****************************************************************/
|
||||
|
||||
static GPattern *standard_pattern = NULL;
|
||||
static GimpPattern *standard_pattern = NULL;
|
||||
|
||||
GPattern *
|
||||
GimpPattern *
|
||||
gimp_context_get_pattern (GimpContext *context)
|
||||
{
|
||||
context_check_current (context);
|
||||
|
@ -1491,7 +1529,7 @@ gimp_context_get_pattern (GimpContext *context)
|
|||
|
||||
void
|
||||
gimp_context_set_pattern (GimpContext *context,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
context_check_current (context);
|
||||
context_return_if_fail (context);
|
||||
|
@ -1511,9 +1549,40 @@ gimp_context_pattern_changed (GimpContext *context)
|
|||
context->pattern);
|
||||
}
|
||||
|
||||
/* the active pattern was modified */
|
||||
static void
|
||||
gimp_context_pattern_dirty (GimpPattern *pattern,
|
||||
GimpContext *context)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
|
||||
gimp_context_pattern_changed (context);
|
||||
}
|
||||
|
||||
/* the active pattern disappeared */
|
||||
static void
|
||||
gimp_context_pattern_removed (GimpContainer *pattern_list,
|
||||
GimpPattern *pattern,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (pattern == context->pattern)
|
||||
{
|
||||
context->pattern = NULL;
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (pattern));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_real_set_pattern (GimpContext *context,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
if (! standard_pattern)
|
||||
standard_pattern = patterns_get_standard_pattern ();
|
||||
|
@ -1527,10 +1596,59 @@ gimp_context_real_set_pattern (GimpContext *context,
|
|||
context->pattern_name = NULL;
|
||||
}
|
||||
|
||||
/* make sure the active pattern is swapped before we get a new one... */
|
||||
if (stingy_memory_use &&
|
||||
context->pattern && context->pattern->mask &&
|
||||
GTK_OBJECT (context->pattern)->ref_count == 2)
|
||||
{
|
||||
temp_buf_swap (pattern->mask);
|
||||
}
|
||||
|
||||
/* disconnect from the old pattern's signals */
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
|
||||
/* if we don't get a new pattern, also disconnect from the pattern list */
|
||||
if (! pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
}
|
||||
}
|
||||
/* if we get a new pattern but didn't have one before... */
|
||||
else if (pattern)
|
||||
{
|
||||
/* ...connect to the pattern list */
|
||||
gtk_signal_connect (GTK_OBJECT (global_pattern_list), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_context_pattern_removed),
|
||||
context);
|
||||
}
|
||||
|
||||
context->pattern = pattern;
|
||||
|
||||
if (pattern && pattern != standard_pattern)
|
||||
context->pattern_name = g_strdup (pattern->name);
|
||||
if (pattern)
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (pattern));
|
||||
gtk_signal_connect (GTK_OBJECT (pattern), "name_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_context_pattern_dirty),
|
||||
context);
|
||||
|
||||
/* Make sure the active pattern is unswapped... */
|
||||
if (stingy_memory_use &&
|
||||
pattern->mask &&
|
||||
GTK_OBJECT (pattern)->ref_count < 2)
|
||||
{
|
||||
temp_buf_unswap (pattern->mask);
|
||||
}
|
||||
|
||||
if (pattern != standard_pattern)
|
||||
context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
}
|
||||
|
||||
gimp_context_pattern_changed (context);
|
||||
}
|
||||
|
@ -1552,20 +1670,23 @@ static void
|
|||
gimp_context_refresh_pattern (GimpContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
if (! context->pattern_name)
|
||||
context->pattern_name = g_strdup (default_pattern);
|
||||
|
||||
if ((pattern = pattern_list_get_pattern (pattern_list,
|
||||
context->pattern_name)))
|
||||
if ((pattern =
|
||||
(GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
context->pattern_name)))
|
||||
{
|
||||
gimp_context_real_set_pattern (context, pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pattern = pattern_list_get_pattern_by_index (pattern_list, 0)))
|
||||
gimp_context_real_set_pattern (context, pattern);
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (global_pattern_list)))
|
||||
gimp_context_real_set_pattern
|
||||
(context, GIMP_PATTERN (gimp_list_get_child_by_index (global_pattern_list,
|
||||
0)));
|
||||
else
|
||||
gimp_context_real_set_pattern (context, patterns_get_standard_pattern ());
|
||||
}
|
||||
|
@ -1573,28 +1694,9 @@ gimp_context_refresh_pattern (GimpContext *context,
|
|||
void
|
||||
gimp_context_refresh_patterns (void)
|
||||
{
|
||||
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_pattern, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_update_pattern (GimpContext *context,
|
||||
GPattern *pattern)
|
||||
{
|
||||
if (context->pattern == pattern)
|
||||
{
|
||||
if (context->pattern_name)
|
||||
g_free (context->pattern_name);
|
||||
|
||||
context->pattern_name = g_strdup (pattern->name);
|
||||
|
||||
gimp_context_pattern_changed (context);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_update_patterns (GPattern *pattern)
|
||||
{
|
||||
g_slist_foreach (context_list, (GFunc) gimp_context_update_pattern, pattern);
|
||||
g_slist_foreach (context_list,
|
||||
(GFunc) gimp_context_refresh_pattern,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -97,7 +97,7 @@ struct _GimpContext
|
|||
GimpBrush *brush;
|
||||
gchar *brush_name;
|
||||
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
gchar *pattern_name;
|
||||
|
||||
gradient_t *gradient;
|
||||
|
@ -127,7 +127,7 @@ struct _GimpContextClass
|
|||
void (* brush_changed) (GimpContext *context,
|
||||
GimpBrush *brush);
|
||||
void (* pattern_changed) (GimpContext *context,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
void (* gradient_changed) (GimpContext *context,
|
||||
gradient_t *gradient);
|
||||
};
|
||||
|
@ -253,12 +253,11 @@ void gimp_context_brush_changed (GimpContext *context);
|
|||
void gimp_context_refresh_brushes (void);
|
||||
|
||||
/* pattern */
|
||||
GPattern * gimp_context_get_pattern (GimpContext *context);
|
||||
GimpPattern * gimp_context_get_pattern (GimpContext *context);
|
||||
void gimp_context_set_pattern (GimpContext *context,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
void gimp_context_pattern_changed (GimpContext *context);
|
||||
void gimp_context_refresh_patterns (void);
|
||||
void gimp_context_update_patterns (GPattern *pattern);
|
||||
|
||||
/* gradient */
|
||||
gradient_t * gimp_context_get_gradient (GimpContext *context);
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static void gimp_pattern_class_init (GimpPatternClass *klass);
|
||||
static void gimp_pattern_init (GimpPattern *pattern);
|
||||
static void gimp_pattern_destroy (GtkObject *object);
|
||||
|
||||
|
||||
static GimpObjectClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_pattern_get_type (void)
|
||||
{
|
||||
static GtkType pattern_type = 0;
|
||||
|
||||
if (! pattern_type)
|
||||
{
|
||||
static const GtkTypeInfo pattern_info =
|
||||
{
|
||||
"GimpPattern",
|
||||
sizeof (GimpPattern),
|
||||
sizeof (GimpPatternClass),
|
||||
(GtkClassInitFunc) gimp_pattern_class_init,
|
||||
(GtkObjectInitFunc) gimp_pattern_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
pattern_type = gtk_type_unique (GIMP_TYPE_OBJECT, &pattern_info);
|
||||
}
|
||||
|
||||
return pattern_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_class_init (GimpPatternClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
object_class->destroy = gimp_pattern_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_init (GimpPattern *pattern)
|
||||
{
|
||||
pattern->filename = NULL;
|
||||
pattern->mask = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_destroy (GtkObject *object)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = GIMP_PATTERN (object);
|
||||
|
||||
g_free (pattern->filename);
|
||||
|
||||
if (pattern->mask)
|
||||
temp_buf_free (pattern->mask);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GimpPattern *
|
||||
gimp_pattern_load (const gchar *filename)
|
||||
{
|
||||
GimpPattern *pattern = NULL;
|
||||
gint fd;
|
||||
PatternHeader header;
|
||||
gint bn_size;
|
||||
gchar *name = NULL;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
fd = open (filename, O_RDONLY | _O_BINARY);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
|
||||
/* Read in the header size */
|
||||
if (read (fd, &header, sizeof (header)) != sizeof (header))
|
||||
goto error;
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
header.header_size = g_ntohl (header.header_size);
|
||||
header.version = g_ntohl (header.version);
|
||||
header.width = g_ntohl (header.width);
|
||||
header.height = g_ntohl (header.height);
|
||||
header.bytes = g_ntohl (header.bytes);
|
||||
header.magic_number = g_ntohl (header.magic_number);
|
||||
|
||||
/* Check for correct file format */
|
||||
if (header.magic_number != GPATTERN_MAGIC || header.version != 1 ||
|
||||
header.header_size <= sizeof (header))
|
||||
{
|
||||
g_message (_("Unknown pattern format version #%d in \"%s\"."),
|
||||
header.version, filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Check for supported bit depths */
|
||||
if (header.bytes != 1 && header.bytes != 3)
|
||||
{
|
||||
g_message ("Unsupported pattern depth: %d\n"
|
||||
"in file \"%s\"\n"
|
||||
"GIMP Patterns must be GRAY or RGB\n",
|
||||
header.bytes, filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Read in the pattern name */
|
||||
if ((bn_size = (header.header_size - sizeof (header))))
|
||||
{
|
||||
name = g_new (gchar, bn_size);
|
||||
|
||||
if ((read (fd, name, bn_size)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP pattern file \"%s\"."), filename);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (_("Unnamed"));
|
||||
}
|
||||
|
||||
pattern = GIMP_PATTERN (gtk_type_new (GIMP_TYPE_PATTERN));
|
||||
pattern->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
if (read (fd, temp_buf_data (pattern->mask),
|
||||
header.width * header.height * header.bytes) <
|
||||
header.width * header.height * header.bytes)
|
||||
{
|
||||
g_message (_("GIMP pattern file appears to be truncated: \"%s\"."),
|
||||
filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
GIMP_OBJECT (pattern)->name = name;
|
||||
|
||||
pattern->filename = g_strdup (filename);
|
||||
|
||||
/* Swap the pattern to disk (if we're being stingy with memory) */
|
||||
if (stingy_memory_use)
|
||||
temp_buf_swap (pattern->mask);
|
||||
|
||||
return pattern;
|
||||
|
||||
error:
|
||||
if (pattern)
|
||||
gtk_object_unref (GTK_OBJECT (pattern));
|
||||
else if (name)
|
||||
g_free (name);
|
||||
|
||||
close (fd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TempBuf *
|
||||
gimp_pattern_get_mask (const GimpPattern *pattern)
|
||||
{
|
||||
g_return_val_if_fail (pattern != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
|
||||
|
||||
return pattern->mask;
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static void gimp_pattern_class_init (GimpPatternClass *klass);
|
||||
static void gimp_pattern_init (GimpPattern *pattern);
|
||||
static void gimp_pattern_destroy (GtkObject *object);
|
||||
|
||||
|
||||
static GimpObjectClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_pattern_get_type (void)
|
||||
{
|
||||
static GtkType pattern_type = 0;
|
||||
|
||||
if (! pattern_type)
|
||||
{
|
||||
static const GtkTypeInfo pattern_info =
|
||||
{
|
||||
"GimpPattern",
|
||||
sizeof (GimpPattern),
|
||||
sizeof (GimpPatternClass),
|
||||
(GtkClassInitFunc) gimp_pattern_class_init,
|
||||
(GtkObjectInitFunc) gimp_pattern_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
pattern_type = gtk_type_unique (GIMP_TYPE_OBJECT, &pattern_info);
|
||||
}
|
||||
|
||||
return pattern_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_class_init (GimpPatternClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
object_class->destroy = gimp_pattern_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_init (GimpPattern *pattern)
|
||||
{
|
||||
pattern->filename = NULL;
|
||||
pattern->mask = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_destroy (GtkObject *object)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = GIMP_PATTERN (object);
|
||||
|
||||
g_free (pattern->filename);
|
||||
|
||||
if (pattern->mask)
|
||||
temp_buf_free (pattern->mask);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GimpPattern *
|
||||
gimp_pattern_load (const gchar *filename)
|
||||
{
|
||||
GimpPattern *pattern = NULL;
|
||||
gint fd;
|
||||
PatternHeader header;
|
||||
gint bn_size;
|
||||
gchar *name = NULL;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
fd = open (filename, O_RDONLY | _O_BINARY);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
|
||||
/* Read in the header size */
|
||||
if (read (fd, &header, sizeof (header)) != sizeof (header))
|
||||
goto error;
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
header.header_size = g_ntohl (header.header_size);
|
||||
header.version = g_ntohl (header.version);
|
||||
header.width = g_ntohl (header.width);
|
||||
header.height = g_ntohl (header.height);
|
||||
header.bytes = g_ntohl (header.bytes);
|
||||
header.magic_number = g_ntohl (header.magic_number);
|
||||
|
||||
/* Check for correct file format */
|
||||
if (header.magic_number != GPATTERN_MAGIC || header.version != 1 ||
|
||||
header.header_size <= sizeof (header))
|
||||
{
|
||||
g_message (_("Unknown pattern format version #%d in \"%s\"."),
|
||||
header.version, filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Check for supported bit depths */
|
||||
if (header.bytes != 1 && header.bytes != 3)
|
||||
{
|
||||
g_message ("Unsupported pattern depth: %d\n"
|
||||
"in file \"%s\"\n"
|
||||
"GIMP Patterns must be GRAY or RGB\n",
|
||||
header.bytes, filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Read in the pattern name */
|
||||
if ((bn_size = (header.header_size - sizeof (header))))
|
||||
{
|
||||
name = g_new (gchar, bn_size);
|
||||
|
||||
if ((read (fd, name, bn_size)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP pattern file \"%s\"."), filename);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (_("Unnamed"));
|
||||
}
|
||||
|
||||
pattern = GIMP_PATTERN (gtk_type_new (GIMP_TYPE_PATTERN));
|
||||
pattern->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
if (read (fd, temp_buf_data (pattern->mask),
|
||||
header.width * header.height * header.bytes) <
|
||||
header.width * header.height * header.bytes)
|
||||
{
|
||||
g_message (_("GIMP pattern file appears to be truncated: \"%s\"."),
|
||||
filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
GIMP_OBJECT (pattern)->name = name;
|
||||
|
||||
pattern->filename = g_strdup (filename);
|
||||
|
||||
/* Swap the pattern to disk (if we're being stingy with memory) */
|
||||
if (stingy_memory_use)
|
||||
temp_buf_swap (pattern->mask);
|
||||
|
||||
return pattern;
|
||||
|
||||
error:
|
||||
if (pattern)
|
||||
gtk_object_unref (GTK_OBJECT (pattern));
|
||||
else if (name)
|
||||
g_free (name);
|
||||
|
||||
close (fd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TempBuf *
|
||||
gimp_pattern_get_mask (const GimpPattern *pattern)
|
||||
{
|
||||
g_return_val_if_fail (pattern != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
|
||||
|
||||
return pattern->mask;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PATTERN_H__
|
||||
#define __GIMP_PATTERN_H__
|
||||
|
||||
|
||||
#include "gimpobject.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PATTERN (gimp_pattern_get_type ())
|
||||
#define GIMP_PATTERN(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PATTERN, GimpPattern))
|
||||
#define GIMP_PATTERN_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATTERN, GimpPatternClass))
|
||||
#define GIMP_IS_PATTERN(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PATTERN))
|
||||
#define GIMP_IS_PATTERN_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATTERN))
|
||||
|
||||
|
||||
typedef struct _GimpPatternClass GimpPatternClass;
|
||||
|
||||
struct _GimpPattern
|
||||
{
|
||||
GimpObject parent_instance;
|
||||
|
||||
gchar *filename; /* actual filename--pattern's location on disk */
|
||||
TempBuf *mask; /* the actual mask */
|
||||
};
|
||||
|
||||
struct _GimpPatternClass
|
||||
{
|
||||
GimpObjectClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_pattern_get_type (void);
|
||||
GimpPattern * gimp_pattern_load (const gchar *filename);
|
||||
|
||||
TempBuf * gimp_pattern_get_mask (const GimpPattern *pattern);
|
||||
|
||||
|
||||
#endif /* __GIMP_PATTERN_H__ */
|
|
@ -33,9 +33,10 @@
|
|||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
|
@ -132,7 +133,7 @@ static void device_status_drop_brush (GtkWidget *widget,
|
|||
GimpBrush *brush,
|
||||
gpointer data);
|
||||
static void device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void device_status_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
|
@ -467,7 +468,8 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
@ -482,9 +484,10 @@ devices_rc_update (gchar *name,
|
|||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
|
@ -703,7 +706,7 @@ devices_write_rc_device (DeviceInfo *device_info,
|
|||
if (gimp_context_get_pattern (device_info->context))
|
||||
{
|
||||
fprintf (fp, "\n (pattern \"%s\")",
|
||||
gimp_context_get_pattern (device_info->context)->name);
|
||||
GIMP_OBJECT (gimp_context_get_pattern (device_info->context))->name);
|
||||
}
|
||||
|
||||
if (gimp_context_get_gradient (device_info->context))
|
||||
|
@ -1185,9 +1188,9 @@ device_status_drop_brush (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
DeviceInfo *device_info;
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "info_window.h"
|
||||
#include "layer_select.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "scale.h"
|
||||
#include "scroll.h"
|
||||
|
@ -1015,9 +1015,9 @@ gdisplay_drop_color (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
gdisplay_bucket_fill (widget, PATTERN_BUCKET_FILL, NULL, pattern->mask, data);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void gdisplay_drop_color (GtkWidget *widget,
|
|||
const GimpRGB *color,
|
||||
gpointer data);
|
||||
void gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "info_window.h"
|
||||
#include "layer_select.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "scale.h"
|
||||
#include "scroll.h"
|
||||
|
@ -1015,9 +1015,9 @@ gdisplay_drop_color (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
gdisplay_bucket_fill (widget, PATTERN_BUCKET_FILL, NULL, pattern->mask, data);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void gdisplay_drop_color (GtkWidget *widget,
|
|||
const GimpRGB *color,
|
||||
gpointer data);
|
||||
void gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "info_window.h"
|
||||
#include "layer_select.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "scale.h"
|
||||
#include "scroll.h"
|
||||
|
@ -1015,9 +1015,9 @@ gdisplay_drop_color (GtkWidget *widget,
|
|||
}
|
||||
|
||||
void
|
||||
gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
gdisplay_bucket_fill (widget, PATTERN_BUCKET_FILL, NULL, pattern->mask, data);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void gdisplay_drop_color (GtkWidget *widget,
|
|||
const GimpRGB *color,
|
||||
gpointer data);
|
||||
void gdisplay_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
|
||||
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
#include "brush_header.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
/* this needs to go away */
|
||||
|
@ -135,7 +133,7 @@ gimp_brush_get_type (void)
|
|||
{
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
if (! type)
|
||||
{
|
||||
static const GtkTypeInfo info =
|
||||
{
|
||||
|
@ -149,7 +147,7 @@ gimp_brush_get_type (void)
|
|||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (gimp_object_get_type (), &info);
|
||||
type = gtk_type_unique (GIMP_TYPE_OBJECT, &info);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
@ -237,7 +235,6 @@ gimp_brush_load_brush (gint fd,
|
|||
const gchar *filename)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
GPattern *pattern;
|
||||
gint bn_size;
|
||||
BrushHeader header;
|
||||
gchar *name;
|
||||
|
@ -310,32 +307,6 @@ gimp_brush_load_brush (gint fd,
|
|||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* For backwards-compatibility, check if a pattern follows.
|
||||
The obsolete .gpb format did it this way. */
|
||||
pattern = pattern_load (fd, filename);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
if (pattern->mask && pattern->mask->bytes == 3)
|
||||
{
|
||||
brush->pixmap = pattern->mask;
|
||||
pattern->mask = NULL;
|
||||
}
|
||||
pattern_free (pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rewind to make brush pipe loader happy */
|
||||
if (lseek (fd, - ((off_t) sizeof (PatternHeader)), SEEK_CUR) < 0)
|
||||
{
|
||||
g_message (_("GIMP brush file appears to be corrupted: \"%s\"."),
|
||||
filename);
|
||||
g_free (name);
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
@ -359,7 +330,9 @@ gimp_brush_load_brush (gint fd,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_message ("Unsupported brush depth: %d\n in file \"%s\"\nGIMP Brushes must be GRAY or RGBA\n",
|
||||
g_message ("Unsupported brush depth: %d\n"
|
||||
"in file \"%s\"\n"
|
||||
"GIMP Brushes must be GRAY or RGBA",
|
||||
header.bytes, filename);
|
||||
g_free (name);
|
||||
return NULL;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -201,14 +202,66 @@ gimp_brush_generated_load (const gchar *file_name)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *file_name)
|
||||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *directory)
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
gchar *filename = NULL;
|
||||
|
||||
if ((fp = fopen (file_name, "wb")) == NULL)
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (brush));
|
||||
g_return_if_fail (directory != NULL);
|
||||
|
||||
if (! GIMP_BRUSH (brush)->filename)
|
||||
{
|
||||
g_warning ("Unable to save file %s", file_name);
|
||||
gchar *safe_name;
|
||||
gint i;
|
||||
gint unum = 1;
|
||||
|
||||
/* make sure we don't create a naughty filename */
|
||||
safe_name = g_strdup (GIMP_OBJECT (brush)->name);
|
||||
if (safe_name[0] == '.')
|
||||
safe_name[0] = '_';
|
||||
for (i = 0; safe_name[i]; i++)
|
||||
if (safe_name[i] == G_DIR_SEPARATOR || isspace (safe_name[i]))
|
||||
safe_name[i] = '_';
|
||||
|
||||
filename = g_strdup_printf ("%s%s.vbr",
|
||||
directory, safe_name);
|
||||
|
||||
while ((fp = fopen (filename, "r")))
|
||||
{
|
||||
/* make sure we don't overite an existing brush */
|
||||
fclose (fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
directory, safe_name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (safe_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = g_strdup (GIMP_BRUSH (brush)->filename);
|
||||
|
||||
if (strlen(filename) < 4 || strcmp (&filename[strlen (filename) - 4],
|
||||
".vbr"))
|
||||
{
|
||||
/* we only want to save .vbr files, so set filename to null
|
||||
* if this isn't a .vbr file
|
||||
*/
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! filename)
|
||||
return;
|
||||
|
||||
/* we are (finaly) ready to try to save the generated brush file */
|
||||
if ((fp = fopen (filename, "wb")) == NULL)
|
||||
{
|
||||
g_warning ("Unable to save file %s", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,16 +53,15 @@ struct _GimpBrushGeneratedClass
|
|||
};
|
||||
|
||||
|
||||
GtkType gimp_brush_generated_get_type (void);
|
||||
|
||||
GimpBrush * gimp_brush_generated_new (gfloat radius,
|
||||
gfloat hardness,
|
||||
gfloat angle,
|
||||
gfloat aspect_ratio);
|
||||
GimpBrush * gimp_brush_generated_load (const gchar *file_name);
|
||||
GtkType gimp_brush_generated_get_type (void);
|
||||
GimpBrush * gimp_brush_generated_new (gfloat radius,
|
||||
gfloat hardness,
|
||||
gfloat angle,
|
||||
gfloat aspect_ratio);
|
||||
GimpBrush * gimp_brush_generated_load (const gchar *file_name);
|
||||
|
||||
void gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const gchar *file_name);
|
||||
const gchar *directory);
|
||||
void gimp_brush_generated_delete (GimpBrushGenerated *brush);
|
||||
|
||||
void gimp_brush_generated_freeze (GimpBrushGenerated *brush);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient_header.h"
|
||||
#include "gradient.h"
|
||||
|
@ -102,14 +103,24 @@ static void gimp_context_copy_paint_mode (GimpContext *src,
|
|||
GimpContext *dest);
|
||||
|
||||
/* brush */
|
||||
static void gimp_context_brush_dirty (GimpBrush *brush,
|
||||
GimpContext *context);
|
||||
static void gimp_context_brush_removed (GimpContainer *brush_list,
|
||||
GimpBrush *brush,
|
||||
GimpContext *context);
|
||||
static void gimp_context_real_set_brush (GimpContext *context,
|
||||
GimpBrush *brush);
|
||||
static void gimp_context_copy_brush (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
/* pattern */
|
||||
static void gimp_context_pattern_dirty (GimpPattern *pattern,
|
||||
GimpContext *context);
|
||||
static void gimp_context_pattern_removed (GimpContainer *brush_list,
|
||||
GimpPattern *pattern,
|
||||
GimpContext *context);
|
||||
static void gimp_context_real_set_pattern (GimpContext *context,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
static void gimp_context_copy_pattern (GimpContext *src,
|
||||
GimpContext *dest);
|
||||
|
||||
|
@ -343,8 +354,13 @@ gimp_context_destroy (GtkObject *object)
|
|||
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->brush), context);
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
}
|
||||
|
||||
if (context->brush_name)
|
||||
|
@ -353,6 +369,17 @@ gimp_context_destroy (GtkObject *object)
|
|||
context->brush_name = NULL;
|
||||
}
|
||||
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
}
|
||||
|
||||
if (context->pattern_name)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
|
@ -1355,8 +1382,12 @@ gimp_context_brush_removed (GimpContainer *brush_list,
|
|||
{
|
||||
context->brush = NULL;
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), context);
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
}
|
||||
}
|
||||
|
@ -1388,20 +1419,24 @@ gimp_context_real_set_brush (GimpContext *context,
|
|||
/* disconnect from the old brush's signals */
|
||||
if (context->brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (context->brush), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->brush));
|
||||
|
||||
/* if we don't get a new brush, also disconnect from the brush list */
|
||||
if (! brush)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_brush_list),
|
||||
gimp_context_brush_removed,
|
||||
context);
|
||||
}
|
||||
}
|
||||
/* if we get a new brush but didn't have one before... */
|
||||
else if (brush)
|
||||
{
|
||||
/* ...connect to the brush list */
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
|
||||
gtk_signal_connect (GTK_OBJECT (global_brush_list), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_context_brush_removed),
|
||||
context);
|
||||
}
|
||||
|
@ -1455,16 +1490,17 @@ gimp_context_refresh_brush (GimpContext *context,
|
|||
if (! context->brush_name)
|
||||
context->brush_name = g_strdup (default_brush);
|
||||
|
||||
if ((brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list,
|
||||
if ((brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
context->brush_name)))
|
||||
{
|
||||
gimp_context_real_set_brush (context, brush);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (brush_list)))
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (global_brush_list)))
|
||||
gimp_context_real_set_brush
|
||||
(context, GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, 0)));
|
||||
(context, GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list,
|
||||
0)));
|
||||
else
|
||||
gimp_context_real_set_brush (context, brushes_get_standard_brush ());
|
||||
}
|
||||
|
@ -1472,15 +1508,17 @@ gimp_context_refresh_brush (GimpContext *context,
|
|||
void
|
||||
gimp_context_refresh_brushes (void)
|
||||
{
|
||||
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_brush, NULL);
|
||||
g_slist_foreach (context_list,
|
||||
(GFunc) gimp_context_refresh_brush,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* pattern *****************************************************************/
|
||||
|
||||
static GPattern *standard_pattern = NULL;
|
||||
static GimpPattern *standard_pattern = NULL;
|
||||
|
||||
GPattern *
|
||||
GimpPattern *
|
||||
gimp_context_get_pattern (GimpContext *context)
|
||||
{
|
||||
context_check_current (context);
|
||||
|
@ -1491,7 +1529,7 @@ gimp_context_get_pattern (GimpContext *context)
|
|||
|
||||
void
|
||||
gimp_context_set_pattern (GimpContext *context,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
context_check_current (context);
|
||||
context_return_if_fail (context);
|
||||
|
@ -1511,9 +1549,40 @@ gimp_context_pattern_changed (GimpContext *context)
|
|||
context->pattern);
|
||||
}
|
||||
|
||||
/* the active pattern was modified */
|
||||
static void
|
||||
gimp_context_pattern_dirty (GimpPattern *pattern,
|
||||
GimpContext *context)
|
||||
{
|
||||
g_free (context->pattern_name);
|
||||
context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
|
||||
gimp_context_pattern_changed (context);
|
||||
}
|
||||
|
||||
/* the active pattern disappeared */
|
||||
static void
|
||||
gimp_context_pattern_removed (GimpContainer *pattern_list,
|
||||
GimpPattern *pattern,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (pattern == context->pattern)
|
||||
{
|
||||
context->pattern = NULL;
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (pattern));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_real_set_pattern (GimpContext *context,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
if (! standard_pattern)
|
||||
standard_pattern = patterns_get_standard_pattern ();
|
||||
|
@ -1527,10 +1596,59 @@ gimp_context_real_set_pattern (GimpContext *context,
|
|||
context->pattern_name = NULL;
|
||||
}
|
||||
|
||||
/* make sure the active pattern is swapped before we get a new one... */
|
||||
if (stingy_memory_use &&
|
||||
context->pattern && context->pattern->mask &&
|
||||
GTK_OBJECT (context->pattern)->ref_count == 2)
|
||||
{
|
||||
temp_buf_swap (pattern->mask);
|
||||
}
|
||||
|
||||
/* disconnect from the old pattern's signals */
|
||||
if (context->pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
gtk_object_unref (GTK_OBJECT (context->pattern));
|
||||
|
||||
/* if we don't get a new pattern, also disconnect from the pattern list */
|
||||
if (! pattern)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (global_pattern_list),
|
||||
gimp_context_pattern_removed,
|
||||
context);
|
||||
}
|
||||
}
|
||||
/* if we get a new pattern but didn't have one before... */
|
||||
else if (pattern)
|
||||
{
|
||||
/* ...connect to the pattern list */
|
||||
gtk_signal_connect (GTK_OBJECT (global_pattern_list), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_context_pattern_removed),
|
||||
context);
|
||||
}
|
||||
|
||||
context->pattern = pattern;
|
||||
|
||||
if (pattern && pattern != standard_pattern)
|
||||
context->pattern_name = g_strdup (pattern->name);
|
||||
if (pattern)
|
||||
{
|
||||
gtk_object_ref (GTK_OBJECT (pattern));
|
||||
gtk_signal_connect (GTK_OBJECT (pattern), "name_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_context_pattern_dirty),
|
||||
context);
|
||||
|
||||
/* Make sure the active pattern is unswapped... */
|
||||
if (stingy_memory_use &&
|
||||
pattern->mask &&
|
||||
GTK_OBJECT (pattern)->ref_count < 2)
|
||||
{
|
||||
temp_buf_unswap (pattern->mask);
|
||||
}
|
||||
|
||||
if (pattern != standard_pattern)
|
||||
context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
}
|
||||
|
||||
gimp_context_pattern_changed (context);
|
||||
}
|
||||
|
@ -1552,20 +1670,23 @@ static void
|
|||
gimp_context_refresh_pattern (GimpContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
if (! context->pattern_name)
|
||||
context->pattern_name = g_strdup (default_pattern);
|
||||
|
||||
if ((pattern = pattern_list_get_pattern (pattern_list,
|
||||
context->pattern_name)))
|
||||
if ((pattern =
|
||||
(GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
context->pattern_name)))
|
||||
{
|
||||
gimp_context_real_set_pattern (context, pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pattern = pattern_list_get_pattern_by_index (pattern_list, 0)))
|
||||
gimp_context_real_set_pattern (context, pattern);
|
||||
if (gimp_container_num_children (GIMP_CONTAINER (global_pattern_list)))
|
||||
gimp_context_real_set_pattern
|
||||
(context, GIMP_PATTERN (gimp_list_get_child_by_index (global_pattern_list,
|
||||
0)));
|
||||
else
|
||||
gimp_context_real_set_pattern (context, patterns_get_standard_pattern ());
|
||||
}
|
||||
|
@ -1573,28 +1694,9 @@ gimp_context_refresh_pattern (GimpContext *context,
|
|||
void
|
||||
gimp_context_refresh_patterns (void)
|
||||
{
|
||||
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_pattern, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_update_pattern (GimpContext *context,
|
||||
GPattern *pattern)
|
||||
{
|
||||
if (context->pattern == pattern)
|
||||
{
|
||||
if (context->pattern_name)
|
||||
g_free (context->pattern_name);
|
||||
|
||||
context->pattern_name = g_strdup (pattern->name);
|
||||
|
||||
gimp_context_pattern_changed (context);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_update_patterns (GPattern *pattern)
|
||||
{
|
||||
g_slist_foreach (context_list, (GFunc) gimp_context_update_pattern, pattern);
|
||||
g_slist_foreach (context_list,
|
||||
(GFunc) gimp_context_refresh_pattern,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -97,7 +97,7 @@ struct _GimpContext
|
|||
GimpBrush *brush;
|
||||
gchar *brush_name;
|
||||
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
gchar *pattern_name;
|
||||
|
||||
gradient_t *gradient;
|
||||
|
@ -127,7 +127,7 @@ struct _GimpContextClass
|
|||
void (* brush_changed) (GimpContext *context,
|
||||
GimpBrush *brush);
|
||||
void (* pattern_changed) (GimpContext *context,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
void (* gradient_changed) (GimpContext *context,
|
||||
gradient_t *gradient);
|
||||
};
|
||||
|
@ -253,12 +253,11 @@ void gimp_context_brush_changed (GimpContext *context);
|
|||
void gimp_context_refresh_brushes (void);
|
||||
|
||||
/* pattern */
|
||||
GPattern * gimp_context_get_pattern (GimpContext *context);
|
||||
GimpPattern * gimp_context_get_pattern (GimpContext *context);
|
||||
void gimp_context_set_pattern (GimpContext *context,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
void gimp_context_pattern_changed (GimpContext *context);
|
||||
void gimp_context_refresh_patterns (void);
|
||||
void gimp_context_update_patterns (GPattern *pattern);
|
||||
|
||||
/* gradient */
|
||||
gradient_t * gimp_context_get_gradient (GimpContext *context);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "gimpbrushpipe.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
#include "patterns.h"
|
||||
|
@ -372,8 +373,8 @@ gimp_context_preview_update (GimpContextPreview *gcp,
|
|||
break;
|
||||
case GCP_PATTERN:
|
||||
{
|
||||
GPattern *pattern = (GPattern *) (gcp->data);
|
||||
name = pattern->name;
|
||||
GimpPattern *pattern = GIMP_PATTERN (gcp->data);
|
||||
name = GIMP_OBJECT (pattern)->name;
|
||||
}
|
||||
break;
|
||||
case GCP_GRADIENT:
|
||||
|
@ -495,7 +496,8 @@ gimp_context_preview_popup_timeout (gpointer data)
|
|||
break;
|
||||
case GCP_PATTERN:
|
||||
{
|
||||
GPattern *pattern = (GPattern*)gcp->data;
|
||||
GimpPattern *pattern = GIMP_PATTERN (gcp->data);
|
||||
|
||||
gcp->popup_width = pattern->mask->width;
|
||||
gcp->popup_height = pattern->mask->height;
|
||||
if (gcp->popup_width <= gcp->width && gcp->popup_height <= gcp->height)
|
||||
|
@ -827,10 +829,10 @@ brush_rename_callback (GimpBrush *brush,
|
|||
/* pattern draw functions */
|
||||
|
||||
void
|
||||
draw_pattern (GtkPreview *preview,
|
||||
GPattern *pattern,
|
||||
gint width,
|
||||
gint height)
|
||||
draw_pattern (GtkPreview *preview,
|
||||
GimpPattern *pattern,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
gint pattern_width, pattern_height;
|
||||
guchar *mask, *src, *buf, *b;
|
||||
|
@ -875,11 +877,12 @@ draw_pattern (GtkPreview *preview,
|
|||
static void
|
||||
gimp_context_preview_draw_pattern_popup (GimpContextPreview *gcp)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
g_return_if_fail (gcp != NULL && gcp->data != NULL);
|
||||
|
||||
pattern = (GPattern*)(gcp->data);
|
||||
pattern = GIMP_PATTERN (gcp->data);
|
||||
|
||||
draw_pattern (GTK_PREVIEW (gcp_popup_preview), pattern,
|
||||
gcp->popup_width, gcp->popup_height);
|
||||
}
|
||||
|
@ -887,11 +890,12 @@ gimp_context_preview_draw_pattern_popup (GimpContextPreview *gcp)
|
|||
static void
|
||||
gimp_context_preview_draw_pattern (GimpContextPreview *gcp)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
g_return_if_fail (gcp != NULL && gcp->data != NULL);
|
||||
|
||||
pattern = (GPattern*)(gcp->data);
|
||||
pattern = GIMP_PATTERN (gcp->data);
|
||||
|
||||
draw_pattern (GTK_PREVIEW (gcp), pattern, gcp->width, gcp->height);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,19 +82,19 @@ void gimp_context_preview_update (GimpContextPreview *gcp,
|
|||
* app and plugins.
|
||||
*/
|
||||
|
||||
void draw_brush (GtkPreview *preview,
|
||||
GimpBrush *brush,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean is_popup);
|
||||
void draw_pattern (GtkPreview *preview,
|
||||
GPattern *pattern,
|
||||
gint width,
|
||||
gint height);
|
||||
void draw_gradient (GtkPreview *preview,
|
||||
gradient_t *gradient,
|
||||
gint width,
|
||||
gint height);
|
||||
void draw_brush (GtkPreview *preview,
|
||||
GimpBrush *brush,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean is_popup);
|
||||
void draw_pattern (GtkPreview *preview,
|
||||
GimpPattern *pattern,
|
||||
gint width,
|
||||
gint height);
|
||||
void draw_gradient (GtkPreview *preview,
|
||||
gradient_t *gradient,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawablepreview.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -661,7 +662,7 @@ gimp_dnd_set_brush_data (GtkWidget *widget,
|
|||
if (strcmp (name, "Standard") == 0)
|
||||
brush = brushes_get_standard_brush ();
|
||||
else
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, name);
|
||||
|
||||
if (brush)
|
||||
(* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data);
|
||||
|
@ -696,8 +697,8 @@ gimp_dnd_get_pattern_icon (GtkWidget *widget,
|
|||
GtkSignalFunc get_pattern_func,
|
||||
gpointer get_pattern_data)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GPattern *pattern;
|
||||
GtkWidget *preview;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = (* (GimpDndDragPatternFunc) get_pattern_func) (widget,
|
||||
get_pattern_data);
|
||||
|
@ -722,8 +723,8 @@ gimp_dnd_get_pattern_data (GtkWidget *widget,
|
|||
gint *format,
|
||||
gint *length)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gchar *name;
|
||||
GimpPattern *pattern;
|
||||
gchar *name;
|
||||
|
||||
pattern = (* (GimpDndDragPatternFunc) get_pattern_func) (widget,
|
||||
get_pattern_data);
|
||||
|
@ -731,7 +732,7 @@ gimp_dnd_get_pattern_data (GtkWidget *widget,
|
|||
if (! pattern)
|
||||
return NULL;
|
||||
|
||||
name = g_strdup (pattern->name);
|
||||
name = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
|
||||
*format = 8;
|
||||
*length = strlen (name) + 1;
|
||||
|
@ -747,8 +748,8 @@ gimp_dnd_set_pattern_data (GtkWidget *widget,
|
|||
gint format,
|
||||
gint length)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gchar *name;
|
||||
GimpPattern *pattern;
|
||||
gchar *name;
|
||||
|
||||
if ((format != 8) || (length < 1))
|
||||
{
|
||||
|
@ -761,7 +762,8 @@ gimp_dnd_set_pattern_data (GtkWidget *widget,
|
|||
if (strcmp (name, "Standard") == 0)
|
||||
pattern = patterns_get_standard_pattern ();
|
||||
else
|
||||
pattern = pattern_list_get_pattern (pattern_list, name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
name);
|
||||
|
||||
if (pattern)
|
||||
(* (GimpDndDropPatternFunc) set_pattern_func) (widget, pattern,
|
||||
|
|
|
@ -124,11 +124,11 @@ void gimp_dnd_brush_dest_set (GtkWidget *widget,
|
|||
|
||||
/* pattern dnd functions */
|
||||
|
||||
typedef void (* GimpDndDropPatternFunc) (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data);
|
||||
typedef GPattern * (* GimpDndDragPatternFunc) (GtkWidget *widget,
|
||||
gpointer data);
|
||||
typedef void (* GimpDndDropPatternFunc) (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
typedef GimpPattern * (* GimpDndDragPatternFunc) (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
void gimp_dnd_pattern_source_set (GtkWidget *widget,
|
||||
GimpDndDragPatternFunc get_pattern_func,
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static void gimp_pattern_class_init (GimpPatternClass *klass);
|
||||
static void gimp_pattern_init (GimpPattern *pattern);
|
||||
static void gimp_pattern_destroy (GtkObject *object);
|
||||
|
||||
|
||||
static GimpObjectClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gimp_pattern_get_type (void)
|
||||
{
|
||||
static GtkType pattern_type = 0;
|
||||
|
||||
if (! pattern_type)
|
||||
{
|
||||
static const GtkTypeInfo pattern_info =
|
||||
{
|
||||
"GimpPattern",
|
||||
sizeof (GimpPattern),
|
||||
sizeof (GimpPatternClass),
|
||||
(GtkClassInitFunc) gimp_pattern_class_init,
|
||||
(GtkObjectInitFunc) gimp_pattern_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
pattern_type = gtk_type_unique (GIMP_TYPE_OBJECT, &pattern_info);
|
||||
}
|
||||
|
||||
return pattern_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_class_init (GimpPatternClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
|
||||
object_class->destroy = gimp_pattern_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_init (GimpPattern *pattern)
|
||||
{
|
||||
pattern->filename = NULL;
|
||||
pattern->mask = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_destroy (GtkObject *object)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = GIMP_PATTERN (object);
|
||||
|
||||
g_free (pattern->filename);
|
||||
|
||||
if (pattern->mask)
|
||||
temp_buf_free (pattern->mask);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
GimpPattern *
|
||||
gimp_pattern_load (const gchar *filename)
|
||||
{
|
||||
GimpPattern *pattern = NULL;
|
||||
gint fd;
|
||||
PatternHeader header;
|
||||
gint bn_size;
|
||||
gchar *name = NULL;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
fd = open (filename, O_RDONLY | _O_BINARY);
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
|
||||
/* Read in the header size */
|
||||
if (read (fd, &header, sizeof (header)) != sizeof (header))
|
||||
goto error;
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
header.header_size = g_ntohl (header.header_size);
|
||||
header.version = g_ntohl (header.version);
|
||||
header.width = g_ntohl (header.width);
|
||||
header.height = g_ntohl (header.height);
|
||||
header.bytes = g_ntohl (header.bytes);
|
||||
header.magic_number = g_ntohl (header.magic_number);
|
||||
|
||||
/* Check for correct file format */
|
||||
if (header.magic_number != GPATTERN_MAGIC || header.version != 1 ||
|
||||
header.header_size <= sizeof (header))
|
||||
{
|
||||
g_message (_("Unknown pattern format version #%d in \"%s\"."),
|
||||
header.version, filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Check for supported bit depths */
|
||||
if (header.bytes != 1 && header.bytes != 3)
|
||||
{
|
||||
g_message ("Unsupported pattern depth: %d\n"
|
||||
"in file \"%s\"\n"
|
||||
"GIMP Patterns must be GRAY or RGB\n",
|
||||
header.bytes, filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Read in the pattern name */
|
||||
if ((bn_size = (header.header_size - sizeof (header))))
|
||||
{
|
||||
name = g_new (gchar, bn_size);
|
||||
|
||||
if ((read (fd, name, bn_size)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP pattern file \"%s\"."), filename);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (_("Unnamed"));
|
||||
}
|
||||
|
||||
pattern = GIMP_PATTERN (gtk_type_new (GIMP_TYPE_PATTERN));
|
||||
pattern->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
if (read (fd, temp_buf_data (pattern->mask),
|
||||
header.width * header.height * header.bytes) <
|
||||
header.width * header.height * header.bytes)
|
||||
{
|
||||
g_message (_("GIMP pattern file appears to be truncated: \"%s\"."),
|
||||
filename);
|
||||
goto error;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
|
||||
GIMP_OBJECT (pattern)->name = name;
|
||||
|
||||
pattern->filename = g_strdup (filename);
|
||||
|
||||
/* Swap the pattern to disk (if we're being stingy with memory) */
|
||||
if (stingy_memory_use)
|
||||
temp_buf_swap (pattern->mask);
|
||||
|
||||
return pattern;
|
||||
|
||||
error:
|
||||
if (pattern)
|
||||
gtk_object_unref (GTK_OBJECT (pattern));
|
||||
else if (name)
|
||||
g_free (name);
|
||||
|
||||
close (fd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TempBuf *
|
||||
gimp_pattern_get_mask (const GimpPattern *pattern)
|
||||
{
|
||||
g_return_val_if_fail (pattern != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
|
||||
|
||||
return pattern->mask;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PATTERN_H__
|
||||
#define __GIMP_PATTERN_H__
|
||||
|
||||
|
||||
#include "gimpobject.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PATTERN (gimp_pattern_get_type ())
|
||||
#define GIMP_PATTERN(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PATTERN, GimpPattern))
|
||||
#define GIMP_PATTERN_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATTERN, GimpPatternClass))
|
||||
#define GIMP_IS_PATTERN(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PATTERN))
|
||||
#define GIMP_IS_PATTERN_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATTERN))
|
||||
|
||||
|
||||
typedef struct _GimpPatternClass GimpPatternClass;
|
||||
|
||||
struct _GimpPattern
|
||||
{
|
||||
GimpObject parent_instance;
|
||||
|
||||
gchar *filename; /* actual filename--pattern's location on disk */
|
||||
TempBuf *mask; /* the actual mask */
|
||||
};
|
||||
|
||||
struct _GimpPatternClass
|
||||
{
|
||||
GimpObjectClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_pattern_get_type (void);
|
||||
GimpPattern * gimp_pattern_load (const gchar *filename);
|
||||
|
||||
TempBuf * gimp_pattern_get_mask (const GimpPattern *pattern);
|
||||
|
||||
|
||||
#endif /* __GIMP_PATTERN_H__ */
|
|
@ -310,7 +310,8 @@ brush_select_new (gchar *title,
|
|||
|
||||
if (title && init_name && strlen (init_name))
|
||||
{
|
||||
active = (GimpBrush *) gimp_list_get_child_by_name (brush_list, init_name);
|
||||
active = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
init_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -526,20 +527,20 @@ brush_select_new (gchar *title,
|
|||
/* add callbacks to keep the display area current */
|
||||
bsp->name_changed_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "name_changed",
|
||||
(GIMP_CONTAINER (global_brush_list), "name_changed",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
bsp->dirty_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (brush_list), "dirty",
|
||||
(GIMP_CONTAINER (global_brush_list), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
bsp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
|
||||
gtk_signal_connect (GTK_OBJECT (global_brush_list), "add",
|
||||
GTK_SIGNAL_FUNC (brush_added_callback),
|
||||
bsp);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
|
||||
gtk_signal_connect (GTK_OBJECT (global_brush_list), "remove",
|
||||
GTK_SIGNAL_FUNC (brush_removed_callback),
|
||||
bsp);
|
||||
|
||||
|
@ -599,12 +600,12 @@ brush_select_free (BrushSelect *bsp)
|
|||
gtk_object_unref (GTK_OBJECT (bsp->context));
|
||||
}
|
||||
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (global_brush_list),
|
||||
bsp->name_changed_handler_id);
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (global_brush_list),
|
||||
bsp->dirty_handler_id);
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), bsp);
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (global_brush_list), bsp);
|
||||
|
||||
g_free (bsp);
|
||||
}
|
||||
|
@ -613,7 +614,7 @@ void
|
|||
brush_select_freeze_all (void)
|
||||
{
|
||||
BrushSelect *bsp;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
for (list = brush_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
|
@ -627,7 +628,7 @@ void
|
|||
brush_select_thaw_all (void)
|
||||
{
|
||||
BrushSelect *bsp;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
for (list = brush_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
|
@ -835,7 +836,7 @@ brush_select_select (BrushSelect *bsp,
|
|||
gint row, col;
|
||||
gint scroll_offset = 0;
|
||||
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
@ -885,7 +886,7 @@ brush_select_brush_dirty_callback (GimpBrush *brush,
|
|||
if (!bsp || bsp->freeze)
|
||||
return;
|
||||
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (brush));
|
||||
index = gimp_list_get_child_index (global_brush_list, GIMP_OBJECT (brush));
|
||||
redraw = (brush != gimp_context_get_brush (bsp->context));
|
||||
|
||||
clear_brush (bsp, brush,
|
||||
|
@ -1351,8 +1352,8 @@ do_display_brush (GimpBrush *brush,
|
|||
static void
|
||||
display_brushes (BrushSelect *bsp)
|
||||
{
|
||||
if (brush_list == NULL ||
|
||||
gimp_container_num_children (GIMP_CONTAINER (brush_list)) == 0)
|
||||
if (global_brush_list == NULL ||
|
||||
gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) == 0)
|
||||
{
|
||||
gtk_widget_set_sensitive (bsp->options_box, FALSE);
|
||||
return;
|
||||
|
@ -1366,7 +1367,7 @@ display_brushes (BrushSelect *bsp)
|
|||
display_setup (bsp);
|
||||
|
||||
brush_counter = 0;
|
||||
gimp_container_foreach (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_foreach (GIMP_CONTAINER (global_brush_list),
|
||||
(GFunc) do_display_brush,
|
||||
bsp);
|
||||
}
|
||||
|
@ -1492,7 +1493,7 @@ preview_calc_scrollbar (BrushSelect *bsp)
|
|||
gint max;
|
||||
|
||||
bsp->scroll_offset = 0;
|
||||
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
num_rows = ((gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) +
|
||||
(bsp->NUM_BRUSH_COLUMNS) - 1)
|
||||
/ (bsp->NUM_BRUSH_COLUMNS));
|
||||
max = num_rows * bsp->cell_width;
|
||||
|
@ -1533,7 +1534,7 @@ brush_select_resize (GtkWidget *widget,
|
|||
bsp->NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid / cell_size);
|
||||
bsp->NUM_BRUSH_ROWS =
|
||||
(gint) ((gimp_container_num_children (GIMP_CONTAINER (brush_list)) +
|
||||
(gint) ((gimp_container_num_children (GIMP_CONTAINER (global_brush_list)) +
|
||||
bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
bsp->NUM_BRUSH_COLUMNS);
|
||||
|
||||
|
@ -1567,7 +1568,8 @@ brush_select_events (GtkWidget *widget,
|
|||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
/* Get the brush and check if it is editable */
|
||||
brush = GIMP_BRUSH (gimp_list_get_child_by_index (brush_list, index));
|
||||
brush = GIMP_BRUSH (gimp_list_get_child_by_index (global_brush_list,
|
||||
index));
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
brush_select_edit_brush_callback (NULL, bsp);
|
||||
break;
|
||||
|
@ -1579,7 +1581,8 @@ brush_select_events (GtkWidget *widget,
|
|||
row = (bevent->y + bsp->scroll_offset) / bsp->cell_height;
|
||||
index = row * bsp->NUM_BRUSH_COLUMNS + col;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_index (brush_list, index);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_index (global_brush_list,
|
||||
index);
|
||||
|
||||
if (brush)
|
||||
bsp->dnd_brush = brush;
|
||||
|
@ -1706,7 +1709,8 @@ brush_select_scroll_update (GtkAdjustment *adjustment,
|
|||
|
||||
if (active)
|
||||
{
|
||||
index = gimp_list_get_child_index (brush_list, GIMP_OBJECT (active));
|
||||
index = gimp_list_get_child_index (global_brush_list,
|
||||
GIMP_OBJECT (active));
|
||||
if (index < 0)
|
||||
return;
|
||||
row = index / bsp->NUM_BRUSH_COLUMNS;
|
||||
|
@ -1810,7 +1814,7 @@ brush_select_new_brush_callback (GtkWidget *widget,
|
|||
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
||||
if (brush)
|
||||
{
|
||||
gimp_container_add (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_add (GIMP_CONTAINER (global_brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
|
||||
gimp_context_set_brush (bsp->context, brush);
|
||||
|
@ -1870,7 +1874,7 @@ brush_select_delete_brush_callback (GtkWidget *widget,
|
|||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
gimp_container_remove (GIMP_CONTAINER (brush_list),
|
||||
gimp_container_remove (GIMP_CONTAINER (global_brush_list),
|
||||
GIMP_OBJECT (brush));
|
||||
gimp_context_refresh_brushes ();
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ extern GSList *brush_active_dialogs;
|
|||
/* the main brush dialog */
|
||||
extern BrushSelect *brush_select_dialog;
|
||||
|
||||
|
||||
BrushSelect * brush_select_new (gchar *title,
|
||||
/* These are the required initial vals
|
||||
* If init_name == NULL then use
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
|
@ -132,7 +133,7 @@ static void device_status_drop_brush (GtkWidget *widget,
|
|||
GimpBrush *brush,
|
||||
gpointer data);
|
||||
static void device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void device_status_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
|
@ -467,7 +468,8 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
@ -482,9 +484,10 @@ devices_rc_update (gchar *name,
|
|||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
|
@ -703,7 +706,7 @@ devices_write_rc_device (DeviceInfo *device_info,
|
|||
if (gimp_context_get_pattern (device_info->context))
|
||||
{
|
||||
fprintf (fp, "\n (pattern \"%s\")",
|
||||
gimp_context_get_pattern (device_info->context)->name);
|
||||
GIMP_OBJECT (gimp_context_get_pattern (device_info->context))->name);
|
||||
}
|
||||
|
||||
if (gimp_context_get_gradient (device_info->context))
|
||||
|
@ -1185,9 +1188,9 @@ device_status_drop_brush (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
DeviceInfo *device_info;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ brush_preview_drop_brush (GtkWidget *widget,
|
|||
|
||||
static void
|
||||
pattern_area_update (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
if (pattern)
|
||||
|
@ -91,9 +91,9 @@ pattern_preview_clicked (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
pattern_preview_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
pattern_preview_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
if (pattern)
|
||||
gimp_context_set_pattern (gimp_context_get_user (), pattern);
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
|
@ -132,7 +133,7 @@ static void device_status_drop_brush (GtkWidget *widget,
|
|||
GimpBrush *brush,
|
||||
gpointer data);
|
||||
static void device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void device_status_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
|
@ -467,7 +468,8 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
@ -482,9 +484,10 @@ devices_rc_update (gchar *name,
|
|||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
|
@ -703,7 +706,7 @@ devices_write_rc_device (DeviceInfo *device_info,
|
|||
if (gimp_context_get_pattern (device_info->context))
|
||||
{
|
||||
fprintf (fp, "\n (pattern \"%s\")",
|
||||
gimp_context_get_pattern (device_info->context)->name);
|
||||
GIMP_OBJECT (gimp_context_get_pattern (device_info->context))->name);
|
||||
}
|
||||
|
||||
if (gimp_context_get_gradient (device_info->context))
|
||||
|
@ -1185,9 +1188,9 @@ device_status_drop_brush (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
DeviceInfo *device_info;
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "dialog_handler.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_select.h"
|
||||
#include "session.h"
|
||||
|
@ -63,40 +65,61 @@
|
|||
static void pattern_change_callbacks (PatternSelect *psp,
|
||||
gboolean closing);
|
||||
|
||||
static GPattern * pattern_select_drag_pattern (GtkWidget *widget,
|
||||
static GimpPattern * pattern_select_drag_pattern(GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void pattern_select_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void pattern_select_pattern_changed (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp);
|
||||
static void pattern_select_select (PatternSelect *psp,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
|
||||
static void pattern_select_pattern_dirty_callback (GimpPattern *brush,
|
||||
PatternSelect *psp);
|
||||
static void pattern_added_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp);
|
||||
static void pattern_removed_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp);
|
||||
|
||||
static gboolean pattern_popup_timeout (gpointer data);
|
||||
static void pattern_popup_open (PatternSelect *psp,
|
||||
gint, gint, GPattern *);
|
||||
static void pattern_popup_close (PatternSelect *);
|
||||
gint ,
|
||||
gint ,
|
||||
GimpPattern *pattern);
|
||||
static void pattern_popup_close (PatternSelect *psp);
|
||||
|
||||
static void display_setup (PatternSelect *);
|
||||
static void display_pattern (PatternSelect *, GPattern *,
|
||||
gint, gint);
|
||||
static void display_patterns (PatternSelect *);
|
||||
static void display_setup (PatternSelect *psp);
|
||||
static void display_pattern (PatternSelect *psp,
|
||||
GimpPattern *pattern,
|
||||
gint ,
|
||||
gint );
|
||||
static void display_patterns (PatternSelect *psp);
|
||||
|
||||
static void pattern_select_show_selected (PatternSelect *, gint, gint);
|
||||
static void update_active_pattern_field (PatternSelect *);
|
||||
static void preview_calc_scrollbar (PatternSelect *);
|
||||
static void pattern_select_show_selected (PatternSelect *psp,
|
||||
gint ,
|
||||
gint );
|
||||
static void update_active_pattern_field (PatternSelect *psp);
|
||||
static void preview_calc_scrollbar (PatternSelect *psp);
|
||||
|
||||
static gint pattern_select_resize (GtkWidget *, GdkEvent *,
|
||||
PatternSelect *);
|
||||
static gint pattern_select_events (GtkWidget *, GdkEvent *,
|
||||
PatternSelect *);
|
||||
static gint pattern_select_resize (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
PatternSelect *psp);
|
||||
static gint pattern_select_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
PatternSelect *psp);
|
||||
|
||||
static void pattern_select_scroll_update (GtkAdjustment *, gpointer);
|
||||
static void pattern_select_scroll_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
|
||||
static void pattern_select_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void pattern_select_refresh_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void pattern_select_close_callback (GtkWidget *, gpointer);
|
||||
static void pattern_select_refresh_callback (GtkWidget *, gpointer);
|
||||
|
||||
/* dnd stuff */
|
||||
static GtkTargetEntry preview_target_table[] =
|
||||
|
@ -131,7 +154,7 @@ pattern_dialog_create (void)
|
|||
}
|
||||
|
||||
void
|
||||
pattern_dialog_free ()
|
||||
pattern_dialog_free (void)
|
||||
{
|
||||
if (pattern_select_dialog)
|
||||
{
|
||||
|
@ -155,7 +178,7 @@ pattern_select_new (gchar *title,
|
|||
GtkWidget *sbar;
|
||||
GtkWidget *label_box;
|
||||
|
||||
GPattern *active = NULL;
|
||||
GimpPattern *active = NULL;
|
||||
|
||||
static gboolean first_call = TRUE;
|
||||
|
||||
|
@ -169,6 +192,8 @@ pattern_select_new (gchar *title,
|
|||
psp->old_row = 0;
|
||||
psp->NUM_PATTERN_COLUMNS = STD_PATTERN_COLUMNS;
|
||||
psp->NUM_PATTERN_ROWS = STD_PATTERN_COLUMNS;
|
||||
psp->redraw = TRUE;
|
||||
psp->freeze = FALSE;
|
||||
|
||||
/* The shell */
|
||||
psp->shell = gimp_dialog_new (title ? title : _("Pattern Selection"),
|
||||
|
@ -205,7 +230,8 @@ pattern_select_new (gchar *title,
|
|||
|
||||
if (title && initial_pattern && strlen (initial_pattern))
|
||||
{
|
||||
active = pattern_list_get_pattern (pattern_list, initial_pattern);
|
||||
active = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
initial_pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -302,6 +328,21 @@ pattern_select_new (gchar *title,
|
|||
|
||||
gtk_widget_show (psp->options_box);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* add callbacks to keep the display area current */
|
||||
psp->name_changed_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (global_pattern_list), "name_changed",
|
||||
GTK_SIGNAL_FUNC (pattern_select_pattern_dirty_callback),
|
||||
psp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (global_pattern_list), "add",
|
||||
GTK_SIGNAL_FUNC (pattern_added_callback),
|
||||
psp);
|
||||
gtk_signal_connect (GTK_OBJECT (global_pattern_list), "remove",
|
||||
GTK_SIGNAL_FUNC (pattern_removed_callback),
|
||||
psp);
|
||||
|
||||
gtk_widget_show (psp->shell);
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
|
@ -342,19 +383,55 @@ pattern_select_free (PatternSelect *psp)
|
|||
gtk_object_unref (GTK_OBJECT (psp->context));
|
||||
}
|
||||
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (global_pattern_list),
|
||||
psp->name_changed_handler_id);
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (global_pattern_list), psp);
|
||||
|
||||
g_free (psp);
|
||||
}
|
||||
|
||||
void
|
||||
pattern_select_freeze_all (void)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
|
||||
for (list = pattern_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
psp = (PatternSelect *) list->data;
|
||||
|
||||
psp->freeze = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pattern_select_thaw_all (void)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
|
||||
for (list = pattern_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
psp = (PatternSelect *) list->data;
|
||||
|
||||
psp->freeze = FALSE;
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Call this dialog's PDB callback */
|
||||
|
||||
static void
|
||||
pattern_change_callbacks (PatternSelect *psp,
|
||||
gboolean closing)
|
||||
{
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
GPattern *pattern;
|
||||
gint nreturn_vals;
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
GimpPattern *pattern;
|
||||
gint nreturn_vals;
|
||||
|
||||
static gboolean busy = FALSE;
|
||||
|
||||
/* Any procs registered to callback? */
|
||||
|
@ -375,7 +452,7 @@ pattern_change_callbacks (PatternSelect *psp,
|
|||
return_vals =
|
||||
procedural_db_run_proc (name,
|
||||
&nreturn_vals,
|
||||
PDB_STRING, pattern->name,
|
||||
PDB_STRING, GIMP_OBJECT (pattern)->name,
|
||||
PDB_INT32, pattern->mask->width,
|
||||
PDB_INT32, pattern->mask->height,
|
||||
PDB_INT32, pattern->mask->bytes,
|
||||
|
@ -398,9 +475,9 @@ void
|
|||
patterns_check_dialogs (void)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
GSList *list;
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = pattern_active_dialogs;
|
||||
|
||||
|
@ -428,7 +505,7 @@ patterns_check_dialogs (void)
|
|||
* Local functions
|
||||
*/
|
||||
|
||||
static GPattern *
|
||||
static GimpPattern *
|
||||
pattern_select_drag_pattern (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
|
@ -440,9 +517,9 @@ pattern_select_drag_pattern (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
pattern_select_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
pattern_select_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
|
||||
|
@ -453,7 +530,7 @@ pattern_select_drop_pattern (GtkWidget *widget,
|
|||
|
||||
static void
|
||||
pattern_select_pattern_changed (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
if (pattern)
|
||||
|
@ -467,13 +544,13 @@ pattern_select_pattern_changed (GimpContext *context,
|
|||
|
||||
static void
|
||||
pattern_select_select (PatternSelect *psp,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
gint index;
|
||||
gint row, col;
|
||||
gint scroll_offset = 0;
|
||||
|
||||
index = pattern->index;
|
||||
index = gimp_list_get_child_index (global_pattern_list, GIMP_OBJECT (pattern));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
@ -502,25 +579,66 @@ pattern_select_select (PatternSelect *psp,
|
|||
gtk_adjustment_set_value (psp->sbar_data, psp->scroll_offset + scroll_offset);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_select_pattern_dirty_callback (GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
gint index;
|
||||
gboolean redraw;
|
||||
|
||||
if (!psp || psp->freeze)
|
||||
return;
|
||||
|
||||
index = gimp_list_get_child_index (global_pattern_list,
|
||||
GIMP_OBJECT (pattern));
|
||||
redraw = (pattern != gimp_context_get_pattern (psp->context));
|
||||
|
||||
display_pattern (psp, pattern,
|
||||
index % (psp->NUM_PATTERN_COLUMNS),
|
||||
index / (psp->NUM_PATTERN_COLUMNS));
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_added_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
if (psp->freeze)
|
||||
return;
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_removed_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
if (psp->freeze)
|
||||
return;
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PatternSelect *psp;
|
||||
int x;
|
||||
int y;
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
} popup_timeout_args_t;
|
||||
|
||||
|
||||
static gboolean
|
||||
pattern_popup_timeout (gpointer data)
|
||||
{
|
||||
popup_timeout_args_t *args = data;
|
||||
PatternSelect *psp = args->psp;
|
||||
GPattern *pattern = args->pattern;
|
||||
gint x, y;
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
popup_timeout_args_t *args = data;
|
||||
PatternSelect *psp = args->psp;
|
||||
GimpPattern *pattern = args->pattern;
|
||||
gint x, y;
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* timeout has gone off so our tag is now invalid */
|
||||
psp->popup_timeout_tag = 0;
|
||||
|
@ -529,6 +647,7 @@ pattern_popup_timeout (gpointer data)
|
|||
if (psp->pattern_popup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
psp->pattern_popup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (psp->pattern_popup),
|
||||
FALSE, FALSE, TRUE);
|
||||
|
@ -593,20 +712,20 @@ static void
|
|||
pattern_popup_open (PatternSelect *psp,
|
||||
gint x,
|
||||
gint y,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
static popup_timeout_args_t popup_timeout_args;
|
||||
|
||||
/* if we've already got a timeout scheduled, then we complain */
|
||||
g_return_if_fail (psp->popup_timeout_tag == 0);
|
||||
|
||||
popup_timeout_args.psp = psp;
|
||||
popup_timeout_args.x = x;
|
||||
popup_timeout_args.y = y;
|
||||
popup_timeout_args.psp = psp;
|
||||
popup_timeout_args.x = x;
|
||||
popup_timeout_args.y = y;
|
||||
popup_timeout_args.pattern = pattern;
|
||||
psp->popup_timeout_tag = gtk_timeout_add (POPUP_DELAY_MS,
|
||||
pattern_popup_timeout,
|
||||
&popup_timeout_args);
|
||||
psp->popup_timeout_tag = gtk_timeout_add (POPUP_DELAY_MS,
|
||||
pattern_popup_timeout,
|
||||
&popup_timeout_args);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -641,20 +760,20 @@ display_setup (PatternSelect *psp)
|
|||
|
||||
static void
|
||||
display_pattern (PatternSelect *psp,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gint col,
|
||||
gint row)
|
||||
{
|
||||
TempBuf * pattern_buf;
|
||||
guchar * src, *s;
|
||||
guchar * buf, *b;
|
||||
gint cell_width, cell_height;
|
||||
gint width, height;
|
||||
gint rowstride;
|
||||
gint offset_x, offset_y;
|
||||
gint yend;
|
||||
gint ystart;
|
||||
gint i, j;
|
||||
TempBuf *pattern_buf;
|
||||
guchar *src, *s;
|
||||
guchar *buf, *b;
|
||||
gint cell_width, cell_height;
|
||||
gint width, height;
|
||||
gint rowstride;
|
||||
gint offset_x, offset_y;
|
||||
gint yend;
|
||||
gint ystart;
|
||||
gint i, j;
|
||||
|
||||
buf = g_new (guchar, psp->cell_width * 3);
|
||||
|
||||
|
@ -710,9 +829,9 @@ display_pattern (PatternSelect *psp,
|
|||
static void
|
||||
display_patterns (PatternSelect *psp)
|
||||
{
|
||||
GSList *list = pattern_list; /* the global pattern list */
|
||||
gint row, col;
|
||||
GPattern *pattern;
|
||||
GList *list = global_pattern_list->list;
|
||||
gint row, col;
|
||||
GimpPattern *pattern;
|
||||
|
||||
if (list == NULL)
|
||||
{
|
||||
|
@ -728,9 +847,9 @@ display_patterns (PatternSelect *psp)
|
|||
display_setup (psp);
|
||||
|
||||
row = col = 0;
|
||||
for (; list; list = g_slist_next (list))
|
||||
for (; list; list = g_list_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
pattern = (GimpPattern *) list->data;
|
||||
|
||||
/* Display the pattern */
|
||||
display_pattern (psp, pattern, col, row);
|
||||
|
@ -830,8 +949,8 @@ pattern_select_show_selected (PatternSelect *psp,
|
|||
static void
|
||||
update_active_pattern_field (PatternSelect *psp)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gchar buf[32];
|
||||
GimpPattern *pattern;
|
||||
gchar buf[32];
|
||||
|
||||
pattern = gimp_context_get_pattern (psp->context);
|
||||
|
||||
|
@ -839,7 +958,8 @@ update_active_pattern_field (PatternSelect *psp)
|
|||
return;
|
||||
|
||||
/* Set pattern name */
|
||||
gtk_label_set_text (GTK_LABEL (psp->pattern_name), pattern->name);
|
||||
gtk_label_set_text (GTK_LABEL (psp->pattern_name),
|
||||
GIMP_OBJECT (pattern)->name);
|
||||
|
||||
/* Set pattern size */
|
||||
g_snprintf (buf, sizeof (buf), "(%d X %d)",
|
||||
|
@ -855,7 +975,8 @@ preview_calc_scrollbar (PatternSelect *psp)
|
|||
gint max;
|
||||
|
||||
psp->scroll_offset = 0;
|
||||
num_rows = ((num_patterns + psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
num_rows = ((GIMP_CONTAINER (global_pattern_list)->num_children +
|
||||
psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
psp->NUM_PATTERN_COLUMNS);
|
||||
max = num_rows * psp->cell_width;
|
||||
if (!num_rows)
|
||||
|
@ -895,7 +1016,8 @@ pattern_select_resize (GtkWidget *widget,
|
|||
psp->NUM_PATTERN_COLUMNS =
|
||||
(gint) (wid / cell_size);
|
||||
psp->NUM_PATTERN_ROWS =
|
||||
(gint) ((num_patterns + psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
(gint) ((GIMP_CONTAINER (global_pattern_list)->num_children +
|
||||
psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
psp->NUM_PATTERN_COLUMNS);
|
||||
|
||||
psp->cell_width = cell_size;
|
||||
|
@ -913,8 +1035,8 @@ pattern_select_events (GtkWidget *widget,
|
|||
PatternSelect *psp)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
GPattern *pattern;
|
||||
int row, col, index;
|
||||
GimpPattern *pattern;
|
||||
gint row, col, index;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
|
@ -925,7 +1047,9 @@ pattern_select_events (GtkWidget *widget,
|
|||
row = (bevent->y + psp->scroll_offset) / psp->cell_height;
|
||||
index = row * psp->NUM_PATTERN_COLUMNS + col;
|
||||
|
||||
pattern = pattern_list_get_pattern_by_index (pattern_list, index);
|
||||
pattern =
|
||||
(GimpPattern *) gimp_list_get_child_by_index (global_pattern_list,
|
||||
index);
|
||||
|
||||
if (pattern)
|
||||
psp->dnd_pattern = pattern;
|
||||
|
@ -1000,8 +1124,8 @@ pattern_select_scroll_update (GtkAdjustment *adjustment,
|
|||
gpointer data)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GPattern *active;
|
||||
gint row, col, index;
|
||||
GimpPattern *active;
|
||||
gint row, col, index;
|
||||
|
||||
psp = (PatternSelect *) data;
|
||||
|
||||
|
@ -1015,9 +1139,12 @@ pattern_select_scroll_update (GtkAdjustment *adjustment,
|
|||
|
||||
if (active)
|
||||
{
|
||||
index = active->index;
|
||||
index = gimp_list_get_child_index (global_pattern_list,
|
||||
GIMP_OBJECT (active));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
row = index / psp->NUM_PATTERN_COLUMNS;
|
||||
col = index - row * psp->NUM_PATTERN_COLUMNS;
|
||||
|
||||
|
@ -1054,7 +1181,7 @@ pattern_select_refresh_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
/* re-init the pattern list */
|
||||
patterns_init (FALSE);
|
||||
|
|
|
@ -31,31 +31,37 @@ struct _PatternSelect
|
|||
GdkGC *gc;
|
||||
GtkAdjustment *sbar_data;
|
||||
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
|
||||
/* Pattern popup */
|
||||
GtkWidget *pattern_popup;
|
||||
GtkWidget *pattern_preview;
|
||||
guint popup_timeout_tag;
|
||||
GtkWidget *pattern_popup;
|
||||
GtkWidget *pattern_preview;
|
||||
guint popup_timeout_tag;
|
||||
|
||||
/* Callback function name */
|
||||
gchar *callback_name;
|
||||
gchar *callback_name;
|
||||
|
||||
/* Context to store the current pattern */
|
||||
GimpContext *context;
|
||||
GimpContext *context;
|
||||
|
||||
GPattern *dnd_pattern;
|
||||
GimpPattern *dnd_pattern;
|
||||
|
||||
/* Some variables to keep the GUI consistent */
|
||||
gint cell_width;
|
||||
gint cell_height;
|
||||
gint scroll_offset;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
gint NUM_PATTERN_COLUMNS;
|
||||
gint NUM_PATTERN_ROWS;
|
||||
gint cell_width;
|
||||
gint cell_height;
|
||||
gint scroll_offset;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
gint NUM_PATTERN_COLUMNS;
|
||||
gint NUM_PATTERN_ROWS;
|
||||
|
||||
gboolean redraw;
|
||||
gboolean freeze; /* so we don't waste so much time during refresh */
|
||||
|
||||
GQuark name_changed_handler_id;
|
||||
GQuark dirty_handler_id;
|
||||
};
|
||||
|
||||
/* list of active dialogs */
|
||||
|
@ -64,16 +70,20 @@ extern GSList *pattern_active_dialogs;
|
|||
/* the main pattern dialog */
|
||||
extern PatternSelect *pattern_select_dialog;
|
||||
|
||||
PatternSelect * pattern_select_new (gchar *title,
|
||||
gchar *initial_pattern);
|
||||
|
||||
void pattern_select_free (PatternSelect *psp);
|
||||
PatternSelect * pattern_select_new (gchar *title,
|
||||
gchar *initial_pattern);
|
||||
|
||||
void patterns_check_dialogs (void);
|
||||
void pattern_select_free (PatternSelect *psp);
|
||||
|
||||
void pattern_select_freeze_all (void);
|
||||
void pattern_select_thaw_all (void);
|
||||
|
||||
void patterns_check_dialogs (void);
|
||||
|
||||
/* the main pattern selection */
|
||||
void pattern_dialog_create (void);
|
||||
void pattern_dialog_free (void);
|
||||
void pattern_dialog_create (void);
|
||||
void pattern_dialog_free (void);
|
||||
|
||||
|
||||
#endif /* __PATTERN_SELECT_H__ */
|
||||
|
|
|
@ -75,7 +75,7 @@ brush_preview_drop_brush (GtkWidget *widget,
|
|||
|
||||
static void
|
||||
pattern_area_update (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
if (pattern)
|
||||
|
@ -91,9 +91,9 @@ pattern_preview_clicked (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
pattern_preview_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
pattern_preview_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
if (pattern)
|
||||
gimp_context_set_pattern (gimp_context_get_user (), pattern);
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppattern.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -105,7 +105,7 @@ static void clone_line_image (GImage *dest,
|
|||
gint width);
|
||||
static void clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
guchar *d,
|
||||
gint x,
|
||||
gint y,
|
||||
|
@ -450,20 +450,20 @@ clone_motion (PaintCore *paint_core,
|
|||
int offset_x,
|
||||
int offset_y)
|
||||
{
|
||||
GImage *gimage;
|
||||
GImage *src_gimage = NULL;
|
||||
unsigned char * s;
|
||||
unsigned char * d;
|
||||
TempBuf * orig;
|
||||
TempBuf * area;
|
||||
void * pr;
|
||||
int y;
|
||||
int x1, y1, x2, y2;
|
||||
int has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
GimpImage *gimage;
|
||||
GimpImage *src_gimage = NULL;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
TempBuf *orig;
|
||||
TempBuf *area;
|
||||
gpointer pr;
|
||||
gint y;
|
||||
gint x1, y1, x2, y2;
|
||||
gint has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
|
||||
pr = NULL;
|
||||
pattern = NULL;
|
||||
|
@ -648,7 +648,7 @@ clone_line_image (GImage *dest,
|
|||
static void
|
||||
clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppattern.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -105,7 +105,7 @@ static void clone_line_image (GImage *dest,
|
|||
gint width);
|
||||
static void clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
guchar *d,
|
||||
gint x,
|
||||
gint y,
|
||||
|
@ -450,20 +450,20 @@ clone_motion (PaintCore *paint_core,
|
|||
int offset_x,
|
||||
int offset_y)
|
||||
{
|
||||
GImage *gimage;
|
||||
GImage *src_gimage = NULL;
|
||||
unsigned char * s;
|
||||
unsigned char * d;
|
||||
TempBuf * orig;
|
||||
TempBuf * area;
|
||||
void * pr;
|
||||
int y;
|
||||
int x1, y1, x2, y2;
|
||||
int has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
GimpImage *gimage;
|
||||
GimpImage *src_gimage = NULL;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
TempBuf *orig;
|
||||
TempBuf *area;
|
||||
gpointer pr;
|
||||
gint y;
|
||||
gint x1, y1, x2, y2;
|
||||
gint has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
|
||||
pr = NULL;
|
||||
pattern = NULL;
|
||||
|
@ -648,7 +648,7 @@ clone_line_image (GImage *dest,
|
|||
static void
|
||||
clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "dialog_handler.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_select.h"
|
||||
#include "session.h"
|
||||
|
@ -63,40 +65,61 @@
|
|||
static void pattern_change_callbacks (PatternSelect *psp,
|
||||
gboolean closing);
|
||||
|
||||
static GPattern * pattern_select_drag_pattern (GtkWidget *widget,
|
||||
static GimpPattern * pattern_select_drag_pattern(GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void pattern_select_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void pattern_select_pattern_changed (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp);
|
||||
static void pattern_select_select (PatternSelect *psp,
|
||||
GPattern *pattern);
|
||||
GimpPattern *pattern);
|
||||
|
||||
static void pattern_select_pattern_dirty_callback (GimpPattern *brush,
|
||||
PatternSelect *psp);
|
||||
static void pattern_added_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp);
|
||||
static void pattern_removed_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp);
|
||||
|
||||
static gboolean pattern_popup_timeout (gpointer data);
|
||||
static void pattern_popup_open (PatternSelect *psp,
|
||||
gint, gint, GPattern *);
|
||||
static void pattern_popup_close (PatternSelect *);
|
||||
gint ,
|
||||
gint ,
|
||||
GimpPattern *pattern);
|
||||
static void pattern_popup_close (PatternSelect *psp);
|
||||
|
||||
static void display_setup (PatternSelect *);
|
||||
static void display_pattern (PatternSelect *, GPattern *,
|
||||
gint, gint);
|
||||
static void display_patterns (PatternSelect *);
|
||||
static void display_setup (PatternSelect *psp);
|
||||
static void display_pattern (PatternSelect *psp,
|
||||
GimpPattern *pattern,
|
||||
gint ,
|
||||
gint );
|
||||
static void display_patterns (PatternSelect *psp);
|
||||
|
||||
static void pattern_select_show_selected (PatternSelect *, gint, gint);
|
||||
static void update_active_pattern_field (PatternSelect *);
|
||||
static void preview_calc_scrollbar (PatternSelect *);
|
||||
static void pattern_select_show_selected (PatternSelect *psp,
|
||||
gint ,
|
||||
gint );
|
||||
static void update_active_pattern_field (PatternSelect *psp);
|
||||
static void preview_calc_scrollbar (PatternSelect *psp);
|
||||
|
||||
static gint pattern_select_resize (GtkWidget *, GdkEvent *,
|
||||
PatternSelect *);
|
||||
static gint pattern_select_events (GtkWidget *, GdkEvent *,
|
||||
PatternSelect *);
|
||||
static gint pattern_select_resize (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
PatternSelect *psp);
|
||||
static gint pattern_select_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
PatternSelect *psp);
|
||||
|
||||
static void pattern_select_scroll_update (GtkAdjustment *, gpointer);
|
||||
static void pattern_select_scroll_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
|
||||
static void pattern_select_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void pattern_select_refresh_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void pattern_select_close_callback (GtkWidget *, gpointer);
|
||||
static void pattern_select_refresh_callback (GtkWidget *, gpointer);
|
||||
|
||||
/* dnd stuff */
|
||||
static GtkTargetEntry preview_target_table[] =
|
||||
|
@ -131,7 +154,7 @@ pattern_dialog_create (void)
|
|||
}
|
||||
|
||||
void
|
||||
pattern_dialog_free ()
|
||||
pattern_dialog_free (void)
|
||||
{
|
||||
if (pattern_select_dialog)
|
||||
{
|
||||
|
@ -155,7 +178,7 @@ pattern_select_new (gchar *title,
|
|||
GtkWidget *sbar;
|
||||
GtkWidget *label_box;
|
||||
|
||||
GPattern *active = NULL;
|
||||
GimpPattern *active = NULL;
|
||||
|
||||
static gboolean first_call = TRUE;
|
||||
|
||||
|
@ -169,6 +192,8 @@ pattern_select_new (gchar *title,
|
|||
psp->old_row = 0;
|
||||
psp->NUM_PATTERN_COLUMNS = STD_PATTERN_COLUMNS;
|
||||
psp->NUM_PATTERN_ROWS = STD_PATTERN_COLUMNS;
|
||||
psp->redraw = TRUE;
|
||||
psp->freeze = FALSE;
|
||||
|
||||
/* The shell */
|
||||
psp->shell = gimp_dialog_new (title ? title : _("Pattern Selection"),
|
||||
|
@ -205,7 +230,8 @@ pattern_select_new (gchar *title,
|
|||
|
||||
if (title && initial_pattern && strlen (initial_pattern))
|
||||
{
|
||||
active = pattern_list_get_pattern (pattern_list, initial_pattern);
|
||||
active = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
initial_pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -302,6 +328,21 @@ pattern_select_new (gchar *title,
|
|||
|
||||
gtk_widget_show (psp->options_box);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* add callbacks to keep the display area current */
|
||||
psp->name_changed_handler_id =
|
||||
gimp_container_add_handler
|
||||
(GIMP_CONTAINER (global_pattern_list), "name_changed",
|
||||
GTK_SIGNAL_FUNC (pattern_select_pattern_dirty_callback),
|
||||
psp);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (global_pattern_list), "add",
|
||||
GTK_SIGNAL_FUNC (pattern_added_callback),
|
||||
psp);
|
||||
gtk_signal_connect (GTK_OBJECT (global_pattern_list), "remove",
|
||||
GTK_SIGNAL_FUNC (pattern_removed_callback),
|
||||
psp);
|
||||
|
||||
gtk_widget_show (psp->shell);
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
|
@ -342,19 +383,55 @@ pattern_select_free (PatternSelect *psp)
|
|||
gtk_object_unref (GTK_OBJECT (psp->context));
|
||||
}
|
||||
|
||||
gimp_container_remove_handler (GIMP_CONTAINER (global_pattern_list),
|
||||
psp->name_changed_handler_id);
|
||||
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (global_pattern_list), psp);
|
||||
|
||||
g_free (psp);
|
||||
}
|
||||
|
||||
void
|
||||
pattern_select_freeze_all (void)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
|
||||
for (list = pattern_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
psp = (PatternSelect *) list->data;
|
||||
|
||||
psp->freeze = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pattern_select_thaw_all (void)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
|
||||
for (list = pattern_active_dialogs; list; list = g_slist_next (list))
|
||||
{
|
||||
psp = (PatternSelect *) list->data;
|
||||
|
||||
psp->freeze = FALSE;
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Call this dialog's PDB callback */
|
||||
|
||||
static void
|
||||
pattern_change_callbacks (PatternSelect *psp,
|
||||
gboolean closing)
|
||||
{
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
GPattern *pattern;
|
||||
gint nreturn_vals;
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
GimpPattern *pattern;
|
||||
gint nreturn_vals;
|
||||
|
||||
static gboolean busy = FALSE;
|
||||
|
||||
/* Any procs registered to callback? */
|
||||
|
@ -375,7 +452,7 @@ pattern_change_callbacks (PatternSelect *psp,
|
|||
return_vals =
|
||||
procedural_db_run_proc (name,
|
||||
&nreturn_vals,
|
||||
PDB_STRING, pattern->name,
|
||||
PDB_STRING, GIMP_OBJECT (pattern)->name,
|
||||
PDB_INT32, pattern->mask->width,
|
||||
PDB_INT32, pattern->mask->height,
|
||||
PDB_INT32, pattern->mask->bytes,
|
||||
|
@ -398,9 +475,9 @@ void
|
|||
patterns_check_dialogs (void)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
GSList *list;
|
||||
gchar *name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = pattern_active_dialogs;
|
||||
|
||||
|
@ -428,7 +505,7 @@ patterns_check_dialogs (void)
|
|||
* Local functions
|
||||
*/
|
||||
|
||||
static GPattern *
|
||||
static GimpPattern *
|
||||
pattern_select_drag_pattern (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
|
@ -440,9 +517,9 @@ pattern_select_drag_pattern (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
pattern_select_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
pattern_select_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
|
||||
|
@ -453,7 +530,7 @@ pattern_select_drop_pattern (GtkWidget *widget,
|
|||
|
||||
static void
|
||||
pattern_select_pattern_changed (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
if (pattern)
|
||||
|
@ -467,13 +544,13 @@ pattern_select_pattern_changed (GimpContext *context,
|
|||
|
||||
static void
|
||||
pattern_select_select (PatternSelect *psp,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
gint index;
|
||||
gint row, col;
|
||||
gint scroll_offset = 0;
|
||||
|
||||
index = pattern->index;
|
||||
index = gimp_list_get_child_index (global_pattern_list, GIMP_OBJECT (pattern));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
@ -502,25 +579,66 @@ pattern_select_select (PatternSelect *psp,
|
|||
gtk_adjustment_set_value (psp->sbar_data, psp->scroll_offset + scroll_offset);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_select_pattern_dirty_callback (GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
gint index;
|
||||
gboolean redraw;
|
||||
|
||||
if (!psp || psp->freeze)
|
||||
return;
|
||||
|
||||
index = gimp_list_get_child_index (global_pattern_list,
|
||||
GIMP_OBJECT (pattern));
|
||||
redraw = (pattern != gimp_context_get_pattern (psp->context));
|
||||
|
||||
display_pattern (psp, pattern,
|
||||
index % (psp->NUM_PATTERN_COLUMNS),
|
||||
index / (psp->NUM_PATTERN_COLUMNS));
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_added_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
if (psp->freeze)
|
||||
return;
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
}
|
||||
|
||||
static void
|
||||
pattern_removed_callback (GimpContainer *container,
|
||||
GimpPattern *pattern,
|
||||
PatternSelect *psp)
|
||||
{
|
||||
if (psp->freeze)
|
||||
return;
|
||||
|
||||
preview_calc_scrollbar (psp);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PatternSelect *psp;
|
||||
int x;
|
||||
int y;
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
} popup_timeout_args_t;
|
||||
|
||||
|
||||
static gboolean
|
||||
pattern_popup_timeout (gpointer data)
|
||||
{
|
||||
popup_timeout_args_t *args = data;
|
||||
PatternSelect *psp = args->psp;
|
||||
GPattern *pattern = args->pattern;
|
||||
gint x, y;
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
popup_timeout_args_t *args = data;
|
||||
PatternSelect *psp = args->psp;
|
||||
GimpPattern *pattern = args->pattern;
|
||||
gint x, y;
|
||||
gint x_org, y_org;
|
||||
gint scr_w, scr_h;
|
||||
gchar *src, *buf;
|
||||
|
||||
/* timeout has gone off so our tag is now invalid */
|
||||
psp->popup_timeout_tag = 0;
|
||||
|
@ -529,6 +647,7 @@ pattern_popup_timeout (gpointer data)
|
|||
if (psp->pattern_popup == NULL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
psp->pattern_popup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_policy (GTK_WINDOW (psp->pattern_popup),
|
||||
FALSE, FALSE, TRUE);
|
||||
|
@ -593,20 +712,20 @@ static void
|
|||
pattern_popup_open (PatternSelect *psp,
|
||||
gint x,
|
||||
gint y,
|
||||
GPattern *pattern)
|
||||
GimpPattern *pattern)
|
||||
{
|
||||
static popup_timeout_args_t popup_timeout_args;
|
||||
|
||||
/* if we've already got a timeout scheduled, then we complain */
|
||||
g_return_if_fail (psp->popup_timeout_tag == 0);
|
||||
|
||||
popup_timeout_args.psp = psp;
|
||||
popup_timeout_args.x = x;
|
||||
popup_timeout_args.y = y;
|
||||
popup_timeout_args.psp = psp;
|
||||
popup_timeout_args.x = x;
|
||||
popup_timeout_args.y = y;
|
||||
popup_timeout_args.pattern = pattern;
|
||||
psp->popup_timeout_tag = gtk_timeout_add (POPUP_DELAY_MS,
|
||||
pattern_popup_timeout,
|
||||
&popup_timeout_args);
|
||||
psp->popup_timeout_tag = gtk_timeout_add (POPUP_DELAY_MS,
|
||||
pattern_popup_timeout,
|
||||
&popup_timeout_args);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -641,20 +760,20 @@ display_setup (PatternSelect *psp)
|
|||
|
||||
static void
|
||||
display_pattern (PatternSelect *psp,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gint col,
|
||||
gint row)
|
||||
{
|
||||
TempBuf * pattern_buf;
|
||||
guchar * src, *s;
|
||||
guchar * buf, *b;
|
||||
gint cell_width, cell_height;
|
||||
gint width, height;
|
||||
gint rowstride;
|
||||
gint offset_x, offset_y;
|
||||
gint yend;
|
||||
gint ystart;
|
||||
gint i, j;
|
||||
TempBuf *pattern_buf;
|
||||
guchar *src, *s;
|
||||
guchar *buf, *b;
|
||||
gint cell_width, cell_height;
|
||||
gint width, height;
|
||||
gint rowstride;
|
||||
gint offset_x, offset_y;
|
||||
gint yend;
|
||||
gint ystart;
|
||||
gint i, j;
|
||||
|
||||
buf = g_new (guchar, psp->cell_width * 3);
|
||||
|
||||
|
@ -710,9 +829,9 @@ display_pattern (PatternSelect *psp,
|
|||
static void
|
||||
display_patterns (PatternSelect *psp)
|
||||
{
|
||||
GSList *list = pattern_list; /* the global pattern list */
|
||||
gint row, col;
|
||||
GPattern *pattern;
|
||||
GList *list = global_pattern_list->list;
|
||||
gint row, col;
|
||||
GimpPattern *pattern;
|
||||
|
||||
if (list == NULL)
|
||||
{
|
||||
|
@ -728,9 +847,9 @@ display_patterns (PatternSelect *psp)
|
|||
display_setup (psp);
|
||||
|
||||
row = col = 0;
|
||||
for (; list; list = g_slist_next (list))
|
||||
for (; list; list = g_list_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
pattern = (GimpPattern *) list->data;
|
||||
|
||||
/* Display the pattern */
|
||||
display_pattern (psp, pattern, col, row);
|
||||
|
@ -830,8 +949,8 @@ pattern_select_show_selected (PatternSelect *psp,
|
|||
static void
|
||||
update_active_pattern_field (PatternSelect *psp)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gchar buf[32];
|
||||
GimpPattern *pattern;
|
||||
gchar buf[32];
|
||||
|
||||
pattern = gimp_context_get_pattern (psp->context);
|
||||
|
||||
|
@ -839,7 +958,8 @@ update_active_pattern_field (PatternSelect *psp)
|
|||
return;
|
||||
|
||||
/* Set pattern name */
|
||||
gtk_label_set_text (GTK_LABEL (psp->pattern_name), pattern->name);
|
||||
gtk_label_set_text (GTK_LABEL (psp->pattern_name),
|
||||
GIMP_OBJECT (pattern)->name);
|
||||
|
||||
/* Set pattern size */
|
||||
g_snprintf (buf, sizeof (buf), "(%d X %d)",
|
||||
|
@ -855,7 +975,8 @@ preview_calc_scrollbar (PatternSelect *psp)
|
|||
gint max;
|
||||
|
||||
psp->scroll_offset = 0;
|
||||
num_rows = ((num_patterns + psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
num_rows = ((GIMP_CONTAINER (global_pattern_list)->num_children +
|
||||
psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
psp->NUM_PATTERN_COLUMNS);
|
||||
max = num_rows * psp->cell_width;
|
||||
if (!num_rows)
|
||||
|
@ -895,7 +1016,8 @@ pattern_select_resize (GtkWidget *widget,
|
|||
psp->NUM_PATTERN_COLUMNS =
|
||||
(gint) (wid / cell_size);
|
||||
psp->NUM_PATTERN_ROWS =
|
||||
(gint) ((num_patterns + psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
(gint) ((GIMP_CONTAINER (global_pattern_list)->num_children +
|
||||
psp->NUM_PATTERN_COLUMNS - 1) /
|
||||
psp->NUM_PATTERN_COLUMNS);
|
||||
|
||||
psp->cell_width = cell_size;
|
||||
|
@ -913,8 +1035,8 @@ pattern_select_events (GtkWidget *widget,
|
|||
PatternSelect *psp)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
GPattern *pattern;
|
||||
int row, col, index;
|
||||
GimpPattern *pattern;
|
||||
gint row, col, index;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
|
@ -925,7 +1047,9 @@ pattern_select_events (GtkWidget *widget,
|
|||
row = (bevent->y + psp->scroll_offset) / psp->cell_height;
|
||||
index = row * psp->NUM_PATTERN_COLUMNS + col;
|
||||
|
||||
pattern = pattern_list_get_pattern_by_index (pattern_list, index);
|
||||
pattern =
|
||||
(GimpPattern *) gimp_list_get_child_by_index (global_pattern_list,
|
||||
index);
|
||||
|
||||
if (pattern)
|
||||
psp->dnd_pattern = pattern;
|
||||
|
@ -1000,8 +1124,8 @@ pattern_select_scroll_update (GtkAdjustment *adjustment,
|
|||
gpointer data)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GPattern *active;
|
||||
gint row, col, index;
|
||||
GimpPattern *active;
|
||||
gint row, col, index;
|
||||
|
||||
psp = (PatternSelect *) data;
|
||||
|
||||
|
@ -1015,9 +1139,12 @@ pattern_select_scroll_update (GtkAdjustment *adjustment,
|
|||
|
||||
if (active)
|
||||
{
|
||||
index = active->index;
|
||||
index = gimp_list_get_child_index (global_pattern_list,
|
||||
GIMP_OBJECT (active));
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
row = index / psp->NUM_PATTERN_COLUMNS;
|
||||
col = index - row * psp->NUM_PATTERN_COLUMNS;
|
||||
|
||||
|
@ -1054,7 +1181,7 @@ pattern_select_refresh_callback (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
PatternSelect *psp;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
|
||||
/* re-init the pattern list */
|
||||
patterns_init (FALSE);
|
||||
|
|
|
@ -31,31 +31,37 @@ struct _PatternSelect
|
|||
GdkGC *gc;
|
||||
GtkAdjustment *sbar_data;
|
||||
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
|
||||
/* Pattern popup */
|
||||
GtkWidget *pattern_popup;
|
||||
GtkWidget *pattern_preview;
|
||||
guint popup_timeout_tag;
|
||||
GtkWidget *pattern_popup;
|
||||
GtkWidget *pattern_preview;
|
||||
guint popup_timeout_tag;
|
||||
|
||||
/* Callback function name */
|
||||
gchar *callback_name;
|
||||
gchar *callback_name;
|
||||
|
||||
/* Context to store the current pattern */
|
||||
GimpContext *context;
|
||||
GimpContext *context;
|
||||
|
||||
GPattern *dnd_pattern;
|
||||
GimpPattern *dnd_pattern;
|
||||
|
||||
/* Some variables to keep the GUI consistent */
|
||||
gint cell_width;
|
||||
gint cell_height;
|
||||
gint scroll_offset;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
gint NUM_PATTERN_COLUMNS;
|
||||
gint NUM_PATTERN_ROWS;
|
||||
gint cell_width;
|
||||
gint cell_height;
|
||||
gint scroll_offset;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
gint NUM_PATTERN_COLUMNS;
|
||||
gint NUM_PATTERN_ROWS;
|
||||
|
||||
gboolean redraw;
|
||||
gboolean freeze; /* so we don't waste so much time during refresh */
|
||||
|
||||
GQuark name_changed_handler_id;
|
||||
GQuark dirty_handler_id;
|
||||
};
|
||||
|
||||
/* list of active dialogs */
|
||||
|
@ -64,16 +70,20 @@ extern GSList *pattern_active_dialogs;
|
|||
/* the main pattern dialog */
|
||||
extern PatternSelect *pattern_select_dialog;
|
||||
|
||||
PatternSelect * pattern_select_new (gchar *title,
|
||||
gchar *initial_pattern);
|
||||
|
||||
void pattern_select_free (PatternSelect *psp);
|
||||
PatternSelect * pattern_select_new (gchar *title,
|
||||
gchar *initial_pattern);
|
||||
|
||||
void patterns_check_dialogs (void);
|
||||
void pattern_select_free (PatternSelect *psp);
|
||||
|
||||
void pattern_select_freeze_all (void);
|
||||
void pattern_select_thaw_all (void);
|
||||
|
||||
void patterns_check_dialogs (void);
|
||||
|
||||
/* the main pattern selection */
|
||||
void pattern_dialog_create (void);
|
||||
void pattern_dialog_free (void);
|
||||
void pattern_dialog_create (void);
|
||||
void pattern_dialog_free (void);
|
||||
|
||||
|
||||
#endif /* __PATTERN_SELECT_H__ */
|
||||
|
|
327
app/patterns.c
327
app/patterns.c
|
@ -18,28 +18,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -47,52 +26,45 @@
|
|||
|
||||
#include "datafiles.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdatalist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_header.h"
|
||||
#include "pattern_select.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static void patterns_load_pattern (const gchar *filename);
|
||||
|
||||
|
||||
/* global variables */
|
||||
GPattern *active_pattern = NULL;
|
||||
GSList *pattern_list = NULL;
|
||||
gint num_patterns = 0;
|
||||
GimpList *global_pattern_list = NULL;
|
||||
|
||||
|
||||
/* static variables */
|
||||
static GPattern *standard_pattern = NULL;
|
||||
static GimpPattern *standard_pattern = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static GPattern * pattern_load_real (gint fd,
|
||||
const gchar *filename,
|
||||
gboolean quiet);
|
||||
static void load_pattern (const gchar *filename);
|
||||
static void pattern_free_func (gpointer data,
|
||||
gpointer dummy);
|
||||
static gint pattern_compare_func (gconstpointer second,
|
||||
gconstpointer first);
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
patterns_init (gboolean no_data)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
if (pattern_list)
|
||||
if (global_pattern_list)
|
||||
patterns_free ();
|
||||
else
|
||||
global_pattern_list = GIMP_LIST (gimp_data_list_new (GIMP_TYPE_PATTERN));
|
||||
|
||||
if (pattern_path != NULL && !no_data)
|
||||
datafiles_read_directories (pattern_path, load_pattern, 0);
|
||||
|
||||
/* assign indexes to the loaded patterns */
|
||||
for (list = pattern_list; list; list = g_slist_next (list))
|
||||
{
|
||||
/* Set the pattern index */
|
||||
((GPattern *) list->data)->index = num_patterns++;
|
||||
pattern_select_freeze_all ();
|
||||
|
||||
datafiles_read_directories (pattern_path, patterns_load_pattern, 0);
|
||||
|
||||
pattern_select_thaw_all ();
|
||||
}
|
||||
|
||||
gimp_context_refresh_patterns ();
|
||||
|
@ -101,29 +73,33 @@ patterns_init (gboolean no_data)
|
|||
void
|
||||
patterns_free (void)
|
||||
{
|
||||
if (pattern_list)
|
||||
if (! global_pattern_list)
|
||||
return;
|
||||
|
||||
pattern_select_freeze_all ();
|
||||
|
||||
while (global_pattern_list->list)
|
||||
{
|
||||
g_slist_foreach (pattern_list, pattern_free_func, NULL);
|
||||
g_slist_free (pattern_list);
|
||||
gimp_container_remove (GIMP_CONTAINER (global_pattern_list),
|
||||
GIMP_OBJECT (global_pattern_list->list->data));
|
||||
}
|
||||
|
||||
num_patterns = 0;
|
||||
pattern_list = NULL;
|
||||
pattern_select_thaw_all ();
|
||||
}
|
||||
|
||||
GPattern *
|
||||
GimpPattern *
|
||||
patterns_get_standard_pattern (void)
|
||||
{
|
||||
if (! standard_pattern)
|
||||
{
|
||||
guchar *data;
|
||||
gint row, col;
|
||||
gint row, col;
|
||||
|
||||
standard_pattern = g_new (GPattern, 1);
|
||||
standard_pattern = GIMP_PATTERN (gtk_type_new (GIMP_TYPE_PATTERN));
|
||||
|
||||
gimp_object_set_name (GIMP_OBJECT (standard_pattern), "Standard");
|
||||
|
||||
standard_pattern->filename = NULL;
|
||||
standard_pattern->name = g_strdup ("Standard");
|
||||
standard_pattern->index = -1; /* not part of the pattern list */
|
||||
standard_pattern->mask = temp_buf_new (32, 32, 3, 0, 0, NULL);
|
||||
|
||||
data = temp_buf_data (standard_pattern->mask);
|
||||
|
@ -134,244 +110,29 @@ patterns_get_standard_pattern (void)
|
|||
memset (data, (col % 2) && (row % 2) ? 255 : 0, 3);
|
||||
data += 3;
|
||||
}
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard pattern */
|
||||
gtk_object_ref (GTK_OBJECT (standard_pattern));
|
||||
gtk_object_ref (GTK_OBJECT (standard_pattern));
|
||||
gtk_object_sink (GTK_OBJECT (standard_pattern));
|
||||
}
|
||||
|
||||
return standard_pattern;
|
||||
}
|
||||
|
||||
GPattern *
|
||||
pattern_list_get_pattern_by_index (GSList *list,
|
||||
gint index)
|
||||
{
|
||||
GPattern *pattern = NULL;
|
||||
|
||||
list = g_slist_nth (list, index);
|
||||
if (list)
|
||||
pattern = (GPattern *) list->data;
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
GPattern *
|
||||
pattern_list_get_pattern (GSList *list,
|
||||
const gchar *name)
|
||||
{
|
||||
GPattern *pattern;
|
||||
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
|
||||
for (; list; list = g_slist_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
|
||||
if (!strcmp (pattern->name, name))
|
||||
return pattern;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GPattern *
|
||||
pattern_load (gint fd,
|
||||
const gchar *filename)
|
||||
{
|
||||
return pattern_load_real (fd, filename, TRUE);
|
||||
}
|
||||
|
||||
static GPattern *
|
||||
pattern_load_real (gint fd,
|
||||
const gchar *filename,
|
||||
gboolean quiet)
|
||||
{
|
||||
GPattern *pattern;
|
||||
PatternHeader header;
|
||||
gint bn_size;
|
||||
gchar *name;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
g_return_val_if_fail (fd != -1, NULL);
|
||||
|
||||
/* Read in the header size */
|
||||
if (read (fd, &header, sizeof (header)) != sizeof (header))
|
||||
return NULL;
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
header.header_size = g_ntohl (header.header_size);
|
||||
header.version = g_ntohl (header.version);
|
||||
header.width = g_ntohl (header.width);
|
||||
header.height = g_ntohl (header.height);
|
||||
header.bytes = g_ntohl (header.bytes);
|
||||
header.magic_number = g_ntohl (header.magic_number);
|
||||
|
||||
/* Check for correct file format */
|
||||
if (header.magic_number != GPATTERN_MAGIC || header.version != 1 ||
|
||||
header.header_size <= sizeof (header))
|
||||
{
|
||||
if (!quiet)
|
||||
g_message (_("Unknown pattern format version #%d in \"%s\"."),
|
||||
header.version, filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check for supported bit depths */
|
||||
if (header.bytes != 1 && header.bytes != 3)
|
||||
{
|
||||
g_message ("Unsupported pattern depth: %d\n in file \"%s\"\nGIMP Patterns must be GRAY or RGB\n",
|
||||
header.bytes, filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Read in the brush name */
|
||||
if ((bn_size = (header.header_size - sizeof (header))))
|
||||
{
|
||||
name = g_new (gchar, bn_size);
|
||||
if ((read (fd, name, bn_size)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP pattern file \"%s\"."), filename);
|
||||
g_free (name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup (_("Unnamed"));
|
||||
}
|
||||
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
pattern->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
if (read (fd, temp_buf_data (pattern->mask),
|
||||
header.width * header.height * header.bytes) < header.width * header.height * header.bytes)
|
||||
{
|
||||
g_message (_("GIMP pattern file appears to be truncated: \"%s\"."),
|
||||
filename);
|
||||
pattern_free (pattern);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pattern->name = name;
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
void
|
||||
pattern_free (GPattern *pattern)
|
||||
{
|
||||
if (pattern->mask)
|
||||
temp_buf_free (pattern->mask);
|
||||
|
||||
g_free (pattern->filename);
|
||||
g_free (pattern->name);
|
||||
|
||||
g_free (pattern);
|
||||
}
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
pattern_free_func (gpointer data,
|
||||
gpointer dummy)
|
||||
patterns_load_pattern (const gchar *filename)
|
||||
{
|
||||
pattern_free ((GPattern *) data);
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_compare_func (gconstpointer first,
|
||||
gconstpointer second)
|
||||
{
|
||||
return strcmp (((const GPattern *) first)->name,
|
||||
((const GPattern *) second)->name);
|
||||
}
|
||||
|
||||
static void
|
||||
load_pattern (const gchar *filename)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gint fd;
|
||||
GSList *list;
|
||||
GSList *list2;
|
||||
gint unique_ext = 0;
|
||||
gchar *ext;
|
||||
gchar *new_name = NULL;
|
||||
GimpPattern *pattern;
|
||||
|
||||
g_return_if_fail (filename != NULL);
|
||||
|
||||
fd = open (filename, O_RDONLY | _O_BINARY);
|
||||
if (fd == -1)
|
||||
return;
|
||||
pattern = gimp_pattern_load (filename);
|
||||
|
||||
pattern = pattern_load_real (fd, filename, FALSE);
|
||||
if (! pattern)
|
||||
g_message (_("Warning: Failed to load pattern\n\"%s\""), filename);
|
||||
|
||||
close (fd);
|
||||
|
||||
if (!pattern)
|
||||
return;
|
||||
|
||||
pattern->filename = g_strdup (filename);
|
||||
|
||||
/* Swap the pattern to disk (if we're being stingy with memory) */
|
||||
if (stingy_memory_use)
|
||||
temp_buf_swap (pattern->mask);
|
||||
|
||||
/* uniquefy pattern name */
|
||||
for (list = pattern_list; list; list = g_slist_next (list))
|
||||
{
|
||||
if (! strcmp (((GPattern *) list->data)->name, pattern->name))
|
||||
{
|
||||
ext = strrchr (pattern->name, '#');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
gchar *ext_str;
|
||||
|
||||
unique_ext = atoi (ext + 1);
|
||||
|
||||
ext_str = g_strdup_printf ("%d", unique_ext);
|
||||
|
||||
/* check if the extension really is of the form "#<n>" */
|
||||
if (! strcmp (ext_str, ext + 1))
|
||||
{
|
||||
*ext = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
g_free (ext_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
unique_ext = 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
unique_ext++;
|
||||
|
||||
g_free (new_name);
|
||||
|
||||
new_name = g_strdup_printf ("%s#%d", pattern->name, unique_ext);
|
||||
|
||||
for (list2 = pattern_list; list2; list2 = g_slist_next (list2))
|
||||
{
|
||||
if (! strcmp (((GPattern *) list2->data)->name, new_name))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (list2);
|
||||
|
||||
g_free (pattern->name);
|
||||
|
||||
pattern->name = new_name;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pattern_list = g_slist_insert_sorted (pattern_list, pattern,
|
||||
pattern_compare_func);
|
||||
if (pattern != NULL)
|
||||
gimp_container_add (GIMP_CONTAINER (global_pattern_list),
|
||||
GIMP_OBJECT (pattern));
|
||||
}
|
||||
|
|
|
@ -20,31 +20,13 @@
|
|||
#define __PATTERNS_H__
|
||||
|
||||
|
||||
struct _GPattern
|
||||
{
|
||||
gchar *filename; /* actual filename--pattern's location on disk */
|
||||
gchar *name; /* pattern's name--for pattern selection dialog */
|
||||
gint index; /* pattern's index... */
|
||||
TempBuf *mask; /* the actual mask... */
|
||||
};
|
||||
extern GimpList *global_pattern_list;
|
||||
|
||||
/* global variables */
|
||||
extern GSList *pattern_list;
|
||||
extern gint num_patterns;
|
||||
|
||||
void patterns_init (gboolean no_data);
|
||||
void patterns_free (void);
|
||||
GPattern * patterns_get_standard_pattern (void);
|
||||
void patterns_init (gboolean no_data);
|
||||
void patterns_free (void);
|
||||
|
||||
GPattern * pattern_list_get_pattern_by_index (GSList *list,
|
||||
gint index);
|
||||
GPattern * pattern_list_get_pattern (GSList *list,
|
||||
const gchar *name);
|
||||
|
||||
/* this is useful for pixmap brushes etc. */
|
||||
GPattern * pattern_load (gint fd,
|
||||
const gchar *filename);
|
||||
void pattern_free (GPattern *pattern);
|
||||
GimpPattern * patterns_get_standard_pattern (void);
|
||||
|
||||
|
||||
#endif /* __PATTERNS_H__ */
|
||||
|
|
|
@ -255,7 +255,8 @@ brushes_set_popup_invoker (Argument *args)
|
|||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(bsp = brush_get_brushselect (name)))
|
||||
{
|
||||
GimpObject *object = gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
GimpObject *object = gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (object)
|
||||
{
|
||||
|
|
|
@ -168,7 +168,7 @@ brushes_set_brush_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
object = gimp_list_get_child_by_name (brush_list, name);
|
||||
object = gimp_list_get_child_by_name (global_brush_list, name);
|
||||
|
||||
if (object)
|
||||
gimp_context_set_brush (NULL, GIMP_BRUSH (object));
|
||||
|
@ -444,9 +444,9 @@ brushes_list_invoker (Argument *args)
|
|||
GList *list = NULL;
|
||||
int i = 0;
|
||||
|
||||
brushes = g_new (char *, GIMP_CONTAINER (brush_list)->num_children);
|
||||
brushes = g_new (char *, GIMP_CONTAINER (global_brush_list)->num_children);
|
||||
|
||||
success = (list = GIMP_LIST (brush_list)->list) != NULL;
|
||||
success = (list = GIMP_LIST (global_brush_list)->list) != NULL;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -458,7 +458,7 @@ brushes_list_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = GIMP_CONTAINER (brush_list)->num_children;
|
||||
return_args[1].value.pdb_int = GIMP_CONTAINER (global_brush_list)->num_children;
|
||||
return_args[2].value.pdb_pointer = brushes;
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ brushes_get_brush_data_invoker (Argument *args)
|
|||
|
||||
success = FALSE;
|
||||
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_list_next (list))
|
||||
for (list = GIMP_LIST (global_brush_list)->list; list; list = g_list_next (list))
|
||||
{
|
||||
brush = (GimpBrush *) list->data;
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "procedural_db.h"
|
||||
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "pattern_select.h"
|
||||
#include "patterns.h"
|
||||
|
||||
|
@ -215,7 +217,9 @@ patterns_set_popup_invoker (Argument *args)
|
|||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(psp = pattern_get_patternselect (name)))
|
||||
{
|
||||
GPattern *active = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
GimpPattern *active =
|
||||
(GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (active)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "procedural_db.h"
|
||||
|
||||
#include "gimpcontext.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "patterns.h"
|
||||
#include "temp_buf.h"
|
||||
|
||||
|
@ -50,7 +52,7 @@ patterns_get_pattern_invoker (Argument *args)
|
|||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
success = (pattern = gimp_context_get_pattern (NULL)) != NULL;
|
||||
|
||||
|
@ -58,7 +60,7 @@ patterns_get_pattern_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (pattern->name);
|
||||
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
return_args[2].value.pdb_int = pattern->mask->width;
|
||||
return_args[3].value.pdb_int = pattern->mask->height;
|
||||
}
|
||||
|
@ -106,8 +108,8 @@ patterns_set_pattern_invoker (Argument *args)
|
|||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
GPattern *pattern;
|
||||
GSList *list;
|
||||
GimpPattern *pattern;
|
||||
GList *list;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
|
@ -117,11 +119,11 @@ patterns_set_pattern_invoker (Argument *args)
|
|||
{
|
||||
success = FALSE;
|
||||
|
||||
for (list = pattern_list; list; list = g_slist_next (list))
|
||||
for (list = global_pattern_list->list; list; list = g_list_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
pattern = (GimpPattern *) list->data;
|
||||
|
||||
if (!strcmp (pattern->name, name))
|
||||
if (! strcmp (GIMP_OBJECT (pattern)->name, name))
|
||||
{
|
||||
gimp_context_set_pattern (NULL, pattern);
|
||||
success = TRUE;
|
||||
|
@ -164,16 +166,16 @@ patterns_list_invoker (Argument *args)
|
|||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar **patterns;
|
||||
GSList *list = NULL;
|
||||
int i = 0;
|
||||
GList *list = NULL;
|
||||
gint i = 0;
|
||||
|
||||
patterns = g_new (char *, num_patterns);
|
||||
patterns = g_new (gchar *, GIMP_CONTAINER (global_pattern_list)->num_children);
|
||||
|
||||
success = (list = pattern_list) != NULL;
|
||||
success = ((list = global_pattern_list->list) != NULL);
|
||||
|
||||
while (list)
|
||||
{
|
||||
patterns[i++] = g_strdup (((GPattern *) list->data)->name);
|
||||
patterns[i++] = g_strdup (GIMP_OBJECT (list->data)->name);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ patterns_list_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = num_patterns;
|
||||
return_args[1].value.pdb_int = GIMP_CONTAINER (global_pattern_list)->num_children;
|
||||
return_args[2].value.pdb_pointer = patterns;
|
||||
}
|
||||
|
||||
|
@ -226,7 +228,7 @@ patterns_get_pattern_data_invoker (Argument *args)
|
|||
gchar *name;
|
||||
gint32 length = 0;
|
||||
guint8 *mask_data = NULL;
|
||||
GPattern *pattern = NULL;
|
||||
GimpPattern *pattern = NULL;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
|
@ -236,15 +238,15 @@ patterns_get_pattern_data_invoker (Argument *args)
|
|||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list;
|
||||
GList *list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
for (list = pattern_list; list; list = g_slist_next (list))
|
||||
for (list = global_pattern_list->list; list; list = g_list_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
pattern = (GimpPattern *) list->data;
|
||||
|
||||
if (!strcmp (pattern->name, name))
|
||||
if (!strcmp (GIMP_OBJECT (pattern)->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
|
@ -267,7 +269,7 @@ patterns_get_pattern_data_invoker (Argument *args)
|
|||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (pattern->name);
|
||||
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
return_args[2].value.pdb_int = pattern->mask->width;
|
||||
return_args[3].value.pdb_int = pattern->mask->height;
|
||||
return_args[4].value.pdb_int = pattern->mask->bytes;
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -376,7 +376,7 @@ bucket_fill (GimpImage *gimage,
|
|||
gint x1, y1, x2, y2;
|
||||
guchar col [MAX_CHANNELS];
|
||||
guchar *d1, *d2;
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
TempBuf *pat_buf;
|
||||
gboolean new_buf = FALSE;
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppattern.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -105,7 +105,7 @@ static void clone_line_image (GImage *dest,
|
|||
gint width);
|
||||
static void clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
guchar *d,
|
||||
gint x,
|
||||
gint y,
|
||||
|
@ -450,20 +450,20 @@ clone_motion (PaintCore *paint_core,
|
|||
int offset_x,
|
||||
int offset_y)
|
||||
{
|
||||
GImage *gimage;
|
||||
GImage *src_gimage = NULL;
|
||||
unsigned char * s;
|
||||
unsigned char * d;
|
||||
TempBuf * orig;
|
||||
TempBuf * area;
|
||||
void * pr;
|
||||
int y;
|
||||
int x1, y1, x2, y2;
|
||||
int has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
GimpImage *gimage;
|
||||
GimpImage *src_gimage = NULL;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
TempBuf *orig;
|
||||
TempBuf *area;
|
||||
gpointer pr;
|
||||
gint y;
|
||||
gint x1, y1, x2, y2;
|
||||
gint has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
|
||||
pr = NULL;
|
||||
pattern = NULL;
|
||||
|
@ -648,7 +648,7 @@ clone_line_image (GImage *dest,
|
|||
static void
|
||||
clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -376,7 +376,7 @@ bucket_fill (GimpImage *gimage,
|
|||
gint x1, y1, x2, y2;
|
||||
guchar col [MAX_CHANNELS];
|
||||
guchar *d1, *d2;
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
TempBuf *pat_buf;
|
||||
gboolean new_buf = FALSE;
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppattern.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -105,7 +105,7 @@ static void clone_line_image (GImage *dest,
|
|||
gint width);
|
||||
static void clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
guchar *d,
|
||||
gint x,
|
||||
gint y,
|
||||
|
@ -450,20 +450,20 @@ clone_motion (PaintCore *paint_core,
|
|||
int offset_x,
|
||||
int offset_y)
|
||||
{
|
||||
GImage *gimage;
|
||||
GImage *src_gimage = NULL;
|
||||
unsigned char * s;
|
||||
unsigned char * d;
|
||||
TempBuf * orig;
|
||||
TempBuf * area;
|
||||
void * pr;
|
||||
int y;
|
||||
int x1, y1, x2, y2;
|
||||
int has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
GimpImage *gimage;
|
||||
GimpImage *src_gimage = NULL;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
TempBuf *orig;
|
||||
TempBuf *area;
|
||||
gpointer pr;
|
||||
gint y;
|
||||
gint x1, y1, x2, y2;
|
||||
gint has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
|
||||
pr = NULL;
|
||||
pattern = NULL;
|
||||
|
@ -648,7 +648,7 @@ clone_line_image (GImage *dest,
|
|||
static void
|
||||
clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppattern.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "patterns.h"
|
||||
#include "pixel_region.h"
|
||||
#include "selection.h"
|
||||
#include "temp_buf.h"
|
||||
|
@ -105,7 +105,7 @@ static void clone_line_image (GImage *dest,
|
|||
gint width);
|
||||
static void clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
guchar *d,
|
||||
gint x,
|
||||
gint y,
|
||||
|
@ -450,20 +450,20 @@ clone_motion (PaintCore *paint_core,
|
|||
int offset_x,
|
||||
int offset_y)
|
||||
{
|
||||
GImage *gimage;
|
||||
GImage *src_gimage = NULL;
|
||||
unsigned char * s;
|
||||
unsigned char * d;
|
||||
TempBuf * orig;
|
||||
TempBuf * area;
|
||||
void * pr;
|
||||
int y;
|
||||
int x1, y1, x2, y2;
|
||||
int has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
GimpImage *gimage;
|
||||
GimpImage *src_gimage = NULL;
|
||||
guchar *s;
|
||||
guchar *d;
|
||||
TempBuf *orig;
|
||||
TempBuf *area;
|
||||
gpointer pr;
|
||||
gint y;
|
||||
gint x1, y1, x2, y2;
|
||||
gint has_alpha = -1;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpPattern *pattern;
|
||||
gint opacity;
|
||||
gdouble scale;
|
||||
|
||||
pr = NULL;
|
||||
pattern = NULL;
|
||||
|
@ -648,7 +648,7 @@ clone_line_image (GImage *dest,
|
|||
static void
|
||||
clone_line_pattern (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
|
@ -132,7 +133,7 @@ static void device_status_drop_brush (GtkWidget *widget,
|
|||
GimpBrush *brush,
|
||||
gpointer data);
|
||||
static void device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void device_status_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
|
@ -467,7 +468,8 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
@ -482,9 +484,10 @@ devices_rc_update (gchar *name,
|
|||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
|
@ -703,7 +706,7 @@ devices_write_rc_device (DeviceInfo *device_info,
|
|||
if (gimp_context_get_pattern (device_info->context))
|
||||
{
|
||||
fprintf (fp, "\n (pattern \"%s\")",
|
||||
gimp_context_get_pattern (device_info->context)->name);
|
||||
GIMP_OBJECT (gimp_context_get_pattern (device_info->context))->name);
|
||||
}
|
||||
|
||||
if (gimp_context_get_gradient (device_info->context))
|
||||
|
@ -1185,9 +1188,9 @@ device_status_drop_brush (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
DeviceInfo *device_info;
|
||||
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
#include "devices.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpcontextpreview.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
|
@ -132,7 +133,7 @@ static void device_status_drop_brush (GtkWidget *widget,
|
|||
GimpBrush *brush,
|
||||
gpointer data);
|
||||
static void device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
static void device_status_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
|
@ -467,7 +468,8 @@ devices_rc_update (gchar *name,
|
|||
{
|
||||
GimpBrush *brush;
|
||||
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
|
@ -482,9 +484,10 @@ devices_rc_update (gchar *name,
|
|||
|
||||
if (values & DEVICE_PATTERN)
|
||||
{
|
||||
GPattern *pattern;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
|
@ -703,7 +706,7 @@ devices_write_rc_device (DeviceInfo *device_info,
|
|||
if (gimp_context_get_pattern (device_info->context))
|
||||
{
|
||||
fprintf (fp, "\n (pattern \"%s\")",
|
||||
gimp_context_get_pattern (device_info->context)->name);
|
||||
GIMP_OBJECT (gimp_context_get_pattern (device_info->context))->name);
|
||||
}
|
||||
|
||||
if (gimp_context_get_gradient (device_info->context))
|
||||
|
@ -1185,9 +1188,9 @@ device_status_drop_brush (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
device_status_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
DeviceInfo *device_info;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawablepreview.h"
|
||||
#include "gimplist.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
@ -661,7 +662,7 @@ gimp_dnd_set_brush_data (GtkWidget *widget,
|
|||
if (strcmp (name, "Standard") == 0)
|
||||
brush = brushes_get_standard_brush ();
|
||||
else
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (brush_list, name);
|
||||
brush = (GimpBrush *) gimp_list_get_child_by_name (global_brush_list, name);
|
||||
|
||||
if (brush)
|
||||
(* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data);
|
||||
|
@ -696,8 +697,8 @@ gimp_dnd_get_pattern_icon (GtkWidget *widget,
|
|||
GtkSignalFunc get_pattern_func,
|
||||
gpointer get_pattern_data)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GPattern *pattern;
|
||||
GtkWidget *preview;
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = (* (GimpDndDragPatternFunc) get_pattern_func) (widget,
|
||||
get_pattern_data);
|
||||
|
@ -722,8 +723,8 @@ gimp_dnd_get_pattern_data (GtkWidget *widget,
|
|||
gint *format,
|
||||
gint *length)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gchar *name;
|
||||
GimpPattern *pattern;
|
||||
gchar *name;
|
||||
|
||||
pattern = (* (GimpDndDragPatternFunc) get_pattern_func) (widget,
|
||||
get_pattern_data);
|
||||
|
@ -731,7 +732,7 @@ gimp_dnd_get_pattern_data (GtkWidget *widget,
|
|||
if (! pattern)
|
||||
return NULL;
|
||||
|
||||
name = g_strdup (pattern->name);
|
||||
name = g_strdup (GIMP_OBJECT (pattern)->name);
|
||||
|
||||
*format = 8;
|
||||
*length = strlen (name) + 1;
|
||||
|
@ -747,8 +748,8 @@ gimp_dnd_set_pattern_data (GtkWidget *widget,
|
|||
gint format,
|
||||
gint length)
|
||||
{
|
||||
GPattern *pattern;
|
||||
gchar *name;
|
||||
GimpPattern *pattern;
|
||||
gchar *name;
|
||||
|
||||
if ((format != 8) || (length < 1))
|
||||
{
|
||||
|
@ -761,7 +762,8 @@ gimp_dnd_set_pattern_data (GtkWidget *widget,
|
|||
if (strcmp (name, "Standard") == 0)
|
||||
pattern = patterns_get_standard_pattern ();
|
||||
else
|
||||
pattern = pattern_list_get_pattern (pattern_list, name);
|
||||
pattern = (GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
name);
|
||||
|
||||
if (pattern)
|
||||
(* (GimpDndDropPatternFunc) set_pattern_func) (widget, pattern,
|
||||
|
|
|
@ -124,11 +124,11 @@ void gimp_dnd_brush_dest_set (GtkWidget *widget,
|
|||
|
||||
/* pattern dnd functions */
|
||||
|
||||
typedef void (* GimpDndDropPatternFunc) (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data);
|
||||
typedef GPattern * (* GimpDndDragPatternFunc) (GtkWidget *widget,
|
||||
gpointer data);
|
||||
typedef void (* GimpDndDropPatternFunc) (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data);
|
||||
typedef GimpPattern * (* GimpDndDragPatternFunc) (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
void gimp_dnd_pattern_source_set (GtkWidget *widget,
|
||||
GimpDndDragPatternFunc get_pattern_func,
|
||||
|
|
|
@ -75,7 +75,7 @@ brush_preview_drop_brush (GtkWidget *widget,
|
|||
|
||||
static void
|
||||
pattern_area_update (GimpContext *context,
|
||||
GPattern *pattern,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
if (pattern)
|
||||
|
@ -91,9 +91,9 @@ pattern_preview_clicked (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
pattern_preview_drop_pattern (GtkWidget *widget,
|
||||
GPattern *pattern,
|
||||
gpointer data)
|
||||
pattern_preview_drop_pattern (GtkWidget *widget,
|
||||
GimpPattern *pattern,
|
||||
gpointer data)
|
||||
{
|
||||
if (pattern)
|
||||
gimp_context_set_pattern (gimp_context_get_user (), pattern);
|
||||
|
|
|
@ -132,7 +132,8 @@ sub brushes_set_popup {
|
|||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(bsp = brush_get_brushselect (name)))
|
||||
{
|
||||
GimpObject *object = gimp_list_get_child_by_name (brush_list, brush_name);
|
||||
GimpObject *object = gimp_list_get_child_by_name (global_brush_list,
|
||||
brush_name);
|
||||
|
||||
if (object)
|
||||
{
|
||||
|
|
|
@ -135,7 +135,7 @@ HELP
|
|||
vars => [ 'GimpObject *object' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
object = gimp_list_get_child_by_name (brush_list, name);
|
||||
object = gimp_list_get_child_by_name (global_brush_list, name);
|
||||
|
||||
if (object)
|
||||
gimp_context_set_brush (NULL, GIMP_BRUSH (object));
|
||||
|
@ -262,16 +262,16 @@ HELP
|
|||
alias => 'brushes',
|
||||
array => { name => 'num_brushes',
|
||||
desc => 'The number of brushes in the brush list',
|
||||
alias => 'GIMP_CONTAINER (brush_list)->num_children', no_declare => 1 } }
|
||||
alias => 'GIMP_CONTAINER (global_brush_list)->num_children', no_declare => 1 } }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GList *list = NULL', 'int i = 0' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
brushes = g_new (char *, GIMP_CONTAINER (brush_list)->num_children);
|
||||
brushes = g_new (char *, GIMP_CONTAINER (global_brush_list)->num_children);
|
||||
|
||||
success = (list = GIMP_LIST (brush_list)->list) != NULL;
|
||||
success = (list = GIMP_LIST (global_brush_list)->list) != NULL;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -329,7 +329,7 @@ HELP
|
|||
|
||||
success = FALSE;
|
||||
|
||||
for (list = GIMP_LIST (brush_list)->list; list; list = g_list_next (list))
|
||||
for (list = GIMP_LIST (global_brush_list)->list; list; list = g_list_next (list))
|
||||
{
|
||||
brush = (GimpBrush *) list->data;
|
||||
|
||||
|
|
|
@ -118,7 +118,9 @@ sub patterns_set_popup {
|
|||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(psp = pattern_get_patternselect (name)))
|
||||
{
|
||||
GPattern *active = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
GimpPattern *active =
|
||||
(GimpPattern *) gimp_list_get_child_by_name (global_pattern_list,
|
||||
pattern_name);
|
||||
|
||||
if (active)
|
||||
{
|
||||
|
@ -135,7 +137,8 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
@headers = qw(<string.h> "patterns.h" "pattern_select.h" "gimpcontext.h");
|
||||
@headers = qw(<string.h> "patterns.h" "pattern_select.h" "gimpcontext.h"
|
||||
"gimplist.h" "gimppattern.h");
|
||||
|
||||
$extra{app}->{code} = <<'CODE';
|
||||
static PatternSelect *
|
||||
|
|
|
@ -33,7 +33,12 @@ sub dim_args () {
|
|||
|
||||
sub pattern_outargs {
|
||||
foreach (@outargs) {
|
||||
my $alias = "pattern->$_->{name}";
|
||||
my $alias;
|
||||
if ($_->{type} eq 'string') {
|
||||
$alias = "GIMP_OBJECT (pattern)->$_->{name}";
|
||||
} else {
|
||||
$alias = "pattern->$_->{name}";
|
||||
}
|
||||
$alias = "g_strdup ($alias)" if $_->{type} eq 'string';
|
||||
$alias =~ s/pattern/pattern->mask/ if $_->{name} =~ /width|height/;
|
||||
$_->{alias} = $alias;
|
||||
|
@ -63,7 +68,7 @@ HELP
|
|||
&pattern_outargs;
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GPattern *pattern' ],
|
||||
vars => [ 'GimpPattern *pattern' ],
|
||||
code => 'success = (pattern = gimp_context_get_pattern (NULL)) != NULL;'
|
||||
);
|
||||
}
|
||||
|
@ -84,16 +89,16 @@ HELP
|
|||
@inargs = ( &pattern_arg );
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GPattern *pattern', 'GSList *list' ],
|
||||
vars => [ 'GimpPattern *pattern', 'GList *list' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
for (list = pattern_list; list; list = g_slist_next (list))
|
||||
for (list = global_pattern_list->list; list; list = g_list_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
pattern = (GimpPattern *) list->data;
|
||||
|
||||
if (!strcmp (pattern->name, name))
|
||||
if (! strcmp (GIMP_OBJECT (pattern)->name, name))
|
||||
{
|
||||
gimp_context_set_pattern (NULL, pattern);
|
||||
success = TRUE;
|
||||
|
@ -121,20 +126,20 @@ HELP
|
|||
alias => 'patterns',
|
||||
array => { name => 'num_patterns',
|
||||
desc => 'The number of patterns in the pattern list',
|
||||
alias => 'num_patterns', no_declare => 1 } }
|
||||
alias => 'GIMP_CONTAINER (global_pattern_list)->num_children', no_declare => 1 } }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GSList *list = NULL', 'int i = 0' ],
|
||||
vars => [ 'GList *list = NULL', 'gint i = 0' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
patterns = g_new (char *, num_patterns);
|
||||
patterns = g_new (gchar *, GIMP_CONTAINER (global_pattern_list)->num_children);
|
||||
|
||||
success = (list = pattern_list) != NULL;
|
||||
success = ((list = global_pattern_list->list) != NULL);
|
||||
|
||||
while (list)
|
||||
{
|
||||
patterns[i++] = g_strdup (((GPattern *) list->data)->name);
|
||||
patterns[i++] = g_strdup (GIMP_OBJECT (list->data)->name);
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
|
@ -176,20 +181,20 @@ HELP
|
|||
|
||||
%invoke = (
|
||||
headers => [ qw(<string.h>) ],
|
||||
vars => [ 'GPattern *pattern = NULL' ],
|
||||
vars => [ 'GimpPattern *pattern = NULL' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list;
|
||||
GList *list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
for (list = pattern_list; list; list = g_slist_next (list))
|
||||
for (list = global_pattern_list->list; list; list = g_list_next (list))
|
||||
{
|
||||
pattern = (GPattern *) list->data;
|
||||
pattern = (GimpPattern *) list->data;
|
||||
|
||||
if (!strcmp (pattern->name, name))
|
||||
if (!strcmp (GIMP_OBJECT (pattern)->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
|
@ -211,7 +216,8 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
@headers = qw("gimpcontext.h" "patterns.h" "temp_buf.h");
|
||||
@headers = qw("gimpcontext.h" "patterns.h" "gimplist.h" "gimppattern.h"
|
||||
"temp_buf.h");
|
||||
|
||||
@procs = qw(patterns_get_pattern patterns_set_pattern patterns_list
|
||||
patterns_get_pattern_data);
|
||||
|
|
Loading…
Reference in New Issue