mirror of https://github.com/GNOME/gimp.git
cleanup & cruft removal.
2003-10-13 Michael Natterer <mitch@gimp.org> * app/widgets/gimptoolbox-color-area.[ch]: cleanup & cruft removal.
This commit is contained in:
parent
927f5d44cb
commit
85cf47ebed
|
@ -1,3 +1,7 @@
|
|||
2003-10-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimptoolbox-color-area.[ch]: cleanup & cruft removal.
|
||||
|
||||
2003-10-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpcontainergridview.c: typo: s/vieport/viewport/g
|
||||
|
|
|
@ -42,10 +42,6 @@
|
|||
|
||||
#include "gui/color-notebook.h"
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
#include "gdisplay_color.h"
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
|
@ -66,16 +62,18 @@ typedef enum
|
|||
|
||||
static ColorAreaTarget color_area_target (gint x,
|
||||
gint y);
|
||||
|
||||
static gboolean color_area_expose_event (GtkWidget *widget,
|
||||
GdkEventExpose *eevent,
|
||||
GimpContext *context);
|
||||
static void color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b);
|
||||
static void color_area_draw (GimpContext *context);
|
||||
const GimpRGB *color);
|
||||
|
||||
static void color_area_select_callback (ColorNotebook *color_notebook,
|
||||
const GimpRGB *color,
|
||||
ColorNotebookState state,
|
||||
|
@ -92,9 +90,6 @@ static gboolean color_area_events (GtkWidget *widget,
|
|||
gpointer data);
|
||||
|
||||
|
||||
/* Global variables */
|
||||
GimpDisplay *color_area_gdisp = NULL;
|
||||
|
||||
/* Static variables */
|
||||
static GtkWidget *color_area = NULL;
|
||||
static ColorNotebook *color_notebook = NULL;
|
||||
|
@ -136,6 +131,9 @@ gimp_toolbox_color_area_create (GimpToolbox *toolbox,
|
|||
g_signal_connect (color_area, "event",
|
||||
G_CALLBACK (color_area_events),
|
||||
context);
|
||||
g_signal_connect (color_area, "expose_event",
|
||||
G_CALLBACK (color_area_expose_event),
|
||||
context);
|
||||
|
||||
/* dnd stuff */
|
||||
gtk_drag_source_set (color_area,
|
||||
|
@ -154,15 +152,6 @@ gimp_toolbox_color_area_create (GimpToolbox *toolbox,
|
|||
G_CALLBACK (gtk_widget_queue_draw),
|
||||
color_area);
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
/* display filter dummy gdisplay */
|
||||
color_area_gdisp = g_new (GimpDisplay, 1);
|
||||
color_area_gdisp->cd_list = NULL;
|
||||
color_area_gdisp->cd_ui = NULL;
|
||||
color_area_gdisp->gimage = g_new (GimpImage, 1);
|
||||
color_area_gdisp->gimage->base_type = RGB;
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
return color_area;
|
||||
}
|
||||
|
||||
|
@ -198,25 +187,91 @@ color_area_target (gint x,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
color_area_expose_event (GtkWidget *widget,
|
||||
GdkEventExpose *eevent,
|
||||
GimpContext *context)
|
||||
{
|
||||
gint rect_w, rect_h;
|
||||
gint width, height;
|
||||
gint w, h;
|
||||
GimpRGB color;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (!GTK_WIDGET_DRAWABLE (color_area))
|
||||
return FALSE;
|
||||
|
||||
width = color_area->allocation.width;
|
||||
height = color_area->allocation.height;
|
||||
|
||||
rect_w = (width * 2) / 3;
|
||||
rect_h = (height * 2) / 3;
|
||||
|
||||
/* draw the background area */
|
||||
gimp_context_get_background (context, &color);
|
||||
color_area_draw_rect (color_area->window, color_area->style->fg_gc[0],
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h,
|
||||
&color);
|
||||
|
||||
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
||||
active_color == FOREGROUND ? GTK_SHADOW_OUT : GTK_SHADOW_IN,
|
||||
NULL, color_area, NULL,
|
||||
(width - rect_w), (height - rect_h),
|
||||
rect_w, rect_h);
|
||||
|
||||
/* draw the foreground area */
|
||||
gimp_context_get_foreground (context, &color);
|
||||
color_area_draw_rect (color_area->window, color_area->style->fg_gc[0],
|
||||
0, 0, rect_w, rect_h,
|
||||
&color);
|
||||
|
||||
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
||||
active_color == BACKGROUND ? GTK_SHADOW_OUT : GTK_SHADOW_IN,
|
||||
NULL, color_area, NULL,
|
||||
0, 0,
|
||||
rect_w, rect_h);
|
||||
|
||||
/* draw the default colors pixbuf */
|
||||
pixbuf = gtk_widget_render_icon (color_area, GIMP_STOCK_DEFAULT_COLORS,
|
||||
GTK_ICON_SIZE_MENU, NULL);
|
||||
w = gdk_pixbuf_get_width (pixbuf);
|
||||
h = gdk_pixbuf_get_height (pixbuf);
|
||||
gdk_draw_pixbuf (color_area->window, NULL, pixbuf,
|
||||
0, 0, 0, height - h, w, h,
|
||||
GDK_RGB_DITHER_MAX, 0, 0);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
/* draw the swap colors pixbuf */
|
||||
pixbuf = gtk_widget_render_icon (color_area, GIMP_STOCK_SWAP_COLORS,
|
||||
GTK_ICON_SIZE_MENU, NULL);
|
||||
w = gdk_pixbuf_get_width (pixbuf);
|
||||
h = gdk_pixbuf_get_height (pixbuf);
|
||||
gdk_draw_pixbuf (color_area->window, NULL, pixbuf,
|
||||
0, 0, width - w, 0, w, h,
|
||||
GDK_RGB_DITHER_MAX, 0, 0);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b)
|
||||
color_area_draw_rect (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
static guchar *color_area_rgb_buf = NULL;
|
||||
static gint color_area_rgb_buf_size;
|
||||
static gint rowstride;
|
||||
|
||||
gint rowstride;
|
||||
guchar r, g, b;
|
||||
gint xx, yy;
|
||||
guchar *bp;
|
||||
#ifdef DISPLAY_FILTERS
|
||||
GList *list;
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
gimp_rgb_get_uchar (color, &r, &g, &b);
|
||||
|
||||
rowstride = 3 * ((width + 3) & -4);
|
||||
|
||||
|
@ -254,89 +309,9 @@ color_area_draw_rect (GdkDrawable *drawable,
|
|||
}
|
||||
|
||||
gdk_draw_rgb_image (drawable, gc, x, y, width, height,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
color_area_rgb_buf,
|
||||
rowstride);
|
||||
}
|
||||
|
||||
static void
|
||||
color_area_draw (GimpContext *context)
|
||||
{
|
||||
gint rect_w, rect_h;
|
||||
gint width, height;
|
||||
gint w, h;
|
||||
GimpRGB color;
|
||||
guchar r, g, b;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (!GTK_WIDGET_DRAWABLE (color_area))
|
||||
return;
|
||||
|
||||
width = color_area->allocation.width;
|
||||
height = color_area->allocation.height;
|
||||
|
||||
rect_w = (width * 2) / 3;
|
||||
rect_h = (height * 2) / 3;
|
||||
|
||||
/* draw the background area */
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_rgb_get_uchar (&color, &r, &g, &b);
|
||||
color_area_draw_rect (color_area->window, color_area->style->fg_gc[0],
|
||||
(width - rect_w), (height - rect_h), rect_w, rect_h,
|
||||
r, g, b);
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_OUT,
|
||||
NULL, color_area, NULL,
|
||||
(width - rect_w), (height - rect_h),
|
||||
rect_w, rect_h);
|
||||
else
|
||||
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_IN,
|
||||
NULL, color_area, NULL,
|
||||
(width - rect_w), (height - rect_h),
|
||||
rect_w, rect_h);
|
||||
|
||||
/* draw the foreground area */
|
||||
gimp_context_get_foreground (context, &color);
|
||||
gimp_rgb_get_uchar (&color, &r, &g, &b);
|
||||
color_area_draw_rect (color_area->window, color_area->style->fg_gc[0],
|
||||
0, 0, rect_w, rect_h,
|
||||
r, g, b);
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_IN,
|
||||
NULL, color_area, NULL,
|
||||
0, 0,
|
||||
rect_w, rect_h);
|
||||
else
|
||||
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_OUT,
|
||||
NULL, color_area, NULL,
|
||||
0, 0,
|
||||
rect_w, rect_h);
|
||||
|
||||
/* draw the default colors pixbuf */
|
||||
pixbuf = gtk_widget_render_icon (color_area, GIMP_STOCK_DEFAULT_COLORS,
|
||||
GTK_ICON_SIZE_MENU, NULL);
|
||||
w = gdk_pixbuf_get_width (pixbuf);
|
||||
h = gdk_pixbuf_get_height (pixbuf);
|
||||
gdk_draw_pixbuf (color_area->window, NULL, pixbuf,
|
||||
0, 0, 0, height - h, w, h,
|
||||
GDK_RGB_DITHER_MAX, 0, 0);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
/* draw the swap colors pixbuf */
|
||||
pixbuf = gtk_widget_render_icon (color_area, GIMP_STOCK_SWAP_COLORS,
|
||||
GTK_ICON_SIZE_MENU, NULL);
|
||||
w = gdk_pixbuf_get_width (pixbuf);
|
||||
h = gdk_pixbuf_get_height (pixbuf);
|
||||
gdk_draw_pixbuf (color_area->window, NULL, pixbuf,
|
||||
0, 0, width - w, 0, w, h,
|
||||
GDK_RGB_DITHER_MAX, 0, 0);
|
||||
g_object_unref (pixbuf);
|
||||
GDK_RGB_DITHER_MAX,
|
||||
color_area_rgb_buf,
|
||||
rowstride);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -345,9 +320,7 @@ color_area_select_callback (ColorNotebook *color_notebook,
|
|||
ColorNotebookState state,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (data);
|
||||
GimpContext *context = GIMP_CONTEXT (data);
|
||||
|
||||
if (color_notebook)
|
||||
{
|
||||
|
@ -357,17 +330,20 @@ color_area_select_callback (ColorNotebook *color_notebook,
|
|||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = FALSE;
|
||||
/* Fallthrough */
|
||||
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
if (edit_color == FOREGROUND)
|
||||
gimp_context_set_foreground (context, color);
|
||||
else
|
||||
gimp_context_set_background (context, color);
|
||||
break;
|
||||
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = FALSE;
|
||||
gimp_context_set_foreground (context, &revert_fg);
|
||||
gimp_context_set_background (context, &revert_bg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,19 +391,9 @@ color_area_edit (GimpContext *context)
|
|||
color_notebook_set_title (color_notebook, title);
|
||||
color_notebook_set_color (color_notebook, &color);
|
||||
|
||||
if (! color_notebook_active)
|
||||
{
|
||||
color_notebook_show (color_notebook);
|
||||
color_notebook_active = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
color_notebook_show (color_notebook);
|
||||
}
|
||||
color_notebook_show (color_notebook);
|
||||
color_notebook_active = TRUE;
|
||||
}
|
||||
|
||||
#undef FG_TITLE
|
||||
#undef BG_TITLE
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -445,10 +411,6 @@ color_area_events (GtkWidget *widget,
|
|||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
color_area_draw (context);
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
|
@ -464,19 +426,22 @@ color_area_events (GtkWidget *widget,
|
|||
if (target != active_color)
|
||||
{
|
||||
active_color = target;
|
||||
color_area_draw (context);
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
press_target = target;
|
||||
}
|
||||
break;
|
||||
|
||||
case SWAP_AREA:
|
||||
gimp_context_swap_colors (context);
|
||||
break;
|
||||
|
||||
case DEFAULT_AREA:
|
||||
gimp_context_set_default_colors (context);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -498,6 +463,7 @@ color_area_events (GtkWidget *widget,
|
|||
case BACK_AREA:
|
||||
color_area_edit (context);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -522,9 +488,7 @@ color_area_drag_color (GtkWidget *widget,
|
|||
GimpRGB *color,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
|
||||
context = GIMP_CONTEXT (data);
|
||||
GimpContext *context = GIMP_CONTEXT (data);
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gimp_context_get_foreground (context, color);
|
||||
|
@ -537,12 +501,9 @@ color_area_drop_color (GtkWidget *widget,
|
|||
const GimpRGB *color,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpContext *context = GIMP_CONTEXT (data);
|
||||
|
||||
context = GIMP_CONTEXT (data);
|
||||
|
||||
if (color_notebook_active &&
|
||||
active_color == edit_color)
|
||||
if (color_notebook_active && active_color == edit_color)
|
||||
{
|
||||
color_notebook_set_color (color_notebook, color);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,6 @@
|
|||
#define __GIMP_TOOLBOX_COLOR_AREA_H__
|
||||
|
||||
|
||||
#ifdef DISPLAY_FILTERS
|
||||
extern GimpDisplay *color_area_gdisp; /* hack for color displays */
|
||||
#endif /* DISPLAY_FILTERS */
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
GtkWidget * gimp_toolbox_color_area_create (GimpToolbox *toolbox,
|
||||
gint width,
|
||||
gint height);
|
||||
|
|
Loading…
Reference in New Issue