Commit 94384767 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

rewritten as proper widget derived from GimpColorButton

2001-01-15  Sven Neumann  <sven@gimp.org>

	* app/color_panel.[ch]: rewritten as proper widget derived from
	GimpColorButton

	* app/channels_dialog.c
	* app/color_picker.c
	* app/qmask.c: use new GimpColorPanel widget

	* libgimp/gimpcolorarea.[ch]
	* libgimp/gimpcolorbutton.[ch]: some changes needed to derive from
	GimpColorButton

	* plug-ins/Lighting/lighting_ui.c
	* plug-ins/MapObject/mapobject_ui.c
	* plug-ins/common/colorify.c
	* plug-ins/common/colortoalpha.c
	* plug-ins/common/exchange.c
	* plug-ins/common/film.c
	* plug-ins/common/grid.c
	* plug-ins/common/mapcolor.c
	* plug-ins/common/nova.c
	* plug-ins/common/papertile.c
	* plug-ins/common/sinus.c
	* plug-ins/gdyntext/gdyntext_ui.c
	* plug-ins/ifscompose/ifscompose.c
	* plug-ins/script-fu/script-fu-scripts.c: follow API changes of
	GimpColorButton and GimpColorArea
parent d8228390
2001-01-15 Sven Neumann <sven@gimp.org>
* app/color_panel.[ch]: rewritten as proper widget derived from
GimpColorButton
* app/channels_dialog.c
* app/color_picker.c
* app/qmask.c: use new GimpColorPanel widget
* libgimp/gimpcolorarea.[ch]
* libgimp/gimpcolorbutton.[ch]: some changes needed to derive from
GimpColorButton
* plug-ins/Lighting/lighting_ui.c
* plug-ins/MapObject/mapobject_ui.c
* plug-ins/common/colorify.c
* plug-ins/common/colortoalpha.c
* plug-ins/common/exchange.c
* plug-ins/common/film.c
* plug-ins/common/grid.c
* plug-ins/common/mapcolor.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/sinus.c
* plug-ins/gdyntext/gdyntext_ui.c
* plug-ins/ifscompose/ifscompose.c
* plug-ins/script-fu/script-fu-scripts.c: follow API changes of
GimpColorButton and GimpColorArea
2001-01-15 Michael Natterer <mitch@gimp.org>
* app/channel.[ch]
......
......@@ -47,10 +47,9 @@ struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
ColorPanel *color_panel;
GtkWidget *color_panel;
GimpImage *gimage;
GimpRGB color;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
......@@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
/* Global variables */
/* Static variables */
/* Prototypes */
static void edit_qmask_channel_query (GDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void edit_qmask_channel_query (GDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
/* Actual code */
......@@ -74,11 +75,22 @@ static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB *color;
GimpRGB color;
color = (GimpRGB *) data;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
color->a = adjustment->value / 100.0;
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
......@@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
/* the new options structure */
options = g_new (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color = options->gimage->qmask_color;
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
......@@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
gtk_widget_show (label);
opacity_scale_data =
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
GTK_SIGNAL_FUNC (qmask_query_scale_update),
&options->color);
options->color_panel);
gtk_widget_show (opacity_scale);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
qmask_color_changed,
opacity_scale_data);
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel->color_panel_widget);
gtk_widget_show (options->color_panel);
gtk_widget_show (table);
gtk_widget_show (vbox);
......@@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
{
EditQmaskOptions *options;
Channel *channel;
GimpRGB color;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
options->color_panel->color.a = options->color.a;
if (options->gimage && channel)
{
if (gimp_rgba_distance (&channel->color,
&options->color_panel->color) > 0.0001)
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
channel_set_color (channel, &options->color_panel->color);
channel->color = color;
channel_update (channel);
}
}
/* update the qmask color no matter what */
options->gimage->qmask_color = options->color_panel->color;
options->gimage->qmask_color = color;
gtk_widget_destroy (options->query_box);
g_free (options);
......
......@@ -47,10 +47,9 @@ struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
ColorPanel *color_panel;
GtkWidget *color_panel;
GimpImage *gimage;
GimpRGB color;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
......@@ -58,15 +57,17 @@ typedef struct _EditQmaskOptions EditQmaskOptions;
/* Global variables */
/* Static variables */
/* Prototypes */
static void edit_qmask_channel_query (GDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
static void edit_qmask_channel_query (GDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
static void edit_qmask_query_cancel_callback (GtkWidget *widget,
gpointer client_data);
static void qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data);
static void qmask_color_changed (GimpColorButton *button,
gpointer data);
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
/* Actual code */
......@@ -74,11 +75,22 @@ static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB *color;
GimpRGB color;
color = (GimpRGB *) data;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
color->a = adjustment->value / 100.0;
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
......@@ -260,9 +272,10 @@ edit_qmask_channel_query (GDisplay * gdisp)
/* the new options structure */
options = g_new (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color = options->gimage->qmask_color;
options->color_panel = color_panel_new (&options->color, FALSE, 48, 64);
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
......@@ -301,19 +314,23 @@ edit_qmask_channel_query (GDisplay * gdisp)
gtk_widget_show (label);
opacity_scale_data =
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
gtk_adjustment_new (options->gimage->qmask_color.a * 100.0,
0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
GTK_SIGNAL_FUNC (qmask_query_scale_update),
&options->color);
options->color_panel);
gtk_widget_show (opacity_scale);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
qmask_color_changed,
opacity_scale_data);
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel->color_panel_widget);
gtk_widget_show (options->color_panel);
gtk_widget_show (table);
gtk_widget_show (vbox);
......@@ -327,24 +344,25 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
{
EditQmaskOptions *options;
Channel *channel;
GimpRGB color;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
options->color_panel->color.a = options->color.a;
if (options->gimage && channel)
{
if (gimp_rgba_distance (&channel->color,
&options->color_panel->color) > 0.0001)
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
channel_set_color (channel, &options->color_panel->color);
channel->color = color;
channel_update (channel);
}
}
/* update the qmask color no matter what */
options->gimage->qmask_color = options->color_panel->color;
options->gimage->qmask_color = color;
gtk_widget_destroy (options->query_box);
g_free (options);
......
......@@ -202,8 +202,10 @@ static void channel_widget_exclusive_visible (ChannelWidget *cw);
static void channel_widget_channel_flush (GtkWidget *widget,
gpointer data);
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
gpointer data);
static void channels_dialog_opacity_update (GtkAdjustment *adjustment,
gpointer data);
static void channels_dialog_color_changed (GimpColorButton *button,
gpointer data);
/* assorted query dialogs */
static void channels_dialog_new_channel_query (GimpImage *gimage);
......@@ -2463,11 +2465,22 @@ static void
channels_dialog_opacity_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB *color;
GimpRGB color;
color = (GimpRGB *) data;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
channels_dialog_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
color->a = adjustment->value / 100.0;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
/**********************************/
......@@ -2480,10 +2493,9 @@ struct _NewChannelOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
ColorPanel *color_panel;
GtkWidget *color_panel;
GimpImage *gimage;
GimpRGB color;
};
static gchar *channel_name = NULL;
......@@ -2506,16 +2518,14 @@ new_channel_query_ok_callback (GtkWidget *widget,
if ((gimage = options->gimage))
{
options->color_panel->color.a = options->color.a;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&channel_color);
new_channel = channel_new (gimage, gimage->width, gimage->height,
channel_name,
&options->color_panel->color);
&channel_color);
drawable_fill (GIMP_DRAWABLE (new_channel), TRANSPARENT_FILL);
channel_color = options->color_panel->color;
gimp_image_add_channel (gimage, new_channel, -1);
gdisplays_flush ();
}
......@@ -2537,11 +2547,10 @@ channels_dialog_new_channel_query (GimpImage* gimage)
/* the new options structure */
options = g_new (NewChannelOptions, 1);
options->gimage = gimage;
options->color = channel_color;
options->color_panel = color_panel_new (&channel_color,
FALSE,
48, 64);
options->color_panel = gimp_color_panel_new (&channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
gimp_dialog_new (_("New Channel Options"), "new_channel_options",
......@@ -2599,20 +2608,23 @@ channels_dialog_new_channel_query (GimpImage* gimage)
gtk_widget_show (label);
opacity_scale_data =
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
gtk_adjustment_new (channel_color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (opacity_scale), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
&options->color);
options->color_panel);
gtk_widget_show (opacity_scale);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
channels_dialog_color_changed,
opacity_scale_data);
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel->color_panel_widget);
gtk_widget_show (options->color_panel);
gtk_widget_show (table);
gtk_widget_show (vbox);
......@@ -2630,11 +2642,10 @@ struct _EditChannelOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
ColorPanel *color_panel;
GtkWidget *color_panel;
ChannelWidget *channel_widget;
GimpImage *gimage;
GimpRGB color;
};
static void
......@@ -2643,6 +2654,7 @@ edit_channel_query_ok_callback (GtkWidget *widget,
{
EditChannelOptions *options;
Channel *channel;
GimpRGB color;
options = (EditChannelOptions *) data;
channel = options->channel_widget->channel;
......@@ -2655,13 +2667,12 @@ edit_channel_query_ok_callback (GtkWidget *widget,
gtk_label_set_text (GTK_LABEL (options->channel_widget->label),
gimp_object_get_name (GIMP_OBJECT (channel)));
options->color_panel->color.a = options->color.a;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
&color);
if (gimp_rgba_distance (&options->color_panel->color,
&channel->color) > 0.0001)
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
{
channel->color = options->color_panel->color;
channel->color = color;
drawable_update (GIMP_DRAWABLE (channel), 0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
......@@ -2687,13 +2698,12 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
options = g_new (EditChannelOptions, 1);
options->channel_widget = channel_widget;
options->gimage = channel_widget->gimage;
options->color = channel_widget->channel->color;
channel_color = options->color;
channel_color = channel_widget->channel->color;
options->color_panel = color_panel_new (&channel_color,
FALSE,
48, 64);
options->color_panel = gimp_color_panel_new (&channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
/* The dialog */
options->query_box =
......@@ -2753,19 +2763,22 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
gtk_widget_show (label);
opacity_scale_data =
gtk_adjustment_new (options->color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
gtk_adjustment_new (channel_color.a * 100.0, 0.0, 100.0, 1.0, 1.0, 0.0);
opacity_scale = gtk_hscale_new (GTK_ADJUSTMENT (opacity_scale_data));
gtk_table_attach_defaults (GTK_TABLE (table), opacity_scale, 1, 2, 1, 2);
gtk_scale_set_value_pos (GTK_SCALE (opacity_scale), GTK_POS_TOP);
gtk_signal_connect (GTK_OBJECT (opacity_scale_data), "value_changed",
GTK_SIGNAL_FUNC (channels_dialog_opacity_update),
&options->color);
options->color_panel);
gtk_widget_show (opacity_scale);
/* The color panel */
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel->color_panel_widget,
gtk_signal_connect (GTK_OBJECT (options->color_panel), "color_changed",
channels_dialog_color_changed,
opacity_scale_data);
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
TRUE, TRUE, 0);
gtk_widget_show (options->color_panel->color_panel_widget);
gtk_widget_show (options->color_panel);
gtk_widget_show (table);
gtk_widget_show (vbox);
......
......@@ -25,305 +25,188 @@
#include "appenv.h"
#include "color_panel.h"
#include "color_notebook.h"
#include "colormaps.h"
#include "gimpdnd.h"
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | \
GDK_LEAVE_NOTIFY_MASK
typedef struct _ColorPanelPrivate ColorPanelPrivate;
struct _ColorPanelPrivate
struct _GimpColorPanel
{
GtkWidget *drawing_area;
GdkGC *gc;
GimpColorButton parent;
gboolean show_alpha;
gboolean button_down;
ColorNotebook *color_notebook;
gboolean color_notebook_active;
ColorNotebook *color_notebook;
gboolean color_notebook_active;
};
/* local function prototypes */
static void color_panel_free (ColorPanel *color_panel);
static void color_panel_draw (ColorPanel *color_panel);
static gint color_panel_events (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void color_panel_select_callback (GimpRGB *color,
ColorNotebookState state,
gpointer data);
static void color_panel_drag_color (GtkWidget *widget,
GimpRGB *color,
gpointer data);
static void color_panel_drop_color (GtkWidget *widget,
GimpRGB *color,
gpointer data);
/* dnd stuff */
static GtkTargetEntry color_panel_target_table[] =
{
GIMP_TARGET_COLOR
};
static guint n_color_panel_targets = (sizeof (color_panel_target_table) /
sizeof (color_panel_target_table[0]));
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
static void gimp_color_panel_init (GimpColorPanel *panel);
static void gimp_color_panel_destroy (GtkObject *object);
static void gimp_color_panel_color_changed (GimpColorButton *button);
static void gimp_color_panel_clicked (GtkButton *button);
/* public functions */
static void gimp_color_panel_select_callback (GimpRGB *color,
ColorNotebookState state,
gpointer data);
ColorPanel *
color_panel_new (GimpRGB *color,
gboolean show_alpha,
gint width,
gint height)
{
ColorPanel *color_panel;
ColorPanelPrivate *private;
g_return_val_if_fail (color != NULL, NULL);
static GimpColorButtonClass *parent_class = NULL;
private = g_new0 (ColorPanelPrivate, 1);
private->color_notebook = NULL;
private->color_notebook_active = FALSE;
private->gc = NULL;
private->show_alpha = show_alpha;
private->button_down = FALSE;
color_panel = g_new (ColorPanel, 1);
color_panel->private_part = private;
color_panel->color = *color;
color_panel->color_panel_widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (color_panel->color_panel_widget),
GTK_SHADOW_IN);
/* drawing area */
private->drawing_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (private->drawing_area),
width, height);
gtk_widget_set_events (private->drawing_area, EVENT_MASK);
gtk_signal_connect (GTK_OBJECT (private->drawing_area), "event",
GTK_SIGNAL_FUNC (color_panel_events),
color_panel);
gtk_container_add (GTK_CONTAINER (color_panel->color_panel_widget),
private->drawing_area);
gtk_widget_show (private->drawing_area);
/* dnd stuff */
gtk_drag_source_set (private->drawing_area,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (private->drawing_area,
color_panel_drag_color, color_panel);
gtk_drag_dest_set (private->drawing_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_panel_target_table, n_color_panel_targets,
GDK_ACTION_COPY);
gimp_dnd_color_dest_set (private->drawing_area,
color_panel_drop_color, color_panel);
gtk_signal_connect_object (GTK_OBJECT (color_panel->color_panel_widget),
"destroy",
GTK_SIGNAL_FUNC (color_panel_free),
(GtkObject *) color_panel);
return color_panel;
}
void
color_panel_set_color (ColorPanel *color_panel,
GimpRGB *color)
GtkType
gimp_color_panel_get_type (void)
{
ColorPanelPrivate *private = color_panel->private_part;
g_return_if_fail (color_panel != NULL);
g_return_if_fail (color != NULL);
color_panel->color = *color;
static guint panel_type = 0;
if (private->color_notebook_active)
color_notebook_set_color (private->color_notebook, color);
if (!panel_type)
{
GtkTypeInfo panel_info =
{
"GimpColorPanel",
sizeof (GimpColorPanel),
sizeof (GimpColorPanelClass),
(GtkClassInitFunc) gimp_color_panel_class_init,
(GtkObjectInitFunc) gimp_color_panel_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
panel_type = gtk_type_unique (GIMP_TYPE_COLOR_BUTTON, &panel_info);
}
return panel_type;
}
if (private->gc)
color_panel_draw (color_panel);
static void
gimp_color_panel_class_init (GimpColorPanelClass *klass)
{
GtkObjectClass *object_class;
GtkButtonClass *button_class;
GimpColorButtonClass *color_button_class;
object_class = (GtkObjectClass *) klass;
button_class = (GtkButtonClass *) klass;
color_button_class = (GimpColorButtonClass *) klass;
parent_class = gtk_type_class (gimp_color_button_get_type ());
object_class->destroy = gimp_color_panel_destroy;
color_button_class->color_changed = gimp_color_panel_color_changed;
button_class->clicked = gimp_color_panel_clicked;
}
/* private functions */
static void
gimp_color_panel_init (GimpColorPanel *panel)
{
panel->color_notebook = NULL;
panel->color_notebook_active = FALSE;
}
static void
color_panel_free (ColorPanel *color_panel)
gimp_color_panel_destroy (GtkObject *object)
{
ColorPanelPrivate *private;
GimpColorPanel *panel;
private = (ColorPanelPrivate *) color_panel->private_part;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_COLOR_PANEL (object));
panel = GIMP_COLOR_PANEL (object);
/* make sure we hide and free color_notebook */
if (private->color_notebook)
if (panel->color_notebook)
{
color_notebook_hide (private->color_notebook);
color_notebook_free (private->color_notebook);
color_notebook_hide (panel->color_notebook);
color_notebook_free (panel->color_notebook);
}
if (private->gc)
gdk_gc_destroy (private->gc);