app/color_area.[ch] pass masks for the "default" and "swap" pixmaps to the

2000-02-22  Michael Natterer  <mitch@gimp.org>

	* app/color_area.[ch]
	* app/interface.c: pass masks for the "default" and "swap" pixmaps
	to the color_area constructor and use them to create a clip mask
	in color_area_draw().

	* app/datafiles.[ch]: some harmless cleanups.

	* libgimp/gimppixmap.c: use gtk_pixmap_set_build_insensitive()
	instead of accessing the field directly.
This commit is contained in:
Michael Natterer
2000-02-22 15:14:54 +00:00
committed by Michael Natterer
parent dcf85066c9
commit a4f6d59af0
18 changed files with 362 additions and 191 deletions

View File

@ -1,3 +1,15 @@
2000-02-22 Michael Natterer <mitch@gimp.org>
* app/color_area.[ch]
* app/interface.c: pass masks for the "default" and "swap" pixmaps
to the color_area constructor and use them to create a clip mask
in color_area_draw().
* app/datafiles.[ch]: some harmless cleanups.
* libgimp/gimppixmap.c: use gtk_pixmap_set_build_insensitive()
instead of accessing the field directly.
Tue Feb 22 01:42:01 CET 2000 Sven Neumann <sven@gimp.org> Tue Feb 22 01:42:01 CET 2000 Sven Neumann <sven@gimp.org>
* plug-ins/perl/Makefile.PL: Made 'make install' work again. * plug-ins/perl/Makefile.PL: Made 'make install' work again.

View File

