app: use gimp_prop_spin_scale_new() in GimpColorBalanceTool

This commit is contained in:
Michael Natterer 2013-05-28 23:18:53 +02:00
parent bf3a1c89ef
commit 1822bd1502
2 changed files with 33 additions and 148 deletions

View File

@ -34,6 +34,7 @@
#include "core/gimpimage.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppropwidgets.h"
#include "display/gimpdisplay.h"
@ -55,18 +56,8 @@ static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_to
static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool);
static void color_balance_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_cr_changed (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_mg_changed (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_yb_changed (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
G_DEFINE_TYPE (GimpColorBalanceTool, gimp_color_balance_tool,
@ -144,10 +135,6 @@ gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
cb_tool->config = g_object_new (GIMP_TYPE_COLOR_BALANCE_CONFIG, NULL);
g_signal_connect_object (cb_tool->config, "notify",
G_CALLBACK (color_balance_config_notify),
G_OBJECT (cb_tool), 0);
*config = G_OBJECT (cb_tool->config);
return gegl_node_new_child (NULL,
@ -161,17 +148,16 @@ gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
/* Color Balance dialog */
/**************************/
static GtkAdjustment *
create_levels_scale (gdouble value,
const gchar *left,
const gchar *right,
GtkWidget *table,
gint col)
static void
create_levels_scale (GObject *config,
const gchar *property_name,
const gchar *left,
const gchar *right,
GtkWidget *table,
gint col)
{
GtkWidget *label;
GtkWidget *slider;
GtkWidget *spinbutton;
GtkAdjustment *adj;
GtkWidget *label;
GtkWidget *scale;
label = gtk_label_new (left);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
@ -179,40 +165,28 @@ create_levels_scale (gdouble value,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
spinbutton = gimp_spin_button_new ((GtkObject **) &adj,
value, -100.0, 100.0,
1.0, 10.0, 0.0, 1.0, 0);
slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adj);
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
gtk_widget_set_size_request (slider, 100, -1);
gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, col, col + 1);
gtk_widget_show (slider);
scale = gimp_prop_spin_scale_new (config, property_name,
NULL, 0.01, 0.1, 2);
gtk_table_attach_defaults (GTK_TABLE (table), scale, 1, 2, col, col + 1);
gtk_widget_show (scale);
label = gtk_label_new (right);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 2, 3, col, col + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table), spinbutton, 3, 4, col, col + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (spinbutton);
return adj;
}
static void
gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
GimpColorBalanceConfig *config = cb_tool->config;
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
GtkWidget *button;
GtkWidget *frame;
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
GtkWidget *button;
GtkWidget *frame;
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
@ -231,38 +205,23 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (vbox);
/* The table containing sliders */
table = gtk_table_new (3, 4, FALSE);
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
cb_tool->cyan_red_adj =
create_levels_scale (config->cyan_red[config->range] * 100.0,
_("Cyan"), _("Red"),
table, 0);
create_levels_scale (image_map_tool->config, "cyan-red",
_("Cyan"), _("Red"),
table, 0);
g_signal_connect (cb_tool->cyan_red_adj, "value-changed",
G_CALLBACK (color_balance_cr_changed),
cb_tool);
create_levels_scale (image_map_tool->config, "magenta-green",
_("Magenta"), _("Green"),
table, 1);
cb_tool->magenta_green_adj =
create_levels_scale (config->magenta_green[config->range] * 100.0,
_("Magenta"), _("Green"),
table, 1);
g_signal_connect (cb_tool->magenta_green_adj, "value-changed",
G_CALLBACK (color_balance_mg_changed),
cb_tool);
cb_tool->yellow_blue_adj =
create_levels_scale (config->yellow_blue[config->range] * 100.0,
_("Yellow"), _("Blue"),
table, 2);
g_signal_connect (cb_tool->yellow_blue_adj, "value-changed",
G_CALLBACK (color_balance_yb_changed),
cb_tool);
create_levels_scale (image_map_tool->config, "yellow-blue",
_("Yellow"), _("Blue"),
table, 2);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
@ -309,78 +268,9 @@ gimp_color_balance_tool_reset (GimpImageMapTool *im_tool)
g_object_thaw_notify (im_tool->config);
}
static void
color_balance_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (object);
if (! cb_tool->cyan_red_adj)
return;
if (! strcmp (pspec->name, "cyan-red"))
{
gtk_adjustment_set_value (cb_tool->cyan_red_adj,
config->cyan_red[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "magenta-green"))
{
gtk_adjustment_set_value (cb_tool->magenta_green_adj,
config->magenta_green[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "yellow-blue"))
{
gtk_adjustment_set_value (cb_tool->yellow_blue_adj,
config->yellow_blue[config->range] * 100.0);
}
}
static void
color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool)
{
gimp_color_balance_config_reset_range (cb_tool->config);
}
static void
color_balance_cr_changed (GtkAdjustment *adjustment,
GimpColorBalanceTool *cb_tool)
{
gdouble value = gtk_adjustment_get_value (adjustment) / 100.0;
if (cb_tool->config->cyan_red[cb_tool->config->range] != value)
{
g_object_set (cb_tool->config,
"cyan-red", value,
NULL);
}
}
static void
color_balance_mg_changed (GtkAdjustment *adjustment,
GimpColorBalanceTool *cb_tool)
{
gdouble value = gtk_adjustment_get_value (adjustment) / 100.0;
if (cb_tool->config->magenta_green[cb_tool->config->range] != value)
{
g_object_set (cb_tool->config,
"magenta-green", value,
NULL);
}
}
static void
color_balance_yb_changed (GtkAdjustment *adjustment,
GimpColorBalanceTool *cb_tool)
{
gdouble value = gtk_adjustment_get_value (adjustment) / 100.0;
if (cb_tool->config->yellow_blue[cb_tool->config->range] != value)
{
g_object_set (cb_tool->config,
"yellow-blue", value,
NULL);
}
}

View File

@ -39,11 +39,6 @@ struct _GimpColorBalanceTool
GimpImageMapTool parent_instance;
GimpColorBalanceConfig *config;
/* dialog */
GtkAdjustment *cyan_red_adj;
GtkAdjustment *magenta_green_adj;
GtkAdjustment *yellow_blue_adj;
};
struct _GimpColorBalanceToolClass