[gimp] app: clean up the generated and custom GEGL GUI code a bit
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: clean up the generated and custom GEGL GUI code a bit
- Date: Mon, 2 Jun 2014 18:31:01 +0000 (UTC)
commit 660854f53c51b16b8126be0e399a4bb3b589f24d
Author: Michael Natterer <mitch gimp org>
Date: Mon Jun 2 20:27:59 2014 +0200
app: clean up the generated and custom GEGL GUI code a bit
Still slightly horrible but getting better...
app/widgets/gimppropgui-constructors.c | 81 ++++++++++++++++----------------
app/widgets/gimppropgui.c | 46 +++++++++++++------
app/widgets/gimppropgui.h | 28 +++++++----
3 files changed, 89 insertions(+), 66 deletions(-)
---
diff --git a/app/widgets/gimppropgui-constructors.c b/app/widgets/gimppropgui-constructors.c
index a2fccbb..6d51ca6 100644
--- a/app/widgets/gimppropgui-constructors.c
+++ b/app/widgets/gimppropgui-constructors.c
@@ -100,12 +100,14 @@ _gimp_prop_gui_new_generic (GObject *config,
i++;
- widget_x = gimp_prop_widget_new (config, pspec, context,
- create_picker_func, picker_creator,
- &label_x);
- widget_y = gimp_prop_widget_new (config, next_pspec, context,
- create_picker_func, picker_creator,
- &label_y);
+ widget_x = gimp_prop_widget_new_from_pspec (config, pspec, context,
+ create_picker_func,
+ picker_creator,
+ &label_x);
+ widget_y = gimp_prop_widget_new_from_pspec (config, next_pspec, context,
+ create_picker_func,
+ picker_creator,
+ &label_y);
adj_x = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget_x));
adj_y = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget_y));
@@ -176,9 +178,10 @@ _gimp_prop_gui_new_generic (GObject *config,
GtkWidget *widget;
const gchar *label;
- widget = gimp_prop_widget_new (config, pspec, context,
- create_picker_func, picker_creator,
- &label);
+ widget = gimp_prop_widget_new_from_pspec (config, pspec, context,
+ create_picker_func,
+ picker_creator,
+ &label);
if (widget && label)
{
@@ -257,10 +260,10 @@ select_all_clicked (GtkWidget *button,
}
static GtkWidget *
-gimp_prop_angle_range_box_new (GObject *config,
- GParamSpec *alpha_pspec,
- GParamSpec *beta_pspec,
- GParamSpec *clockwise_pspec)
+gimp_prop_angle_range_box_new (GObject *config,
+ const gchar *alpha_property_name,
+ const gchar *beta_property_name,
+ const gchar *clockwise_property_name)
{
GtkWidget *main_hbox;
GtkWidget *vbox;
@@ -277,15 +280,13 @@ gimp_prop_angle_range_box_new (GObject *config,
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
- scale = gimp_prop_spin_scale_new (config, alpha_pspec->name,
- g_param_spec_get_nick (alpha_pspec),
+ scale = gimp_prop_spin_scale_new (config, alpha_property_name, NULL,
1.0, 15.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (scale), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
- scale = gimp_prop_spin_scale_new (config, beta_pspec->name,
- g_param_spec_get_nick (beta_pspec),
+ scale = gimp_prop_spin_scale_new (config, beta_property_name, NULL,
1.0, 15.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (scale), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
@@ -296,8 +297,8 @@ gimp_prop_angle_range_box_new (GObject *config,
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
- button = gimp_prop_check_button_new (config, clockwise_pspec->name,
- g_param_spec_get_nick (clockwise_pspec));
+ button = gimp_prop_check_button_new (config, clockwise_property_name,
+ _("Clockwise"));
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
@@ -310,9 +311,9 @@ gimp_prop_angle_range_box_new (GObject *config,
gtk_widget_show (all_button);
dial = gimp_prop_angle_range_dial_new (config,
- alpha_pspec->name,
- beta_pspec->name,
- clockwise_pspec->name);
+ alpha_property_name,
+ beta_property_name,
+ clockwise_property_name);
gtk_box_pack_start (GTK_BOX (main_hbox), dial, FALSE, FALSE, 0);
gtk_widget_show (dial);
@@ -328,9 +329,9 @@ gimp_prop_angle_range_box_new (GObject *config,
}
static GtkWidget *
-gimp_prop_polar_box_new (GObject *config,
- GParamSpec *angle_pspec,
- GParamSpec *radius_pspec)
+gimp_prop_polar_box_new (GObject *config,
+ const gchar *angle_property_name,
+ const gchar *radius_property_name)
{
GtkWidget *main_hbox;
GtkWidget *vbox;
@@ -343,22 +344,20 @@ gimp_prop_polar_box_new (GObject *config,
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
- scale = gimp_prop_spin_scale_new (config, angle_pspec->name,
- g_param_spec_get_nick (angle_pspec),
+ scale = gimp_prop_spin_scale_new (config, angle_property_name, NULL,
1.0, 15.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (scale), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
- scale = gimp_prop_spin_scale_new (config, radius_pspec->name,
- g_param_spec_get_nick (radius_pspec),
+ scale = gimp_prop_spin_scale_new (config, radius_property_name, NULL,
1.0, 15.0, 2);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
polar = gimp_prop_polar_new (config,
- angle_pspec->name,
- radius_pspec->name);
+ angle_property_name,
+ radius_property_name);
gtk_box_pack_start (GTK_BOX (main_hbox), polar, FALSE, FALSE, 0);
gtk_widget_show (polar);
@@ -390,9 +389,9 @@ _gimp_prop_gui_new_color_rotate (GObject *config,
gtk_widget_show (frame);
box = gimp_prop_angle_range_box_new (config,
- param_specs[1],
- param_specs[2],
- param_specs[0]);
+ param_specs[1]->name,
+ param_specs[2]->name,
+ param_specs[0]->name);
gtk_container_add (GTK_CONTAINER (frame), box);
gtk_widget_show (box);
@@ -401,9 +400,9 @@ _gimp_prop_gui_new_color_rotate (GObject *config,
gtk_widget_show (frame);
box = gimp_prop_angle_range_box_new (config,
- param_specs[4],
- param_specs[5],
- param_specs[3]);
+ param_specs[4]->name,
+ param_specs[5]->name,
+ param_specs[3]->name);
gtk_container_add (GTK_CONTAINER (frame), box);
gtk_widget_show (box);
@@ -424,8 +423,8 @@ _gimp_prop_gui_new_color_rotate (GObject *config,
gtk_widget_show (box);
box = gimp_prop_polar_box_new (config,
- param_specs[8],
- param_specs[9]);
+ param_specs[8]->name,
+ param_specs[9]->name);
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, FALSE, 0);
gtk_widget_show (box);
@@ -487,12 +486,12 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
- scale = gimp_prop_widget_new (config, param_specs[25],
+ scale = gimp_prop_widget_new (config, "divisor",
context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
gtk_widget_show (scale);
- scale = gimp_prop_widget_new (config, param_specs[26],
+ scale = gimp_prop_widget_new (config, "offset",
context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
gtk_widget_show (scale);
diff --git a/app/widgets/gimppropgui.c b/app/widgets/gimppropgui.c
index 8021dd2..788ba7f 100644
--- a/app/widgets/gimppropgui.c
+++ b/app/widgets/gimppropgui.c
@@ -61,18 +61,37 @@ static void gimp_prop_widget_new_seed_clicked (GtkButton *button,
/* public functions */
GtkWidget *
-gimp_prop_widget_new (GObject *config,
- GParamSpec *pspec,
- GimpContext *context,
- GimpCreatePickerFunc create_picker_func,
- gpointer picker_creator,
- const gchar **label)
+gimp_prop_widget_new (GObject *config,
+ const gchar *property_name,
+ GimpContext *context,
+ GimpCreatePickerFunc create_picker_func,
+ gpointer picker_creator,
+ const gchar **label)
+{
+ GParamSpec *pspec;
+
+ g_return_val_if_fail (G_IS_OBJECT (config), NULL);
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
+ property_name);
+
+ return gimp_prop_widget_new_from_pspec (config, pspec, context,
+ create_picker_func, picker_creator,
+ label);
+}
+
+GtkWidget *
+gimp_prop_widget_new_from_pspec (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 (pspec != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (label != NULL, NULL);
@@ -167,8 +186,7 @@ gimp_prop_widget_new (GObject *config,
}
}
- widget = gimp_prop_spin_scale_new (config, pspec->name,
- g_param_spec_get_nick (pspec),
+ widget = gimp_prop_spin_scale_new (config, pspec->name, NULL,
step, page, digits);
if (HAS_KEY (pspec, "unit", "degree") &&
@@ -216,10 +234,10 @@ gimp_prop_widget_new (GObject *config,
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);
+ 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))
{
diff --git a/app/widgets/gimppropgui.h b/app/widgets/gimppropgui.h
index e822158..4ea35ee 100644
--- a/app/widgets/gimppropgui.h
+++ b/app/widgets/gimppropgui.h
@@ -29,17 +29,23 @@ typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
const gchar *icon_name,
const gchar *tooltip);
-GtkWidget * gimp_prop_widget_new (GObject *config,
- GParamSpec *pspec,
- GimpContext *context,
- GimpCreatePickerFunc create_picker_func,
- gpointer picker_creator,
- const gchar **label);
-GtkWidget * gimp_prop_gui_new (GObject *config,
- GType owner_type,
- GimpContext *context,
- GimpCreatePickerFunc create_picker_func,
- gpointer picker_creator);
+GtkWidget * gimp_prop_widget_new (GObject *config,
+ const gchar *property_name,
+ GimpContext *context,
+ GimpCreatePickerFunc create_picker,
+ gpointer picker_creator,
+ const gchar **label);
+GtkWidget * gimp_prop_widget_new_from_pspec (GObject *config,
+ GParamSpec *pspec,
+ GimpContext *context,
+ GimpCreatePickerFunc create_picker,
+ gpointer picker_creator,
+ const gchar **label);
+GtkWidget * gimp_prop_gui_new (GObject *config,
+ GType owner_type,
+ GimpContext *context,
+ GimpCreatePickerFunc create_picker,
+ gpointer picker_creator);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]