added a "title" parameter to the constructor. Pass a pointer to the

2001-01-21  Michael Natterer  <mitch@gimp.org>

	* app/color_notebook.[ch]: added a "title" parameter to the
	constructor. Pass a pointer to the ColorNotebook to the callback.
	Added a _get_color() function.

	* app/color_panel.[ch]: added a "title" parameter which is used
	for the notebook.

	* app/channels_dialog.c
	* app/color_area.c
	* app/colormap_dialog.c
	* app/convert.c
	* app/palette_select.c
	* app/qmask.c: changed the calls to color_notebook_new(),
	color_panel_new() and the ColorNotebook callbacks.

	* app/gradient.c: use a ColorNotebook instead of GtkColorSelection.

	* app/palette.c
	* app/palette_entries.h: use GimpRGB to store the color in the
	PaletteEntry.

	* po/POTFILES.in: added app/color_area.c
This commit is contained in:
Michael Natterer 2001-01-21 13:41:07 +00:00 committed by Michael Natterer
parent c31d2639e3
commit f96d3776fe
42 changed files with 1203 additions and 1496 deletions

View File

@ -1,3 +1,28 @@
2001-01-21 Michael Natterer <mitch@gimp.org>
* app/color_notebook.[ch]: added a "title" parameter to the
constructor. Pass a pointer to the ColorNotebook to the callback.
Added a _get_color() function.
* app/color_panel.[ch]: added a "title" parameter which is used
for the notebook.
* app/channels_dialog.c
* app/color_area.c
* app/colormap_dialog.c
* app/convert.c
* app/palette_select.c
* app/qmask.c: changed the calls to color_notebook_new(),
color_panel_new() and the ColorNotebook callbacks.
* app/gradient.c: use a ColorNotebook instead of GtkColorSelection.
* app/palette.c
* app/palette_entries.h: use GimpRGB to store the color in the
PaletteEntry.
* po/POTFILES.in: added app/color_area.c
2001-01-20 Michael Natterer <mitch@gimp.org>
* app/gradient.[ch]: made gradient_get_color_at() use GimpRGB.

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -2547,7 +2547,8 @@ channels_dialog_new_channel_query (GimpImage* gimage)
/* the new options structure */
options = g_new (NewChannelOptions, 1);
options->gimage = gimage;
options->color_panel = gimp_color_panel_new (&channel_color,
options->color_panel = gimp_color_panel_new (_("New Channel Color"),
&channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
@ -2701,7 +2702,8 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
channel_color = channel_widget->channel->color;
options->color_panel = gimp_color_panel_new (&channel_color,
options->color_panel = gimp_color_panel_new (_("Edit Channel Color"),
&channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -39,6 +39,9 @@
#include "gdisplay_color.h"
#endif /* DISPLAY_FILTERS */
#include "libgimp/gimpintl.h"
typedef enum
{
FORE_AREA,
@ -273,7 +276,8 @@ color_area_draw (void)
}
static void
color_area_select_callback (const GimpRGB *color,
color_area_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer client_data)
{
@ -323,7 +327,8 @@ color_area_edit (void)
if (! color_notebook)
{
color_notebook = color_notebook_new ((const GimpRGB *) &color,
color_notebook = color_notebook_new (_("Color Selection"),
(const GimpRGB *) &color,
color_area_select_callback,
NULL, TRUE, FALSE);
color_notebook_active = TRUE;

View File

@ -56,6 +56,39 @@ typedef enum
} ColorNotebookUpdateType;
/* "class" information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
/* "instance" information we keep on each notebook tab */
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
struct _ColorNotebook
{
GtkWidget *shell;
@ -87,33 +120,6 @@ struct _ColorNotebook
};
/* information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
static void color_notebook_ok_callback (GtkWidget *widget,
gpointer data);
static void color_notebook_cancel_callback (GtkWidget *widget,
@ -172,7 +178,8 @@ static gboolean color_history_initialized = FALSE;
ColorNotebook *
color_notebook_new (const GimpRGB *color,
color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
@ -243,7 +250,7 @@ color_notebook_new (const GimpRGB *color,
color_notebook_update_hsv_values (cnp);
cnp->shell =
gimp_dialog_new (_("Color Selection"), "color_selection",
gimp_dialog_new (title, "color_selection",
color_notebook_help_func, (const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
@ -607,6 +614,16 @@ color_notebook_set_color (ColorNotebook *cnp,
UPDATE_NEW_COLOR);
}
void
color_notebook_get_color (ColorNotebook *cnp,
GimpRGB *color)
{
g_return_if_fail (cnp != NULL);
g_return_if_fail (color != NULL);
*color = cnp->rgb;
}
static void
color_notebook_set_white (ColorNotebook *cnp)
{
@ -694,7 +711,8 @@ color_notebook_ok_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_OK,
cnp->client_data);
}
@ -710,7 +728,8 @@ color_notebook_cancel_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->orig_rgb,
(* cnp->callback) (cnp,
&cnp->orig_rgb,
COLOR_NOTEBOOK_CANCEL,
cnp->client_data);
}
@ -909,7 +928,8 @@ color_notebook_update_caller (ColorNotebook *cnp)
{
if (cnp && cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_UPDATE,
cnp->client_data);
}

View File

@ -27,14 +27,15 @@ typedef enum
COLOR_NOTEBOOK_UPDATE
} ColorNotebookState;
typedef void (* ColorNotebookCallback) (const GimpRGB *color,
typedef void (* ColorNotebookCallback) (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
typedef struct _ColorSelectorInstance ColorSelectorInstance;
ColorNotebook * color_notebook_new (const GimpRGB *color,
ColorNotebook * color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer data,
gboolean wants_update,
@ -46,8 +47,12 @@ void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
void color_notebook_get_color (ColorNotebook *cnb,
GimpRGB *color);
/* color history functions */
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);

View File

@ -44,7 +44,8 @@ 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);
static void gimp_color_panel_select_callback (const GimpRGB *color,
static void gimp_color_panel_select_callback (ColorNotebook *notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
@ -88,7 +89,7 @@ gimp_color_panel_class_init (GimpColorPanelClass *klass)
button_class = (GtkButtonClass *) klass;
color_button_class = (GimpColorButtonClass *) klass;
parent_class = gtk_type_class (gimp_color_button_get_type ());
parent_class = gtk_type_class (GIMP_TYPE_COLOR_BUTTON);
object_class->destroy = gimp_color_panel_destroy;
button_class->clicked = gimp_color_panel_clicked;
@ -124,7 +125,8 @@ gimp_color_panel_destroy (GtkObject *object)
}
GtkWidget *
gimp_color_panel_new (const GimpRGB *color,
gimp_color_panel_new (const gchar *title,
const GimpRGB *color,
GimpColorAreaType type,
gint width,
gint height)
@ -133,12 +135,14 @@ gimp_color_panel_new (const GimpRGB *color,
g_return_val_if_fail (color != NULL, NULL);
panel = gtk_type_new (gimp_color_panel_get_type ());
panel = gtk_type_new (GIMP_TYPE_COLOR_PANEL);
GIMP_COLOR_BUTTON (panel)->title = g_strdup (title);
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
return GTK_WIDGET (panel);
}
@ -170,7 +174,8 @@ gimp_color_panel_clicked (GtkButton *button)
if (! panel->color_notebook)
{
panel->color_notebook =
color_notebook_new ((const GimpRGB *) &color,
color_notebook_new (GIMP_COLOR_BUTTON (button)->title,
(const GimpRGB *) &color,
gimp_color_panel_select_callback,
panel,
FALSE,
@ -189,7 +194,8 @@ gimp_color_panel_clicked (GtkButton *button)
}
static void
gimp_color_panel_select_callback (const GimpRGB *color,
gimp_color_panel_select_callback (ColorNotebook *notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{

View File

@ -38,7 +38,8 @@ struct _GimpColorPanelClass
};
GtkType gimp_color_panel_get_type (void);
GtkWidget * gimp_color_panel_new (const GimpRGB *color,
GtkWidget * gimp_color_panel_new (const gchar *title,
const GimpRGB *color,
GimpColorAreaType type,
gint width,
gint height);

View File

@ -87,7 +87,8 @@ static void ipal_edit_callback (GtkWidget *widget,
gpointer data);
static void ipal_close_callback (GtkWidget *widget,
gpointer data);
static void ipal_select_callback (const GimpRGB *color,
static void ipal_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
@ -931,7 +932,8 @@ ipal_edit_callback (GtkWidget *widget,
if (! ipal->color_notebook)
{
ipal->color_notebook
= color_notebook_new ((const GimpRGB *) &color,
= color_notebook_new (_("Edit Indexed Color"),
(const GimpRGB *) &color,
ipal_select_callback, ipal, FALSE, FALSE);
}
else
@ -953,7 +955,8 @@ ipal_close_callback (GtkWidget *widget,
}
static void
ipal_select_callback (const GimpRGB *color,
ipal_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{

View File

@ -2960,9 +2960,10 @@ webpal_pass1 (QuantizeObj *quantobj)
static void
custompal_pass1 (QuantizeObj *quantobj)
{
int i;
GSList *list;
gint i;
GSList *list;
PaletteEntry *entry;
guchar r, g, b;
/* fprintf(stderr, "custompal_pass1: using (theCustomPalette %s) from (file %s)\n",
theCustomPalette->name, theCustomPalette->filename); */
@ -2972,9 +2973,12 @@ custompal_pass1 (QuantizeObj *quantobj)
i++,list=g_slist_next(list))
{
entry = (PaletteEntry *) list->data;
quantobj->cmap[i].red = entry->color[0];
quantobj->cmap[i].green = entry->color[1];
quantobj->cmap[i].blue = entry->color[2];
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
quantobj->cmap[i].red = (gint) r;
quantobj->cmap[i].green = (gint) g;
quantobj->cmap[i].blue = (gint) b;
}
quantobj -> actual_number_of_colors = i;
}

View File

@ -2960,9 +2960,10 @@ webpal_pass1 (QuantizeObj *quantobj)
static void
custompal_pass1 (QuantizeObj *quantobj)
{
int i;
GSList *list;
gint i;
GSList *list;
PaletteEntry *entry;
guchar r, g, b;
/* fprintf(stderr, "custompal_pass1: using (theCustomPalette %s) from (file %s)\n",
theCustomPalette->name, theCustomPalette->filename); */
@ -2972,9 +2973,12 @@ custompal_pass1 (QuantizeObj *quantobj)
i++,list=g_slist_next(list))
{
entry = (PaletteEntry *) list->data;
quantobj->cmap[i].red = entry->color[0];
quantobj->cmap[i].green = entry->color[1];
quantobj->cmap[i].blue = entry->color[2];
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
quantobj->cmap[i].red = (gint) r;
quantobj->cmap[i].green = (gint) g;
quantobj->cmap[i].blue = (gint) b;
}
quantobj -> actual_number_of_colors = i;
}

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -56,6 +56,39 @@ typedef enum
} ColorNotebookUpdateType;
/* "class" information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
/* "instance" information we keep on each notebook tab */
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
struct _ColorNotebook
{
GtkWidget *shell;
@ -87,33 +120,6 @@ struct _ColorNotebook
};
/* information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
static void color_notebook_ok_callback (GtkWidget *widget,
gpointer data);
static void color_notebook_cancel_callback (GtkWidget *widget,
@ -172,7 +178,8 @@ static gboolean color_history_initialized = FALSE;
ColorNotebook *
color_notebook_new (const GimpRGB *color,
color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
@ -243,7 +250,7 @@ color_notebook_new (const GimpRGB *color,
color_notebook_update_hsv_values (cnp);
cnp->shell =
gimp_dialog_new (_("Color Selection"), "color_selection",
gimp_dialog_new (title, "color_selection",
color_notebook_help_func, (const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
@ -607,6 +614,16 @@ color_notebook_set_color (ColorNotebook *cnp,
UPDATE_NEW_COLOR);
}
void
color_notebook_get_color (ColorNotebook *cnp,
GimpRGB *color)
{
g_return_if_fail (cnp != NULL);
g_return_if_fail (color != NULL);
*color = cnp->rgb;
}
static void
color_notebook_set_white (ColorNotebook *cnp)
{
@ -694,7 +711,8 @@ color_notebook_ok_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_OK,
cnp->client_data);
}
@ -710,7 +728,8 @@ color_notebook_cancel_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->orig_rgb,
(* cnp->callback) (cnp,
&cnp->orig_rgb,
COLOR_NOTEBOOK_CANCEL,
cnp->client_data);
}
@ -909,7 +928,8 @@ color_notebook_update_caller (ColorNotebook *cnp)
{
if (cnp && cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_UPDATE,
cnp->client_data);
}

View File

@ -27,14 +27,15 @@ typedef enum
COLOR_NOTEBOOK_UPDATE
} ColorNotebookState;
typedef void (* ColorNotebookCallback) (const GimpRGB *color,
typedef void (* ColorNotebookCallback) (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
typedef struct _ColorSelectorInstance ColorSelectorInstance;
ColorNotebook * color_notebook_new (const GimpRGB *color,
ColorNotebook * color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer data,
gboolean wants_update,
@ -46,8 +47,12 @@ void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
void color_notebook_get_color (ColorNotebook *cnb,
GimpRGB *color);
/* color history functions */
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -2960,9 +2960,10 @@ webpal_pass1 (QuantizeObj *quantobj)
static void
custompal_pass1 (QuantizeObj *quantobj)
{
int i;
GSList *list;
gint i;
GSList *list;
PaletteEntry *entry;
guchar r, g, b;
/* fprintf(stderr, "custompal_pass1: using (theCustomPalette %s) from (file %s)\n",
theCustomPalette->name, theCustomPalette->filename); */
@ -2972,9 +2973,12 @@ custompal_pass1 (QuantizeObj *quantobj)
i++,list=g_slist_next(list))
{
entry = (PaletteEntry *) list->data;
quantobj->cmap[i].red = entry->color[0];
quantobj->cmap[i].green = entry->color[1];
quantobj->cmap[i].blue = entry->color[2];
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
quantobj->cmap[i].red = (gint) r;
quantobj->cmap[i].green = (gint) g;
quantobj->cmap[i].blue = (gint) b;
}
quantobj -> actual_number_of_colors = i;
}

View File

@ -62,6 +62,7 @@
#include "apptypes.h"
#include "appenv.h"
#include "color_notebook.h"
#include "cursorutil.h"
#include "datafiles.h"
#include "errors.h"
@ -437,47 +438,25 @@ static void cpopup_load_right_callback (GtkWidget *widget,
static void cpopup_save_right_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static void cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static grad_segment_t * cpopup_save_selection (void);
static void cpopup_free_selection (grad_segment_t *seg);
static void cpopup_replace_selection (grad_segment_t *replace_seg);
/* ----- */
static void cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static void cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
/* ----- */
@ -4244,33 +4223,6 @@ cpopup_save_right_callback (GtkWidget *widget,
/*****/
static void
cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
col[0] = color->r;
col[1] = color->g;
col[2] = color->b;
col[3] = color->a;
gtk_color_selection_set_color (cs, col);
}
static void
cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
gtk_color_selection_get_color (cs, col);
gimp_rgba_set (color, col[0], col[1], col[2], col[3]);
}
/*****/
static grad_segment_t *
cpopup_save_selection (void)
{
@ -4355,58 +4307,6 @@ cpopup_replace_selection (grad_segment_t *replace_seg)
/***** Color dialogs for left and right endpoint *****/
static void
cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback)
{
GtkWidget *window;
GtkColorSelection *cs;
GtkColorSelectionDialog *csd;
window = gtk_color_selection_dialog_new (title);
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (window)->help_button);
gimp_help_connect_help_accel (window, gimp_standard_help_func,
"dialogs/gradient_editor/gradient_editor.html");
csd = GTK_COLOR_SELECTION_DIALOG (window);
cs = GTK_COLOR_SELECTION (csd->colorsel);
gtk_color_selection_set_opacity (cs, TRUE);
gtk_color_selection_set_update_policy (cs,
g_editor->instant_update ?
GTK_UPDATE_CONTINUOUS :
GTK_UPDATE_DELAYED);
/* FIXME: this is a hack; we set the color twice so that the
* color selector remembers it as its "old" color, too
*/
cpopup_set_color_selection_color (cs, color);
cpopup_set_color_selection_color (cs, color);
gtk_signal_connect (GTK_OBJECT (csd), "delete_event",
delete_callback, window);
gtk_signal_connect (GTK_OBJECT (cs), "color_changed",
color_changed_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->ok_button), "clicked",
ok_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
cancel_callback, window);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
gtk_widget_show (window);
}
/*****/
static void
cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data)
@ -4414,71 +4314,16 @@ cpopup_set_left_color_callback (GtkWidget *widget,
g_editor->left_saved_dirty = curr_gradient->dirty;
g_editor->left_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Left endpoint's color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
(GtkSignalFunc) cpopup_left_color_dialog_ok,
(GtkSignalFunc) cpopup_left_color_dialog_cancel,
(GtkSignalFunc) cpopup_left_color_dialog_delete);
color_notebook_new (_("Left Endpoint Color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_left_color_changed (GtkWidget *widget,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data)
{
cpopup_left_color_changed (widget, data);
curr_gradient->dirty = TRUE;
cpopup_free_selection(g_editor->left_saved_segments);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static void
cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->left_saved_dirty;
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_left_color_dialog_cancel (widget, data);
return TRUE;
}
/*****/
static void
cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data)
@ -4486,67 +4331,87 @@ cpopup_set_right_color_callback (GtkWidget *widget,
g_editor->right_saved_dirty = curr_gradient->dirty;
g_editor->right_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Right endpoint's color"),
&g_editor->control_sel_r->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
(GtkSignalFunc) cpopup_right_color_dialog_ok,
(GtkSignalFunc) cpopup_right_color_dialog_cancel,
(GtkSignalFunc) cpopup_right_color_dialog_delete);
color_notebook_new (_("Right Endpoint Color"),
&g_editor->control_sel_l->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_right_color_changed (GtkWidget *widget,
gpointer data)
cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
switch (state)
{
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
cpopup_free_selection (g_editor->left_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&g_editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
curr_gradient->dirty = g_editor->left_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data)
cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
cpopup_right_color_changed (widget, data);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
curr_gradient->dirty = TRUE;
cpopup_free_selection (g_editor->right_saved_segments);
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
cpopup_free_selection (g_editor->right_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->right_saved_segments);
curr_gradient->dirty = g_editor->right_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
static void
cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->right_saved_dirty;
cpopup_replace_selection (g_editor->right_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_right_color_dialog_cancel (widget, data);
return TRUE;
}
/***** Blending menu *****/

View File

@ -62,6 +62,7 @@
#include "apptypes.h"
#include "appenv.h"
#include "color_notebook.h"
#include "cursorutil.h"
#include "datafiles.h"
#include "errors.h"
@ -437,47 +438,25 @@ static void cpopup_load_right_callback (GtkWidget *widget,
static void cpopup_save_right_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static void cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static grad_segment_t * cpopup_save_selection (void);
static void cpopup_free_selection (grad_segment_t *seg);
static void cpopup_replace_selection (grad_segment_t *replace_seg);
/* ----- */
static void cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static void cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
/* ----- */
@ -4244,33 +4223,6 @@ cpopup_save_right_callback (GtkWidget *widget,
/*****/
static void
cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
col[0] = color->r;
col[1] = color->g;
col[2] = color->b;
col[3] = color->a;
gtk_color_selection_set_color (cs, col);
}
static void
cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
gtk_color_selection_get_color (cs, col);
gimp_rgba_set (color, col[0], col[1], col[2], col[3]);
}
/*****/
static grad_segment_t *
cpopup_save_selection (void)
{
@ -4355,58 +4307,6 @@ cpopup_replace_selection (grad_segment_t *replace_seg)
/***** Color dialogs for left and right endpoint *****/
static void
cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback)
{
GtkWidget *window;
GtkColorSelection *cs;
GtkColorSelectionDialog *csd;
window = gtk_color_selection_dialog_new (title);
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (window)->help_button);
gimp_help_connect_help_accel (window, gimp_standard_help_func,
"dialogs/gradient_editor/gradient_editor.html");
csd = GTK_COLOR_SELECTION_DIALOG (window);
cs = GTK_COLOR_SELECTION (csd->colorsel);
gtk_color_selection_set_opacity (cs, TRUE);
gtk_color_selection_set_update_policy (cs,
g_editor->instant_update ?
GTK_UPDATE_CONTINUOUS :
GTK_UPDATE_DELAYED);
/* FIXME: this is a hack; we set the color twice so that the
* color selector remembers it as its "old" color, too
*/
cpopup_set_color_selection_color (cs, color);
cpopup_set_color_selection_color (cs, color);
gtk_signal_connect (GTK_OBJECT (csd), "delete_event",
delete_callback, window);
gtk_signal_connect (GTK_OBJECT (cs), "color_changed",
color_changed_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->ok_button), "clicked",
ok_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
cancel_callback, window);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
gtk_widget_show (window);
}
/*****/
static void
cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data)
@ -4414,71 +4314,16 @@ cpopup_set_left_color_callback (GtkWidget *widget,
g_editor->left_saved_dirty = curr_gradient->dirty;
g_editor->left_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Left endpoint's color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
(GtkSignalFunc) cpopup_left_color_dialog_ok,
(GtkSignalFunc) cpopup_left_color_dialog_cancel,
(GtkSignalFunc) cpopup_left_color_dialog_delete);
color_notebook_new (_("Left Endpoint Color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_left_color_changed (GtkWidget *widget,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data)
{
cpopup_left_color_changed (widget, data);
curr_gradient->dirty = TRUE;
cpopup_free_selection(g_editor->left_saved_segments);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static void
cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->left_saved_dirty;
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_left_color_dialog_cancel (widget, data);
return TRUE;
}
/*****/
static void
cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data)
@ -4486,67 +4331,87 @@ cpopup_set_right_color_callback (GtkWidget *widget,
g_editor->right_saved_dirty = curr_gradient->dirty;
g_editor->right_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Right endpoint's color"),
&g_editor->control_sel_r->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
(GtkSignalFunc) cpopup_right_color_dialog_ok,
(GtkSignalFunc) cpopup_right_color_dialog_cancel,
(GtkSignalFunc) cpopup_right_color_dialog_delete);
color_notebook_new (_("Right Endpoint Color"),
&g_editor->control_sel_l->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_right_color_changed (GtkWidget *widget,
gpointer data)
cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
switch (state)
{
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
cpopup_free_selection (g_editor->left_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&g_editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
curr_gradient->dirty = g_editor->left_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data)
cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
cpopup_right_color_changed (widget, data);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
curr_gradient->dirty = TRUE;
cpopup_free_selection (g_editor->right_saved_segments);
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
cpopup_free_selection (g_editor->right_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->right_saved_segments);
curr_gradient->dirty = g_editor->right_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
static void
cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->right_saved_dirty;
cpopup_replace_selection (g_editor->right_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_right_color_dialog_cancel (widget, data);
return TRUE;
}
/***** Blending menu *****/

View File

@ -2547,7 +2547,8 @@ channels_dialog_new_channel_query (GimpImage* gimage)
/* the new options structure */
options = g_new (NewChannelOptions, 1);
options->gimage = gimage;
options->color_panel = gimp_color_panel_new (&channel_color,
options->color_panel = gimp_color_panel_new (_("New Channel Color"),
&channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);
@ -2701,7 +2702,8 @@ channels_dialog_edit_channel_query (ChannelWidget *channel_widget)
channel_color = channel_widget->channel->color;
options->color_panel = gimp_color_panel_new (&channel_color,
options->color_panel = gimp_color_panel_new (_("Edit Channel Color"),
&channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -39,6 +39,9 @@
#include "gdisplay_color.h"
#endif /* DISPLAY_FILTERS */
#include "libgimp/gimpintl.h"
typedef enum
{
FORE_AREA,
@ -273,7 +276,8 @@ color_area_draw (void)
}
static void
color_area_select_callback (const GimpRGB *color,
color_area_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer client_data)
{
@ -323,7 +327,8 @@ color_area_edit (void)
if (! color_notebook)
{
color_notebook = color_notebook_new ((const GimpRGB *) &color,
color_notebook = color_notebook_new (_("Color Selection"),
(const GimpRGB *) &color,
color_area_select_callback,
NULL, TRUE, FALSE);
color_notebook_active = TRUE;

View File

@ -56,6 +56,39 @@ typedef enum
} ColorNotebookUpdateType;
/* "class" information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
/* "instance" information we keep on each notebook tab */
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
struct _ColorNotebook
{
GtkWidget *shell;
@ -87,33 +120,6 @@ struct _ColorNotebook
};
/* information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
static void color_notebook_ok_callback (GtkWidget *widget,
gpointer data);
static void color_notebook_cancel_callback (GtkWidget *widget,
@ -172,7 +178,8 @@ static gboolean color_history_initialized = FALSE;
ColorNotebook *
color_notebook_new (const GimpRGB *color,
color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
@ -243,7 +250,7 @@ color_notebook_new (const GimpRGB *color,
color_notebook_update_hsv_values (cnp);
cnp->shell =
gimp_dialog_new (_("Color Selection"), "color_selection",
gimp_dialog_new (title, "color_selection",
color_notebook_help_func, (const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
@ -607,6 +614,16 @@ color_notebook_set_color (ColorNotebook *cnp,
UPDATE_NEW_COLOR);
}
void
color_notebook_get_color (ColorNotebook *cnp,
GimpRGB *color)
{
g_return_if_fail (cnp != NULL);
g_return_if_fail (color != NULL);
*color = cnp->rgb;
}
static void
color_notebook_set_white (ColorNotebook *cnp)
{
@ -694,7 +711,8 @@ color_notebook_ok_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_OK,
cnp->client_data);
}
@ -710,7 +728,8 @@ color_notebook_cancel_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->orig_rgb,
(* cnp->callback) (cnp,
&cnp->orig_rgb,
COLOR_NOTEBOOK_CANCEL,
cnp->client_data);
}
@ -909,7 +928,8 @@ color_notebook_update_caller (ColorNotebook *cnp)
{
if (cnp && cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_UPDATE,
cnp->client_data);
}

View File

@ -27,14 +27,15 @@ typedef enum
COLOR_NOTEBOOK_UPDATE
} ColorNotebookState;
typedef void (* ColorNotebookCallback) (const GimpRGB *color,
typedef void (* ColorNotebookCallback) (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
typedef struct _ColorSelectorInstance ColorSelectorInstance;
ColorNotebook * color_notebook_new (const GimpRGB *color,
ColorNotebook * color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer data,
gboolean wants_update,
@ -46,8 +47,12 @@ void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
void color_notebook_get_color (ColorNotebook *cnb,
GimpRGB *color);
/* color history functions */
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);

View File

@ -87,7 +87,8 @@ static void ipal_edit_callback (GtkWidget *widget,
gpointer data);
static void ipal_close_callback (GtkWidget *widget,
gpointer data);
static void ipal_select_callback (const GimpRGB *color,
static void ipal_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
@ -931,7 +932,8 @@ ipal_edit_callback (GtkWidget *widget,
if (! ipal->color_notebook)
{
ipal->color_notebook
= color_notebook_new ((const GimpRGB *) &color,
= color_notebook_new (_("Edit Indexed Color"),
(const GimpRGB *) &color,
ipal_select_callback, ipal, FALSE, FALSE);
}
else
@ -953,7 +955,8 @@ ipal_close_callback (GtkWidget *widget,
}
static void
ipal_select_callback (const GimpRGB *color,
ipal_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{

View File

@ -62,6 +62,7 @@
#include "apptypes.h"
#include "appenv.h"
#include "color_notebook.h"
#include "cursorutil.h"
#include "datafiles.h"
#include "errors.h"
@ -437,47 +438,25 @@ static void cpopup_load_right_callback (GtkWidget *widget,
static void cpopup_save_right_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static void cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static grad_segment_t * cpopup_save_selection (void);
static void cpopup_free_selection (grad_segment_t *seg);
static void cpopup_replace_selection (grad_segment_t *replace_seg);
/* ----- */
static void cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static void cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
/* ----- */
@ -4244,33 +4223,6 @@ cpopup_save_right_callback (GtkWidget *widget,
/*****/
static void
cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
col[0] = color->r;
col[1] = color->g;
col[2] = color->b;
col[3] = color->a;
gtk_color_selection_set_color (cs, col);
}
static void
cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
gtk_color_selection_get_color (cs, col);
gimp_rgba_set (color, col[0], col[1], col[2], col[3]);
}
/*****/
static grad_segment_t *
cpopup_save_selection (void)
{
@ -4355,58 +4307,6 @@ cpopup_replace_selection (grad_segment_t *replace_seg)
/***** Color dialogs for left and right endpoint *****/
static void
cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback)
{
GtkWidget *window;
GtkColorSelection *cs;
GtkColorSelectionDialog *csd;
window = gtk_color_selection_dialog_new (title);
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (window)->help_button);
gimp_help_connect_help_accel (window, gimp_standard_help_func,
"dialogs/gradient_editor/gradient_editor.html");
csd = GTK_COLOR_SELECTION_DIALOG (window);
cs = GTK_COLOR_SELECTION (csd->colorsel);
gtk_color_selection_set_opacity (cs, TRUE);
gtk_color_selection_set_update_policy (cs,
g_editor->instant_update ?
GTK_UPDATE_CONTINUOUS :
GTK_UPDATE_DELAYED);
/* FIXME: this is a hack; we set the color twice so that the
* color selector remembers it as its "old" color, too
*/
cpopup_set_color_selection_color (cs, color);
cpopup_set_color_selection_color (cs, color);
gtk_signal_connect (GTK_OBJECT (csd), "delete_event",
delete_callback, window);
gtk_signal_connect (GTK_OBJECT (cs), "color_changed",
color_changed_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->ok_button), "clicked",
ok_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
cancel_callback, window);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
gtk_widget_show (window);
}
/*****/
static void
cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data)
@ -4414,71 +4314,16 @@ cpopup_set_left_color_callback (GtkWidget *widget,
g_editor->left_saved_dirty = curr_gradient->dirty;
g_editor->left_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Left endpoint's color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
(GtkSignalFunc) cpopup_left_color_dialog_ok,
(GtkSignalFunc) cpopup_left_color_dialog_cancel,
(GtkSignalFunc) cpopup_left_color_dialog_delete);
color_notebook_new (_("Left Endpoint Color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_left_color_changed (GtkWidget *widget,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data)
{
cpopup_left_color_changed (widget, data);
curr_gradient->dirty = TRUE;
cpopup_free_selection(g_editor->left_saved_segments);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static void
cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->left_saved_dirty;
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_left_color_dialog_cancel (widget, data);
return TRUE;
}
/*****/
static void
cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data)
@ -4486,67 +4331,87 @@ cpopup_set_right_color_callback (GtkWidget *widget,
g_editor->right_saved_dirty = curr_gradient->dirty;
g_editor->right_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Right endpoint's color"),
&g_editor->control_sel_r->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
(GtkSignalFunc) cpopup_right_color_dialog_ok,
(GtkSignalFunc) cpopup_right_color_dialog_cancel,
(GtkSignalFunc) cpopup_right_color_dialog_delete);
color_notebook_new (_("Right Endpoint Color"),
&g_editor->control_sel_l->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_right_color_changed (GtkWidget *widget,
gpointer data)
cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
switch (state)
{
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
cpopup_free_selection (g_editor->left_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&g_editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
curr_gradient->dirty = g_editor->left_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data)
cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
cpopup_right_color_changed (widget, data);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
curr_gradient->dirty = TRUE;
cpopup_free_selection (g_editor->right_saved_segments);
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
cpopup_free_selection (g_editor->right_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->right_saved_segments);
curr_gradient->dirty = g_editor->right_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
static void
cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->right_saved_dirty;
cpopup_replace_selection (g_editor->right_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_right_color_dialog_cancel (widget, data);
return TRUE;
}
/***** Blending menu *****/

View File

@ -284,8 +284,8 @@ static PaletteEntries *
palette_entries_new (gchar *palette_name)
{
PaletteEntries *entries = NULL;
GList *pal_path;
gchar *pal_dir;
GList *pal_path;
gchar *pal_dir;
if (!palette_name || !palette_path)
return NULL;
@ -323,7 +323,7 @@ static void
palette_entries_free (PaletteEntries *entries)
{
PaletteEntry *entry;
GSList *list;
GSList *list;
for (list = entries->colors; list; list = g_slist_next (list))
{
@ -348,10 +348,8 @@ palette_entries_free (PaletteEntries *entries)
static PaletteEntry *
palette_entries_add_entry (PaletteEntries *entries,
gchar *name,
gint r,
gint g,
gint b)
const gchar *name,
GimpRGB *color)
{
PaletteEntry *entry;
@ -359,9 +357,8 @@ palette_entries_add_entry (PaletteEntries *entries,
{
entry = g_new (PaletteEntry, 1);
entry->color[0] = r;
entry->color[1] = g;
entry->color[2] = b;
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
entry->position = entries->n_colors;
@ -379,11 +376,12 @@ static void
palette_entries_load (const gchar *filename)
{
PaletteEntries *entries;
gchar str[512];
gchar *tok;
FILE *fp;
gint r, g, b;
gint linenum;
gchar str[512];
gchar *tok;
FILE *fp;
gint r, g, b;
GimpRGB color;
gint linenum;
r = g = b = 0;
@ -472,7 +470,13 @@ palette_entries_load (const gchar *filename)
g_message (_("Loading palette %s (line %d):\n"
"RGB value out of range"), filename, linenum);
palette_entries_add_entry (entries, tok, r, g, b);
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
palette_entries_add_entry (entries, tok, &color);
}
}
@ -511,6 +515,7 @@ palette_entries_save (PaletteEntries *palette,
PaletteEntry *entry;
GSList *list;
FILE *fp;
guchar r, g, b;
if (! filename)
return;
@ -529,8 +534,11 @@ palette_entries_save (PaletteEntries *palette,
{
entry = (PaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
fprintf (fp, "%d %d %d\t%s\n",
entry->color[0], entry->color[1], entry->color[2], entry->name);
r, g, b,
entry->name);
}
/* Clean up */
@ -579,15 +587,20 @@ palette_entries_update_small_preview (PaletteEntries *entries,
for (list = entries->colors; list; list = g_slist_next (list))
{
guchar cell[3*3*3];
gint loop;
gint loop;
entry = list->data;
for (loop = 0; loop < 27 ; loop+=3)
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0+loop] = entry->color[0];
cell[1+loop] = entry->color[1];
cell[2+loop] = entry->color[2];
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (entries->pixmap,
@ -864,7 +877,7 @@ palette_draw_all (PaletteEntries *entries,
PaletteEntry *color)
{
PaletteDialog *palette;
GdkGC *gc = NULL;
GdkGC *gc = NULL;
if (top_level_palette)
gc = top_level_palette->gc;
@ -935,6 +948,12 @@ palette_set_active_color (gint r,
{
GimpRGB color;
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (top_level_edit_palette && top_level_edit_palette->entries)
{
switch (state)
@ -942,14 +961,15 @@ palette_set_active_color (gint r,
case COLOR_NEW:
top_level_edit_palette->color =
palette_entries_add_entry (top_level_edit_palette->entries,
_("Untitled"), r, g, b);
NULL,
&color);
palette_update_all (top_level_edit_palette->entries);
break;
case COLOR_UPDATE_NEW:
top_level_edit_palette->color->color[0] = r;
top_level_edit_palette->color->color[1] = g;
top_level_edit_palette->color->color[2] = b;
top_level_edit_palette->color->color = color;
palette_draw_all (top_level_edit_palette->entries,
top_level_edit_palette->color);
break;
@ -959,12 +979,6 @@ palette_set_active_color (gint r,
}
}
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
@ -1015,12 +1029,12 @@ palette_create_edit (PaletteEntries *entries)
}
static void
palette_select_callback (const GimpRGB *callback_color,
palette_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
PaletteDialog *palette;
guchar *color;
palette = data;
@ -1034,18 +1048,13 @@ palette_select_callback (const GimpRGB *callback_color,
case COLOR_NOTEBOOK_OK:
if (palette->color)
{
color = palette->color->color;
gimp_rgb_get_uchar (callback_color,
&color[0], &color[1], &color[2]);
palette->color->color = *color;
/* Update either foreground or background colors */
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (),
callback_color);
gimp_context_set_foreground (gimp_context_get_user (), color);
else if (active_color == BACKGROUND)
gimp_context_set_background (gimp_context_get_user (),
callback_color);
gimp_context_set_background (gimp_context_get_user (), color);
palette_draw_all (palette->entries, palette->color);
}
@ -1073,19 +1082,16 @@ palette_dialog_new_entry_callback (GtkWidget *widget,
if (palette && palette->entries)
{
GimpRGB color;
guchar r, g, b;
GimpRGB color;
if (active_color == FOREGROUND)
gimp_context_get_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
gimp_context_get_background (gimp_context_get_user (), &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
palette->color = palette_entries_add_entry (palette->entries,
_("Untitled"),
r, g, b);
NULL,
&color);
palette_update_all (palette->entries);
}
@ -1096,20 +1102,16 @@ palette_dialog_edit_entry_callback (GtkWidget *widget,
gpointer data)
{
PaletteDialog *palette;
GimpRGB color;
guchar *col;
palette = data;
if (palette && palette->entries && palette->color)
{
col = palette->color->color;
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], 255);
if (!palette->color_notebook)
{
palette->color_notebook =
color_notebook_new ((const GimpRGB *) &color,
color_notebook_new (_("Edit Palette Color"),
(const GimpRGB *) &palette->color->color,
palette_select_callback, palette,
FALSE, FALSE);
palette->color_notebook_active = TRUE;
@ -1122,7 +1124,8 @@ palette_dialog_edit_entry_callback (GtkWidget *widget,
palette->color_notebook_active = TRUE;
}
color_notebook_set_color (palette->color_notebook, &color);
color_notebook_set_color (palette->color_notebook,
&palette->color->color);
}
}
}
@ -1169,11 +1172,17 @@ palette_dialog_delete_entry_callback (GtkWidget *widget,
}
if (palette->entries->n_colors == 0)
palette->color =
palette_entries_add_entry (palette->entries,
_("Black"), 0, 0, 0);
{
GimpRGB color;
palette_update_all (palette->entries);
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
palette->color = palette_entries_add_entry (palette->entries,
_("Black"),
&color);
palette_update_all (palette->entries);
}
}
}
@ -1245,7 +1254,6 @@ palette_dialog_color_area_events (GtkWidget *widget,
{
GdkEventButton *bevent;
GSList *tmp_link;
GimpRGB color;
gint entry_width;
gint entry_height;
gint row, col;
@ -1284,30 +1292,23 @@ palette_dialog_color_area_events (GtkWidget *widget,
}
palette->color = tmp_link->data;
/* Update either foreground or background colors */
gimp_rgba_set_uchar (&color,
palette->color->color[0],
palette->color->color[1],
palette->color->color[2],
255);
if (active_color == FOREGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_background (gimp_context_get_user (),
&color);
&palette->color->color);
else
gimp_context_set_foreground (gimp_context_get_user (),
&color);
&palette->color->color);
}
else if (active_color == BACKGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_foreground (gimp_context_get_user (),
&color);
&palette->color->color);
else
gimp_context_set_background (gimp_context_get_user (),
&color);
&palette->color->color);
}
palette_dialog_draw_entries (palette, row, col);
@ -1358,8 +1359,8 @@ palette_dialog_color_area_events (GtkWidget *widget,
/* functions for drawing & updating the palette dialog color area **********/
static int
palette_dialog_draw_color_row (guchar **colors,
gint ncolors,
palette_dialog_draw_color_row (guchar *colors,
gint n_colors,
gint y,
gint column_highlight,
guchar *buffer,
@ -1443,7 +1444,7 @@ palette_dialog_draw_color_row (guchar **colors,
if (vsize > 0)
{
p = buffer;
for (i = 0; i < ncolors; i++)
for (i = 0; i < n_colors; i++)
{
for (j = 0; j < SPACING; j++)
{
@ -1454,13 +1455,13 @@ palette_dialog_draw_color_row (guchar **colors,
for (j = 0; j < entry_width; j++)
{
*p++ = colors[i][0];
*p++ = colors[i][1];
*p++ = colors[i][2];
*p++ = colors[i * 3];
*p++ = colors[i * 3 + 1];
*p++ = colors[i * 3 + 2];
}
}
for (i = 0; i < (palette->columns - ncolors); i++)
for (i = 0; i < (palette->columns - n_colors); i++)
{
for (j = 0; j < (SPACING + entry_width); j++)
{
@ -1472,7 +1473,7 @@ palette_dialog_draw_color_row (guchar **colors,
for (j = 0; j < SPACING; j++)
{
if (ncolors == column_highlight)
if (n_colors == column_highlight)
{
*p++ = ~bcolor;
*p++ = ~bcolor;
@ -1519,7 +1520,7 @@ palette_dialog_draw_entries (PaletteDialog *palette,
{
PaletteEntry *entry;
guchar *buffer;
guchar **colors;
guchar *colors;
GSList *tmp_link;
gint width, height;
gint entry_width;
@ -1536,8 +1537,8 @@ palette_dialog_draw_entries (PaletteDialog *palette,
if (entry_width <= 0) return;
colors = g_malloc (sizeof (guchar *) * palette->columns * 3);
buffer = g_malloc (width * 3);
colors = g_new (guchar, palette->columns * 3);
buffer = g_new (guchar, width * 3);
if (row_start < 0)
{
@ -1558,7 +1559,10 @@ palette_dialog_draw_entries (PaletteDialog *palette,
entry = tmp_link->data;
tmp_link = tmp_link->next;
colors[index] = entry->color;
gimp_rgb_get_uchar (&entry->color,
&colors[index * 3],
&colors[index * 3 + 1],
&colors[index * 3 + 2]);
index++;
if (index == palette->columns)
@ -1899,9 +1903,7 @@ palette_dialog_merge_entries_callback (GtkWidget *widget,
PaletteEntry *entry = cols->data;
palette_entries_add_entry (new_entries,
entry->name,
entry->color[0],
entry->color[1],
entry->color[2]);
&entry->color);
cols = cols->next;
}
sel_list = sel_list->next;
@ -2005,15 +2007,11 @@ palette_dialog_drag_color (GtkWidget *widget,
if (palette && palette->entries && palette->dnd_color)
{
gimp_rgba_set_uchar (color,
(guchar) palette->dnd_color->color[0],
(guchar) palette->dnd_color->color[1],
(guchar) palette->dnd_color->color[2],
(guchar) 255);
*color = palette->dnd_color->color;
}
else
{
gimp_rgba_set_uchar (color, 0.0, 0.0, 0.0, 255.0);
gimp_rgba_set (color, 0.0, 0.0, 0.0, 1.0);
}
}
@ -2023,16 +2021,14 @@ palette_dialog_drop_color (GtkWidget *widget,
gpointer data)
{
PaletteDialog *palette;
guchar r, g, b;
palette = (PaletteDialog *) data;
if (palette && palette->entries)
{
gimp_rgb_get_uchar (color, &r, &g, &b);
palette->color =
palette_entries_add_entry (palette->entries, _("Untitled"), r, g, b);
palette->color = palette_entries_add_entry (palette->entries,
NULL,
(GimpRGB *) color);
palette_update_all (palette->entries);
}
@ -2468,16 +2464,24 @@ palette_import_image_sel_callback (GtkWidget *widget,
pdb_image_to_id (import_dialog->gimage));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
static void
palette_import_image_menu_add (GimpImage *gimage)
{
GtkWidget *menuitem;
gchar *lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
pdb_image_to_id (gimage));
gchar *lab;
lab= g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
pdb_image_to_id (gimage));
menuitem = gtk_menu_item_new_with_label (lab);
g_free (lab);
gtk_widget_show (menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC (palette_import_image_sel_callback),
@ -2569,12 +2573,16 @@ palette_import_image_menu_activate (gint redo,
/* reset to last one */
if (redo && act_num >= 0)
{
gchar *lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (import_dialog->gimage)),
pdb_image_to_id (import_dialog->gimage));
gchar *lab;
lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (import_dialog->gimage)),
pdb_image_to_id (import_dialog->gimage));
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu1), act_num);
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
}
g_slist_free (list);
@ -2584,6 +2592,8 @@ palette_import_image_menu_activate (gint redo,
pdb_image_to_id (import_dialog->gimage));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
/* the import source menu item callbacks ***********************************/
@ -2739,7 +2749,6 @@ palette_import_create_from_grad (gchar *name)
/* Add names to entry */
gdouble dx, cur_x;
GimpRGB color;
guchar r, g, b;
gint sample_sz;
gint loop;
@ -2754,13 +2763,8 @@ palette_import_create_from_grad (gchar *name)
{
gradient_get_color_at (gradient, cur_x, &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
cur_x += dx;
palette_entries_add_entry (entries, _("Untitled"),
(gint) r,
(gint) g,
(gint) b);
palette_entries_add_entry (entries, NULL, &color);
}
palette_insert_all (entries);
@ -2881,10 +2885,14 @@ static void
palette_import_create_image_palette (gpointer data,
gpointer user_data)
{
PaletteEntries *entries = (PaletteEntries *) user_data;
ImgColors *color_tab = (ImgColors *) data;
gint sample_sz;
gchar *lab;
PaletteEntries *entries;
ImgColors *color_tab;
gint sample_sz;
gchar *lab;
GimpRGB color;
entries = (PaletteEntries *) user_data;
color_tab = (ImgColors *) data;
sample_sz = (gint) import_dialog->sample->value;
@ -2894,11 +2902,16 @@ palette_import_create_image_palette (gpointer data,
lab = g_strdup_printf ("%s (occurs %u)", _("Untitled"), color_tab->count);
/* Adjust the colors to the mean of the the sample */
palette_entries_add_entry
(entries, lab,
(gint) color_tab->r + (color_tab->r_adj / color_tab->count),
(gint) color_tab->g + (color_tab->g_adj / color_tab->count),
(gint) color_tab->b + (color_tab->b_adj / color_tab->count));
gimp_rgba_set_uchar
(&color,
(guchar) color_tab->r + (color_tab->r_adj / color_tab->count),
(guchar) color_tab->g + (color_tab->g_adj / color_tab->count),
(guchar) color_tab->b + (color_tab->b_adj / color_tab->count),
255);
palette_entries_add_entry (entries, lab, &color);
g_free (lab);
}
static gboolean
@ -3025,7 +3038,9 @@ palette_import_create_from_indexed (GImage *gimage,
gchar *pname)
{
PaletteEntries *entries;
gint samples, count;
gint samples;
gint count;
GimpRGB color;
samples = (gint) import_dialog->sample->value;
@ -3039,10 +3054,13 @@ palette_import_create_from_indexed (GImage *gimage,
for (count= 0; count < samples && count < gimage->num_cols; ++count)
{
palette_entries_add_entry (entries, NULL,
gimage->cmap[count*3],
gimage->cmap[count*3+1],
gimage->cmap[count*3+2]);
gimp_rgba_set_uchar (&color,
gimage->cmap[count*3],
gimage->cmap[count*3+1],
gimage->cmap[count*3+2],
255);
palette_entries_add_entry (entries, NULL, &color);
}
palette_insert_all (entries);

View File

@ -31,13 +31,21 @@
#include "libgimp/gimpintl.h"
/* List of active dialogs */
/* local function prototypes */
static gint palette_select_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static void palette_select_close_callback (GtkWidget *widget,
gpointer data);
static void palette_select_edit_callback (GtkWidget *widget,
gpointer data);
/* list of active dialogs */
static GSList *active_dialogs = NULL;
/* local function prototypes */
static gint palette_select_button_press (GtkWidget *, GdkEventButton *, gpointer);
static void palette_select_close_callback (GtkWidget *, gpointer);
static void palette_select_edit_callback (GtkWidget *, gpointer);
/* public functions */
@ -146,9 +154,9 @@ void
palette_select_clist_insert_all (PaletteEntries *p_entries)
{
PaletteEntries *chk_entries;
PaletteSelect *psp;
GSList *list;
gint pos = 0;
PaletteSelect *psp;
GSList *list;
gint pos = 0;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
@ -178,10 +186,10 @@ void
palette_select_set_text_all (PaletteEntries *entries)
{
PaletteEntries *p_entries = NULL;
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
gint pos = 0;
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
gint pos = 0;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
@ -209,10 +217,10 @@ palette_select_set_text_all (PaletteEntries *entries)
}
void
palette_select_refresh_all ()
palette_select_refresh_all (void)
{
PaletteSelect *psp;
GSList *list;
GSList *list;
for (list = active_dialogs; list; list = g_slist_next (list))
{
@ -251,8 +259,10 @@ palette_select_edit_callback (GtkWidget *widget,
gpointer data)
{
PaletteEntries *p_entries = NULL;
PaletteSelect *psp = (PaletteSelect *) data;
GList *sel_list;
PaletteSelect *psp;
GList *sel_list;
psp = (PaletteSelect *) data;
sel_list = GTK_CLIST (psp->clist)->selection;

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -284,8 +284,8 @@ static PaletteEntries *
palette_entries_new (gchar *palette_name)
{
PaletteEntries *entries = NULL;
GList *pal_path;
gchar *pal_dir;
GList *pal_path;
gchar *pal_dir;
if (!palette_name || !palette_path)
return NULL;
@ -323,7 +323,7 @@ static void
palette_entries_free (PaletteEntries *entries)
{
PaletteEntry *entry;
GSList *list;
GSList *list;
for (list = entries->colors; list; list = g_slist_next (list))
{
@ -348,10 +348,8 @@ palette_entries_free (PaletteEntries *entries)
static PaletteEntry *
palette_entries_add_entry (PaletteEntries *entries,
gchar *name,
gint r,
gint g,
gint b)
const gchar *name,
GimpRGB *color)
{
PaletteEntry *entry;
@ -359,9 +357,8 @@ palette_entries_add_entry (PaletteEntries *entries,
{
entry = g_new (PaletteEntry, 1);
entry->color[0] = r;
entry->color[1] = g;
entry->color[2] = b;
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
entry->position = entries->n_colors;
@ -379,11 +376,12 @@ static void
palette_entries_load (const gchar *filename)
{
PaletteEntries *entries;
gchar str[512];
gchar *tok;
FILE *fp;
gint r, g, b;
gint linenum;
gchar str[512];
gchar *tok;
FILE *fp;
gint r, g, b;
GimpRGB color;
gint linenum;
r = g = b = 0;
@ -472,7 +470,13 @@ palette_entries_load (const gchar *filename)
g_message (_("Loading palette %s (line %d):\n"
"RGB value out of range"), filename, linenum);
palette_entries_add_entry (entries, tok, r, g, b);
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
palette_entries_add_entry (entries, tok, &color);
}
}
@ -511,6 +515,7 @@ palette_entries_save (PaletteEntries *palette,
PaletteEntry *entry;
GSList *list;
FILE *fp;
guchar r, g, b;
if (! filename)
return;
@ -529,8 +534,11 @@ palette_entries_save (PaletteEntries *palette,
{
entry = (PaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
fprintf (fp, "%d %d %d\t%s\n",
entry->color[0], entry->color[1], entry->color[2], entry->name);
r, g, b,
entry->name);
}
/* Clean up */
@ -579,15 +587,20 @@ palette_entries_update_small_preview (PaletteEntries *entries,
for (list = entries->colors; list; list = g_slist_next (list))
{
guchar cell[3*3*3];
gint loop;
gint loop;
entry = list->data;
for (loop = 0; loop < 27 ; loop+=3)
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0+loop] = entry->color[0];
cell[1+loop] = entry->color[1];
cell[2+loop] = entry->color[2];
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (entries->pixmap,
@ -864,7 +877,7 @@ palette_draw_all (PaletteEntries *entries,
PaletteEntry *color)
{
PaletteDialog *palette;
GdkGC *gc = NULL;
GdkGC *gc = NULL;
if (top_level_palette)
gc = top_level_palette->gc;
@ -935,6 +948,12 @@ palette_set_active_color (gint r,
{
GimpRGB color;
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (top_level_edit_palette && top_level_edit_palette->entries)
{
switch (state)
@ -942,14 +961,15 @@ palette_set_active_color (gint r,
case COLOR_NEW:
top_level_edit_palette->color =
palette_entries_add_entry (top_level_edit_palette->entries,
_("Untitled"), r, g, b);
NULL,
&color);
palette_update_all (top_level_edit_palette->entries);
break;
case COLOR_UPDATE_NEW:
top_level_edit_palette->color->color[0] = r;
top_level_edit_palette->color->color[1] = g;
top_level_edit_palette->color->color[2] = b;
top_level_edit_palette->color->color = color;
palette_draw_all (top_level_edit_palette->entries,
top_level_edit_palette->color);
break;
@ -959,12 +979,6 @@ palette_set_active_color (gint r,
}
}
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
@ -1015,12 +1029,12 @@ palette_create_edit (PaletteEntries *entries)
}
static void
palette_select_callback (const GimpRGB *callback_color,
palette_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
PaletteDialog *palette;
guchar *color;
palette = data;
@ -1034,18 +1048,13 @@ palette_select_callback (const GimpRGB *callback_color,
case COLOR_NOTEBOOK_OK:
if (palette->color)
{
color = palette->color->color;
gimp_rgb_get_uchar (callback_color,
&color[0], &color[1], &color[2]);
palette->color->color = *color;
/* Update either foreground or background colors */
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (),
callback_color);
gimp_context_set_foreground (gimp_context_get_user (), color);
else if (active_color == BACKGROUND)
gimp_context_set_background (gimp_context_get_user (),
callback_color);
gimp_context_set_background (gimp_context_get_user (), color);
palette_draw_all (palette->entries, palette->color);
}
@ -1073,19 +1082,16 @@ palette_dialog_new_entry_callback (GtkWidget *widget,
if (palette && palette->entries)
{
GimpRGB color;
guchar r, g, b;
GimpRGB color;
if (active_color == FOREGROUND)
gimp_context_get_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
gimp_context_get_background (gimp_context_get_user (), &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
palette->color = palette_entries_add_entry (palette->entries,
_("Untitled"),
r, g, b);
NULL,
&color);
palette_update_all (palette->entries);
}
@ -1096,20 +1102,16 @@ palette_dialog_edit_entry_callback (GtkWidget *widget,
gpointer data)
{
PaletteDialog *palette;
GimpRGB color;
guchar *col;
palette = data;
if (palette && palette->entries && palette->color)
{
col = palette->color->color;
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], 255);
if (!palette->color_notebook)
{
palette->color_notebook =
color_notebook_new ((const GimpRGB *) &color,
color_notebook_new (_("Edit Palette Color"),
(const GimpRGB *) &palette->color->color,
palette_select_callback, palette,
FALSE, FALSE);
palette->color_notebook_active = TRUE;
@ -1122,7 +1124,8 @@ palette_dialog_edit_entry_callback (GtkWidget *widget,
palette->color_notebook_active = TRUE;
}
color_notebook_set_color (palette->color_notebook, &color);
color_notebook_set_color (palette->color_notebook,
&palette->color->color);
}
}
}
@ -1169,11 +1172,17 @@ palette_dialog_delete_entry_callback (GtkWidget *widget,
}
if (palette->entries->n_colors == 0)
palette->color =
palette_entries_add_entry (palette->entries,
_("Black"), 0, 0, 0);
{
GimpRGB color;
palette_update_all (palette->entries);
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
palette->color = palette_entries_add_entry (palette->entries,
_("Black"),
&color);
palette_update_all (palette->entries);
}
}
}
@ -1245,7 +1254,6 @@ palette_dialog_color_area_events (GtkWidget *widget,
{
GdkEventButton *bevent;
GSList *tmp_link;
GimpRGB color;
gint entry_width;
gint entry_height;
gint row, col;
@ -1284,30 +1292,23 @@ palette_dialog_color_area_events (GtkWidget *widget,
}
palette->color = tmp_link->data;
/* Update either foreground or background colors */
gimp_rgba_set_uchar (&color,
palette->color->color[0],
palette->color->color[1],
palette->color->color[2],
255);
if (active_color == FOREGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_background (gimp_context_get_user (),
&color);
&palette->color->color);
else
gimp_context_set_foreground (gimp_context_get_user (),
&color);
&palette->color->color);
}
else if (active_color == BACKGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_foreground (gimp_context_get_user (),
&color);
&palette->color->color);
else
gimp_context_set_background (gimp_context_get_user (),
&color);
&palette->color->color);
}
palette_dialog_draw_entries (palette, row, col);
@ -1358,8 +1359,8 @@ palette_dialog_color_area_events (GtkWidget *widget,
/* functions for drawing & updating the palette dialog color area **********/
static int
palette_dialog_draw_color_row (guchar **colors,
gint ncolors,
palette_dialog_draw_color_row (guchar *colors,
gint n_colors,
gint y,
gint column_highlight,
guchar *buffer,
@ -1443,7 +1444,7 @@ palette_dialog_draw_color_row (guchar **colors,
if (vsize > 0)
{
p = buffer;
for (i = 0; i < ncolors; i++)
for (i = 0; i < n_colors; i++)
{
for (j = 0; j < SPACING; j++)
{
@ -1454,13 +1455,13 @@ palette_dialog_draw_color_row (guchar **colors,
for (j = 0; j < entry_width; j++)
{
*p++ = colors[i][0];
*p++ = colors[i][1];
*p++ = colors[i][2];
*p++ = colors[i * 3];
*p++ = colors[i * 3 + 1];
*p++ = colors[i * 3 + 2];
}
}
for (i = 0; i < (palette->columns - ncolors); i++)
for (i = 0; i < (palette->columns - n_colors); i++)
{
for (j = 0; j < (SPACING + entry_width); j++)
{
@ -1472,7 +1473,7 @@ palette_dialog_draw_color_row (guchar **colors,
for (j = 0; j < SPACING; j++)
{
if (ncolors == column_highlight)
if (n_colors == column_highlight)
{
*p++ = ~bcolor;
*p++ = ~bcolor;
@ -1519,7 +1520,7 @@ palette_dialog_draw_entries (PaletteDialog *palette,
{
PaletteEntry *entry;
guchar *buffer;
guchar **colors;
guchar *colors;
GSList *tmp_link;
gint width, height;
gint entry_width;
@ -1536,8 +1537,8 @@ palette_dialog_draw_entries (PaletteDialog *palette,
if (entry_width <= 0) return;
colors = g_malloc (sizeof (guchar *) * palette->columns * 3);
buffer = g_malloc (width * 3);
colors = g_new (guchar, palette->columns * 3);
buffer = g_new (guchar, width * 3);
if (row_start < 0)
{
@ -1558,7 +1559,10 @@ palette_dialog_draw_entries (PaletteDialog *palette,
entry = tmp_link->data;
tmp_link = tmp_link->next;
colors[index] = entry->color;
gimp_rgb_get_uchar (&entry->color,
&colors[index * 3],
&colors[index * 3 + 1],
&colors[index * 3 + 2]);
index++;
if (index == palette->columns)
@ -1899,9 +1903,7 @@ palette_dialog_merge_entries_callback (GtkWidget *widget,
PaletteEntry *entry = cols->data;
palette_entries_add_entry (new_entries,
entry->name,
entry->color[0],
entry->color[1],
entry->color[2]);
&entry->color);
cols = cols->next;
}
sel_list = sel_list->next;
@ -2005,15 +2007,11 @@ palette_dialog_drag_color (GtkWidget *widget,
if (palette && palette->entries && palette->dnd_color)
{
gimp_rgba_set_uchar (color,
(guchar) palette->dnd_color->color[0],
(guchar) palette->dnd_color->color[1],
(guchar) palette->dnd_color->color[2],
(guchar) 255);
*color = palette->dnd_color->color;
}
else
{
gimp_rgba_set_uchar (color, 0.0, 0.0, 0.0, 255.0);
gimp_rgba_set (color, 0.0, 0.0, 0.0, 1.0);
}
}
@ -2023,16 +2021,14 @@ palette_dialog_drop_color (GtkWidget *widget,
gpointer data)
{
PaletteDialog *palette;
guchar r, g, b;
palette = (PaletteDialog *) data;
if (palette && palette->entries)
{
gimp_rgb_get_uchar (color, &r, &g, &b);
palette->color =
palette_entries_add_entry (palette->entries, _("Untitled"), r, g, b);
palette->color = palette_entries_add_entry (palette->entries,
NULL,
(GimpRGB *) color);
palette_update_all (palette->entries);
}
@ -2468,16 +2464,24 @@ palette_import_image_sel_callback (GtkWidget *widget,
pdb_image_to_id (import_dialog->gimage));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
static void
palette_import_image_menu_add (GimpImage *gimage)
{
GtkWidget *menuitem;
gchar *lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
pdb_image_to_id (gimage));
gchar *lab;
lab= g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
pdb_image_to_id (gimage));
menuitem = gtk_menu_item_new_with_label (lab);
g_free (lab);
gtk_widget_show (menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC (palette_import_image_sel_callback),
@ -2569,12 +2573,16 @@ palette_import_image_menu_activate (gint redo,
/* reset to last one */
if (redo && act_num >= 0)
{
gchar *lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (import_dialog->gimage)),
pdb_image_to_id (import_dialog->gimage));
gchar *lab;
lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (import_dialog->gimage)),
pdb_image_to_id (import_dialog->gimage));
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu1), act_num);
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
}
g_slist_free (list);
@ -2584,6 +2592,8 @@ palette_import_image_menu_activate (gint redo,
pdb_image_to_id (import_dialog->gimage));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
/* the import source menu item callbacks ***********************************/
@ -2739,7 +2749,6 @@ palette_import_create_from_grad (gchar *name)
/* Add names to entry */
gdouble dx, cur_x;
GimpRGB color;
guchar r, g, b;
gint sample_sz;
gint loop;
@ -2754,13 +2763,8 @@ palette_import_create_from_grad (gchar *name)
{
gradient_get_color_at (gradient, cur_x, &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
cur_x += dx;
palette_entries_add_entry (entries, _("Untitled"),
(gint) r,
(gint) g,
(gint) b);
palette_entries_add_entry (entries, NULL, &color);
}
palette_insert_all (entries);
@ -2881,10 +2885,14 @@ static void
palette_import_create_image_palette (gpointer data,
gpointer user_data)
{
PaletteEntries *entries = (PaletteEntries *) user_data;
ImgColors *color_tab = (ImgColors *) data;
gint sample_sz;
gchar *lab;
PaletteEntries *entries;
ImgColors *color_tab;
gint sample_sz;
gchar *lab;
GimpRGB color;
entries = (PaletteEntries *) user_data;
color_tab = (ImgColors *) data;
sample_sz = (gint) import_dialog->sample->value;
@ -2894,11 +2902,16 @@ palette_import_create_image_palette (gpointer data,
lab = g_strdup_printf ("%s (occurs %u)", _("Untitled"), color_tab->count);
/* Adjust the colors to the mean of the the sample */
palette_entries_add_entry
(entries, lab,
(gint) color_tab->r + (color_tab->r_adj / color_tab->count),
(gint) color_tab->g + (color_tab->g_adj / color_tab->count),
(gint) color_tab->b + (color_tab->b_adj / color_tab->count));
gimp_rgba_set_uchar
(&color,
(guchar) color_tab->r + (color_tab->r_adj / color_tab->count),
(guchar) color_tab->g + (color_tab->g_adj / color_tab->count),
(guchar) color_tab->b + (color_tab->b_adj / color_tab->count),
255);
palette_entries_add_entry (entries, lab, &color);
g_free (lab);
}
static gboolean
@ -3025,7 +3038,9 @@ palette_import_create_from_indexed (GImage *gimage,
gchar *pname)
{
PaletteEntries *entries;
gint samples, count;
gint samples;
gint count;
GimpRGB color;
samples = (gint) import_dialog->sample->value;
@ -3039,10 +3054,13 @@ palette_import_create_from_indexed (GImage *gimage,
for (count= 0; count < samples && count < gimage->num_cols; ++count)
{
palette_entries_add_entry (entries, NULL,
gimage->cmap[count*3],
gimage->cmap[count*3+1],
gimage->cmap[count*3+2]);
gimp_rgba_set_uchar (&color,
gimage->cmap[count*3],
gimage->cmap[count*3+1],
gimage->cmap[count*3+2],
255);
palette_entries_add_entry (entries, NULL, &color);
}
palette_insert_all (entries);

View File

@ -32,9 +32,9 @@ struct _PaletteEntries
struct _PaletteEntry
{
guchar color[3];
gchar *name;
gint position;
GimpRGB color;
gchar *name;
gint position;
};
extern GSList * palette_entries_list;

View File

@ -31,13 +31,21 @@
#include "libgimp/gimpintl.h"
/* List of active dialogs */
/* local function prototypes */
static gint palette_select_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static void palette_select_close_callback (GtkWidget *widget,
gpointer data);
static void palette_select_edit_callback (GtkWidget *widget,
gpointer data);
/* list of active dialogs */
static GSList *active_dialogs = NULL;
/* local function prototypes */
static gint palette_select_button_press (GtkWidget *, GdkEventButton *, gpointer);
static void palette_select_close_callback (GtkWidget *, gpointer);
static void palette_select_edit_callback (GtkWidget *, gpointer);
/* public functions */
@ -146,9 +154,9 @@ void
palette_select_clist_insert_all (PaletteEntries *p_entries)
{
PaletteEntries *chk_entries;
PaletteSelect *psp;
GSList *list;
gint pos = 0;
PaletteSelect *psp;
GSList *list;
gint pos = 0;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
@ -178,10 +186,10 @@ void
palette_select_set_text_all (PaletteEntries *entries)
{
PaletteEntries *p_entries = NULL;
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
gint pos = 0;
PaletteSelect *psp;
GSList *list;
gchar *num_buf;
gint pos = 0;
for (list = palette_entries_list; list; list = g_slist_next (list))
{
@ -209,10 +217,10 @@ palette_select_set_text_all (PaletteEntries *entries)
}
void
palette_select_refresh_all ()
palette_select_refresh_all (void)
{
PaletteSelect *psp;
GSList *list;
GSList *list;
for (list = active_dialogs; list; list = g_slist_next (list))
{
@ -251,8 +259,10 @@ palette_select_edit_callback (GtkWidget *widget,
gpointer data)
{
PaletteEntries *p_entries = NULL;
PaletteSelect *psp = (PaletteSelect *) data;
GList *sel_list;
PaletteSelect *psp;
GList *sel_list;
psp = (PaletteSelect *) data;
sel_list = GTK_CLIST (psp->clist)->selection;

View File

@ -273,13 +273,12 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
options = g_new0 (EditQmaskOptions, 1);
options->gimage = gdisp->gimage;
options->color_panel = gimp_color_panel_new (&options->gimage->qmask_color,
options->color_panel = gimp_color_panel_new (_("Edit Qmask Color"),
&options->gimage->qmask_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
48, 64);

View File

@ -56,6 +56,39 @@ typedef enum
} ColorNotebookUpdateType;
/* "class" information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
/* "instance" information we keep on each notebook tab */
typedef struct _ColorSelectorInstance ColorSelectorInstance;
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
struct _ColorNotebook
{
GtkWidget *shell;
@ -87,33 +120,6 @@ struct _ColorNotebook
};
/* information we keep on each registered colour selector */
typedef struct _ColorSelectorInfo ColorSelectorInfo;
struct _ColorSelectorInfo
{
gchar *name; /* label used in notebook tab */
gchar *help_page;
GimpColorSelectorMethods methods;
gint refs; /* number of instances around */
gboolean active;
GimpColorSelectorFinishedCB death_callback;
gpointer death_data;
ColorSelectorInfo *next;
};
struct _ColorSelectorInstance
{
ColorNotebook *color_notebook;
ColorSelectorInfo *info;
GtkWidget *frame; /* main widget */
gpointer selector_data;
ColorSelectorInstance *next;
};
static void color_notebook_ok_callback (GtkWidget *widget,
gpointer data);
static void color_notebook_cancel_callback (GtkWidget *widget,
@ -172,7 +178,8 @@ static gboolean color_history_initialized = FALSE;
ColorNotebook *
color_notebook_new (const GimpRGB *color,
color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
@ -243,7 +250,7 @@ color_notebook_new (const GimpRGB *color,
color_notebook_update_hsv_values (cnp);
cnp->shell =
gimp_dialog_new (_("Color Selection"), "color_selection",
gimp_dialog_new (title, "color_selection",
color_notebook_help_func, (const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
@ -607,6 +614,16 @@ color_notebook_set_color (ColorNotebook *cnp,
UPDATE_NEW_COLOR);
}
void
color_notebook_get_color (ColorNotebook *cnp,
GimpRGB *color)
{
g_return_if_fail (cnp != NULL);
g_return_if_fail (color != NULL);
*color = cnp->rgb;
}
static void
color_notebook_set_white (ColorNotebook *cnp)
{
@ -694,7 +711,8 @@ color_notebook_ok_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_OK,
cnp->client_data);
}
@ -710,7 +728,8 @@ color_notebook_cancel_callback (GtkWidget *widget,
if (cnp->callback)
{
(* cnp->callback) (&cnp->orig_rgb,
(* cnp->callback) (cnp,
&cnp->orig_rgb,
COLOR_NOTEBOOK_CANCEL,
cnp->client_data);
}
@ -909,7 +928,8 @@ color_notebook_update_caller (ColorNotebook *cnp)
{
if (cnp && cnp->callback)
{
(* cnp->callback) (&cnp->rgb,
(* cnp->callback) (cnp,
&cnp->rgb,
COLOR_NOTEBOOK_UPDATE,
cnp->client_data);
}

View File

@ -27,14 +27,15 @@ typedef enum
COLOR_NOTEBOOK_UPDATE
} ColorNotebookState;
typedef void (* ColorNotebookCallback) (const GimpRGB *color,
typedef void (* ColorNotebookCallback) (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
typedef struct _ColorSelectorInstance ColorSelectorInstance;
ColorNotebook * color_notebook_new (const GimpRGB *color,
ColorNotebook * color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer data,
gboolean wants_update,
@ -46,8 +47,12 @@ void color_notebook_free (ColorNotebook *cnb);
void color_notebook_set_color (ColorNotebook *cnb,
const GimpRGB *color);
void color_notebook_get_color (ColorNotebook *cnb,
GimpRGB *color);
/* color history functions */
void color_history_add_color_from_rc (GimpRGB *color);
void color_history_write (FILE *fp);

View File

@ -87,7 +87,8 @@ static void ipal_edit_callback (GtkWidget *widget,
gpointer data);
static void ipal_close_callback (GtkWidget *widget,
gpointer data);
static void ipal_select_callback (const GimpRGB *color,
static void ipal_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
@ -931,7 +932,8 @@ ipal_edit_callback (GtkWidget *widget,
if (! ipal->color_notebook)
{
ipal->color_notebook
= color_notebook_new ((const GimpRGB *) &color,
= color_notebook_new (_("Edit Indexed Color"),
(const GimpRGB *) &color,
ipal_select_callback, ipal, FALSE, FALSE);
}
else
@ -953,7 +955,8 @@ ipal_close_callback (GtkWidget *widget,
}
static void
ipal_select_callback (const GimpRGB *color,
ipal_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{

View File

@ -44,7 +44,8 @@ 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);
static void gimp_color_panel_select_callback (const GimpRGB *color,
static void gimp_color_panel_select_callback (ColorNotebook *notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
@ -88,7 +89,7 @@ gimp_color_panel_class_init (GimpColorPanelClass *klass)
button_class = (GtkButtonClass *) klass;
color_button_class = (GimpColorButtonClass *) klass;
parent_class = gtk_type_class (gimp_color_button_get_type ());
parent_class = gtk_type_class (GIMP_TYPE_COLOR_BUTTON);
object_class->destroy = gimp_color_panel_destroy;
button_class->clicked = gimp_color_panel_clicked;
@ -124,7 +125,8 @@ gimp_color_panel_destroy (GtkObject *object)
}
GtkWidget *
gimp_color_panel_new (const GimpRGB *color,
gimp_color_panel_new (const gchar *title,
const GimpRGB *color,
GimpColorAreaType type,
gint width,
gint height)
@ -133,12 +135,14 @@ gimp_color_panel_new (const GimpRGB *color,
g_return_val_if_fail (color != NULL, NULL);
panel = gtk_type_new (gimp_color_panel_get_type ());
panel = gtk_type_new (GIMP_TYPE_COLOR_PANEL);
GIMP_COLOR_BUTTON (panel)->title = g_strdup (title);
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
return GTK_WIDGET (panel);
}
@ -170,7 +174,8 @@ gimp_color_panel_clicked (GtkButton *button)
if (! panel->color_notebook)
{
panel->color_notebook =
color_notebook_new ((const GimpRGB *) &color,
color_notebook_new (GIMP_COLOR_BUTTON (button)->title,
(const GimpRGB *) &color,
gimp_color_panel_select_callback,
panel,
FALSE,
@ -189,7 +194,8 @@ gimp_color_panel_clicked (GtkButton *button)
}
static void
gimp_color_panel_select_callback (const GimpRGB *color,
gimp_color_panel_select_callback (ColorNotebook *notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{

View File

@ -38,7 +38,8 @@ struct _GimpColorPanelClass
};
GtkType gimp_color_panel_get_type (void);
GtkWidget * gimp_color_panel_new (const GimpRGB *color,
GtkWidget * gimp_color_panel_new (const gchar *title,
const GimpRGB *color,
GimpColorAreaType type,
gint width,
gint height);

View File

@ -62,6 +62,7 @@
#include "apptypes.h"
#include "appenv.h"
#include "color_notebook.h"
#include "cursorutil.h"
#include "datafiles.h"
#include "errors.h"
@ -437,47 +438,25 @@ static void cpopup_load_right_callback (GtkWidget *widget,
static void cpopup_save_right_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static void cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color);
static grad_segment_t * cpopup_save_selection (void);
static void cpopup_free_selection (grad_segment_t *seg);
static void cpopup_replace_selection (grad_segment_t *replace_seg);
/* ----- */
static void cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_changed (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data);
static void cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data);
static gint cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static void cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
/* ----- */
@ -4244,33 +4223,6 @@ cpopup_save_right_callback (GtkWidget *widget,
/*****/
static void
cpopup_set_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
col[0] = color->r;
col[1] = color->g;
col[2] = color->b;
col[3] = color->a;
gtk_color_selection_set_color (cs, col);
}
static void
cpopup_get_color_selection_color (GtkColorSelection *cs,
GimpRGB *color)
{
gdouble col[4];
gtk_color_selection_get_color (cs, col);
gimp_rgba_set (color, col[0], col[1], col[2], col[3]);
}
/*****/
static grad_segment_t *
cpopup_save_selection (void)
{
@ -4355,58 +4307,6 @@ cpopup_replace_selection (grad_segment_t *replace_seg)
/***** Color dialogs for left and right endpoint *****/
static void
cpopup_create_color_dialog (gchar *title,
GimpRGB *color,
GtkSignalFunc color_changed_callback,
GtkSignalFunc ok_callback,
GtkSignalFunc cancel_callback,
GtkSignalFunc delete_callback)
{
GtkWidget *window;
GtkColorSelection *cs;
GtkColorSelectionDialog *csd;
window = gtk_color_selection_dialog_new (title);
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (window)->help_button);
gimp_help_connect_help_accel (window, gimp_standard_help_func,
"dialogs/gradient_editor/gradient_editor.html");
csd = GTK_COLOR_SELECTION_DIALOG (window);
cs = GTK_COLOR_SELECTION (csd->colorsel);
gtk_color_selection_set_opacity (cs, TRUE);
gtk_color_selection_set_update_policy (cs,
g_editor->instant_update ?
GTK_UPDATE_CONTINUOUS :
GTK_UPDATE_DELAYED);
/* FIXME: this is a hack; we set the color twice so that the
* color selector remembers it as its "old" color, too
*/
cpopup_set_color_selection_color (cs, color);
cpopup_set_color_selection_color (cs, color);
gtk_signal_connect (GTK_OBJECT (csd), "delete_event",
delete_callback, window);
gtk_signal_connect (GTK_OBJECT (cs), "color_changed",
color_changed_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->ok_button), "clicked",
ok_callback, window);
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
cancel_callback, window);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
gtk_widget_show (window);
}
/*****/
static void
cpopup_set_left_color_callback (GtkWidget *widget,
gpointer data)
@ -4414,71 +4314,16 @@ cpopup_set_left_color_callback (GtkWidget *widget,
g_editor->left_saved_dirty = curr_gradient->dirty;
g_editor->left_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Left endpoint's color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
(GtkSignalFunc) cpopup_left_color_dialog_ok,
(GtkSignalFunc) cpopup_left_color_dialog_cancel,
(GtkSignalFunc) cpopup_left_color_dialog_delete);
color_notebook_new (_("Left Endpoint Color"),
&g_editor->control_sel_l->left_color,
(GtkSignalFunc) cpopup_left_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_left_color_changed (GtkWidget *widget,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_left_color_dialog_ok (GtkWidget *widget,
gpointer data)
{
cpopup_left_color_changed (widget, data);
curr_gradient->dirty = TRUE;
cpopup_free_selection(g_editor->left_saved_segments);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static void
cpopup_left_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->left_saved_dirty;
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_left_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_left_color_dialog_cancel (widget, data);
return TRUE;
}
/*****/
static void
cpopup_set_right_color_callback (GtkWidget *widget,
gpointer data)
@ -4486,67 +4331,87 @@ cpopup_set_right_color_callback (GtkWidget *widget,
g_editor->right_saved_dirty = curr_gradient->dirty;
g_editor->right_saved_segments = cpopup_save_selection ();
cpopup_create_color_dialog (_("Right endpoint's color"),
&g_editor->control_sel_r->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
(GtkSignalFunc) cpopup_right_color_dialog_ok,
(GtkSignalFunc) cpopup_right_color_dialog_cancel,
(GtkSignalFunc) cpopup_right_color_dialog_delete);
color_notebook_new (_("Right Endpoint Color"),
&g_editor->control_sel_l->right_color,
(GtkSignalFunc) cpopup_right_color_changed,
NULL,
g_editor->instant_update,
TRUE);
gtk_widget_set_sensitive (g_editor->shell, FALSE);
}
static void
cpopup_right_color_changed (GtkWidget *widget,
gpointer data)
cpopup_left_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
GtkColorSelection *cs;
GimpRGB color;
switch (state)
{
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
cpopup_free_selection (g_editor->left_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
cs = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (data)->colorsel);
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints ((GimpRGB *) color,
&g_editor->control_sel_r->right_color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
cpopup_get_color_selection_color (cs, &color);
cpopup_blend_endpoints (&g_editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->left_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
curr_gradient->dirty = g_editor->left_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
ed_update_editor (GRAD_UPDATE_GRADIENT);
}
static void
cpopup_right_color_dialog_ok (GtkWidget *widget,
gpointer data)
cpopup_right_color_changed (ColorNotebook *cnb,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
cpopup_right_color_changed (widget, data);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
curr_gradient->dirty = TRUE;
break;
curr_gradient->dirty = TRUE;
cpopup_free_selection (g_editor->right_saved_segments);
case COLOR_NOTEBOOK_OK:
cpopup_blend_endpoints (&g_editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
cpopup_free_selection (g_editor->right_saved_segments);
curr_gradient->dirty = TRUE;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
case COLOR_NOTEBOOK_CANCEL:
cpopup_replace_selection (g_editor->right_saved_segments);
curr_gradient->dirty = g_editor->right_saved_dirty;
color_notebook_free (cnb);
gtk_widget_set_sensitive (g_editor->shell, TRUE);
break;
}
static void
cpopup_right_color_dialog_cancel (GtkWidget *widget,
gpointer data)
{
curr_gradient->dirty = g_editor->right_saved_dirty;
cpopup_replace_selection (g_editor->right_saved_segments);
ed_update_editor (GRAD_UPDATE_GRADIENT);
gtk_widget_destroy (GTK_WIDGET (data));
gtk_widget_set_sensitive (g_editor->shell, TRUE);
}
static int
cpopup_right_color_dialog_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
cpopup_right_color_dialog_cancel (widget, data);
return TRUE;
}
/***** Blending menu *****/

View File

@ -284,8 +284,8 @@ static PaletteEntries *
palette_entries_new (gchar *palette_name)
{
PaletteEntries *entries = NULL;
GList *pal_path;
gchar *pal_dir;
GList *pal_path;
gchar *pal_dir;
if (!palette_name || !palette_path)
return NULL;
@ -323,7 +323,7 @@ static void
palette_entries_free (PaletteEntries *entries)
{
PaletteEntry *entry;
GSList *list;
GSList *list;
for (list = entries->colors; list; list = g_slist_next (list))
{
@ -348,10 +348,8 @@ palette_entries_free (PaletteEntries *entries)
static PaletteEntry *
palette_entries_add_entry (PaletteEntries *entries,
gchar *name,
gint r,
gint g,
gint b)
const gchar *name,
GimpRGB *color)
{
PaletteEntry *entry;
@ -359,9 +357,8 @@ palette_entries_add_entry (PaletteEntries *entries,
{
entry = g_new (PaletteEntry, 1);
entry->color[0] = r;
entry->color[1] = g;
entry->color[2] = b;
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
entry->position = entries->n_colors;
@ -379,11 +376,12 @@ static void
palette_entries_load (const gchar *filename)
{
PaletteEntries *entries;
gchar str[512];
gchar *tok;
FILE *fp;
gint r, g, b;
gint linenum;
gchar str[512];
gchar *tok;
FILE *fp;
gint r, g, b;
GimpRGB color;
gint linenum;
r = g = b = 0;
@ -472,7 +470,13 @@ palette_entries_load (const gchar *filename)
g_message (_("Loading palette %s (line %d):\n"
"RGB value out of range"), filename, linenum);
palette_entries_add_entry (entries, tok, r, g, b);
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
palette_entries_add_entry (entries, tok, &color);
}
}
@ -511,6 +515,7 @@ palette_entries_save (PaletteEntries *palette,
PaletteEntry *entry;
GSList *list;
FILE *fp;
guchar r, g, b;
if (! filename)
return;
@ -529,8 +534,11 @@ palette_entries_save (PaletteEntries *palette,
{
entry = (PaletteEntry *) list->data;
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
fprintf (fp, "%d %d %d\t%s\n",
entry->color[0], entry->color[1], entry->color[2], entry->name);
r, g, b,
entry->name);
}
/* Clean up */
@ -579,15 +587,20 @@ palette_entries_update_small_preview (PaletteEntries *entries,
for (list = entries->colors; list; list = g_slist_next (list))
{
guchar cell[3*3*3];
gint loop;
gint loop;
entry = list->data;
for (loop = 0; loop < 27 ; loop+=3)
gimp_rgb_get_uchar (&entry->color,
&cell[0],
&cell[1],
&cell[2]);
for (loop = 3; loop < 27 ; loop += 3)
{
cell[0+loop] = entry->color[0];
cell[1+loop] = entry->color[1];
cell[2+loop] = entry->color[2];
cell[0 + loop] = cell[0];
cell[1 + loop] = cell[1];
cell[2 + loop] = cell[2];
}
gdk_draw_rgb_image (entries->pixmap,
@ -864,7 +877,7 @@ palette_draw_all (PaletteEntries *entries,
PaletteEntry *color)
{
PaletteDialog *palette;
GdkGC *gc = NULL;
GdkGC *gc = NULL;
if (top_level_palette)
gc = top_level_palette->gc;
@ -935,6 +948,12 @@ palette_set_active_color (gint r,
{
GimpRGB color;
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (top_level_edit_palette && top_level_edit_palette->entries)
{
switch (state)
@ -942,14 +961,15 @@ palette_set_active_color (gint r,
case COLOR_NEW:
top_level_edit_palette->color =
palette_entries_add_entry (top_level_edit_palette->entries,
_("Untitled"), r, g, b);
NULL,
&color);
palette_update_all (top_level_edit_palette->entries);
break;
case COLOR_UPDATE_NEW:
top_level_edit_palette->color->color[0] = r;
top_level_edit_palette->color->color[1] = g;
top_level_edit_palette->color->color[2] = b;
top_level_edit_palette->color->color = color;
palette_draw_all (top_level_edit_palette->entries,
top_level_edit_palette->color);
break;
@ -959,12 +979,6 @@ palette_set_active_color (gint r,
}
}
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
@ -1015,12 +1029,12 @@ palette_create_edit (PaletteEntries *entries)
}
static void
palette_select_callback (const GimpRGB *callback_color,
palette_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
PaletteDialog *palette;
guchar *color;
palette = data;
@ -1034,18 +1048,13 @@ palette_select_callback (const GimpRGB *callback_color,
case COLOR_NOTEBOOK_OK:
if (palette->color)
{
color = palette->color->color;
gimp_rgb_get_uchar (callback_color,
&color[0], &color[1], &color[2]);
palette->color->color = *color;
/* Update either foreground or background colors */
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (),
callback_color);
gimp_context_set_foreground (gimp_context_get_user (), color);
else if (active_color == BACKGROUND)
gimp_context_set_background (gimp_context_get_user (),
callback_color);
gimp_context_set_background (gimp_context_get_user (), color);
palette_draw_all (palette->entries, palette->color);
}
@ -1073,19 +1082,16 @@ palette_dialog_new_entry_callback (GtkWidget *widget,
if (palette && palette->entries)
{
GimpRGB color;
guchar r, g, b;
GimpRGB color;
if (active_color == FOREGROUND)
gimp_context_get_foreground (gimp_context_get_user (), &color);
else if (active_color == BACKGROUND)
gimp_context_get_background (gimp_context_get_user (), &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
palette->color = palette_entries_add_entry (palette->entries,
_("Untitled"),
r, g, b);
NULL,
&color);
palette_update_all (palette->entries);
}
@ -1096,20 +1102,16 @@ palette_dialog_edit_entry_callback (GtkWidget *widget,
gpointer data)
{
PaletteDialog *palette;
GimpRGB color;
guchar *col;
palette = data;
if (palette && palette->entries && palette->color)
{
col = palette->color->color;
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], 255);
if (!palette->color_notebook)
{
palette->color_notebook =
color_notebook_new ((const GimpRGB *) &color,
color_notebook_new (_("Edit Palette Color"),
(const GimpRGB *) &palette->color->color,
palette_select_callback, palette,
FALSE, FALSE);
palette->color_notebook_active = TRUE;
@ -1122,7 +1124,8 @@ palette_dialog_edit_entry_callback (GtkWidget *widget,
palette->color_notebook_active = TRUE;
}
color_notebook_set_color (palette->color_notebook, &color);
color_notebook_set_color (palette->color_notebook,
&palette->color->color);
}
}
}
@ -1169,11 +1172,17 @@ palette_dialog_delete_entry_callback (GtkWidget *widget,
}
if (palette->entries->n_colors == 0)
palette->color =
palette_entries_add_entry (palette->entries,
_("Black"), 0, 0, 0);
{
GimpRGB color;
palette_update_all (palette->entries);
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
palette->color = palette_entries_add_entry (palette->entries,
_("Black"),
&color);
palette_update_all (palette->entries);
}
}
}
@ -1245,7 +1254,6 @@ palette_dialog_color_area_events (GtkWidget *widget,
{
GdkEventButton *bevent;
GSList *tmp_link;
GimpRGB color;
gint entry_width;
gint entry_height;
gint row, col;
@ -1284,30 +1292,23 @@ palette_dialog_color_area_events (GtkWidget *widget,
}
palette->color = tmp_link->data;
/* Update either foreground or background colors */
gimp_rgba_set_uchar (&color,
palette->color->color[0],
palette->color->color[1],
palette->color->color[2],
255);
if (active_color == FOREGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_background (gimp_context_get_user (),
&color);
&palette->color->color);
else
gimp_context_set_foreground (gimp_context_get_user (),
&color);
&palette->color->color);
}
else if (active_color == BACKGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_foreground (gimp_context_get_user (),
&color);
&palette->color->color);
else
gimp_context_set_background (gimp_context_get_user (),
&color);
&palette->color->color);
}
palette_dialog_draw_entries (palette, row, col);
@ -1358,8 +1359,8 @@ palette_dialog_color_area_events (GtkWidget *widget,
/* functions for drawing & updating the palette dialog color area **********/
static int
palette_dialog_draw_color_row (guchar **colors,
gint ncolors,
palette_dialog_draw_color_row (guchar *colors,
gint n_colors,
gint y,
gint column_highlight,
guchar *buffer,
@ -1443,7 +1444,7 @@ palette_dialog_draw_color_row (guchar **colors,
if (vsize > 0)
{
p = buffer;
for (i = 0; i < ncolors; i++)
for (i = 0; i < n_colors; i++)
{
for (j = 0; j < SPACING; j++)
{
@ -1454,13 +1455,13 @@ palette_dialog_draw_color_row (guchar **colors,
for (j = 0; j < entry_width; j++)
{
*p++ = colors[i][0];
*p++ = colors[i][1];
*p++ = colors[i][2];
*p++ = colors[i * 3];
*p++ = colors[i * 3 + 1];
*p++ = colors[i * 3 + 2];
}
}
for (i = 0; i < (palette->columns - ncolors); i++)
for (i = 0; i < (palette->columns - n_colors); i++)
{
for (j = 0; j < (SPACING + entry_width); j++)
{
@ -1472,7 +1473,7 @@ palette_dialog_draw_color_row (guchar **colors,
for (j = 0; j < SPACING; j++)
{
if (ncolors == column_highlight)
if (n_colors == column_highlight)
{
*p++ = ~bcolor;
*p++ = ~bcolor;
@ -1519,7 +1520,7 @@ palette_dialog_draw_entries (PaletteDialog *palette,
{
PaletteEntry *entry;
guchar *buffer;
guchar **colors;
guchar *colors;
GSList *tmp_link;
gint width, height;
gint entry_width;
@ -1536,8 +1537,8 @@ palette_dialog_draw_entries (PaletteDialog *palette,
if (entry_width <= 0) return;
colors = g_malloc (sizeof (guchar *) * palette->columns * 3);
buffer = g_malloc (width * 3);
colors = g_new (guchar, palette->columns * 3);
buffer = g_new (guchar, width * 3);
if (row_start < 0)
{
@ -1558,7 +1559,10 @@ palette_dialog_draw_entries (PaletteDialog *palette,
entry = tmp_link->data;
tmp_link = tmp_link->next;
colors[index] = entry->color;
gimp_rgb_get_uchar (&entry->color,
&colors[index * 3],
&colors[index * 3 + 1],
&colors[index * 3 + 2]);
index++;
if (index == palette->columns)
@ -1899,9 +1903,7 @@ palette_dialog_merge_entries_callback (GtkWidget *widget,
PaletteEntry *entry = cols->data;
palette_entries_add_entry (new_entries,
entry->name,
entry->color[0],
entry->color[1],
entry->color[2]);
&entry->color);
cols = cols->next;
}
sel_list = sel_list->next;
@ -2005,15 +2007,11 @@ palette_dialog_drag_color (GtkWidget *widget,
if (palette && palette->entries && palette->dnd_color)
{
gimp_rgba_set_uchar (color,
(guchar) palette->dnd_color->color[0],
(guchar) palette->dnd_color->color[1],
(guchar) palette->dnd_color->color[2],
(guchar) 255);
*color = palette->dnd_color->color;
}
else
{
gimp_rgba_set_uchar (color, 0.0, 0.0, 0.0, 255.0);
gimp_rgba_set (color, 0.0, 0.0, 0.0, 1.0);
}
}
@ -2023,16 +2021,14 @@ palette_dialog_drop_color (GtkWidget *widget,
gpointer data)
{
PaletteDialog *palette;
guchar r, g, b;
palette = (PaletteDialog *) data;
if (palette && palette->entries)
{
gimp_rgb_get_uchar (color, &r, &g, &b);
palette->color =
palette_entries_add_entry (palette->entries, _("Untitled"), r, g, b);
palette->color = palette_entries_add_entry (palette->entries,
NULL,
(GimpRGB *) color);
palette_update_all (palette->entries);
}
@ -2468,16 +2464,24 @@ palette_import_image_sel_callback (GtkWidget *widget,
pdb_image_to_id (import_dialog->gimage));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
static void
palette_import_image_menu_add (GimpImage *gimage)
{
GtkWidget *menuitem;
gchar *lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
pdb_image_to_id (gimage));
gchar *lab;
lab= g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
pdb_image_to_id (gimage));
menuitem = gtk_menu_item_new_with_label (lab);
g_free (lab);
gtk_widget_show (menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC (palette_import_image_sel_callback),
@ -2569,12 +2573,16 @@ palette_import_image_menu_activate (gint redo,
/* reset to last one */
if (redo && act_num >= 0)
{
gchar *lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (import_dialog->gimage)),
pdb_image_to_id (import_dialog->gimage));
gchar *lab;
lab = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (import_dialog->gimage)),
pdb_image_to_id (import_dialog->gimage));
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu1), act_num);
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
}
g_slist_free (list);
@ -2584,6 +2592,8 @@ palette_import_image_menu_activate (gint redo,
pdb_image_to_id (import_dialog->gimage));
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
g_free (lab);
}
/* the import source menu item callbacks ***********************************/
@ -2739,7 +2749,6 @@ palette_import_create_from_grad (gchar *name)
/* Add names to entry */
gdouble dx, cur_x;
GimpRGB color;
guchar r, g, b;
gint sample_sz;
gint loop;
@ -2754,13 +2763,8 @@ palette_import_create_from_grad (gchar *name)
{
gradient_get_color_at (gradient, cur_x, &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
cur_x += dx;
palette_entries_add_entry (entries, _("Untitled"),
(gint) r,
(gint) g,
(gint) b);
palette_entries_add_entry (entries, NULL, &color);
}
palette_insert_all (entries);
@ -2881,10 +2885,14 @@ static void
palette_import_create_image_palette (gpointer data,
gpointer user_data)
{
PaletteEntries *entries = (PaletteEntries *) user_data;
ImgColors *color_tab = (ImgColors *) data;
gint sample_sz;
gchar *lab;
PaletteEntries *entries;
ImgColors *color_tab;
gint sample_sz;
gchar *lab;
GimpRGB color;
entries = (PaletteEntries *) user_data;
color_tab = (ImgColors *) data;
sample_sz = (gint) import_dialog->sample->value;
@ -2894,11 +2902,16 @@ palette_import_create_image_palette (gpointer data,
lab = g_strdup_printf ("%s (occurs %u)", _("Untitled"), color_tab->count);
/* Adjust the colors to the mean of the the sample */
palette_entries_add_entry
(entries, lab,
(gint) color_tab->r + (color_tab->r_adj / color_tab->count),
(gint) color_tab->g + (color_tab->g_adj / color_tab->count),
(gint) color_tab->b + (color_tab->b_adj / color_tab->count));
gimp_rgba_set_uchar
(&color,
(guchar) color_tab->r + (color_tab->r_adj / color_tab->count),
(guchar) color_tab->g + (color_tab->g_adj / color_tab->count),
(guchar) color_tab->b + (color_tab->b_adj / color_tab->count),
255);
palette_entries_add_entry (entries, lab, &color);
g_free (lab);
}
static gboolean
@ -3025,7 +3038,9 @@ palette_import_create_from_indexed (GImage *gimage,
gchar *pname)
{
PaletteEntries *entries;
gint samples, count;
gint samples;
gint count;
GimpRGB color;
samples = (gint) import_dialog->sample->value;
@ -3039,10 +3054,13 @@ palette_import_create_from_indexed (GImage *gimage,
for (count= 0; count < samples && count < gimage->num_cols; ++count)
{
palette_entries_add_entry (entries, NULL,
gimage->cmap[count*3],
gimage->cmap[count*3+1],
gimage->cmap[count*3+2]);
gimp_rgba_set_uchar (&color,
gimage->cmap[count*3],
gimage->cmap[count*3+1],
gimage->cmap[count*3+2],
255);
palette_entries_add_entry (entries, NULL, &color);
}
palette_insert_all (entries);

View File

@ -39,6 +39,9 @@
#include "gdisplay_color.h"
#endif /* DISPLAY_FILTERS */
#include "libgimp/gimpintl.h"
typedef enum
{
FORE_AREA,
@ -273,7 +276,8 @@ color_area_draw (void)
}
static void
color_area_select_callback (const GimpRGB *color,
color_area_select_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer client_data)
{
@ -323,7 +327,8 @@ color_area_edit (void)
if (! color_notebook)
{
color_notebook = color_notebook_new ((const GimpRGB *) &color,
color_notebook = color_notebook_new (_("Color Selection"),
(const GimpRGB *) &color,
color_area_select_callback,
NULL, TRUE, FALSE);
color_notebook_active = TRUE;

View File

@ -15,6 +15,7 @@ app/channel.c
app/channel_ops.c
app/channels_dialog.c
app/clone.c
app/color_area.c
app/color_balance.c
app/color_notebook.c
app/color_picker.c