libgimpwidgets, plug-ins: remove legacy gimp_color_scale_entry_new().

Former gimp_color_scale_entry_new() is finally replaced by the
GimpColorScaleEntry implementation.
Both places which used it (GimpColorScales and compose plug-in) now use
the new widget.

Also making "upper" and "lower" properties of GimpScaleEntry into
construction properties, and create the main GtkAjustment at init, so
that we are sure that lower and upper bounds are properly set before we
set the value (when setting all properties at once, we cannot ensure
that these limit properties are set before the "value" one).
This commit is contained in:
Jehan 2020-11-01 02:23:03 +01:00
parent 1cdfb0bd3f
commit 77d2a93a52
7 changed files with 140 additions and 342 deletions

View File

@ -82,7 +82,7 @@ gimp_color_scale_entry_new_range_widget (GtkAdjustment *adjustment)
} }
/** /**
* gimp_color_scale_entry_new2: * gimp_color_scale_entry_new:
* @text: The text for the #GtkLabel. * @text: The text for the #GtkLabel.
* @value: The initial value. * @value: The initial value.
* @lower: The lower boundary. * @lower: The lower boundary.
@ -92,7 +92,7 @@ gimp_color_scale_entry_new_range_widget (GtkAdjustment *adjustment)
* Returns: (transfer full): The new #GimpColorScale widget. * Returns: (transfer full): The new #GimpColorScale widget.
**/ **/
GtkWidget * GtkWidget *
gimp_color_scale_entry_new2 (const gchar *text, gimp_color_scale_entry_new (const gchar *text,
gdouble value, gdouble value,
gdouble lower, gdouble lower,
gdouble upper, gdouble upper,

View File

@ -33,7 +33,7 @@ G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_SCALE_ENTRY (gimp_color_scale_entry_get_type ()) #define GIMP_TYPE_COLOR_SCALE_ENTRY (gimp_color_scale_entry_get_type ())
G_DECLARE_FINAL_TYPE (GimpColorScaleEntry, gimp_color_scale_entry, GIMP, COLOR_SCALE_ENTRY, GimpScaleEntry) G_DECLARE_FINAL_TYPE (GimpColorScaleEntry, gimp_color_scale_entry, GIMP, COLOR_SCALE_ENTRY, GimpScaleEntry)
GtkWidget * gimp_color_scale_entry_new2 (const gchar *text, GtkWidget * gimp_color_scale_entry_new (const gchar *text,
gdouble value, gdouble value,
gdouble lower, gdouble lower,
gdouble upper, gdouble upper,

View File

@ -113,7 +113,6 @@ struct _GimpColorScales
GtkWidget *dummy_u8_toggle; GtkWidget *dummy_u8_toggle;
GtkWidget *toggles[14]; GtkWidget *toggles[14];
GtkAdjustment *adjustments[14];
GtkWidget *scales[14]; GtkWidget *scales[14];
}; };
@ -157,7 +156,7 @@ static void gimp_color_scales_update_scales (GimpColorScales *scales,
gint skip); gint skip);
static void gimp_color_scales_toggle_changed (GtkWidget *widget, static void gimp_color_scales_toggle_changed (GtkWidget *widget,
GimpColorScales *scales); GimpColorScales *scales);
static void gimp_color_scales_scale_changed (GtkAdjustment *adjustment, static void gimp_color_scales_scale_changed (GtkWidget *scale,
GimpColorScales *scales); GimpColorScales *scales);
static void gimp_color_scales_toggle_lch_hsv (GtkToggleButton *toggle, static void gimp_color_scales_toggle_lch_hsv (GtkToggleButton *toggle,
GimpColorScales *scales); GimpColorScales *scales);
@ -308,39 +307,36 @@ create_group (GimpColorScales *scales,
gtk_size_group_add_widget (size_group0, scales->toggles[i]); gtk_size_group_add_widget (size_group0, scales->toggles[i]);
scales->adjustments[i] = scales->scales[i] =
gimp_color_scale_entry_new (GTK_GRID (grid), 1, row, gimp_color_scale_entry_new (gettext (enum_desc->value_desc),
gettext (enum_desc->value_desc),
-1, -1,
scale_defs[i].default_value,
scale_defs[i].scale_min_value,
scale_defs[i].scale_max_value,
1.0,
scale_defs[i].scale_inc,
1,
gettext (enum_desc->value_help),
NULL);
gtk_adjustment_configure (scales->adjustments[i],
scale_defs[i].default_value, scale_defs[i].default_value,
scale_defs[i].spin_min_value, scale_defs[i].spin_min_value,
scale_defs[i].spin_max_value, scale_defs[i].spin_max_value,
1.0, 1);
scale_defs[i].scale_inc, gtk_grid_attach (GTK_GRID (grid), scales->scales[i], 1, row, 3, 1);
0); gimp_scale_entry_set_increments (GIMP_SCALE_ENTRY (scales->scales[i]),
1.0, scale_defs[i].scale_inc);
gimp_help_set_help_data (scales->scales[i],
gettext (enum_desc->value_help),
NULL);
gtk_widget_show (scales->scales[i]);
gimp_scale_entry_set_range (GIMP_SCALE_ENTRY (scales->scales[i]),
scale_defs[i].scale_min_value,
scale_defs[i].scale_max_value,
TRUE);
scales->scales[i] = GIMP_SCALE_ENTRY_SCALE (scales->adjustments[i]);
g_object_add_weak_pointer (G_OBJECT (scales->scales[i]), g_object_add_weak_pointer (G_OBJECT (scales->scales[i]),
(gpointer) &scales->scales[i]); (gpointer) &scales->scales[i]);
gimp_color_scale_set_channel (GIMP_COLOR_SCALE (scales->scales[i]), gimp_color_scale_set_channel (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
enum_value); enum_value);
gtk_size_group_add_widget (size_group1, scales->scales[i]); gtk_size_group_add_widget (size_group1, scales->scales[i]);
gtk_size_group_add_widget (size_group2, gtk_size_group_add_widget (size_group2,
GIMP_SCALE_ENTRY_SPINBUTTON (scales->adjustments[i])); gimp_scale_entry_get_spin_button (GIMP_SCALE_ENTRY (scales->scales[i])));
g_signal_connect (scales->adjustments[i], "value-changed", g_signal_connect (scales->scales[i], "value-changed",
G_CALLBACK (gimp_color_scales_scale_changed), G_CALLBACK (gimp_color_scales_scale_changed),
scales); scales);
} }
@ -610,7 +606,7 @@ gimp_color_scales_set_config (GimpColorSelector *selector,
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++) for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
{ {
if (scales->scales[i]) if (scales->scales[i])
gimp_color_scale_set_color_config (GIMP_COLOR_SCALE (scales->scales[i]), gimp_color_scale_set_color_config (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
config); config);
} }
} }
@ -711,18 +707,18 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
{ {
if (i != skip) if (i != skip)
{ {
g_signal_handlers_block_by_func (scales->adjustments[i], g_signal_handlers_block_by_func (scales->scales[i],
gimp_color_scales_scale_changed, gimp_color_scales_scale_changed,
scales); scales);
gtk_adjustment_set_value (scales->adjustments[i], values[i]); gimp_scale_entry_set_value (GIMP_SCALE_ENTRY (scales->scales[i]), values[i]);
g_signal_handlers_unblock_by_func (scales->adjustments[i], g_signal_handlers_unblock_by_func (scales->scales[i],
gimp_color_scales_scale_changed, gimp_color_scales_scale_changed,
scales); scales);
} }
gimp_color_scale_set_color (GIMP_COLOR_SCALE (scales->scales[i]), gimp_color_scale_set_color (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
&selector->rgb, &selector->hsv); &selector->rgb, &selector->hsv);
} }
} }
@ -757,16 +753,16 @@ gimp_color_scales_toggle_changed (GtkWidget *widget,
} }
static void static void
gimp_color_scales_scale_changed (GtkAdjustment *adjustment, gimp_color_scales_scale_changed (GtkWidget *scale,
GimpColorScales *scales) GimpColorScales *scales)
{ {
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales); GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
gdouble value = gtk_adjustment_get_value (adjustment); gdouble value = gimp_scale_entry_get_value (GIMP_SCALE_ENTRY (scale));
GimpLCH lch; GimpLCH lch;
gint i; gint i;
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++) for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
if (scales->adjustments[i] == adjustment) if (scales->scales[i] == scale)
break; break;
switch (i) switch (i)

