mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
libgimpwidgets: GimpColorSelection made final.
This commit is contained in:
parent
95b1963723
commit
8822ca71a2
2 changed files with 120 additions and 214 deletions
|
@ -80,8 +80,10 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpColorSelectionPrivate
|
struct _GimpColorSelection
|
||||||
{
|
{
|
||||||
|
GtkBox parent_instance;
|
||||||
|
|
||||||
gboolean show_alpha;
|
gboolean show_alpha;
|
||||||
|
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
|
@ -95,7 +97,7 @@ typedef struct _GimpColorSelectionPrivate
|
||||||
|
|
||||||
GtkWidget *new_color;
|
GtkWidget *new_color;
|
||||||
GtkWidget *old_color;
|
GtkWidget *old_color;
|
||||||
} GimpColorSelectionPrivate;
|
};
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_selection_finalize (GObject *object);
|
static void gimp_color_selection_finalize (GObject *object);
|
||||||
|
@ -129,8 +131,7 @@ static void gimp_color_selection_update (GimpColorSelection *select
|
||||||
UpdateType update);
|
UpdateType update);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorSelection, gimp_color_selection,
|
G_DEFINE_TYPE (GimpColorSelection, gimp_color_selection, GTK_TYPE_BOX)
|
||||||
GTK_TYPE_BOX)
|
|
||||||
|
|
||||||
#define parent_class gimp_color_selection_parent_class
|
#define parent_class gimp_color_selection_parent_class
|
||||||
|
|
||||||
|
@ -145,8 +146,6 @@ gimp_color_selection_class_init (GimpColorSelectionClass *klass)
|
||||||
object_class->finalize = gimp_color_selection_finalize;
|
object_class->finalize = gimp_color_selection_finalize;
|
||||||
object_class->set_property = gimp_color_selection_set_property;
|
object_class->set_property = gimp_color_selection_set_property;
|
||||||
|
|
||||||
klass->color_changed = NULL;
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_CONFIG,
|
g_object_class_install_property (object_class, PROP_CONFIG,
|
||||||
g_param_spec_object ("config",
|
g_param_spec_object ("config",
|
||||||
"Config",
|
"Config",
|
||||||
|
@ -158,7 +157,7 @@ gimp_color_selection_class_init (GimpColorSelectionClass *klass)
|
||||||
g_signal_new ("color-changed",
|
g_signal_new ("color-changed",
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (GimpColorSelectionClass, color_changed),
|
0,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
@ -168,36 +167,33 @@ gimp_color_selection_class_init (GimpColorSelectionClass *klass)
|
||||||
static void
|
static void
|
||||||
gimp_color_selection_init (GimpColorSelection *selection)
|
gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GtkWidget *main_hbox;
|
||||||
GtkWidget *main_hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *hbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *vbox;
|
GtkWidget *frame;
|
||||||
GtkWidget *frame;
|
GtkWidget *label;
|
||||||
GtkWidget *label;
|
GtkWidget *entry;
|
||||||
GtkWidget *entry;
|
GtkWidget *button;
|
||||||
GtkWidget *button;
|
GtkSizeGroup *new_group;
|
||||||
GtkSizeGroup *new_group;
|
GtkSizeGroup *old_group;
|
||||||
GtkSizeGroup *old_group;
|
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
selection->show_alpha = TRUE;
|
||||||
|
|
||||||
priv->show_alpha = TRUE;
|
|
||||||
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
||||||
GTK_ORIENTATION_VERTICAL);
|
GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
priv->color = gegl_color_new ("black");
|
selection->color = gegl_color_new ("black");
|
||||||
priv->channel = GIMP_COLOR_SELECTOR_HUE;
|
selection->channel = GIMP_COLOR_SELECTOR_HUE;
|
||||||
|
|
||||||
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (selection), main_hbox, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (selection), main_hbox, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (main_hbox);
|
gtk_widget_show (main_hbox);
|
||||||
|
|
||||||
/* The left vbox with the notebook */
|
/* The left vbox with the notebook */
|
||||||
priv->left_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
selection->left_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (main_hbox), priv->left_vbox,
|
gtk_box_pack_start (GTK_BOX (main_hbox), selection->left_vbox,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (priv->left_vbox);
|
gtk_widget_show (selection->left_vbox);
|
||||||
|
|
||||||
if (_gimp_ensure_modules_func)
|
if (_gimp_ensure_modules_func)
|
||||||
{
|
{
|
||||||
|
@ -205,28 +201,28 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
_gimp_ensure_modules_func ();
|
_gimp_ensure_modules_func ();
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK, priv->color, priv->channel);
|
selection->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK, selection->color, selection->channel);
|
||||||
|
|
||||||
if (_gimp_ensure_modules_func)
|
if (_gimp_ensure_modules_func)
|
||||||
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
||||||
|
|
||||||
gimp_color_selector_set_toggles_visible
|
gimp_color_selector_set_toggles_visible
|
||||||
(GIMP_COLOR_SELECTOR (priv->notebook), FALSE);
|
(GIMP_COLOR_SELECTOR (selection->notebook), FALSE);
|
||||||
gtk_box_pack_start (GTK_BOX (priv->left_vbox), priv->notebook,
|
gtk_box_pack_start (GTK_BOX (selection->left_vbox), selection->notebook,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (priv->notebook);
|
gtk_widget_show (selection->notebook);
|
||||||
|
|
||||||
g_signal_connect (priv->notebook, "color-changed",
|
g_signal_connect (selection->notebook, "color-changed",
|
||||||
G_CALLBACK (gimp_color_selection_notebook_changed),
|
G_CALLBACK (gimp_color_selection_notebook_changed),
|
||||||
selection);
|
selection);
|
||||||
g_signal_connect (gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (priv->notebook)),
|
g_signal_connect (gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (selection->notebook)),
|
||||||
"switch-page",
|
"switch-page",
|
||||||
G_CALLBACK (gimp_color_selection_switch_page),
|
G_CALLBACK (gimp_color_selection_switch_page),
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
/* The hbox for the color_areas */
|
/* The hbox for the color_areas */
|
||||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_box_pack_end (GTK_BOX (priv->left_vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_end (GTK_BOX (selection->left_vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
/* The labels */
|
/* The labels */
|
||||||
|
@ -262,56 +258,56 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
priv->new_color = gimp_color_area_new (priv->color,
|
selection->new_color = gimp_color_area_new (selection->color,
|
||||||
priv->show_alpha ?
|
selection->show_alpha ?
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
GIMP_COLOR_AREA_FLAT,
|
GIMP_COLOR_AREA_FLAT,
|
||||||
GDK_BUTTON1_MASK |
|
GDK_BUTTON1_MASK |
|
||||||
GDK_BUTTON2_MASK);
|
GDK_BUTTON2_MASK);
|
||||||
gtk_size_group_add_widget (new_group, priv->new_color);
|
gtk_size_group_add_widget (new_group, selection->new_color);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), priv->new_color, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), selection->new_color, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (priv->new_color);
|
gtk_widget_show (selection->new_color);
|
||||||
|
|
||||||
g_signal_connect (priv->new_color, "color-changed",
|
g_signal_connect (selection->new_color, "color-changed",
|
||||||
G_CALLBACK (gimp_color_selection_new_color_changed),
|
G_CALLBACK (gimp_color_selection_new_color_changed),
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
priv->old_color = gimp_color_area_new (priv->color,
|
selection->old_color = gimp_color_area_new (selection->color,
|
||||||
priv->show_alpha ?
|
selection->show_alpha ?
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
GIMP_COLOR_AREA_FLAT,
|
GIMP_COLOR_AREA_FLAT,
|
||||||
GDK_BUTTON1_MASK |
|
GDK_BUTTON1_MASK |
|
||||||
GDK_BUTTON2_MASK);
|
GDK_BUTTON2_MASK);
|
||||||
gtk_drag_dest_unset (priv->old_color);
|
gtk_drag_dest_unset (selection->old_color);
|
||||||
gtk_size_group_add_widget (old_group, priv->old_color);
|
gtk_size_group_add_widget (old_group, selection->old_color);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), priv->old_color, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), selection->old_color, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (priv->old_color);
|
gtk_widget_show (selection->old_color);
|
||||||
|
|
||||||
/* The right vbox with color scales */
|
/* The right vbox with color scales */
|
||||||
priv->right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
selection->right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (main_hbox), priv->right_vbox,
|
gtk_box_pack_start (GTK_BOX (main_hbox), selection->right_vbox,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (priv->right_vbox);
|
gtk_widget_show (selection->right_vbox);
|
||||||
|
|
||||||
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES, priv->color, priv->channel);
|
selection->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES, selection->color, selection->channel);
|
||||||
|
|
||||||
gimp_color_selector_set_toggles_visible
|
gimp_color_selector_set_toggles_visible
|
||||||
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
(GIMP_COLOR_SELECTOR (selection->scales), TRUE);
|
||||||
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (selection->scales),
|
||||||
priv->show_alpha);
|
selection->show_alpha);
|
||||||
gtk_box_pack_start (GTK_BOX (priv->right_vbox), priv->scales,
|
gtk_box_pack_start (GTK_BOX (selection->right_vbox), selection->scales,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (priv->scales);
|
gtk_widget_show (selection->scales);
|
||||||
|
|
||||||
g_signal_connect (priv->scales, "channel-changed",
|
g_signal_connect (selection->scales, "channel-changed",
|
||||||
G_CALLBACK (gimp_color_selection_channel_changed),
|
G_CALLBACK (gimp_color_selection_channel_changed),
|
||||||
selection);
|
selection);
|
||||||
g_signal_connect (priv->scales, "color-changed",
|
g_signal_connect (selection->scales, "color-changed",
|
||||||
G_CALLBACK (gimp_color_selection_scales_changed),
|
G_CALLBACK (gimp_color_selection_scales_changed),
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (priv->right_vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (selection->right_vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
/* The color picker */
|
/* The color picker */
|
||||||
|
@ -343,12 +339,9 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
static void
|
static void
|
||||||
gimp_color_selection_finalize (GObject *object)
|
gimp_color_selection_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GimpColorSelection *selection = GIMP_COLOR_SELECTION (object);
|
GimpColorSelection *selection = GIMP_COLOR_SELECTION (object);
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
g_object_unref (selection->color);
|
||||||
|
|
||||||
g_object_unref (priv->color);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -398,27 +391,23 @@ void
|
||||||
gimp_color_selection_set_show_alpha (GimpColorSelection *selection,
|
gimp_color_selection_set_show_alpha (GimpColorSelection *selection,
|
||||||
gboolean show_alpha)
|
gboolean show_alpha)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
if (show_alpha != selection->show_alpha)
|
||||||
|
|
||||||
if (show_alpha != priv->show_alpha)
|
|
||||||
{
|
{
|
||||||
priv->show_alpha = show_alpha ? TRUE : FALSE;
|
selection->show_alpha = show_alpha ? TRUE : FALSE;
|
||||||
|
|
||||||
gimp_color_selector_set_show_alpha
|
gimp_color_selector_set_show_alpha
|
||||||
(GIMP_COLOR_SELECTOR (priv->notebook), priv->show_alpha);
|
(GIMP_COLOR_SELECTOR (selection->notebook), selection->show_alpha);
|
||||||
gimp_color_selector_set_show_alpha
|
gimp_color_selector_set_show_alpha
|
||||||
(GIMP_COLOR_SELECTOR (priv->scales), priv->show_alpha);
|
(GIMP_COLOR_SELECTOR (selection->scales), selection->show_alpha);
|
||||||
|
|
||||||
gimp_color_area_set_type (GIMP_COLOR_AREA (priv->new_color),
|
gimp_color_area_set_type (GIMP_COLOR_AREA (selection->new_color),
|
||||||
priv->show_alpha ?
|
selection->show_alpha ?
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
GIMP_COLOR_AREA_FLAT);
|
GIMP_COLOR_AREA_FLAT);
|
||||||
gimp_color_area_set_type (GIMP_COLOR_AREA (priv->old_color),
|
gimp_color_area_set_type (GIMP_COLOR_AREA (selection->old_color),
|
||||||
priv->show_alpha ?
|
selection->show_alpha ?
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
GIMP_COLOR_AREA_FLAT);
|
GIMP_COLOR_AREA_FLAT);
|
||||||
}
|
}
|
||||||
|
@ -435,13 +424,9 @@ gimp_color_selection_set_show_alpha (GimpColorSelection *selection,
|
||||||
gboolean
|
gboolean
|
||||||
gimp_color_selection_get_show_alpha (GimpColorSelection *selection)
|
gimp_color_selection_get_show_alpha (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), FALSE);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), FALSE);
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
return selection->show_alpha;
|
||||||
|
|
||||||
return priv->show_alpha;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -455,17 +440,14 @@ void
|
||||||
gimp_color_selection_set_color (GimpColorSelection *selection,
|
gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||||
GeglColor *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GeglColor *old_color;
|
||||||
GeglColor *old_color;
|
UpdateType update;
|
||||||
UpdateType update;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
old_color = selection->color;
|
||||||
|
selection->color = gegl_color_duplicate (color);
|
||||||
old_color = priv->color;
|
|
||||||
priv->color = gegl_color_duplicate (color);
|
|
||||||
|
|
||||||
update = UPDATE_ALL;
|
update = UPDATE_ALL;
|
||||||
if (gimp_color_is_perceptually_identical (color, old_color))
|
if (gimp_color_is_perceptually_identical (color, old_color))
|
||||||
|
@ -488,13 +470,9 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||||
GeglColor *
|
GeglColor *
|
||||||
gimp_color_selection_get_color (GimpColorSelection *selection)
|
gimp_color_selection_get_color (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
return gegl_color_duplicate (selection->color);
|
||||||
|
|
||||||
return gegl_color_duplicate (priv->color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -508,14 +486,10 @@ void
|
||||||
gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
||||||
GeglColor *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (selection->old_color), color);
|
||||||
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->old_color), color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,13 +501,9 @@ gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
||||||
GeglColor *
|
GeglColor *
|
||||||
gimp_color_selection_get_old_color (GimpColorSelection *selection)
|
gimp_color_selection_get_old_color (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
return gimp_color_area_get_color (GIMP_COLOR_AREA (selection->old_color));
|
||||||
|
|
||||||
return gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -545,14 +515,11 @@ gimp_color_selection_get_old_color (GimpColorSelection *selection)
|
||||||
void
|
void
|
||||||
gimp_color_selection_reset (GimpColorSelection *selection)
|
gimp_color_selection_reset (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GeglColor *color;
|
||||||
GeglColor *color;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
color = gimp_color_area_get_color (GIMP_COLOR_AREA (selection->old_color));
|
||||||
|
|
||||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
|
||||||
gimp_color_selection_set_color (selection, color);
|
gimp_color_selection_set_color (selection, color);
|
||||||
|
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
|
@ -585,15 +552,11 @@ void
|
||||||
gimp_color_selection_set_format (GimpColorSelection *selection,
|
gimp_color_selection_set_format (GimpColorSelection *selection,
|
||||||
const Babl *format)
|
const Babl *format)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
gimp_color_notebook_set_format (GIMP_COLOR_NOTEBOOK (selection->notebook),
|
||||||
|
|
||||||
gimp_color_notebook_set_format (GIMP_COLOR_NOTEBOOK (priv->notebook),
|
|
||||||
format);
|
format);
|
||||||
gimp_color_selector_set_format (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_format (GIMP_COLOR_SELECTOR (selection->scales),
|
||||||
format);
|
format);
|
||||||
|
|
||||||
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
||||||
|
@ -616,13 +579,9 @@ gimp_color_selection_set_simulation (GimpColorSelection *selection,
|
||||||
GimpColorRenderingIntent intent,
|
GimpColorRenderingIntent intent,
|
||||||
gboolean bpc)
|
gboolean bpc)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
gimp_color_notebook_set_simulation (GIMP_COLOR_NOTEBOOK (selection->notebook),
|
||||||
|
|
||||||
gimp_color_notebook_set_simulation (GIMP_COLOR_NOTEBOOK (priv->notebook),
|
|
||||||
profile,
|
profile,
|
||||||
intent,
|
intent,
|
||||||
bpc);
|
bpc);
|
||||||
|
@ -643,20 +602,16 @@ void
|
||||||
gimp_color_selection_set_config (GimpColorSelection *selection,
|
gimp_color_selection_set_config (GimpColorSelection *selection,
|
||||||
GimpColorConfig *config)
|
GimpColorConfig *config)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
|
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (selection->notebook),
|
||||||
|
|
||||||
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (priv->notebook),
|
|
||||||
config);
|
config);
|
||||||
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (selection->scales),
|
||||||
config);
|
config);
|
||||||
gimp_color_area_set_color_config (GIMP_COLOR_AREA (priv->old_color),
|
gimp_color_area_set_color_config (GIMP_COLOR_AREA (selection->old_color),
|
||||||
config);
|
config);
|
||||||
gimp_color_area_set_color_config (GIMP_COLOR_AREA (priv->new_color),
|
gimp_color_area_set_color_config (GIMP_COLOR_AREA (selection->new_color),
|
||||||
config);
|
config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,13 +626,9 @@ gimp_color_selection_set_config (GimpColorSelection *selection,
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_selection_get_notebook (GimpColorSelection *selection)
|
gimp_color_selection_get_notebook (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
return selection->notebook;
|
||||||
|
|
||||||
return priv->notebook;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -692,13 +643,9 @@ gimp_color_selection_get_notebook (GimpColorSelection *selection)
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_selection_get_right_vbox (GimpColorSelection *selection)
|
gimp_color_selection_get_right_vbox (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
return selection->right_vbox;
|
||||||
|
|
||||||
return priv->right_vbox;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -710,20 +657,18 @@ gimp_color_selection_switch_page (GtkWidget *widget,
|
||||||
guint page_num,
|
guint page_num,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GimpColorNotebook *notebook;
|
||||||
GimpColorNotebook *notebook;
|
GimpColorSelector *current;
|
||||||
GimpColorSelector *current;
|
gboolean sensitive;
|
||||||
gboolean sensitive;
|
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
notebook = GIMP_COLOR_NOTEBOOK (selection->notebook);
|
||||||
notebook = GIMP_COLOR_NOTEBOOK (priv->notebook);
|
|
||||||
|
|
||||||
current = gimp_color_notebook_get_current_selector (notebook);
|
current = gimp_color_notebook_get_current_selector (notebook);
|
||||||
|
|
||||||
sensitive = (GIMP_COLOR_SELECTOR_GET_CLASS (current)->set_channel != NULL);
|
sensitive = (GIMP_COLOR_SELECTOR_GET_CLASS (current)->set_channel != NULL);
|
||||||
|
|
||||||
gimp_color_selector_set_toggles_sensitive
|
gimp_color_selector_set_toggles_sensitive
|
||||||
(GIMP_COLOR_SELECTOR (priv->scales), sensitive);
|
(GIMP_COLOR_SELECTOR (selection->scales), sensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -731,14 +676,11 @@ gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
||||||
GeglColor *color,
|
GeglColor *color,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GeglColor *old_color;
|
||||||
GeglColor *old_color;
|
UpdateType update;
|
||||||
UpdateType update;
|
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
old_color = selection->color;
|
||||||
|
selection->color = gegl_color_duplicate (color);
|
||||||
old_color = priv->color;
|
|
||||||
priv->color = gegl_color_duplicate (color);
|
|
||||||
|
|
||||||
update = UPDATE_SCALES | UPDATE_ENTRY;
|
update = UPDATE_SCALES | UPDATE_ENTRY;
|
||||||
if (! gimp_color_is_perceptually_identical (color, old_color))
|
if (! gimp_color_is_perceptually_identical (color, old_color))
|
||||||
|
@ -755,14 +697,11 @@ gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
||||||
GeglColor *color,
|
GeglColor *color,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
UpdateType update;
|
||||||
UpdateType update;
|
GeglColor *old_color;
|
||||||
GeglColor *old_color;
|
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
old_color = selection->color;
|
||||||
|
selection->color = gegl_color_duplicate (color);
|
||||||
old_color = priv->color;
|
|
||||||
priv->color = gegl_color_duplicate (color);
|
|
||||||
|
|
||||||
update = UPDATE_ENTRY | UPDATE_NOTEBOOK;
|
update = UPDATE_ENTRY | UPDATE_NOTEBOOK;
|
||||||
if (! gimp_color_is_perceptually_identical (color, old_color))
|
if (! gimp_color_is_perceptually_identical (color, old_color))
|
||||||
|
@ -788,12 +727,8 @@ static void
|
||||||
gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
|
gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
g_object_unref (selection->color);
|
||||||
|
selection->color = gimp_color_hex_entry_get_color (entry);
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
|
||||||
|
|
||||||
g_object_unref (priv->color);
|
|
||||||
priv->color = gimp_color_hex_entry_get_color (entry);
|
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
gimp_color_selection_update (selection,
|
||||||
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
|
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
|
||||||
|
@ -805,26 +740,18 @@ gimp_color_selection_channel_changed (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel,
|
GimpColorSelectorChannel channel,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
selection->channel = channel;
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
gimp_color_selector_set_channel (GIMP_COLOR_SELECTOR (selection->notebook),
|
||||||
|
selection->channel);
|
||||||
priv->channel = channel;
|
|
||||||
|
|
||||||
gimp_color_selector_set_channel (GIMP_COLOR_SELECTOR (priv->notebook),
|
|
||||||
priv->channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_selection_new_color_changed (GtkWidget *widget,
|
gimp_color_selection_new_color_changed (GtkWidget *widget,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
g_object_unref (selection->color);
|
||||||
|
selection->color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
|
||||||
|
|
||||||
g_object_unref (priv->color);
|
|
||||||
priv->color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
gimp_color_selection_update (selection,
|
||||||
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
|
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
|
||||||
|
@ -835,32 +762,28 @@ static void
|
||||||
gimp_color_selection_update (GimpColorSelection *selection,
|
gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
UpdateType update)
|
UpdateType update)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
|
||||||
|
|
||||||
priv = gimp_color_selection_get_instance_private (selection);
|
|
||||||
|
|
||||||
if (update & UPDATE_NOTEBOOK)
|
if (update & UPDATE_NOTEBOOK)
|
||||||
{
|
{
|
||||||
g_signal_handlers_block_by_func (priv->notebook,
|
g_signal_handlers_block_by_func (selection->notebook,
|
||||||
gimp_color_selection_notebook_changed,
|
gimp_color_selection_notebook_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->notebook), priv->color);
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (selection->notebook), selection->color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->notebook,
|
g_signal_handlers_unblock_by_func (selection->notebook,
|
||||||
gimp_color_selection_notebook_changed,
|
gimp_color_selection_notebook_changed,
|
||||||
selection);
|
selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update & UPDATE_SCALES)
|
if (update & UPDATE_SCALES)
|
||||||
{
|
{
|
||||||
g_signal_handlers_block_by_func (priv->scales,
|
g_signal_handlers_block_by_func (selection->scales,
|
||||||
gimp_color_selection_scales_changed,
|
gimp_color_selection_scales_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->scales), priv->color);
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (selection->scales), selection->color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->scales,
|
g_signal_handlers_unblock_by_func (selection->scales,
|
||||||
gimp_color_selection_scales_changed,
|
gimp_color_selection_scales_changed,
|
||||||
selection);
|
selection);
|
||||||
}
|
}
|
||||||
|
@ -875,7 +798,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
gimp_color_selection_entry_changed,
|
gimp_color_selection_entry_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_hex_entry_set_color (entry, priv->color);
|
gimp_color_hex_entry_set_color (entry, selection->color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (entry,
|
g_signal_handlers_unblock_by_func (entry,
|
||||||
gimp_color_selection_entry_changed,
|
gimp_color_selection_entry_changed,
|
||||||
|
@ -884,13 +807,13 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
|
|
||||||
if (update & UPDATE_COLOR)
|
if (update & UPDATE_COLOR)
|
||||||
{
|
{
|
||||||
g_signal_handlers_block_by_func (priv->new_color,
|
g_signal_handlers_block_by_func (selection->new_color,
|
||||||
gimp_color_selection_new_color_changed,
|
gimp_color_selection_new_color_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->new_color), priv->color);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (selection->new_color), selection->color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->new_color,
|
g_signal_handlers_unblock_by_func (selection->new_color,
|
||||||
gimp_color_selection_new_color_changed,
|
gimp_color_selection_new_color_changed,
|
||||||
selection);
|
selection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,24 +32,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_COLOR_SELECTION (gimp_color_selection_get_type ())
|
#define GIMP_TYPE_COLOR_SELECTION (gimp_color_selection_get_type ())
|
||||||
G_DECLARE_DERIVABLE_TYPE (GimpColorSelection, gimp_color_selection, GIMP, COLOR_SELECTION, GtkBox)
|
G_DECLARE_FINAL_TYPE (GimpColorSelection, gimp_color_selection, GIMP, COLOR_SELECTION, GtkBox)
|
||||||
|
|
||||||
struct _GimpColorSelectionClass
|
|
||||||
{
|
|
||||||
GtkBoxClass parent_class;
|
|
||||||
|
|
||||||
void (* color_changed) (GimpColorSelection *selection);
|
|
||||||
|
|
||||||
/* Padding for future expansion */
|
|
||||||
void (* _gimp_reserved1) (void);
|
|
||||||
void (* _gimp_reserved2) (void);
|
|
||||||
void (* _gimp_reserved3) (void);
|
|
||||||
void (* _gimp_reserved4) (void);
|
|
||||||
void (* _gimp_reserved5) (void);
|
|
||||||
void (* _gimp_reserved6) (void);
|
|
||||||
void (* _gimp_reserved7) (void);
|
|
||||||
void (* _gimp_reserved8) (void);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget * gimp_color_selection_new (void);
|
GtkWidget * gimp_color_selection_new (void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue