Commit 8447e775 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

Bug 783680 - Allow to hide color models in GimpColorScales

Redo the entire thing again:

- Rename the values of enum GimpColorSelectorModel to include "MODEL"
- Change GimpColorSelector API from set_model() to set_model_visible()
  so visibility of each model can be toggled individually and is not
  exclusive any longer
- The GUI is back to what it was before, except that the "GIMP" page
  now honors the model visibility and has a resonable minimum height
parent 8f71aeda
......@@ -68,6 +68,10 @@ static void gimp_color_notebook_set_color (GimpColorSelector *selector,
const GimpHSV *hsv);
static void gimp_color_notebook_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel);
static void gimp_color_notebook_set_model_visible
(GimpColorSelector *selector,
GimpColorSelectorModel model,
gboolean gboolean);
static void gimp_color_notebook_set_config (GimpColorSelector *selector,
GimpColorConfig *config);
......@@ -84,6 +88,11 @@ static void gimp_color_notebook_color_changed (GimpColorSelector *page,
static void gimp_color_notebook_channel_changed (GimpColorSelector *page,
GimpColorSelectorChannel channel,
GimpColorNotebook *notebook);
static void gimp_color_notebook_model_visible_changed
(GimpColorSelector *page,
GimpColorSelectorModel model,
gboolean visible,
GimpColorNotebook *notebook);
static GtkWidget * gimp_color_notebook_add_page (GimpColorNotebook *notebook,
GType page_type);
......@@ -113,6 +122,7 @@ gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
selector_class->set_show_alpha = gimp_color_notebook_set_show_alpha;
selector_class->set_color = gimp_color_notebook_set_color;
selector_class->set_channel = gimp_color_notebook_set_channel;
selector_class->set_model_visible = gimp_color_notebook_set_model_visible;
selector_class->set_config = gimp_color_notebook_set_config;
gtk_widget_class_install_style_property (widget_class,
......@@ -122,6 +132,7 @@ gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
0, G_MAXINT,
DEFAULT_TAB_BORDER,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("tab-icon-size",
NULL,
......@@ -292,6 +303,24 @@ gimp_color_notebook_set_channel (GimpColorSelector *selector,
notebook);
}
static void
gimp_color_notebook_set_model_visible (GimpColorSelector *selector,
GimpColorSelectorModel model,
gboolean visible)
{
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
g_signal_handlers_block_by_func (notebook->cur_page,
gimp_color_notebook_model_visible_changed,
notebook);
gimp_color_selector_set_model_visible (notebook->cur_page, model, visible);
g_signal_handlers_unblock_by_func (notebook->cur_page,
gimp_color_notebook_model_visible_changed,
notebook);
}
static void
gimp_color_notebook_set_config (GimpColorSelector *selector,
GimpColorConfig *config)
......@@ -313,8 +342,9 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
guint page_num,
GimpColorNotebook *notebook)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
GtkWidget *page_widget;
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
GtkWidget *page_widget;
GimpColorSelectorModel model;
page_widget = gtk_notebook_get_nth_page (gtk_notebook, page_num);
......@@ -326,6 +356,9 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
g_signal_handlers_block_by_func (notebook->cur_page,
gimp_color_notebook_channel_changed,
notebook);
g_signal_handlers_block_by_func (notebook->cur_page,
gimp_color_notebook_model_visible_changed,
notebook);
gimp_color_selector_set_color (notebook->cur_page,
&selector->rgb,
......@@ -333,12 +366,25 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
gimp_color_selector_set_channel (notebook->cur_page,
gimp_color_selector_get_channel (selector));
for (model = GIMP_COLOR_SELECTOR_MODEL_RGB;
model <= GIMP_COLOR_SELECTOR_MODEL_HSV;
model++)
{
gboolean visible = gimp_color_selector_get_model_visible (selector, model);
gimp_color_selector_set_model_visible (notebook->cur_page, model,
visible);
}
g_signal_handlers_unblock_by_func (notebook->cur_page,
gimp_color_notebook_color_changed,
notebook);
g_signal_handlers_unblock_by_func (notebook->cur_page,
gimp_color_notebook_channel_changed,
notebook);
g_signal_handlers_unblock_by_func (notebook->cur_page,
gimp_color_notebook_model_visible_changed,
notebook);
}
static void
......@@ -365,6 +411,17 @@ gimp_color_notebook_channel_changed (GimpColorSelector *page,
gimp_color_selector_set_channel (selector, channel);
}
static void
gimp_color_notebook_model_visible_changed (GimpColorSelector *page,
GimpColorSelectorModel model,
gboolean visible,
GimpColorNotebook *notebook)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
gimp_color_selector_set_model_visible (selector, model, visible);
}
static GtkWidget *
gimp_color_notebook_add_page (GimpColorNotebook *notebook,
GType page_type)
......@@ -420,6 +477,9 @@ gimp_color_notebook_add_page (GimpColorNotebook *notebook,
g_signal_connect (page, "channel-changed",
G_CALLBACK (gimp_color_notebook_channel_changed),
notebook);
g_signal_connect (page, "model-visible-changed",
G_CALLBACK (gimp_color_notebook_model_visible_changed),
notebook);
return page;
}
......
......@@ -104,6 +104,8 @@ struct _GimpColorScales
gboolean show_rgb_u8;
GtkWidget *lch_group;
GtkWidget *hsv_group;
GtkWidget *rgb_percent_group;
GtkWidget *rgb_u8_group;
GtkWidget *alpha_percent_group;
......@@ -143,6 +145,10 @@ static void gimp_color_scales_set_color (GimpColorSelector *selector,
const GimpHSV *hsv);
static void gimp_color_scales_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel);
static void gimp_color_scales_set_model_visible
(GimpColorSelector *selector,
GimpColorSelectorModel model,
gboolean visible);
static void gimp_color_scales_set_config (GimpColorSelector *selector,
GimpColorConfig *config);
......@@ -153,13 +159,8 @@ static void gimp_color_scales_toggle_changed (GtkWidget *widget,
GimpColorScales *scales);
static void gimp_color_scales_scale_changed (GtkAdjustment *adjustment,
GimpColorScales *scales);
static void gimp_color_scales_switch_page (GtkNotebook *notebook,
GtkWidget *page,
gint num,
static void gimp_color_scales_toggle_lch_hsv (GtkToggleButton *toggle,
GimpColorScales *scales);
static void gimp_color_scales_model_changed (GimpColorSelector *selector,
GimpColorSelectorModel model,
GtkNotebook *notebook);
G_DEFINE_TYPE (GimpColorScales, gimp_color_scales, GIMP_TYPE_COLOR_SELECTOR)
......@@ -209,6 +210,7 @@ gimp_color_scales_class_init (GimpColorScalesClass *klass)
selector_class->set_show_alpha = gimp_color_scales_set_show_alpha;
selector_class->set_color = gimp_color_scales_set_color;
selector_class->set_channel = gimp_color_scales_set_channel;
selector_class->set_model_visible = gimp_color_scales_set_model_visible;
selector_class->set_config = gimp_color_scales_set_config;
g_object_class_install_property (object_class, PROP_SHOW_RGB_U8,
......@@ -220,9 +222,9 @@ gimp_color_scales_class_init (GimpColorScalesClass *klass)
G_PARAM_CONSTRUCT));
fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
babl_format ("CIE LCH(ab) double"));
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
babl_format ("R'G'B' double"));
babl_format ("CIE LCH(ab) alpha double"));
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) alpha double"),
babl_format ("R'G'B'A double"));
}
static GtkWidget *
......@@ -354,9 +356,7 @@ gimp_color_scales_init (GimpColorScales *scales)
GtkSizeGroup *size_group0;
GtkSizeGroup *size_group1;
GtkSizeGroup *size_group2;
GtkWidget *notebook;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *radio1;
GtkWidget *radio2;
GtkWidget *table;
......@@ -366,22 +366,16 @@ gimp_color_scales_init (GimpColorScales *scales)
gtk_box_set_spacing (GTK_BOX (scales), 5);
/* don't needs the toggles for our own operation */
/* don't need the toggles for our own operation */
selector->toggles_visible = FALSE;
notebook = gtk_notebook_new ();
gtk_widget_show (notebook);
gtk_box_pack_start (GTK_BOX (scales), notebook, 0, 0, FALSE);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_pack_start (GTK_BOX (scales), hbox, 0, 0, FALSE);
gtk_widget_show (hbox);
main_group = NULL;
u8_group = NULL;
/* RGB page. */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (vbox);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, NULL);
gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (notebook), vbox, _("RGB"));
scales->dummy_u8_toggle = gtk_radio_button_new (NULL);
g_object_ref_sink (scales->dummy_u8_toggle);
u8_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->dummy_u8_toggle));
......@@ -395,21 +389,48 @@ gimp_color_scales_init (GimpColorScales *scales)
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_RED,
GIMP_COLOR_SELECTOR_BLUE);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
scales->rgb_u8_group =
table = create_group (scales, &u8_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_RED_U8,
GIMP_COLOR_SELECTOR_BLUE_U8);
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
/* U8/percent buttons. */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, 0, 0, FALSE);
gtk_widget_show (hbox);
scales->lch_group =
table = create_group (scales, &main_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_LCH_LIGHTNESS,
GIMP_COLOR_SELECTOR_LCH_HUE);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
scales->hsv_group =
table = create_group (scales, &main_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_HUE,
GIMP_COLOR_SELECTOR_VALUE);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
scales->alpha_percent_group =
table = create_group (scales, &main_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_ALPHA,
GIMP_COLOR_SELECTOR_ALPHA);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
scales->alpha_u8_group =
table = create_group (scales, &u8_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_ALPHA_U8,
GIMP_COLOR_SELECTOR_ALPHA_U8);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
g_object_unref (size_group0);
g_object_unref (size_group1);
g_object_unref (size_group2);
gimp_color_scales_update_visible (scales);
radio_group = NULL;
......@@ -434,55 +455,28 @@ gimp_color_scales_init (GimpColorScales *scales)
G_BINDING_SYNC_CREATE |
G_BINDING_BIDIRECTIONAL);
/* LCH page. */
table = create_group (scales, &main_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_LCH_LIGHTNESS,
GIMP_COLOR_SELECTOR_LCH_HUE);
gtk_widget_show (table);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, NULL);
gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (notebook), table, _("LCH"));
/* HSV page. */
table = create_group (scales, &main_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_HUE,
GIMP_COLOR_SELECTOR_VALUE);
gtk_widget_show (table);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, NULL);
gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (notebook), table, _("HSV"));
radio_group = NULL;
scales->alpha_percent_group =
table = create_group (scales, &main_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_ALPHA,
GIMP_COLOR_SELECTOR_ALPHA);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
radio1 = gtk_radio_button_new_with_label (NULL, _("LCH"));
radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));
radio2 = gtk_radio_button_new_with_label (radio_group, _("HSV"));
scales->alpha_u8_group =
table = create_group (scales, &u8_group,
size_group0, size_group1, size_group2,
GIMP_COLOR_SELECTOR_ALPHA_U8,
GIMP_COLOR_SELECTOR_ALPHA_U8);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio1), FALSE);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio2), FALSE);
g_object_unref (size_group0);
g_object_unref (size_group1);
g_object_unref (size_group2);
gtk_box_pack_end (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
/* This works because we ordered the notebook tabs in the same order
* as the GimpColorSelectorModel enum.
*/
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
(gint) gimp_color_selector_get_model (selector));
g_signal_connect (notebook, "switch-page",
G_CALLBACK (gimp_color_scales_switch_page),
scales);
g_signal_connect (scales, "model-changed",
G_CALLBACK (gimp_color_scales_model_changed),
notebook);
gtk_widget_show (radio1);
gtk_widget_show (radio2);
gimp_color_scales_update_visible (scales);
if (gimp_color_selector_get_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_HSV))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio2), TRUE);
g_signal_connect (radio1, "toggled",
G_CALLBACK (gimp_color_scales_toggle_lch_hsv),
scales);
}
static void
......@@ -597,6 +591,14 @@ gimp_color_scales_set_channel (GimpColorSelector *selector,
}
}
static void
gimp_color_scales_set_model_visible (GimpColorSelector *selector,
GimpColorSelectorModel model,
gboolean visible)
{
gimp_color_scales_update_visible (GIMP_COLOR_SCALES (selector));
}
static void
gimp_color_scales_set_config (GimpColorSelector *selector,
GimpColorConfig *config)
......@@ -615,7 +617,6 @@ gimp_color_scales_set_config (GimpColorSelector *selector,
/* public functions */
void
gimp_color_scales_set_show_rgb_u8 (GimpColorScales *scales,
gboolean show_rgb_u8)
......@@ -650,11 +651,25 @@ gimp_color_scales_update_visible (GimpColorScales *scales)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
gboolean show_alpha;
show_alpha = gimp_color_selector_get_show_alpha (selector);
gtk_widget_set_visible (scales->rgb_percent_group, ! scales->show_rgb_u8);
gtk_widget_set_visible (scales->rgb_u8_group, scales->show_rgb_u8);
gboolean rgb_visible;
gboolean lch_visible;
gboolean hsv_visible;
show_alpha = gimp_color_selector_get_show_alpha (selector);
rgb_visible = gimp_color_selector_get_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_RGB);
lch_visible = gimp_color_selector_get_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_LCH);
hsv_visible = gimp_color_selector_get_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_HSV);
gtk_widget_set_visible (scales->rgb_percent_group,
rgb_visible && ! scales->show_rgb_u8);
gtk_widget_set_visible (scales->rgb_u8_group,
rgb_visible && scales->show_rgb_u8);
gtk_widget_set_visible (scales->lch_group, lch_visible);
gtk_widget_set_visible (scales->hsv_group, hsv_visible);
gtk_widget_set_visible (scales->alpha_percent_group,
show_alpha && ! scales->show_rgb_u8);
......@@ -843,25 +858,27 @@ gimp_color_scales_scale_changed (GtkAdjustment *adjustment,
}
static void
gimp_color_scales_switch_page (GtkNotebook *notebook,
GtkWidget *page,
gint num,
GimpColorScales *scales)
gimp_color_scales_toggle_lch_hsv (GtkToggleButton *toggle,
GimpColorScales *scales)
{
/* This works because we ordered the notebook tabs in the same order
* as the GimpColorSelectorModel enum.
*/
gimp_color_selector_set_model (GIMP_COLOR_SELECTOR (scales),
(GimpColorSelectorModel) num);
}
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
static void
gimp_color_scales_model_changed (GimpColorSelector *selector,
GimpColorSelectorModel model,
GtkNotebook *notebook)
{
if (gtk_notebook_get_current_page (notebook) != (gint) model)
if (gtk_toggle_button_get_active (toggle))
{
gimp_color_selector_set_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_LCH,
TRUE);
gimp_color_selector_set_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_HSV,
FALSE);
}
else
{
gtk_notebook_set_current_page (notebook, (gint) model);
gimp_color_selector_set_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_LCH,
FALSE);
gimp_color_selector_set_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_HSV,
TRUE);
}
}
......@@ -192,6 +192,10 @@ static void gimp_color_select_set_color (GimpColorSelector *selector,
const GimpHSV *hsv);
static void gimp_color_select_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel);
static void gimp_color_select_set_model_visible
(GimpColorSelector *selector,
GimpColorSelectorModel model,
gboolean visible);
static void gimp_color_select_set_config (GimpColorSelector *selector,
GimpColorConfig *config);
......@@ -270,13 +274,6 @@ static void gimp_color_select_notify_config (GimpColorConfig *config,
const GParamSpec *pspec,
GimpColorSelect *select);
static void gimp_color_select_switch_page (GtkNotebook *notebook,
GtkWidget *page,
gint num,
GimpColorSelect *select);
static void gimp_color_select_model_changed (GimpColorSelector *selector,
GimpColorSelectorModel model,
GtkNotebook *color_model_notebook);
G_DEFINE_TYPE (GimpColorSelect, gimp_color_select, GIMP_TYPE_COLOR_SELECTOR)
......@@ -330,6 +327,7 @@ gimp_color_select_class_init (GimpColorSelectClass *klass)
selector_class->set_toggles_sensitive = gimp_color_select_togg_sensitive;
selector_class->set_color = gimp_color_select_set_color;
selector_class->set_channel = gimp_color_select_set_channel;
selector_class->set_model_visible = gimp_color_select_set_model_visible;
selector_class->set_config = gimp_color_select_set_config;
fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
......@@ -346,11 +344,12 @@ gimp_color_select_init (GimpColorSelect *select)
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *notebook;
GtkWidget *vbox;
GEnumClass *model_class;
GEnumClass *channel_class;
GimpEnumDesc *enum_desc;
GimpColorSelectorModel model;
GSList *group = NULL;
/* Default values. */
select->z_color_fill = COLOR_SELECT_HUE;
......@@ -419,99 +418,82 @@ gimp_color_select_init (GimpColorSelect *select)
G_CALLBACK (gimp_color_select_z_events),
select);
notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_RIGHT);
gtk_widget_show (notebook);
gtk_box_pack_start (GTK_BOX (hbox), notebook, FALSE, FALSE, 0);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
model_class = g_type_class_ref (GIMP_TYPE_COLOR_SELECTOR_MODEL);
channel_class = g_type_class_ref (GIMP_TYPE_COLOR_SELECTOR_CHANNEL);
for (model = GIMP_COLOR_SELECTOR_RGB;
model <= GIMP_COLOR_SELECTOR_HSV;
for (model = GIMP_COLOR_SELECTOR_MODEL_RGB;
model <= GIMP_COLOR_SELECTOR_MODEL_HSV;
model++)
{
GtkWidget *label;
enum_desc = gimp_enum_get_desc (model_class, model);
select->toggle_box[model] = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_widget_show (select->toggle_box[model]);
gtk_box_pack_start (GTK_BOX (vbox), select->toggle_box[model],
FALSE, FALSE, 0);
label = gtk_label_new (gettext (enum_desc->value_desc));
gtk_label_set_angle (GTK_LABEL (label), 270.0);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
select->toggle_box[model],
label);
gimp_help_set_help_data (gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook),
select->toggle_box[model]),
gettext (enum_desc->value_help), NULL);
if (gimp_color_selector_get_model_visible (selector, model))
gtk_widget_show (select->toggle_box[model]);
/* channel toggles */
{
GimpColorSelectorChannel channel = GIMP_COLOR_SELECTOR_RED;
GimpColorSelectorChannel end_channel;
GSList *group = NULL;
switch (model)
{
case GIMP_COLOR_SELECTOR_RGB:
channel = GIMP_COLOR_SELECTOR_RED;
break;
case GIMP_COLOR_SELECTOR_LCH:
channel = GIMP_COLOR_SELECTOR_LCH_LIGHTNESS;
break;
case GIMP_COLOR_SELECTOR_HSV:
channel = GIMP_COLOR_SELECTOR_HUE;
break;
default:
/* Should not happen. */
g_return_if_reached ();
break;
}
end_channel = channel + 3;
for (; channel < end_channel; channel++)
{
GtkWidget *button;
enum_desc = gimp_enum_get_desc (channel_class, channel);
button = gtk_radio_button_new_with_mnemonic (group,
gettext (enum_desc->value_desc));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_box_pack_start (GTK_BOX (select->toggle_box[model]), button,
TRUE, TRUE, 0);
gtk_widget_show (button);
g_object_set_data (G_OBJECT (button), "channel",
GINT_TO_POINTER (channel));
if (channel == gimp_color_selector_get_channel (selector))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gimp_help_set_help_data (button, gettext (enum_desc->value_help), NULL);
g_signal_connect (button, "toggled",
G_CALLBACK (gimp_color_select_channel_toggled),
select);
}
}
{
GimpColorSelectorChannel channel = GIMP_COLOR_SELECTOR_RED;
GimpColorSelectorChannel end_channel;
switch (model)
{
case GIMP_COLOR_SELECTOR_MODEL_RGB:
channel = GIMP_COLOR_SELECTOR_RED;
break;
case GIMP_COLOR_SELECTOR_MODEL_LCH:
channel = GIMP_COLOR_SELECTOR_LCH_LIGHTNESS;
break;
case GIMP_COLOR_SELECTOR_MODEL_HSV:
channel = GIMP_COLOR_SELECTOR_HUE;
break;
default:
/* Should not happen. */
g_return_if_reached ();
break;
}