View File

@ -25,7 +25,6 @@
#include <gegl.h> #include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
@ -67,6 +66,8 @@ typedef struct _GimpScaleEntryPrivate
GBinding *binding; GBinding *binding;
GtkAdjustment *spin_adjustment;
gboolean logarithmic; gboolean logarithmic;
} GimpScaleEntryPrivate; } GimpScaleEntryPrivate;
@ -93,25 +94,6 @@ static gboolean gimp_scale_entry_log_to_linear (GBinding *binding,
GValue *to_value, GValue *to_value,
gpointer user_data); gpointer user_data);
static GtkAdjustment * gimp_scale_entry_new_internal (gboolean color_scale,
GtkGrid *grid,
gint column,
gint row,
const gchar *text,
gint scale_width,
gint spinbutton_width,
gdouble value,
gdouble lower,
gdouble upper,
gdouble step_increment,
gdouble page_increment,
guint digits,
gboolean constrain,
gdouble unconstrained_lower,
gdouble unconstrained_upper,
const gchar *tooltip,
const gchar *help_id);
G_DEFINE_TYPE_WITH_PRIVATE (GimpScaleEntry, gimp_scale_entry, GTK_TYPE_GRID) G_DEFINE_TYPE_WITH_PRIVATE (GimpScaleEntry, gimp_scale_entry, GTK_TYPE_GRID)
@ -165,24 +147,34 @@ gimp_scale_entry_class_init (GimpScaleEntryClass *klass)
/** /**
* GimpScaleEntry:lower: * GimpScaleEntry:lower:
* *
* The lower bound of the widget. If the spin button and the scale
* widgets have different limits (see gimp_scale_entry_set_range()),
* this corresponds to the spin button lower value.
*
* Since: 3.0 * Since: 3.0
**/ **/
g_object_class_install_property (object_class, PROP_LOWER, g_object_class_install_property (object_class, PROP_LOWER,
g_param_spec_double ("lower", NULL, g_param_spec_double ("lower", NULL,
"Minimum value", "Minimum value",
-G_MAXDOUBLE, G_MAXDOUBLE, 1.0, -G_MAXDOUBLE, G_MAXDOUBLE, 1.0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/** /**
* GimpScaleEntry:upper: * GimpScaleEntry:upper:
* *
* The upper bound of the widget. If the spin button and the scale
* widgets have different limits (see gimp_scale_entry_set_range()),
* this corresponds to the spin button upper value.
*
* Since: 3.0 * Since: 3.0
**/ **/
g_object_class_install_property (object_class, PROP_UPPER, g_object_class_install_property (object_class, PROP_UPPER,
g_param_spec_double ("upper", NULL, g_param_spec_double ("upper", NULL,
"Max value", "Max value",
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/** /**
* GimpScaleEntry:digits: * GimpScaleEntry:digits:
@ -199,6 +191,15 @@ gimp_scale_entry_class_init (GimpScaleEntryClass *klass)
static void static void
gimp_scale_entry_init (GimpScaleEntry *entry) gimp_scale_entry_init (GimpScaleEntry *entry)
{ {
GimpScaleEntryPrivate *priv = gimp_scale_entry_get_instance_private (entry);
/* The main adjustment (the scale adjustment in particular might be
* smaller). We want it to exist at init so that construction
* properties can apply (default values are bogus but should be
* properly overrided with expected values if the object was created
* with gimp_scale_entry_new().
*/
priv->spin_adjustment = gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0);
} }
static void static void
@ -207,27 +208,24 @@ gimp_scale_entry_constructed (GObject *object)
GimpScaleEntryClass *klass; GimpScaleEntryClass *klass;
GimpScaleEntry *entry = GIMP_SCALE_ENTRY (object); GimpScaleEntry *entry = GIMP_SCALE_ENTRY (object);
GimpScaleEntryPrivate *priv = gimp_scale_entry_get_instance_private (entry); GimpScaleEntryPrivate *priv = gimp_scale_entry_get_instance_private (entry);
GtkAdjustment *spin_adjustment;
GtkAdjustment *scale_adjustment; GtkAdjustment *scale_adjustment;
/* Construction values are a bit random but should be properly
* overrided with expected values if the object was created with
* gimp_scale_entry_new().
*/
/* Label */ /* Label */
priv->label = gtk_label_new_with_mnemonic (NULL); priv->label = gtk_label_new_with_mnemonic (NULL);
gtk_label_set_xalign (GTK_LABEL (priv->label), 0.0); gtk_label_set_xalign (GTK_LABEL (priv->label), 0.0);
/* Spin button */ /* Spin button */
spin_adjustment = gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0); priv->spinbutton = gimp_spin_button_new (priv->spin_adjustment, 2.0, 2.0);
priv->spinbutton = gimp_spin_button_new (spin_adjustment, 2.0, 2.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (priv->spinbutton), TRUE); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (priv->spinbutton), TRUE);
gtk_label_set_mnemonic_widget (GTK_LABEL (priv->label), priv->spinbutton); gtk_label_set_mnemonic_widget (GTK_LABEL (priv->label), priv->spinbutton);
/* Scale */ /* Scale */
scale_adjustment = gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0); scale_adjustment = gtk_adjustment_new (gtk_adjustment_get_value (priv->spin_adjustment),
gtk_adjustment_get_lower (priv->spin_adjustment),
gtk_adjustment_get_upper (priv->spin_adjustment),
gtk_adjustment_get_step_increment (priv->spin_adjustment),
gtk_adjustment_get_page_increment (priv->spin_adjustment),
gtk_adjustment_get_page_size (priv->spin_adjustment));
klass = GIMP_SCALE_ENTRY_GET_CLASS (entry); klass = GIMP_SCALE_ENTRY_GET_CLASS (entry);
if (klass->new_range_widget) if (klass->new_range_widget)
@ -251,7 +249,7 @@ gimp_scale_entry_constructed (GObject *object)
gtk_widget_show (priv->scale); gtk_widget_show (priv->scale);
gtk_widget_show (priv->spinbutton); gtk_widget_show (priv->spinbutton);
priv->binding = g_object_bind_property (G_OBJECT (spin_adjustment), "value", priv->binding = g_object_bind_property (G_OBJECT (priv->spin_adjustment), "value",
G_OBJECT (scale_adjustment), "value", G_OBJECT (scale_adjustment), "value",
G_BINDING_BIDIRECTIONAL | G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE); G_BINDING_SYNC_CREATE);
@ -260,10 +258,13 @@ gimp_scale_entry_constructed (GObject *object)
* will allow config object to bind the "value" property of this * will allow config object to bind the "value" property of this
* widget, and therefore be updated automatically. * widget, and therefore be updated automatically.
*/ */
g_object_bind_property (G_OBJECT (spin_adjustment), "value", g_object_bind_property (G_OBJECT (priv->spin_adjustment), "value",
object, "value", object, "value",
G_BINDING_BIDIRECTIONAL | G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE); G_BINDING_SYNC_CREATE);
gimp_scale_entry_update_spin_width (entry);
gimp_scale_entry_update_steps (entry);
} }
static void static void
@ -313,42 +314,40 @@ gimp_scale_entry_set_property (GObject *object,
break; break;
case PROP_LOWER: case PROP_LOWER:
{ {
GtkSpinButton *spinbutton; gtk_adjustment_set_lower (priv->spin_adjustment,
GtkRange *scale;
g_return_if_fail (priv->spinbutton);
/* This sets the range for both the spin button and the scale.
* To change only the scale, see gimp_scale_entry_set_range().
*/
spinbutton = GTK_SPIN_BUTTON (priv->spinbutton);
scale = GTK_RANGE (priv->scale);
gtk_adjustment_set_lower (gtk_spin_button_get_adjustment (spinbutton),
g_value_get_double (value)); g_value_get_double (value));
if (priv->scale)
{
GtkRange *scale = GTK_RANGE (priv->scale);
/* If the widget does not exist, it means this is a
* pre-constructed property setting.
*/
gtk_adjustment_set_lower (gtk_range_get_adjustment (scale), gtk_adjustment_set_lower (gtk_range_get_adjustment (scale),
g_value_get_double (value)); g_value_get_double (value));
gimp_scale_entry_update_spin_width (entry); gimp_scale_entry_update_spin_width (entry);
gimp_scale_entry_update_steps (entry); gimp_scale_entry_update_steps (entry);
} }
}
break; break;
case PROP_UPPER: case PROP_UPPER:
{ {
GtkSpinButton *spinbutton; gtk_adjustment_set_upper (priv->spin_adjustment,
GtkRange *scale;
g_return_if_fail (priv->scale && priv->spinbutton);
spinbutton = GTK_SPIN_BUTTON (priv->spinbutton);
scale = GTK_RANGE (priv->scale);
gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (spinbutton),
g_value_get_double (value)); g_value_get_double (value));
if (priv->scale)
{
GtkRange *scale = GTK_RANGE (priv->scale);
gtk_adjustment_set_upper (gtk_range_get_adjustment (scale), gtk_adjustment_set_upper (gtk_range_get_adjustment (scale),
g_value_get_double (value)); g_value_get_double (value));
gimp_scale_entry_update_spin_width (entry); gimp_scale_entry_update_spin_width (entry);
gimp_scale_entry_update_steps (entry); gimp_scale_entry_update_steps (entry);
} }
}
break; break;
case PROP_DIGITS: case PROP_DIGITS:
{ {
@ -550,112 +549,7 @@ gimp_scale_entry_log_to_linear (GBinding *binding,
return TRUE; return TRUE;
} }
static GtkAdjustment * /* Public functions */
gimp_scale_entry_new_internal (gboolean color_scale,
GtkGrid *grid,
gint column,
gint row,
const gchar *text,
gint scale_width,
gint spinbutton_width,
gdouble value,
gdouble lower,
gdouble upper,
gdouble step_increment,
gdouble page_increment,
guint digits,
gboolean constrain,
gdouble unconstrained_lower,
gdouble unconstrained_upper,
const gchar *tooltip,
const gchar *help_id)
{
GtkWidget *label;
GtkWidget *scale;
GtkWidget *spinbutton;
GtkAdjustment *scale_adjustment;
GtkAdjustment *spin_adjustment;
GBinding *binding;
label = gtk_label_new_with_mnemonic (text);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_show (label);
scale_adjustment = gtk_adjustment_new (value, lower, upper,
step_increment, page_increment, 0.0);
if (! constrain &&
unconstrained_lower <= lower &&
unconstrained_upper >= upper)
{
spin_adjustment = gtk_adjustment_new (value,
unconstrained_lower,
unconstrained_upper,
step_increment, page_increment, 0.0);
}
else
{
spin_adjustment = gtk_adjustment_new (value, lower, upper,
step_increment, page_increment, 0.0);
}
binding = g_object_bind_property (G_OBJECT (spin_adjustment), "value",
G_OBJECT (scale_adjustment), "value",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
spinbutton = gimp_spin_button_new (spin_adjustment, step_increment, digits);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_show (spinbutton);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
if (spinbutton_width > 0)
{
if (spinbutton_width < 17)
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), spinbutton_width);
else
gtk_widget_set_size_request (spinbutton, spinbutton_width, -1);
}
if (color_scale)
{
scale = gimp_color_scale_new (GTK_ORIENTATION_HORIZONTAL,
GIMP_COLOR_SELECTOR_VALUE);
gtk_range_set_adjustment (GTK_RANGE (scale), scale_adjustment);
}
else
{
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, scale_adjustment);
gtk_scale_set_digits (GTK_SCALE (scale), digits);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
}
if (scale_width > 0)
gtk_widget_set_size_request (scale, scale_width, -1);
gtk_widget_show (scale);
gtk_widget_set_hexpand (scale, TRUE);
gtk_grid_attach (grid, label, column, row, 1, 1);
gtk_grid_attach (grid, scale, column + 1, row, 1, 1);
gtk_grid_attach (grid, spinbutton, column + 2, row, 1, 1);
if (tooltip || help_id)
{
gimp_help_set_help_data (label, tooltip, help_id);
gimp_help_set_help_data (scale, tooltip, help_id);
gimp_help_set_help_data (spinbutton, tooltip, help_id);
}
g_object_set_data (G_OBJECT (spin_adjustment), "label", label);
g_object_set_data (G_OBJECT (spin_adjustment), "scale", scale);
g_object_set_data (G_OBJECT (spin_adjustment), "spinbutton", spinbutton);
g_object_set_data (G_OBJECT (spin_adjustment), "binding", binding);
return spin_adjustment;
}
/** /**
* gimp_scale_entry_new2: * gimp_scale_entry_new2:
@ -1025,52 +919,3 @@ gimp_scale_entry_set_increments (GimpScaleEntry *entry,
"climb-rate", step, "climb-rate", step,
NULL); NULL);
} }
/**
* gimp_color_scale_entry_new:
* @grid: The #GtkGrid the widgets will be attached to.
* @column: The column to start with.
* @row: The row to attach the widgets.
* @text: The text for the #GtkLabel which will appear
* left of the #GtkHScale.
* @scale_width: The minimum horizontal size of the #GtkHScale.
* @spinbutton_width: The minimum horizontal size of the #GtkSpinButton.
* @value: The initial value.
* @lower: The lower boundary.
* @upper: The upper boundary.
* @step_increment: The step increment.
* @page_increment: The page increment.
* @digits: The number of decimal digits.
* @tooltip: A tooltip message for the scale and the spinbutton.
* @help_id: The widgets' help_id (see gimp_help_set_help_data()).
*
* This function creates a #GtkLabel, a #GimpColorScale and a
* #GtkSpinButton and attaches them to a 3-column #GtkGrid.
*
* Returns: (transfer none): The #GtkSpinButton's #GtkAdjustment.
**/
GtkAdjustment *
gimp_color_scale_entry_new (GtkGrid *grid,
gint column,
gint row,
const gchar *text,
gint scale_width,
gint spinbutton_width,
gdouble value,
gdouble lower,
gdouble upper,
gdouble step_increment,
gdouble page_increment,
guint digits,
const gchar *tooltip,
const gchar *help_id)
{
return gimp_scale_entry_new_internal (TRUE,
grid, column, row,
text, scale_width, spinbutton_width,
value, lower, upper,
step_increment, page_increment,
digits,
TRUE, 0.0, 0.0,
tooltip, help_id);
}

