Commit f96d3776 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

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
parent c31d2639
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.
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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,7 +47,11 @@ 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);
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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;