mirror of https://github.com/GNOME/gimp.git
app: factor gimp_prop_widget_new() out of gimp_prop_table_new()
The new function generically returns a widget for one property and is used in gimp_prop_table_new().
This commit is contained in:
parent
21d97b02ce
commit
5ffa278da5
|
@ -47,214 +47,77 @@
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_prop_table_chain_toggled (GimpChainButton *chain,
|
|
||||||
GtkAdjustment *x_adj)
|
|
||||||
{
|
|
||||||
GtkAdjustment *y_adj;
|
|
||||||
|
|
||||||
y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
|
|
||||||
|
|
||||||
if (gimp_chain_button_get_active (chain))
|
|
||||||
{
|
|
||||||
GBinding *binding;
|
|
||||||
|
|
||||||
binding = g_object_bind_property (x_adj, "value",
|
|
||||||
y_adj, "value",
|
|
||||||
G_BINDING_BIDIRECTIONAL);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (chain), "binding", binding);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GBinding *binding;
|
|
||||||
|
|
||||||
binding = g_object_get_data (G_OBJECT (chain), "binding");
|
|
||||||
|
|
||||||
g_object_unref (binding);
|
|
||||||
g_object_set_data (G_OBJECT (chain), "binding", NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_prop_table_new_seed_clicked (GtkButton *button,
|
|
||||||
GtkAdjustment *adj)
|
|
||||||
{
|
|
||||||
guint32 value = g_random_int_range (gtk_adjustment_get_lower (adj),
|
|
||||||
gtk_adjustment_get_upper (adj));
|
|
||||||
|
|
||||||
gtk_adjustment_set_value (adj, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gimp_prop_table_new (GObject *config,
|
|
||||||
GType owner_type,
|
|
||||||
GimpContext *context,
|
|
||||||
GimpCreatePickerFunc create_picker_func,
|
|
||||||
gpointer picker_creator)
|
|
||||||
{
|
|
||||||
GtkWidget *table;
|
|
||||||
GtkSizeGroup *size_group;
|
|
||||||
GParamSpec **param_specs;
|
|
||||||
guint n_param_specs;
|
|
||||||
gint i;
|
|
||||||
gint row = 0;
|
|
||||||
GParamSpec *last_pspec = NULL;
|
|
||||||
GtkAdjustment *last_x_adj = NULL;
|
|
||||||
gint last_x_row = 0;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
|
||||||
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
|
|
||||||
|
|
||||||
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
|
|
||||||
&n_param_specs);
|
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
||||||
|
|
||||||
table = gtk_table_new (3, 1, FALSE);
|
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
||||||
|
|
||||||
for (i = 0; i < n_param_specs; i++)
|
|
||||||
{
|
|
||||||
GParamSpec *pspec = param_specs[i];
|
|
||||||
GtkWidget *widget = NULL;
|
|
||||||
const gchar *label = NULL;
|
|
||||||
|
|
||||||
/* ignore properties of parent classes of owner_type */
|
|
||||||
if (! g_type_is_a (pspec->owner_type, owner_type))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
|
#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
|
||||||
|
|
||||||
if (HAS_KEY (pspec, "role", "output-extent"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (G_IS_PARAM_SPEC_STRING (pspec))
|
static void gimp_prop_widget_new_seed_clicked (GtkButton *button,
|
||||||
|
GtkAdjustment *adj);
|
||||||
|
static void gimp_prop_table_chain_toggled (GimpChainButton *chain,
|
||||||
|
GtkAdjustment *x_adj);
|
||||||
|
|
||||||
|
|
||||||
|
/* public functions */
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gimp_prop_widget_new (GObject *config,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpCreatePickerFunc create_picker_func,
|
||||||
|
gpointer picker_creator,
|
||||||
|
const gchar **label)
|
||||||
|
{
|
||||||
|
GtkWidget *widget = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
||||||
|
g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (config), pspec->owner_type),
|
||||||
|
NULL);
|
||||||
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||||
|
g_return_val_if_fail (label != NULL, NULL);
|
||||||
|
|
||||||
|
*label = NULL;
|
||||||
|
|
||||||
|
if (G_IS_PARAM_SPEC_INT (pspec) ||
|
||||||
|
G_IS_PARAM_SPEC_UINT (pspec) ||
|
||||||
|
G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
||||||
|
G_IS_PARAM_SPEC_DOUBLE (pspec))
|
||||||
|
{
|
||||||
|
gdouble lower;
|
||||||
|
gdouble upper;
|
||||||
|
gdouble step;
|
||||||
|
gdouble page;
|
||||||
|
gint digits;
|
||||||
|
|
||||||
|
if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
|
||||||
{
|
{
|
||||||
static GQuark multiline_quark = 0;
|
GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
|
||||||
|
|
||||||
if (! multiline_quark)
|
lower = gspec->ui_minimum;
|
||||||
multiline_quark = g_quark_from_static_string ("multiline");
|
upper = gspec->ui_maximum;
|
||||||
|
step = gspec->ui_step_small;
|
||||||
if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
|
page = gspec->ui_step_big;
|
||||||
{
|
digits = gspec->ui_digits;
|
||||||
widget = gimp_prop_file_chooser_button_new (config,
|
|
||||||
pspec->name,
|
|
||||||
g_param_spec_get_nick (pspec),
|
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
||||||
}
|
|
||||||
else if (g_param_spec_get_qdata (pspec, multiline_quark))
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkWidget *view;
|
|
||||||
|
|
||||||
buffer = gimp_prop_text_buffer_new (config, pspec->name, -1);
|
|
||||||
view = gtk_text_view_new_with_buffer (buffer);
|
|
||||||
|
|
||||||
widget = gtk_scrolled_window_new (NULL, NULL);
|
|
||||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
|
|
||||||
GTK_SHADOW_IN);
|
|
||||||
gtk_container_add (GTK_CONTAINER (widget), view);
|
|
||||||
gtk_widget_show (view);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
widget = gimp_prop_entry_new (config, pspec->name, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
label = g_param_spec_get_nick (pspec);
|
|
||||||
}
|
}
|
||||||
else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
|
else if (GEGL_IS_PARAM_SPEC_INT (pspec))
|
||||||
{
|
{
|
||||||
widget = gimp_prop_check_button_new (config, pspec->name,
|
GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
|
||||||
g_param_spec_get_nick (pspec));
|
|
||||||
|
lower = gspec->ui_minimum;
|
||||||
|
upper = gspec->ui_maximum;
|
||||||
|
step = gspec->ui_step_small;
|
||||||
|
page = gspec->ui_step_big;
|
||||||
|
digits = 0;
|
||||||
}
|
}
|
||||||
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
else
|
||||||
{
|
{
|
||||||
widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0);
|
gdouble value;
|
||||||
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget),
|
|
||||||
g_param_spec_get_nick (pspec));
|
|
||||||
}
|
|
||||||
else if (GEGL_IS_PARAM_SPEC_SEED (pspec))
|
|
||||||
{
|
|
||||||
GtkAdjustment *adj;
|
|
||||||
GtkWidget *spin;
|
|
||||||
GtkWidget *button;
|
|
||||||
|
|
||||||
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
_gimp_prop_widgets_get_numeric_values (config, pspec,
|
||||||
|
&value, &lower, &upper,
|
||||||
|
G_STRFUNC);
|
||||||
|
|
||||||
spin = gimp_prop_spin_button_new (config, pspec->name,
|
if ((upper - lower <= 1.0) &&
|
||||||
1.0, 10.0, 0);
|
(G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
||||||
gtk_box_pack_start (GTK_BOX (widget), spin, TRUE, TRUE, 0);
|
G_IS_PARAM_SPEC_DOUBLE (pspec)))
|
||||||
gtk_widget_show (spin);
|
|
||||||
|
|
||||||
button = gtk_button_new_with_label (_("New Seed"));
|
|
||||||
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (button);
|
|
||||||
|
|
||||||
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
|
|
||||||
|
|
||||||
g_signal_connect (button, "clicked",
|
|
||||||
G_CALLBACK (gimp_prop_table_new_seed_clicked),
|
|
||||||
adj);
|
|
||||||
|
|
||||||
label = g_param_spec_get_nick (pspec);
|
|
||||||
}
|
|
||||||
else if (G_IS_PARAM_SPEC_INT (pspec) ||
|
|
||||||
G_IS_PARAM_SPEC_UINT (pspec) ||
|
|
||||||
G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
|
||||||
G_IS_PARAM_SPEC_DOUBLE (pspec))
|
|
||||||
{
|
|
||||||
GtkAdjustment *adj;
|
|
||||||
gdouble lower;
|
|
||||||
gdouble upper;
|
|
||||||
gdouble step;
|
|
||||||
gdouble page;
|
|
||||||
gint digits;
|
|
||||||
|
|
||||||
if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
|
|
||||||
{
|
|
||||||
GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
|
|
||||||
|
|
||||||
lower = gspec->ui_minimum;
|
|
||||||
upper = gspec->ui_maximum;
|
|
||||||
}
|
|
||||||
else if (GEGL_IS_PARAM_SPEC_INT (pspec))
|
|
||||||
{
|
|
||||||
GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
|
|
||||||
|
|
||||||
lower = gspec->ui_minimum;
|
|
||||||
upper = gspec->ui_maximum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gdouble value;
|
|
||||||
|
|
||||||
_gimp_prop_widgets_get_numeric_values (config, pspec,
|
|
||||||
&value, &lower, &upper,
|
|
||||||
G_STRFUNC);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
|
|
||||||
{
|
|
||||||
GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
|
|
||||||
|
|
||||||
step = gspec->ui_step_small;
|
|
||||||
page = gspec->ui_step_big;
|
|
||||||
digits = gspec->ui_digits;
|
|
||||||
}
|
|
||||||
else if (GEGL_IS_PARAM_SPEC_INT (pspec))
|
|
||||||
{
|
|
||||||
GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
|
|
||||||
|
|
||||||
step = gspec->ui_step_small;
|
|
||||||
page = gspec->ui_step_big;
|
|
||||||
digits = 0;
|
|
||||||
}
|
|
||||||
else if ((upper - lower <= 1.0) &&
|
|
||||||
(G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
|
||||||
G_IS_PARAM_SPEC_DOUBLE (pspec)))
|
|
||||||
{
|
{
|
||||||
step = 0.01;
|
step = 0.01;
|
||||||
page = 0.1;
|
page = 0.1;
|
||||||
|
@ -275,28 +138,189 @@ gimp_prop_table_new (GObject *config,
|
||||||
digits = (G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
digits = (G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
||||||
G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0;
|
G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
widget = gimp_prop_spin_scale_new (config, pspec->name,
|
widget = gimp_prop_spin_scale_new (config, pspec->name,
|
||||||
g_param_spec_get_nick (pspec),
|
g_param_spec_get_nick (pspec),
|
||||||
step, page, digits);
|
step, page, digits);
|
||||||
|
|
||||||
|
if (HAS_KEY (pspec, "unit", "degree") &&
|
||||||
|
(upper - lower) == 360.0)
|
||||||
|
{
|
||||||
|
GtkWidget *hbox;
|
||||||
|
GtkWidget *dial;
|
||||||
|
|
||||||
|
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE);
|
||||||
|
|
||||||
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show (widget);
|
||||||
|
|
||||||
|
dial = gimp_prop_angle_dial_new (config, pspec->name);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), dial, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (dial);
|
||||||
|
|
||||||
|
widget = hbox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (G_IS_PARAM_SPEC_STRING (pspec))
|
||||||
|
{
|
||||||
|
static GQuark multiline_quark = 0;
|
||||||
|
|
||||||
|
if (! multiline_quark)
|
||||||
|
multiline_quark = g_quark_from_static_string ("multiline");
|
||||||
|
|
||||||
|
if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
|
||||||
|
{
|
||||||
|
widget = gimp_prop_file_chooser_button_new (config,
|
||||||
|
pspec->name,
|
||||||
|
g_param_spec_get_nick (pspec),
|
||||||
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||||
|
}
|
||||||
|
else if (g_param_spec_get_qdata (pspec, multiline_quark))
|
||||||
|
{
|
||||||
|
GtkTextBuffer *buffer;
|
||||||
|
GtkWidget *view;
|
||||||
|
|
||||||
|
buffer = gimp_prop_text_buffer_new (config, pspec->name, -1);
|
||||||
|
view = gtk_text_view_new_with_buffer (buffer);
|
||||||
|
|
||||||
|
widget = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
|
||||||
|
GTK_SHADOW_IN);
|
||||||
|
gtk_container_add (GTK_CONTAINER (widget), view);
|
||||||
|
gtk_widget_show (view);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
widget = gimp_prop_entry_new (config, pspec->name, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
*label = g_param_spec_get_nick (pspec);
|
||||||
|
}
|
||||||
|
else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
|
||||||
|
{
|
||||||
|
widget = gimp_prop_check_button_new (config, pspec->name,
|
||||||
|
g_param_spec_get_nick (pspec));
|
||||||
|
}
|
||||||
|
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
||||||
|
{
|
||||||
|
widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0);
|
||||||
|
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget),
|
||||||
|
g_param_spec_get_nick (pspec));
|
||||||
|
}
|
||||||
|
else if (GEGL_IS_PARAM_SPEC_SEED (pspec))
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj;
|
||||||
|
GtkWidget *spin;
|
||||||
|
GtkWidget *button;
|
||||||
|
|
||||||
|
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||||
|
|
||||||
|
spin = gimp_prop_spin_button_new (config, pspec->name,
|
||||||
|
1.0, 10.0, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (widget), spin, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show (spin);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label (_("New Seed"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
|
||||||
|
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
|
||||||
|
|
||||||
|
g_signal_connect (button, "clicked",
|
||||||
|
G_CALLBACK (gimp_prop_widget_new_seed_clicked),
|
||||||
|
adj);
|
||||||
|
|
||||||
|
*label = g_param_spec_get_nick (pspec);
|
||||||
|
}
|
||||||
|
else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
|
||||||
|
{
|
||||||
|
GtkWidget *button;
|
||||||
|
|
||||||
|
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||||
|
|
||||||
|
button = gimp_prop_color_button_new (config, pspec->name,
|
||||||
|
g_param_spec_get_nick (pspec),
|
||||||
|
128, 24,
|
||||||
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||||
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
|
||||||
|
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
|
||||||
|
gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
|
||||||
|
if (create_picker_func)
|
||||||
|
{
|
||||||
|
button = create_picker_func (picker_creator,
|
||||||
|
pspec->name,
|
||||||
|
GIMP_STOCK_COLOR_PICKER_GRAY,
|
||||||
|
_("Pick color from the image"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
}
|
||||||
|
|
||||||
|
*label = g_param_spec_get_nick (pspec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC,
|
||||||
|
g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gimp_prop_table_new (GObject *config,
|
||||||
|
GType owner_type,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpCreatePickerFunc create_picker_func,
|
||||||
|
gpointer picker_creator)
|
||||||
|
{
|
||||||
|
GtkWidget *table;
|
||||||
|
GParamSpec **param_specs;
|
||||||
|
guint n_param_specs;
|
||||||
|
gint i;
|
||||||
|
gint row = 0;
|
||||||
|
GParamSpec *last_pspec = NULL;
|
||||||
|
GtkAdjustment *last_x_adj = NULL;
|
||||||
|
gint last_x_row = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
||||||
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||||
|
|
||||||
|
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
|
||||||
|
&n_param_specs);
|
||||||
|
|
||||||
|
table = gtk_table_new (3, 1, FALSE);
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
||||||
|
|
||||||
|
for (i = 0; i < n_param_specs; i++)
|
||||||
|
{
|
||||||
|
GParamSpec *pspec = param_specs[i];
|
||||||
|
GtkWidget *widget = NULL;
|
||||||
|
const gchar *label = NULL;
|
||||||
|
|
||||||
|
/* ignore properties of parent classes of owner_type */
|
||||||
|
if (! g_type_is_a (pspec->owner_type, owner_type))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (HAS_KEY (pspec, "role", "output-extent"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
widget = gimp_prop_widget_new (config, pspec, context,
|
||||||
|
create_picker_func, picker_creator,
|
||||||
|
&label);
|
||||||
|
|
||||||
|
if (GTK_IS_SPIN_BUTTON (widget))
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj;
|
||||||
|
|
||||||
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
|
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
|
||||||
|
|
||||||
if (HAS_KEY (pspec, "unit", "degree") &&
|
if (HAS_KEY (pspec, "axis", "x"))
|
||||||
(upper - lower) == 360.0)
|
|
||||||
{
|
|
||||||
GtkWidget *dial;
|
|
||||||
|
|
||||||
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE);
|
|
||||||
|
|
||||||
dial = gimp_prop_angle_dial_new (config, pspec->name);
|
|
||||||
gtk_table_attach (GTK_TABLE (table), dial,
|
|
||||||
4, 5, row, row + 1,
|
|
||||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL,
|
|
||||||
0, 0);
|
|
||||||
gtk_widget_show (dial);
|
|
||||||
}
|
|
||||||
else if (HAS_KEY (pspec, "axis", "x"))
|
|
||||||
{
|
{
|
||||||
last_pspec = pspec;
|
last_pspec = pspec;
|
||||||
last_x_adj = adj;
|
last_x_adj = adj;
|
||||||
|
@ -362,38 +386,6 @@ gimp_prop_table_new (GObject *config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
|
|
||||||
{
|
|
||||||
GtkWidget *button;
|
|
||||||
|
|
||||||
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
|
||||||
|
|
||||||
button = gimp_prop_color_button_new (config, pspec->name,
|
|
||||||
g_param_spec_get_nick (pspec),
|
|
||||||
128, 24,
|
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
|
||||||
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
|
|
||||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
|
|
||||||
gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_show (button);
|
|
||||||
|
|
||||||
if (create_picker_func)
|
|
||||||
{
|
|
||||||
button = create_picker_func (picker_creator,
|
|
||||||
pspec->name,
|
|
||||||
GIMP_STOCK_COLOR_PICKER_GRAY,
|
|
||||||
_("Pick color from the image"));
|
|
||||||
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (button);
|
|
||||||
}
|
|
||||||
|
|
||||||
label = g_param_spec_get_nick (pspec);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC,
|
|
||||||
g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget)
|
if (widget)
|
||||||
{
|
{
|
||||||
|
@ -414,9 +406,49 @@ gimp_prop_table_new (GObject *config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (size_group);
|
|
||||||
|
|
||||||
g_free (param_specs);
|
g_free (param_specs);
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* private functions */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_prop_widget_new_seed_clicked (GtkButton *button,
|
||||||
|
GtkAdjustment *adj)
|
||||||
|
{
|
||||||
|
guint32 value = g_random_int_range (gtk_adjustment_get_lower (adj),
|
||||||
|
gtk_adjustment_get_upper (adj));
|
||||||
|
|
||||||
|
gtk_adjustment_set_value (adj, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_prop_table_chain_toggled (GimpChainButton *chain,
|
||||||
|
GtkAdjustment *x_adj)
|
||||||
|
{
|
||||||
|
GtkAdjustment *y_adj;
|
||||||
|
|
||||||
|
y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
|
||||||
|
|
||||||
|
if (gimp_chain_button_get_active (chain))
|
||||||
|
{
|
||||||
|
GBinding *binding;
|
||||||
|
|
||||||
|
binding = g_object_bind_property (x_adj, "value",
|
||||||
|
y_adj, "value",
|
||||||
|
G_BINDING_BIDIRECTIONAL);
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (chain), "binding", binding);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GBinding *binding;
|
||||||
|
|
||||||
|
binding = g_object_get_data (G_OBJECT (chain), "binding");
|
||||||
|
|
||||||
|
g_object_unref (binding);
|
||||||
|
g_object_set_data (G_OBJECT (chain), "binding", NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -29,11 +29,18 @@ typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
|
||||||
const gchar *icon_name,
|
const gchar *icon_name,
|
||||||
const gchar *tooltip);
|
const gchar *tooltip);
|
||||||
|
|
||||||
GtkWidget * gimp_prop_table_new (GObject *config,
|
GtkWidget * gimp_prop_widget_new (GObject *config,
|
||||||
GType owner_type,
|
GParamSpec *pspec,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GimpCreatePickerFunc create_picker_func,
|
GimpCreatePickerFunc create_picker_func,
|
||||||
gpointer picker_creator);
|
gpointer picker_creator,
|
||||||
|
const gchar **label);
|
||||||
|
GtkWidget * gimp_prop_table_new (GObject *config,
|
||||||
|
GType owner_type,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpCreatePickerFunc create_picker_func,
|
||||||
|
gpointer picker_creator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_PROP_TABLE_H__ */
|
#endif /* __GIMP_PROP_TABLE_H__ */
|
||||||
|
|
Loading…
Reference in New Issue