View File

@ -81,40 +81,6 @@ void gimp_scale_entry_set_increments (GimpScaleEntry *entry,
gdouble step, gdouble step,
gdouble page); gdouble page);
/**
* GIMP_SCALE_ENTRY_SCALE:
* @adj: The #GtkAdjustment returned by gimp_scale_entry_new().
*
* Returns: the scale_entry's #GtkHScale.
**/
#define GIMP_SCALE_ENTRY_SCALE(adj) \
(g_object_get_data (G_OBJECT (adj), "scale"))
/**
* GIMP_SCALE_ENTRY_SPINBUTTON:
* @adj: The #GtkAdjustment returned by gimp_scale_entry_new().
*
* Returns: the scale_entry's #GtkSpinButton.
**/
#define GIMP_SCALE_ENTRY_SPINBUTTON(adj) \
(g_object_get_data (G_OBJECT (adj), "spinbutton"))
GtkAdjustment * gimp_color_scale_entry_new (GtkGrid *grid,
gint column,
gint row,
const gchar *text,
gint scale_width,
gint spinbutton_width,
gdouble value,
gdouble lower,
gdouble upper,
gdouble step_increment,
gdouble page_increment,
guint digits,
const gchar *tooltip,
const gchar *help_id);
G_END_DECLS G_END_DECLS

