[gimp] libgimpwidgets: several GimpColorSelector cleanups / changes
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: several GimpColorSelector cleanups / changes
- Date: Sun, 31 Dec 2017 18:06:38 +0000 (UTC)
commit 1e99b12abadd7dd0414f635109d1e67e18a4a81d
Author: Michael Natterer <mitch gimp org>
Date: Sun Dec 31 19:04:17 2017 +0100
libgimpwidgets: several GimpColorSelector cleanups / changes
- make RED the default channel and reorder RGB before LCH/HSV
- use more of the new getters
- also use more of the previously existing setters
libgimpwidgets/gimpcolornotebook.c | 8 ++---
libgimpwidgets/gimpcolorscales.c | 61 +++++++++++++++++++----------------
libgimpwidgets/gimpcolorselect.c | 7 +---
libgimpwidgets/gimpcolorselection.c | 2 +-
libgimpwidgets/gimpcolorselector.c | 4 +-
5 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolornotebook.c b/libgimpwidgets/gimpcolornotebook.c
index 29e31a7..74823b1 100644
--- a/libgimpwidgets/gimpcolornotebook.c
+++ b/libgimpwidgets/gimpcolornotebook.c
@@ -331,7 +331,7 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
&selector->rgb,
&selector->hsv);
gimp_color_selector_set_channel (notebook->cur_page,
- selector->channel);
+ gimp_color_selector_get_channel (selector));
g_signal_handlers_unblock_by_func (notebook->cur_page,
gimp_color_notebook_color_changed,
@@ -362,9 +362,7 @@ gimp_color_notebook_channel_changed (GimpColorSelector *page,
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
- selector->channel = channel;
-
- gimp_color_selector_channel_changed (selector);
+ gimp_color_selector_set_channel (selector, channel);
}
static GtkWidget *
@@ -382,7 +380,7 @@ gimp_color_notebook_add_page (GimpColorNotebook *notebook,
page = gimp_color_selector_new (page_type,
&selector->rgb,
&selector->hsv,
- selector->channel);
+ gimp_color_selector_get_channel (selector));
if (! page)
return NULL;
diff --git a/libgimpwidgets/gimpcolorscales.c b/libgimpwidgets/gimpcolorscales.c
index d463e8d..ea8a1f9 100644
--- a/libgimpwidgets/gimpcolorscales.c
+++ b/libgimpwidgets/gimpcolorscales.c
@@ -278,6 +278,10 @@ create_group (GimpColorScales *scales,
*radio_group =
gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->toggles[i]));
+ if (enum_value == gimp_color_selector_get_channel (selector))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scales->toggles[i]),
+ TRUE);
+
if (is_u8)
{
/* bind the RGB U8 toggles to the RGB percent toggles */
@@ -298,7 +302,7 @@ create_group (GimpColorScales *scales,
0, 1, row, row + 1,
GTK_SHRINK, GTK_EXPAND, 0, 0);
- if (selector->toggles_visible)
+ if (gimp_color_selector_get_toggles_visible (selector))
gtk_widget_show (scales->toggles[i]);
gimp_help_set_help_data (scales->toggles[i],
@@ -382,20 +386,6 @@ gimp_color_scales_init (GimpColorScales *scales)
size_group1 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
size_group2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- scales->lch_group =
- table = create_group (scales, &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, &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->rgb_percent_group =
table = create_group (scales, &group,
size_group0, size_group1, size_group2,
@@ -410,6 +400,20 @@ gimp_color_scales_init (GimpColorScales *scales)
GIMP_COLOR_SELECTOR_BLUE_U8);
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
+ scales->lch_group =
+ table = create_group (scales, &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, &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, &group,
size_group0, size_group1, size_group2,
@@ -432,9 +436,9 @@ gimp_color_scales_init (GimpColorScales *scales)
group = NULL;
- radio1 = gtk_radio_button_new_with_label (NULL, _("LCH"));
+ radio1 = gtk_radio_button_new_with_label (NULL, _("0..100"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));
- radio2 = gtk_radio_button_new_with_label (group, _("HSV"));
+ radio2 = gtk_radio_button_new_with_label (group, _("0..255"));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio1), FALSE);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio2), FALSE);
@@ -445,19 +449,19 @@ gimp_color_scales_init (GimpColorScales *scales)
gtk_widget_show (radio1);
gtk_widget_show (radio2);
- if (scales->show_hsv)
+ if (scales->show_rgb_u8)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio2), TRUE);
g_object_bind_property (G_OBJECT (radio2), "active",
- G_OBJECT (scales), "show-hsv",
+ G_OBJECT (scales), "show-rgb-u8",
G_BINDING_SYNC_CREATE |
G_BINDING_BIDIRECTIONAL);
group = NULL;
- radio1 = gtk_radio_button_new_with_label (NULL, _("0..100"));
+ radio1 = gtk_radio_button_new_with_label (NULL, _("LCH"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));
- radio2 = gtk_radio_button_new_with_label (group, _("0..255"));
+ radio2 = gtk_radio_button_new_with_label (group, _("HSV"));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio1), FALSE);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio2), FALSE);
@@ -468,11 +472,11 @@ gimp_color_scales_init (GimpColorScales *scales)
gtk_widget_show (radio1);
gtk_widget_show (radio2);
- if (scales->show_rgb_u8)
+ if (scales->show_hsv)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio2), TRUE);
g_object_bind_property (G_OBJECT (radio2), "active",
- G_OBJECT (scales), "show-rgb-u8",
+ G_OBJECT (scales), "show-hsv",
G_BINDING_SYNC_CREATE |
G_BINDING_BIDIRECTIONAL);
}
@@ -690,6 +694,9 @@ static void
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->lch_group, ! scales->show_hsv);
gtk_widget_set_visible (scales->hsv_group, scales->show_hsv);
@@ -698,9 +705,9 @@ gimp_color_scales_update_visible (GimpColorScales *scales)
gtk_widget_set_visible (scales->rgb_u8_group, scales->show_rgb_u8);
gtk_widget_set_visible (scales->alpha_percent_group,
- selector->show_alpha && ! scales->show_rgb_u8);
+ show_alpha && ! scales->show_rgb_u8);
gtk_widget_set_visible (scales->alpha_u8_group,
- selector->show_alpha && scales->show_rgb_u8);
+ show_alpha && scales->show_rgb_u8);
}
static void
@@ -766,7 +773,7 @@ gimp_color_scales_toggle_changed (GtkWidget *widget,
{
if (widget == scales->toggles[i])
{
- selector->channel = (GimpColorSelectorChannel) i;
+ gimp_color_selector_set_channel (selector, i);
if (i < GIMP_COLOR_SELECTOR_RED ||
i > GIMP_COLOR_SELECTOR_BLUE)
@@ -778,8 +785,6 @@ gimp_color_scales_toggle_changed (GtkWidget *widget,
break;
}
}
-
- gimp_color_selector_channel_changed (selector);
}
}
diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c
index 882712b..ba8fb15 100644
--- a/libgimpwidgets/gimpcolorselect.c
+++ b/libgimpwidgets/gimpcolorselect.c
@@ -441,7 +441,7 @@ gimp_color_select_init (GimpColorSelect *select)
g_object_set_data (G_OBJECT (button), "channel",
GINT_TO_POINTER (channel));
- if (channel == selector->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);
@@ -608,10 +608,7 @@ gimp_color_select_channel_toggled (GtkWidget *widget,
channel = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"channel"));
- selector->channel = channel;
- gimp_color_select_set_channel (selector, channel);
-
- gimp_color_selector_channel_changed (selector);
+ gimp_color_selector_set_channel (selector, channel);
}
}
diff --git a/libgimpwidgets/gimpcolorselection.c b/libgimpwidgets/gimpcolorselection.c
index c190b73..4de60a9 100644
--- a/libgimpwidgets/gimpcolorselection.c
+++ b/libgimpwidgets/gimpcolorselection.c
@@ -169,7 +169,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
gimp_rgba_set (&selection->rgb, 0.0, 0.0, 0.0, 1.0);
gimp_rgb_to_hsv (&selection->rgb, &selection->hsv);
- selection->channel = GIMP_COLOR_SELECTOR_HUE;
+ selection->channel = GIMP_COLOR_SELECTOR_RED;
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (selection), main_hbox, TRUE, TRUE, 0);
diff --git a/libgimpwidgets/gimpcolorselector.c b/libgimpwidgets/gimpcolorselector.c
index d86021a..99f5b9f 100644
--- a/libgimpwidgets/gimpcolorselector.c
+++ b/libgimpwidgets/gimpcolorselector.c
@@ -122,7 +122,7 @@ gimp_color_selector_init (GimpColorSelector *selector)
gimp_rgba_set (&selector->rgb, 0.0, 0.0, 0.0, 1.0);
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
- selector->channel = GIMP_COLOR_SELECTOR_HUE;
+ selector->channel = GIMP_COLOR_SELECTOR_RED;
}
static void
@@ -410,7 +410,7 @@ GimpColorSelectorChannel
gimp_color_selector_get_channel (GimpColorSelector *selector)
{
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector),
- GIMP_COLOR_SELECTOR_HUE);
+ GIMP_COLOR_SELECTOR_RED);
return selector->channel;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]