@ -15,17 +15,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdlib.h>
#include <string.h>
#include "appenv.h" #include "appenv.h"
#include "color_area.h" #include "color_area.h"
#include "color_notebook.h" #include "color_notebook.h"
#include "colormaps.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "gdisplay_color.h" #include "gdisplay_color.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h" #include "gimpdnd.h"
#include "gimpimageP.h"
typedef enum typedef enum
{ {
@ -37,25 +34,40 @@ typedef enum
} ColorAreaTarget; } ColorAreaTarget;
/* local function prototypes */ /* local function prototypes */
static void color_area_drop_color (GtkWidget *, static void color_area_drop_color (GtkWidget *widget,
guchar, guchar, guchar, gpointer); guchar r,
static void color_area_drag_color (GtkWidget *, guchar g,
guchar *, guchar *, guchar *, gpointer); guchar b,
static void color_area_color_changed (GimpContext *, gpointer data);
gint, gint, gint, gpointer); static void color_area_drag_color (GtkWidget *widget,
guchar *r,
guchar *g,
guchar *b,
gpointer data);
static void color_area_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
/* Global variables */ /* Global variables */
gint active_color = FOREGROUND; gint active_color = FOREGROUND;
GDisplay *color_area_gdisp = NULL; GDisplay *color_area_gdisp = NULL;
/* Static variables */ /* Static variables */
static GdkGC *color_area_gc = NULL; static GdkGC *color_area_gc = NULL;
static GtkWidget *color_area = NULL; static GdkGC *mask_gc = NULL;
static GtkWidget *color_area = NULL;
static GdkPixmap *color_area_pixmap = NULL; static GdkPixmap *color_area_pixmap = NULL;
static GdkPixmap *default_pixmap = NULL; static GdkBitmap *color_area_mask = NULL;
static GdkPixmap *swap_pixmap = NULL; static GdkPixmap *default_pixmap = NULL;
static ColorNotebook *color_notebook = NULL; static GdkBitmap *default_mask = NULL;
static GdkPixmap *swap_pixmap = NULL;
static GdkBitmap *swap_mask = NULL;
static ColorNotebook *color_notebook = NULL;
static gboolean color_notebook_active = FALSE; static gboolean color_notebook_active = FALSE;
static gint edit_color; static gint edit_color;
static guchar revert_fg_r, revert_fg_g, revert_fg_b; static guchar revert_fg_r, revert_fg_g, revert_fg_b;
@ -111,11 +123,11 @@ color_area_draw_rect (GdkDrawable *drawable,
guchar b) guchar b)
{ {
static guchar *color_area_rgb_buf = NULL; static guchar *color_area_rgb_buf = NULL;
static gint color_area_rgb_buf_size; static gint color_area_rgb_buf_size;
static gint rowstride; static gint rowstride;
gint xx, yy; gint xx, yy;
guchar *bp; guchar *bp;
GList *list; GList *list;
rowstride = 3 * ((width + 3) & -4); rowstride = 3 * ((width + 3) & -4);
@ -137,12 +149,11 @@ color_area_draw_rect (GdkDrawable *drawable,
bp = color_area_rgb_buf; bp = color_area_rgb_buf;
list = color_area_gdisp->cd_list; for (list = color_area_gdisp->cd_list; list; list = g_list_next (list))
while (list)
{ {
ColorDisplayNode *node = (ColorDisplayNode *) list->data; ColorDisplayNode *node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride); node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride);
list = list->next;
} }
for (yy = 1; yy < height; yy++) for (yy = 1; yy < height; yy++)
@ -160,37 +171,40 @@ color_area_draw_rect (GdkDrawable *drawable,
static void static void
color_area_draw (void) color_area_draw (void)
{ {
GdkColor *win_bg; gint rect_w, rect_h;
GdkColor fg, bg, bd; gint width, height;
gint rect_w, rect_h; gint def_width, def_height;
gint width, height; gint swap_width, swap_height;
gint def_width, def_height; guchar r, g, b;
gint swap_width, swap_height; GdkColor mask_pattern;
guchar r, g, b;
/* Check we haven't gotten initial expose yet, /* Check we haven't gotten initial expose yet,
* no point in drawing anything */ * no point in drawing anything
*/
if (!color_area_pixmap || !color_area_gc) if (!color_area_pixmap || !color_area_gc)
return; return;
gdk_window_get_size (color_area_pixmap, &width, &height); gdk_window_get_size (color_area_pixmap, &width, &height);
win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
fg.pixel = foreground_pixel;
bg.pixel = background_pixel;
bd.pixel = g_black_pixel;
rect_w = width * 0.65; rect_w = width * 0.65;
rect_h = height * 0.65; rect_h = height * 0.65;
gdk_gc_set_foreground (color_area_gc, win_bg); /* initialize the mask to transparent */
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1, mask_pattern.pixel = 0;
0, 0, width, height); gdk_gc_set_foreground (mask_gc, &mask_pattern);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE, 0, 0, -1, -1);
/* set the mask's gc to opaque */
mask_pattern.pixel = 1;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
/* draw the background area */
gimp_context_get_background (gimp_context_get_user (), &r, &g, &b); gimp_context_get_background (gimp_context_get_user (), &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc, color_area_draw_rect (color_area_pixmap, color_area_gc,
(width - rect_w), (height - rect_h), rect_w, rect_h, (width - rect_w), (height - rect_h), rect_w, rect_h,
r, g, b); r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
(width - rect_w), (height - rect_h), rect_w, rect_h);
if (active_color == FOREGROUND) if (active_color == FOREGROUND)
gtk_draw_shadow (color_area->style, color_area_pixmap, gtk_draw_shadow (color_area->style, color_area_pixmap,
@ -201,10 +215,13 @@ color_area_draw (void)
GTK_STATE_NORMAL, GTK_SHADOW_IN, GTK_STATE_NORMAL, GTK_SHADOW_IN,
(width - rect_w), (height - rect_h), rect_w, rect_h); (width - rect_w), (height - rect_h), rect_w, rect_h);
/* draw the foreground area */
gimp_context_get_foreground (gimp_context_get_user (), &r, &g, &b); gimp_context_get_foreground (gimp_context_get_user (), &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc, color_area_draw_rect (color_area_pixmap, color_area_gc,
0, 0, rect_w, rect_h, 0, 0, rect_w, rect_h,
r, g, b); r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
0, 0, rect_w, rect_h);
if (active_color == FOREGROUND) if (active_color == FOREGROUND)
gtk_draw_shadow (color_area->style, color_area_pixmap, gtk_draw_shadow (color_area->style, color_area_pixmap,
@ -215,17 +232,28 @@ color_area_draw (void)
GTK_STATE_NORMAL, GTK_SHADOW_OUT, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
0, 0, rect_w, rect_h); 0, 0, rect_w, rect_h);
/* draw the default pixmap */
gdk_window_get_size (default_pixmap, &def_width, &def_height); gdk_window_get_size (default_pixmap, &def_width, &def_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap, gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap,
0, 0, 0, height - def_height, def_width, def_height); 0, 0, 0, height - def_height, def_width, def_height);
gdk_draw_pixmap (color_area_mask, mask_gc, default_mask,
0, 0, 0, height - def_height, def_width, def_height);
/* draw the swap pixmap */
gdk_window_get_size (swap_pixmap, &swap_width, &swap_height); gdk_window_get_size (swap_pixmap, &swap_width, &swap_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap, gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap,
0, 0, width - swap_width, 0, swap_width, swap_height); 0, 0, width - swap_width, 0, swap_width, swap_height);
gdk_draw_pixmap (color_area_mask, mask_gc, swap_mask,
0, 0, width - swap_width, 0, swap_width, swap_height);
/* draw the widget */
gdk_gc_set_clip_mask (color_area_gc, color_area_mask);
gdk_gc_set_clip_origin (color_area_gc, 0, 0);
gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap, gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap,
0, 0, 0, 0, width, height); 0, 0, 0, 0, width, height);
/* reset the clip mask */
gdk_gc_set_clip_mask (color_area_gc, NULL);
} }
static void static void
@ -316,18 +344,27 @@ color_area_events (GtkWidget *widget,
{ {
case GDK_CONFIGURE: case GDK_CONFIGURE:
if (color_area_pixmap) if (color_area_pixmap)
gdk_pixmap_unref (color_area_pixmap); {
gdk_pixmap_unref (color_area_pixmap);
gdk_bitmap_unref (color_area_mask);
}
color_area_pixmap = gdk_pixmap_new (widget->window, color_area_pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width, widget->allocation.width,
widget->allocation.height, -1); widget->allocation.height, -1);
color_area_mask = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height, 1);
break; break;
case GDK_EXPOSE: case GDK_EXPOSE:
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
{ {
if (!color_area_gc) if (!color_area_gc)
color_area_gc = gdk_gc_new (widget->window); {
color_area_gc = gdk_gc_new (widget->window);
mask_gc = gdk_gc_new (color_area_mask);
}
color_area_draw (); color_area_draw ();
} }
@ -405,19 +442,27 @@ GtkWidget *
color_area_create (gint width, color_area_create (gint width,
gint height, gint height,
GdkPixmap *default_pmap, GdkPixmap *default_pmap,
GdkPixmap *swap_pmap) GdkBitmap *default_msk,
GdkPixmap *swap_pmap,
GdkBitmap *swap_msk)
{ {
color_area = gtk_drawing_area_new (); color_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height); gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height);
gtk_widget_set_events (color_area, gtk_widget_set_events (color_area,
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
gtk_signal_connect (GTK_OBJECT (color_area), "event", gtk_signal_connect (GTK_OBJECT (color_area), "event",
(GtkSignalFunc) color_area_events, GTK_SIGNAL_FUNC (color_area_events),
NULL); NULL);
default_pixmap = default_pmap; default_pixmap = default_pmap;
default_mask = default_msk;
swap_pixmap = swap_pmap; swap_pixmap = swap_pmap;
swap_mask = swap_msk;
/* dnd stuff */ /* dnd stuff */
gtk_drag_source_set (color_area, gtk_drag_source_set (color_area,

View File

@ -37,7 +37,9 @@ extern GDisplay *color_area_gdisp; /* hack for color displays */
GtkWidget * color_area_create (gint width, GtkWidget * color_area_create (gint width,
gint height, gint height,
GdkPixmap *default_pixmap, GdkPixmap *default_pixmap,
GdkPixmap *swap_pixmap); GdkBitmap *default_mask,
GdkPixmap *swap_pixmap,
GdkBitmap *swap_mask);
/* Exported for use by color_select */ /* Exported for use by color_select */
void color_area_draw_rect (GdkDrawable *drawable, void color_area_draw_rect (GdkDrawable *drawable,

View File

@ -51,18 +51,18 @@
/***** Functions *****/ /***** Functions *****/
static gint filestat_valid = 0; static gboolean filestat_valid = FALSE;
static struct stat filestat; static struct stat filestat;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
/* /*
* On Windows there is no concept like the Unix executable flag. There * On Windows there is no concept like the Unix executable flag.
* There is a weak emulation provided by the MS C Runtime using file * There is a weak emulation provided by the MS C Runtime using file
* extensions (com, exe, cmd, bat). This needs to be extended to treat * extensions (com, exe, cmd, bat). This needs to be extended to treat
* scripts (Python, Perl, ...) as executables, too. We use the PATHEXT * scripts (Python, Perl, ...) as executables, too. We use the PATHEXT
* variable, which is also used by cmd.exe. * variable, which is also used by cmd.exe.
*/ */
gboolean static gboolean
is_script (const gchar *filename) is_script (const gchar *filename)
{ {
const gchar *ext = strrchr (filename, '.'); const gchar *ext = strrchr (filename, '.');
@ -102,7 +102,7 @@ is_script (const gchar *filename)
void void
datafiles_read_directories (gchar *path_str, datafiles_read_directories (gchar *path_str,
GimpDataFileLoaderFunc loader_func, GimpDataFileLoaderFunc loader_func,
gint flags) GimpDataFileFlags flags)
{ {
gchar *local_path; gchar *local_path;
GList *path; GList *path;
@ -141,7 +141,7 @@ datafiles_read_directories (gchar *path_str,
} }
else else
{ {
while ((dir_ent = readdir(dir))) while ((dir_ent = readdir (dir)))
{ {
filename = g_strdup_printf ("%s%s", filename = g_strdup_printf ("%s%s",
(gchar *) list->data, (gchar *) list->data,
@ -155,9 +155,9 @@ datafiles_read_directories (gchar *path_str,
(filestat.st_mode & S_IXUSR) || (filestat.st_mode & S_IXUSR) ||
is_script (filename))) is_script (filename)))
{ {
filestat_valid = 1; filestat_valid = TRUE;
(*loader_func) (filename); (*loader_func) (filename);
filestat_valid = 0; filestat_valid = FALSE;
} }
g_free (filename); g_free (filename);

View File

@ -25,12 +25,14 @@
#include <time.h> #include <time.h>
#include <glib.h> #include <glib.h>
#define INCLUDE_TEMP_DIR 0x1
#define MODE_EXECUTABLE 0x2
/***** Types *****/ /***** Types *****/
typedef enum
{
INCLUDE_TEMP_DIR = 1 << 0,
MODE_EXECUTABLE = 1 << 1
} GimpDataFileFlags;
typedef void (* GimpDataFileLoaderFunc) (gchar *filename); typedef void (* GimpDataFileLoaderFunc) (gchar *filename);
@ -38,7 +40,7 @@ typedef void (* GimpDataFileLoaderFunc) (gchar *filename);
void datafiles_read_directories (gchar *path_str, void datafiles_read_directories (gchar *path_str,
GimpDataFileLoaderFunc loader_func, GimpDataFileLoaderFunc loader_func,
gint flags); GimpDataFileFlags flags);
/* Return the current datafiles access, modification /* Return the current datafiles access, modification
* or change time. The current datafile is the one for * or change time. The current datafile is the one for

View File

@ -51,18 +51,18 @@
/***** Functions *****/ /***** Functions *****/
static gint filestat_valid = 0; static gboolean filestat_valid = FALSE;
static struct stat filestat; static struct stat filestat;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
/* /*
* On Windows there is no concept like the Unix executable flag. There * On Windows there is no concept like the Unix executable flag.
* There is a weak emulation provided by the MS C Runtime using file * There is a weak emulation provided by the MS C Runtime using file
* extensions (com, exe, cmd, bat). This needs to be extended to treat * extensions (com, exe, cmd, bat). This needs to be extended to treat
* scripts (Python, Perl, ...) as executables, too. We use the PATHEXT * scripts (Python, Perl, ...) as executables, too. We use the PATHEXT
* variable, which is also used by cmd.exe. * variable, which is also used by cmd.exe.
*/ */
gboolean static gboolean
is_script (const gchar *filename) is_script (const gchar *filename)
{ {
const gchar *ext = strrchr (filename, '.'); const gchar *ext = strrchr (filename, '.');
@ -102,7 +102,7 @@ is_script (const gchar *filename)
void void
datafiles_read_directories (gchar *path_str, datafiles_read_directories (gchar *path_str,
GimpDataFileLoaderFunc loader_func, GimpDataFileLoaderFunc loader_func,
gint flags) GimpDataFileFlags flags)
{ {
gchar *local_path; gchar *local_path;
GList *path; GList *path;
@ -141,7 +141,7 @@ datafiles_read_directories (gchar *path_str,
} }
else else
{ {
while ((dir_ent = readdir(dir))) while ((dir_ent = readdir (dir)))
{ {
filename = g_strdup_printf ("%s%s", filename = g_strdup_printf ("%s%s",
(gchar *) list->data, (gchar *) list->data,
@ -155,9 +155,9 @@ datafiles_read_directories (gchar *path_str,
(filestat.st_mode & S_IXUSR) || (filestat.st_mode & S_IXUSR) ||
is_script (filename))) is_script (filename)))
{ {
filestat_valid = 1; filestat_valid = TRUE;
(*loader_func) (filename); (*loader_func) (filename);
filestat_valid = 0; filestat_valid = FALSE;
} }
g_free (filename); g_free (filename);

View File

@ -25,12 +25,14 @@
#include <time.h> #include <time.h>
#include <glib.h> #include <glib.h>
#define INCLUDE_TEMP_DIR 0x1
#define MODE_EXECUTABLE 0x2
/***** Types *****/ /***** Types *****/
typedef enum
{
INCLUDE_TEMP_DIR = 1 << 0,
MODE_EXECUTABLE = 1 << 1
} GimpDataFileFlags;
typedef void (* GimpDataFileLoaderFunc) (gchar *filename); typedef void (* GimpDataFileLoaderFunc) (gchar *filename);
@ -38,7 +40,7 @@ typedef void (* GimpDataFileLoaderFunc) (gchar *filename);
void datafiles_read_directories (gchar *path_str, void datafiles_read_directories (gchar *path_str,
GimpDataFileLoaderFunc loader_func, GimpDataFileLoaderFunc loader_func,
gint flags); GimpDataFileFlags flags);
/* Return the current datafiles access, modification /* Return the current datafiles access, modification
* or change time. The current datafile is the one for * or change time. The current datafile is the one for

View File

@ -280,13 +280,15 @@ create_color_area (GtkWidget *parent)
GtkWidget *alignment; GtkWidget *alignment;
GtkWidget *col_area; GtkWidget *col_area;
GdkPixmap *default_pixmap; GdkPixmap *default_pixmap;
GdkBitmap *default_mask;
GdkPixmap *swap_pixmap; GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
gtk_widget_realize (parent); gtk_widget_realize (parent);
default_pixmap = create_pixmap (parent->window, NULL, default_bits, default_pixmap = create_pixmap (parent->window, &default_mask, default_bits,
default_width, default_height); default_width, default_height);
swap_pixmap = create_pixmap (parent->window, NULL, swap_bits, swap_pixmap = create_pixmap (parent->window, &swap_mask, swap_bits,
swap_width, swap_height); swap_width, swap_height);
frame = gtk_frame_new (NULL); frame = gtk_frame_new (NULL);
@ -301,7 +303,9 @@ create_color_area (GtkWidget *parent)
gimp_help_set_help_data (alignment, NULL, "#color_area"); gimp_help_set_help_data (alignment, NULL, "#color_area");
col_area = color_area_create (54, 42, default_pixmap, swap_pixmap); col_area = color_area_create (54, 42,
default_pixmap, default_mask,
swap_pixmap, swap_mask);
gtk_container_add (GTK_CONTAINER (alignment), col_area); gtk_container_add (GTK_CONTAINER (alignment), col_area);
gimp_help_set_help_data gimp_help_set_help_data
(col_area, (col_area,

View File

@ -280,13 +280,15 @@ create_color_area (GtkWidget *parent)
GtkWidget *alignment; GtkWidget *alignment;
GtkWidget *col_area; GtkWidget *col_area;
GdkPixmap *default_pixmap; GdkPixmap *default_pixmap;
GdkBitmap *default_mask;
GdkPixmap *swap_pixmap; GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
gtk_widget_realize (parent); gtk_widget_realize (parent);
default_pixmap = create_pixmap (parent->window, NULL, default_bits, default_pixmap = create_pixmap (parent->window, &default_mask, default_bits,
default_width, default_height); default_width, default_height);
swap_pixmap = create_pixmap (parent->window, NULL, swap_bits, swap_pixmap = create_pixmap (parent->window, &swap_mask, swap_bits,
swap_width, swap_height); swap_width, swap_height);
frame = gtk_frame_new (NULL); frame = gtk_frame_new (NULL);
@ -301,7 +303,9 @@ create_color_area (GtkWidget *parent)
gimp_help_set_help_data (alignment, NULL, "#color_area"); gimp_help_set_help_data (alignment, NULL, "#color_area");
col_area = color_area_create (54, 42, default_pixmap, swap_pixmap); col_area = color_area_create (54, 42,
default_pixmap, default_mask,
swap_pixmap, swap_mask);
gtk_container_add (GTK_CONTAINER (alignment), col_area); gtk_container_add (GTK_CONTAINER (alignment), col_area);
gimp_help_set_help_data gimp_help_set_help_data
(col_area, (col_area,

View File

@ -15,17 +15,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdlib.h>
#include <string.h>
#include "appenv.h" #include "appenv.h"
#include "color_area.h" #include "color_area.h"
#include "color_notebook.h" #include "color_notebook.h"
#include "colormaps.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "gdisplay_color.h" #include "gdisplay_color.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h" #include "gimpdnd.h"
#include "gimpimageP.h"
typedef enum typedef enum
{ {
@ -37,25 +34,40 @@ typedef enum
} ColorAreaTarget; } ColorAreaTarget;
/* local function prototypes */ /* local function prototypes */
static void color_area_drop_color (GtkWidget *, static void color_area_drop_color (GtkWidget *widget,
guchar, guchar, guchar, gpointer); guchar r,
static void color_area_drag_color (GtkWidget *, guchar g,
guchar *, guchar *, guchar *, gpointer); guchar b,
static void color_area_color_changed (GimpContext *, gpointer data);
gint, gint, gint, gpointer); static void color_area_drag_color (GtkWidget *widget,
guchar *r,
guchar *g,
guchar *b,
gpointer data);
static void color_area_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
/* Global variables */ /* Global variables */
gint active_color = FOREGROUND; gint active_color = FOREGROUND;
GDisplay *color_area_gdisp = NULL; GDisplay *color_area_gdisp = NULL;
/* Static variables */ /* Static variables */
static GdkGC *color_area_gc = NULL; static GdkGC *color_area_gc = NULL;
static GtkWidget *color_area = NULL; static GdkGC *mask_gc = NULL;
static GtkWidget *color_area = NULL;
static GdkPixmap *color_area_pixmap = NULL; static GdkPixmap *color_area_pixmap = NULL;
static GdkPixmap *default_pixmap = NULL; static GdkBitmap *color_area_mask = NULL;
static GdkPixmap *swap_pixmap = NULL; static GdkPixmap *default_pixmap = NULL;
static ColorNotebook *color_notebook = NULL; static GdkBitmap *default_mask = NULL;
static GdkPixmap *swap_pixmap = NULL;
static GdkBitmap *swap_mask = NULL;
static ColorNotebook *color_notebook = NULL;
static gboolean color_notebook_active = FALSE; static gboolean color_notebook_active = FALSE;
static gint edit_color; static gint edit_color;
static guchar revert_fg_r, revert_fg_g, revert_fg_b; static guchar revert_fg_r, revert_fg_g, revert_fg_b;
@ -111,11 +123,11 @@ color_area_draw_rect (GdkDrawable *drawable,
guchar b) guchar b)
{ {
static guchar *color_area_rgb_buf = NULL; static guchar *color_area_rgb_buf = NULL;
static gint color_area_rgb_buf_size; static gint color_area_rgb_buf_size;
static gint rowstride; static gint rowstride;
gint xx, yy; gint xx, yy;
guchar *bp; guchar *bp;
GList *list; GList *list;
rowstride = 3 * ((width + 3) & -4); rowstride = 3 * ((width + 3) & -4);
@ -137,12 +149,11 @@ color_area_draw_rect (GdkDrawable *drawable,
bp = color_area_rgb_buf; bp = color_area_rgb_buf;
list = color_area_gdisp->cd_list; for (list = color_area_gdisp->cd_list; list; list = g_list_next (list))
while (list)
{ {
ColorDisplayNode *node = (ColorDisplayNode *) list->data; ColorDisplayNode *node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride); node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride);
list = list->next;
} }
for (yy = 1; yy < height; yy++) for (yy = 1; yy < height; yy++)
@ -160,37 +171,40 @@ color_area_draw_rect (GdkDrawable *drawable,
static void static void
color_area_draw (void) color_area_draw (void)
{ {
GdkColor *win_bg; gint rect_w, rect_h;
GdkColor fg, bg, bd; gint width, height;
gint rect_w, rect_h; gint def_width, def_height;
gint width, height; gint swap_width, swap_height;
gint def_width, def_height; guchar r, g, b;
gint swap_width, swap_height; GdkColor mask_pattern;
guchar r, g, b;
/* Check we haven't gotten initial expose yet, /* Check we haven't gotten initial expose yet,
* no point in drawing anything */ * no point in drawing anything
*/
if (!color_area_pixmap || !color_area_gc) if (!color_area_pixmap || !color_area_gc)
return; return;
gdk_window_get_size (color_area_pixmap, &width, &height); gdk_window_get_size (color_area_pixmap, &width, &height);
win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
fg.pixel = foreground_pixel;
bg.pixel = background_pixel;
bd.pixel = g_black_pixel;
rect_w = width * 0.65; rect_w = width * 0.65;
rect_h = height * 0.65; rect_h = height * 0.65;
gdk_gc_set_foreground (color_area_gc, win_bg); /* initialize the mask to transparent */
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1, mask_pattern.pixel = 0;
0, 0, width, height); gdk_gc_set_foreground (mask_gc, &mask_pattern);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE, 0, 0, -1, -1);
/* set the mask's gc to opaque */
mask_pattern.pixel = 1;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
/* draw the background area */
gimp_context_get_background (gimp_context_get_user (), &r, &g, &b); gimp_context_get_background (gimp_context_get_user (), &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc, color_area_draw_rect (color_area_pixmap, color_area_gc,
(width - rect_w), (height - rect_h), rect_w, rect_h, (width - rect_w), (height - rect_h), rect_w, rect_h,
r, g, b); r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
(width - rect_w), (height - rect_h), rect_w, rect_h);
if (active_color == FOREGROUND) if (active_color == FOREGROUND)
gtk_draw_shadow (color_area->style, color_area_pixmap, gtk_draw_shadow (color_area->style, color_area_pixmap,
@ -201,10 +215,13 @@ color_area_draw (void)
GTK_STATE_NORMAL, GTK_SHADOW_IN, GTK_STATE_NORMAL, GTK_SHADOW_IN,
(width - rect_w), (height - rect_h), rect_w, rect_h); (width - rect_w), (height - rect_h), rect_w, rect_h);
/* draw the foreground area */
gimp_context_get_foreground (gimp_context_get_user (), &r, &g, &b); gimp_context_get_foreground (gimp_context_get_user (), &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc, color_area_draw_rect (color_area_pixmap, color_area_gc,
0, 0, rect_w, rect_h, 0, 0, rect_w, rect_h,
r, g, b); r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
0, 0, rect_w, rect_h);
if (active_color == FOREGROUND) if (active_color == FOREGROUND)
gtk_draw_shadow (color_area->style, color_area_pixmap, gtk_draw_shadow (color_area->style, color_area_pixmap,
@ -215,17 +232,28 @@ color_area_draw (void)
GTK_STATE_NORMAL, GTK_SHADOW_OUT, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
0, 0, rect_w, rect_h); 0, 0, rect_w, rect_h);
/* draw the default pixmap */
gdk_window_get_size (default_pixmap, &def_width, &def_height); gdk_window_get_size (default_pixmap, &def_width, &def_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap, gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap,
0, 0, 0, height - def_height, def_width, def_height); 0, 0, 0, height - def_height, def_width, def_height);
gdk_draw_pixmap (color_area_mask, mask_gc, default_mask,
0, 0, 0, height - def_height, def_width, def_height);
/* draw the swap pixmap */
gdk_window_get_size (swap_pixmap, &swap_width, &swap_height); gdk_window_get_size (swap_pixmap, &swap_width, &swap_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap, gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap,
0, 0, width - swap_width, 0, swap_width, swap_height); 0, 0, width - swap_width, 0, swap_width, swap_height);
gdk_draw_pixmap (color_area_mask, mask_gc, swap_mask,
0, 0, width - swap_width, 0, swap_width, swap_height);
/* draw the widget */
gdk_gc_set_clip_mask (color_area_gc, color_area_mask);
gdk_gc_set_clip_origin (color_area_gc, 0, 0);
gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap, gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap,
0, 0, 0, 0, width, height); 0, 0, 0, 0, width, height);
/* reset the clip mask */
gdk_gc_set_clip_mask (color_area_gc, NULL);
} }
static void static void
@ -316,18 +344,27 @@ color_area_events (GtkWidget *widget,
{ {
case GDK_CONFIGURE: case GDK_CONFIGURE:
if (color_area_pixmap) if (color_area_pixmap)
gdk_pixmap_unref (color_area_pixmap); {
gdk_pixmap_unref (color_area_pixmap);
gdk_bitmap_unref (color_area_mask);
}
color_area_pixmap = gdk_pixmap_new (widget->window, color_area_pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width, widget->allocation.width,
widget->allocation.height, -1); widget->allocation.height, -1);
color_area_mask = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height, 1);
break; break;
case GDK_EXPOSE: case GDK_EXPOSE:
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
{ {
if (!color_area_gc) if (!color_area_gc)
color_area_gc = gdk_gc_new (widget->window); {
color_area_gc = gdk_gc_new (widget->window);
mask_gc = gdk_gc_new (color_area_mask);
}
color_area_draw (); color_area_draw ();
} }
@ -405,19 +442,27 @@ GtkWidget *
color_area_create (gint width, color_area_create (gint width,
gint height, gint height,
GdkPixmap *default_pmap, GdkPixmap *default_pmap,
GdkPixmap *swap_pmap) GdkBitmap *default_msk,
GdkPixmap *swap_pmap,
GdkBitmap *swap_msk)
{ {
color_area = gtk_drawing_area_new (); color_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height); gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height);
gtk_widget_set_events (color_area, gtk_widget_set_events (color_area,
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
gtk_signal_connect (GTK_OBJECT (color_area), "event", gtk_signal_connect (GTK_OBJECT (color_area), "event",
(GtkSignalFunc) color_area_events, GTK_SIGNAL_FUNC (color_area_events),
NULL); NULL);
default_pixmap = default_pmap; default_pixmap = default_pmap;
default_mask = default_msk;
swap_pixmap = swap_pmap; swap_pixmap = swap_pmap;
swap_mask = swap_msk;
/* dnd stuff */ /* dnd stuff */
gtk_drag_source_set (color_area, gtk_drag_source_set (color_area,

View File

@ -37,7 +37,9 @@ extern GDisplay *color_area_gdisp; /* hack for color displays */
GtkWidget * color_area_create (gint width, GtkWidget * color_area_create (gint width,
gint height, gint height,
GdkPixmap *default_pixmap, GdkPixmap *default_pixmap,
GdkPixmap *swap_pixmap); GdkBitmap *default_mask,
GdkPixmap *swap_pixmap,
GdkBitmap *swap_mask);
/* Exported for use by color_select */ /* Exported for use by color_select */
void color_area_draw_rect (GdkDrawable *drawable, void color_area_draw_rect (GdkDrawable *drawable,

View File

@ -280,13 +280,15 @@ create_color_area (GtkWidget *parent)
GtkWidget *alignment; GtkWidget *alignment;
GtkWidget *col_area; GtkWidget *col_area;
GdkPixmap *default_pixmap; GdkPixmap *default_pixmap;
GdkBitmap *default_mask;
GdkPixmap *swap_pixmap; GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
gtk_widget_realize (parent); gtk_widget_realize (parent);
default_pixmap = create_pixmap (parent->window, NULL, default_bits, default_pixmap = create_pixmap (parent->window, &default_mask, default_bits,
default_width, default_height); default_width, default_height);
swap_pixmap = create_pixmap (parent->window, NULL, swap_bits, swap_pixmap = create_pixmap (parent->window, &swap_mask, swap_bits,
swap_width, swap_height); swap_width, swap_height);
frame = gtk_frame_new (NULL); frame = gtk_frame_new (NULL);
@ -301,7 +303,9 @@ create_color_area (GtkWidget *parent)
gimp_help_set_help_data (alignment, NULL, "#color_area"); gimp_help_set_help_data (alignment, NULL, "#color_area");
col_area = color_area_create (54, 42, default_pixmap, swap_pixmap); col_area = color_area_create (54, 42,
default_pixmap, default_mask,
swap_pixmap, swap_mask);
gtk_container_add (GTK_CONTAINER (alignment), col_area); gtk_container_add (GTK_CONTAINER (alignment), col_area);
gimp_help_set_help_data gimp_help_set_help_data
(col_area, (col_area,

View File

@ -15,17 +15,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdlib.h>
#include <string.h>
#include "appenv.h" #include "appenv.h"
#include "color_area.h" #include "color_area.h"
#include "color_notebook.h" #include "color_notebook.h"
#include "colormaps.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "gdisplay_color.h" #include "gdisplay_color.h"
#include "gimpcontext.h" #include "gimpcontext.h"
#include "gimpdnd.h" #include "gimpdnd.h"
#include "gimpimageP.h"
typedef enum typedef enum
{ {
@ -37,25 +34,40 @@ typedef enum
} ColorAreaTarget; } ColorAreaTarget;
/* local function prototypes */ /* local function prototypes */
static void color_area_drop_color (GtkWidget *, static void color_area_drop_color (GtkWidget *widget,
guchar, guchar, guchar, gpointer); guchar r,
static void color_area_drag_color (GtkWidget *, guchar g,
guchar *, guchar *, guchar *, gpointer); guchar b,
static void color_area_color_changed (GimpContext *, gpointer data);
gint, gint, gint, gpointer); static void color_area_drag_color (GtkWidget *widget,
guchar *r,
guchar *g,
guchar *b,
gpointer data);
static void color_area_color_changed (GimpContext *context,
gint r,
gint g,
gint b,
gpointer data);
/* Global variables */ /* Global variables */
gint active_color = FOREGROUND; gint active_color = FOREGROUND;
GDisplay *color_area_gdisp = NULL; GDisplay *color_area_gdisp = NULL;
/* Static variables */ /* Static variables */
static GdkGC *color_area_gc = NULL; static GdkGC *color_area_gc = NULL;
static GtkWidget *color_area = NULL; static GdkGC *mask_gc = NULL;
static GtkWidget *color_area = NULL;
static GdkPixmap *color_area_pixmap = NULL; static GdkPixmap *color_area_pixmap = NULL;
static GdkPixmap *default_pixmap = NULL; static GdkBitmap *color_area_mask = NULL;
static GdkPixmap *swap_pixmap = NULL; static GdkPixmap *default_pixmap = NULL;
static ColorNotebook *color_notebook = NULL; static GdkBitmap *default_mask = NULL;
static GdkPixmap *swap_pixmap = NULL;
static GdkBitmap *swap_mask = NULL;
static ColorNotebook *color_notebook = NULL;
static gboolean color_notebook_active = FALSE; static gboolean color_notebook_active = FALSE;
static gint edit_color; static gint edit_color;
static guchar revert_fg_r, revert_fg_g, revert_fg_b; static guchar revert_fg_r, revert_fg_g, revert_fg_b;
@ -111,11 +123,11 @@ color_area_draw_rect (GdkDrawable *drawable,
guchar b) guchar b)
{ {
static guchar *color_area_rgb_buf = NULL; static guchar *color_area_rgb_buf = NULL;
static gint color_area_rgb_buf_size; static gint color_area_rgb_buf_size;
static gint rowstride; static gint rowstride;
gint xx, yy; gint xx, yy;
guchar *bp; guchar *bp;
GList *list; GList *list;
rowstride = 3 * ((width + 3) & -4); rowstride = 3 * ((width + 3) & -4);
@ -137,12 +149,11 @@ color_area_draw_rect (GdkDrawable *drawable,
bp = color_area_rgb_buf; bp = color_area_rgb_buf;
list = color_area_gdisp->cd_list; for (list = color_area_gdisp->cd_list; list; list = g_list_next (list))
while (list)
{ {
ColorDisplayNode *node = (ColorDisplayNode *) list->data; ColorDisplayNode *node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride); node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride);
list = list->next;
} }
for (yy = 1; yy < height; yy++) for (yy = 1; yy < height; yy++)
@ -160,37 +171,40 @@ color_area_draw_rect (GdkDrawable *drawable,
static void static void
color_area_draw (void) color_area_draw (void)
{ {
GdkColor *win_bg; gint rect_w, rect_h;
GdkColor fg, bg, bd; gint width, height;
gint rect_w, rect_h; gint def_width, def_height;
gint width, height; gint swap_width, swap_height;
gint def_width, def_height; guchar r, g, b;
gint swap_width, swap_height; GdkColor mask_pattern;
guchar r, g, b;
/* Check we haven't gotten initial expose yet, /* Check we haven't gotten initial expose yet,
* no point in drawing anything */ * no point in drawing anything
*/
if (!color_area_pixmap || !color_area_gc) if (!color_area_pixmap || !color_area_gc)
return; return;
gdk_window_get_size (color_area_pixmap, &width, &height); gdk_window_get_size (color_area_pixmap, &width, &height);
win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
fg.pixel = foreground_pixel;
bg.pixel = background_pixel;
bd.pixel = g_black_pixel;
rect_w = width * 0.65; rect_w = width * 0.65;
rect_h = height * 0.65; rect_h = height * 0.65;
gdk_gc_set_foreground (color_area_gc, win_bg); /* initialize the mask to transparent */
gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1, mask_pattern.pixel = 0;
0, 0, width, height); gdk_gc_set_foreground (mask_gc, &mask_pattern);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE, 0, 0, -1, -1);
/* set the mask's gc to opaque */
mask_pattern.pixel = 1;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
/* draw the background area */
gimp_context_get_background (gimp_context_get_user (), &r, &g, &b); gimp_context_get_background (gimp_context_get_user (), &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc, color_area_draw_rect (color_area_pixmap, color_area_gc,
(width - rect_w), (height - rect_h), rect_w, rect_h, (width - rect_w), (height - rect_h), rect_w, rect_h,
r, g, b); r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
(width - rect_w), (height - rect_h), rect_w, rect_h);
if (active_color == FOREGROUND) if (active_color == FOREGROUND)
gtk_draw_shadow (color_area->style, color_area_pixmap, gtk_draw_shadow (color_area->style, color_area_pixmap,
@ -201,10 +215,13 @@ color_area_draw (void)
GTK_STATE_NORMAL, GTK_SHADOW_IN, GTK_STATE_NORMAL, GTK_SHADOW_IN,
(width - rect_w), (height - rect_h), rect_w, rect_h); (width - rect_w), (height - rect_h), rect_w, rect_h);
/* draw the foreground area */
gimp_context_get_foreground (gimp_context_get_user (), &r, &g, &b); gimp_context_get_foreground (gimp_context_get_user (), &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc, color_area_draw_rect (color_area_pixmap, color_area_gc,
0, 0, rect_w, rect_h, 0, 0, rect_w, rect_h,
r, g, b); r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
0, 0, rect_w, rect_h);
if (active_color == FOREGROUND) if (active_color == FOREGROUND)
gtk_draw_shadow (color_area->style, color_area_pixmap, gtk_draw_shadow (color_area->style, color_area_pixmap,
@ -215,17 +232,28 @@ color_area_draw (void)
GTK_STATE_NORMAL, GTK_SHADOW_OUT, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
0, 0, rect_w, rect_h); 0, 0, rect_w, rect_h);
/* draw the default pixmap */
gdk_window_get_size (default_pixmap, &def_width, &def_height); gdk_window_get_size (default_pixmap, &def_width, &def_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap, gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap,
0, 0, 0, height - def_height, def_width, def_height); 0, 0, 0, height - def_height, def_width, def_height);
gdk_draw_pixmap (color_area_mask, mask_gc, default_mask,
0, 0, 0, height - def_height, def_width, def_height);
/* draw the swap pixmap */
gdk_window_get_size (swap_pixmap, &swap_width, &swap_height); gdk_window_get_size (swap_pixmap, &swap_width, &swap_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap, gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap,
0, 0, width - swap_width, 0, swap_width, swap_height); 0, 0, width - swap_width, 0, swap_width, swap_height);
gdk_draw_pixmap (color_area_mask, mask_gc, swap_mask,
0, 0, width - swap_width, 0, swap_width, swap_height);
/* draw the widget */
gdk_gc_set_clip_mask (color_area_gc, color_area_mask);
gdk_gc_set_clip_origin (color_area_gc, 0, 0);
gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap, gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap,
0, 0, 0, 0, width, height); 0, 0, 0, 0, width, height);
/* reset the clip mask */
gdk_gc_set_clip_mask (color_area_gc, NULL);
} }
static void static void
@ -316,18 +344,27 @@ color_area_events (GtkWidget *widget,
{ {
case GDK_CONFIGURE: case GDK_CONFIGURE:
if (color_area_pixmap) if (color_area_pixmap)
gdk_pixmap_unref (color_area_pixmap); {
gdk_pixmap_unref (color_area_pixmap);
gdk_bitmap_unref (color_area_mask);
}
color_area_pixmap = gdk_pixmap_new (widget->window, color_area_pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width, widget->allocation.width,
widget->allocation.height, -1); widget->allocation.height, -1);
color_area_mask = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height, 1);
break; break;
case GDK_EXPOSE: case GDK_EXPOSE:
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
{ {
if (!color_area_gc) if (!color_area_gc)
color_area_gc = gdk_gc_new (widget->window); {
color_area_gc = gdk_gc_new (widget->window);
mask_gc = gdk_gc_new (color_area_mask);
}
color_area_draw (); color_area_draw ();
} }
@ -405,19 +442,27 @@ GtkWidget *
color_area_create (gint width, color_area_create (gint width,
gint height, gint height,
GdkPixmap *default_pmap, GdkPixmap *default_pmap,
GdkPixmap *swap_pmap) GdkBitmap *default_msk,
GdkPixmap *swap_pmap,
GdkBitmap *swap_msk)
{ {
color_area = gtk_drawing_area_new (); color_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height); gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height);
gtk_widget_set_events (color_area, gtk_widget_set_events (color_area,
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
gtk_signal_connect (GTK_OBJECT (color_area), "event", gtk_signal_connect (GTK_OBJECT (color_area), "event",
(GtkSignalFunc) color_area_events, GTK_SIGNAL_FUNC (color_area_events),
NULL); NULL);
default_pixmap = default_pmap; default_pixmap = default_pmap;
default_mask = default_msk;
swap_pixmap = swap_pmap; swap_pixmap = swap_pmap;
swap_mask = swap_msk;
/* dnd stuff */ /* dnd stuff */
gtk_drag_source_set (color_area, gtk_drag_source_set (color_area,

View File

@ -37,7 +37,9 @@ extern GDisplay *color_area_gdisp; /* hack for color displays */
GtkWidget * color_area_create (gint width, GtkWidget * color_area_create (gint width,
gint height, gint height,
GdkPixmap *default_pixmap, GdkPixmap *default_pixmap,
GdkPixmap *swap_pixmap); GdkBitmap *default_mask,
GdkPixmap *swap_pixmap,
GdkBitmap *swap_mask);
/* Exported for use by color_select */ /* Exported for use by color_select */
void color_area_draw_rect (GdkDrawable *drawable, void color_area_draw_rect (GdkDrawable *drawable,

View File

@ -111,7 +111,7 @@ gimp_pixmap_new (gchar **xpm_data)
pixmap = gtk_type_new (gimp_pixmap_get_type ()); pixmap = gtk_type_new (gimp_pixmap_get_type ());
GTK_PIXMAP (pixmap)->build_insensitive = TRUE; gtk_pixmap_set_build_insensitive (GTK_PIXMAP (pixmap), TRUE);
gimp_pixmap_set (pixmap, xpm_data); gimp_pixmap_set (pixmap, xpm_data);
return GTK_WIDGET (pixmap); return GTK_WIDGET (pixmap);

View File

@ -51,18 +51,18 @@
/***** Functions *****/ /***** Functions *****/
static gint filestat_valid = 0; static gboolean filestat_valid = FALSE;
static struct stat filestat; static struct stat filestat;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
/* /*
* On Windows there is no concept like the Unix executable flag. There * On Windows there is no concept like the Unix executable flag.
* There is a weak emulation provided by the MS C Runtime using file * There is a weak emulation provided by the MS C Runtime using file
* extensions (com, exe, cmd, bat). This needs to be extended to treat * extensions (com, exe, cmd, bat). This needs to be extended to treat
* scripts (Python, Perl, ...) as executables, too. We use the PATHEXT * scripts (Python, Perl, ...) as executables, too. We use the PATHEXT
* variable, which is also used by cmd.exe. * variable, which is also used by cmd.exe.
*/ */
gboolean static gboolean
is_script (const gchar *filename) is_script (const gchar *filename)
{ {
const gchar *ext = strrchr (filename, '.'); const gchar *ext = strrchr (filename, '.');
@ -102,7 +102,7 @@ is_script (const gchar *filename)
void void
datafiles_read_directories (gchar *path_str, datafiles_read_directories (gchar *path_str,
GimpDataFileLoaderFunc loader_func, GimpDataFileLoaderFunc loader_func,
gint flags) GimpDataFileFlags flags)
{ {
gchar *local_path; gchar *local_path;
GList *path; GList *path;
@ -141,7 +141,7 @@ datafiles_read_directories (gchar *path_str,
} }
else else
{ {
while ((dir_ent = readdir(dir))) while ((dir_ent = readdir (dir)))
{ {
filename = g_strdup_printf ("%s%s", filename = g_strdup_printf ("%s%s",
(gchar *) list->data, (gchar *) list->data,
@ -155,9 +155,9 @@ datafiles_read_directories (gchar *path_str,
(filestat.st_mode & S_IXUSR) || (filestat.st_mode & S_IXUSR) ||
is_script (filename))) is_script (filename)))
{ {
filestat_valid = 1; filestat_valid = TRUE;
(*loader_func) (filename); (*loader_func) (filename);
filestat_valid = 0; filestat_valid = FALSE;
} }
g_free (filename); g_free (filename);

View File

@ -25,12 +25,14 @@
#include <time.h> #include <time.h>
#include <glib.h> #include <glib.h>
#define INCLUDE_TEMP_DIR 0x1
#define MODE_EXECUTABLE 0x2
/***** Types *****/ /***** Types *****/
typedef enum
{
INCLUDE_TEMP_DIR = 1 << 0,
MODE_EXECUTABLE = 1 << 1
} GimpDataFileFlags;
typedef void (* GimpDataFileLoaderFunc) (gchar *filename); typedef void (* GimpDataFileLoaderFunc) (gchar *filename);
@ -38,7 +40,7 @@ typedef void (* GimpDataFileLoaderFunc) (gchar *filename);
void datafiles_read_directories (gchar *path_str, void datafiles_read_directories (gchar *path_str,
GimpDataFileLoaderFunc loader_func, GimpDataFileLoaderFunc loader_func,
gint flags); GimpDataFileFlags flags);
/* Return the current datafiles access, modification /* Return the current datafiles access, modification
* or change time. The current datafile is the one for * or change time. The current datafile is the one for

View File

@ -111,7 +111,7 @@ gimp_pixmap_new (gchar **xpm_data)
pixmap = gtk_type_new (gimp_pixmap_get_type ()); pixmap = gtk_type_new (gimp_pixmap_get_type ());
GTK_PIXMAP (pixmap)->build_insensitive = TRUE; gtk_pixmap_set_build_insensitive (GTK_PIXMAP (pixmap), TRUE);
gimp_pixmap_set (pixmap, xpm_data); gimp_pixmap_set (pixmap, xpm_data);
return GTK_WIDGET (pixmap); return GTK_WIDGET (pixmap);