View File

@ -101,7 +101,6 @@ EXPORTS
gimp_color_profile_view_set_profile gimp_color_profile_view_set_profile
gimp_color_scale_entry_get_type gimp_color_scale_entry_get_type
gimp_color_scale_entry_new gimp_color_scale_entry_new
gimp_color_scale_entry_new2
gimp_color_scale_get_type gimp_color_scale_get_type
gimp_color_scale_new gimp_color_scale_new
gimp_color_scale_set_channel gimp_color_scale_set_channel

View File

@ -103,8 +103,7 @@ typedef struct
GtkWidget *channel_label[MAX_COMPOSE_IMAGES]; /* The labels to change */ GtkWidget *channel_label[MAX_COMPOSE_IMAGES]; /* The labels to change */
GtkWidget *channel_icon[MAX_COMPOSE_IMAGES]; /* The icons */ GtkWidget *channel_icon[MAX_COMPOSE_IMAGES]; /* The icons */
GtkWidget *channel_menu[MAX_COMPOSE_IMAGES]; /* The menus */ GtkWidget *channel_menu[MAX_COMPOSE_IMAGES]; /* The menus */
GtkWidget *color_scales[MAX_COMPOSE_IMAGES]; /* The values color scales */ GtkWidget *scales[MAX_COMPOSE_IMAGES]; /* The values color scales */
GtkWidget *color_spins[MAX_COMPOSE_IMAGES]; /* The values spin buttons */
ComposeInput selected[MAX_COMPOSE_IMAGES]; /* Image Ids or mask values from menus */ ComposeInput selected[MAX_COMPOSE_IMAGES]; /* Image Ids or mask values from menus */
@ -180,7 +179,7 @@ static gboolean check_gray (GimpImage *image,
static void combo_callback (GimpIntComboBox *cbox, static void combo_callback (GimpIntComboBox *cbox,
gpointer data); gpointer data);
static void scale_callback (GtkAdjustment *adj, static void scale_callback (GimpScaleEntry *scale,
ComposeInput *input); ComposeInput *input);
static void check_response (GtkWidget *dialog, static void check_response (GtkWidget *dialog,
@ -332,7 +331,6 @@ static ComposeInterface composeint =
{ NULL }, /* Icon Widgets */ { NULL }, /* Icon Widgets */
{ NULL }, /* Menu Widgets */ { NULL }, /* Menu Widgets */
{ NULL }, /* Color Scale Widgets */ { NULL }, /* Color Scale Widgets */
{ NULL }, /* Color Spin Widgets */
{{ 0, }}, /* Image Ids or mask values from menus */ {{ 0, }}, /* Image Ids or mask values from menus */
0 /* Compose type */ 0 /* Compose type */
}; };
@ -1228,7 +1226,7 @@ compose_dialog (const gchar *compose_type,
GtkWidget *image; GtkWidget *image;
GtkWidget *label; GtkWidget *label;
GtkWidget *combo; GtkWidget *combo;
GtkAdjustment *scale; GtkWidget *scale;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreeModel *model; GtkTreeModel *model;
@ -1277,15 +1275,12 @@ compose_dialog (const gchar *compose_type,
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
scale = gimp_color_scale_entry_new (GTK_GRID (grid), 2, j, NULL, scale = gimp_color_scale_entry_new (NULL, 255.0, 0.0, 255.0, 0);
100, 4, gtk_grid_attach (GTK_GRID (grid), scale, 2, j, 3, 1);
255.0, 0.0, 255.0, 1.0, 10.0, 0, gtk_widget_show (scale);
NULL, NULL); composeint.scales[j] = scale;
composeint.color_scales[j] = GIMP_SCALE_ENTRY_SCALE (scale);
composeint.color_spins[j] = GIMP_SCALE_ENTRY_SPINBUTTON (scale);
gtk_widget_set_sensitive (composeint.color_scales[j], FALSE); gtk_widget_set_sensitive (scale, FALSE);
gtk_widget_set_sensitive (composeint.color_spins[j], FALSE);
g_signal_connect (scale, "value-changed", g_signal_connect (scale, "value-changed",
G_CALLBACK (scale_callback), G_CALLBACK (scale_callback),
@ -1407,17 +1402,15 @@ combo_callback (GimpIntComboBox *widget,
if (id == -1) if (id == -1)
{ {
gtk_widget_set_sensitive (composeint.color_scales[n], TRUE); gtk_widget_set_sensitive (composeint.scales[n], TRUE);
gtk_widget_set_sensitive (composeint.color_spins[n], TRUE);
composeint.selected[n].is_object = FALSE; composeint.selected[n].is_object = FALSE;
composeint.selected[n].comp.val = composeint.selected[n].comp.val =
gtk_range_get_value (GTK_RANGE (composeint.color_scales[n])); gimp_scale_entry_get_value (GIMP_SCALE_ENTRY (composeint.scales[n]));
} }
else else
{ {
gtk_widget_set_sensitive (composeint.color_scales[n], FALSE); gtk_widget_set_sensitive (composeint.scales[n], FALSE);
gtk_widget_set_sensitive (composeint.color_spins[n], FALSE);
composeint.selected[n].is_object = TRUE; composeint.selected[n].is_object = TRUE;
composeint.selected[n].comp.object = gimp_drawable_get_by_id (id); composeint.selected[n].comp.object = gimp_drawable_get_by_id (id);
@ -1425,10 +1418,10 @@ combo_callback (GimpIntComboBox *widget,
} }
static void static void
scale_callback (GtkAdjustment *adj, scale_callback (GimpScaleEntry *scale,
ComposeInput *input) ComposeInput *input)
{ {
input->comp.val = gtk_adjustment_get_value (adj); input->comp.val = gimp_scale_entry_get_value (scale);
} }
static void static void
@ -1472,7 +1465,6 @@ type_combo_callback (GimpIntComboBox *combo,
gtk_widget_set_sensitive (composeint.channel_menu[3], combo4); gtk_widget_set_sensitive (composeint.channel_menu[3], combo4);
scale4 = combo4 && !composeint.selected[3].is_object; scale4 = combo4 && !composeint.selected[3].is_object;
gtk_widget_set_sensitive (composeint.color_scales[3], scale4); gtk_widget_set_sensitive (composeint.scales[3], scale4);
gtk_widget_set_sensitive (composeint.color_spins[3], scale4);
} }
} }