added new prop_widget gimp_prop_int_combo_box_new() which takes a

2004-12-08  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimppropwidgets.[ch]: added new prop_widget
	gimp_prop_int_combo_box_new() which takes a pre-built GimpIntStore
	and allows to create views on int properties with arbitrary sets
	of values (not just enums).

	* app/widgets/gimpcontrollereditor.c
	(gimp_controller_editor_constructor): added support for generic
	combo boxes controlled exclusively by controller properties: if an
	int property "foo" is followed by an object property "foo-values"
	and the contained object is a GimpIntStore, use that store as
	model for selecting "foo"'s values using
	gimp_prop_int_combo_box_new().

	(Allows for more flexible controller configuration, the actual use
	case in the midi controller is still work in progress).
This commit is contained in:
Michael Natterer 2004-12-08 12:46:21 +00:00 committed by Michael Natterer
parent 578ef3f9b0
commit d90360e29f
6 changed files with 198 additions and 37 deletions

View File

@ -1,3 +1,21 @@
2004-12-08 Michael Natterer <mitch@gimp.org>
* app/widgets/gimppropwidgets.[ch]: added new prop_widget
gimp_prop_int_combo_box_new() which takes a pre-built GimpIntStore
and allows to create views on int properties with arbitrary sets
of values (not just enums).
* app/widgets/gimpcontrollereditor.c
(gimp_controller_editor_constructor): added support for generic
combo boxes controlled exclusively by controller properties: if an
int property "foo" is followed by an object property "foo-values"
and the contained object is a GimpIntStore, use that store as
model for selecting "foo"'s values using
gimp_prop_int_combo_box_new().
(Allows for more flexible controller configuration, the actual use
case in the midi controller is still work in progress).
2004-12-06 Sven Neumann <sven@gimp.org>
* tools/authorsgen/contributors: removed duplicate entry for Roman.

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -273,9 +275,36 @@ gimp_controller_editor_constructor (GType type,
{
if (prop_spec->flags & G_PARAM_WRITABLE)
{
widget = gimp_prop_spin_button_new (G_OBJECT (controller),
prop_spec->name,
1, 8, 0);
GimpIntStore *model = NULL;
gchar *model_name = g_strdup_printf ("%s-values",
prop_spec->name);
if (((i + 1) < n_property_specs) &&
! strcmp (model_name, property_specs[i + 1]->name) &&
G_IS_PARAM_SPEC_OBJECT (property_specs[i + 1]) &&
g_type_is_a (property_specs[i + 1]->value_type,
GIMP_TYPE_INT_STORE))
{
g_object_get (controller,
property_specs[i + 1]->name, &model,
NULL);
}
g_free (model_name);
if (model)
{
widget = gimp_prop_int_combo_box_new (G_OBJECT (controller),
prop_spec->name,
model);
g_object_unref (model);
}
else
{
widget = gimp_prop_spin_button_new (G_OBJECT (controller),
prop_spec->name,
1, 8, 0);
}
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
g_param_spec_get_nick (prop_spec),

View File

@ -289,15 +289,65 @@ gimp_prop_enum_check_button_notify (GObject *config,
}
/*********************/
/* enum combo box */
/*********************/
/*************************/
/* int/enum combo box */
/*************************/
static void gimp_prop_enum_combo_box_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_enum_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *widget);
static void gimp_prop_int_combo_box_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_int_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *widget);
GtkWidget *
gimp_prop_int_combo_box_new (GObject *config,
const gchar *property_name,
GimpIntStore *store)
{
GParamSpec *param_spec;
GtkWidget *combo_box;
GtkWidget *widget;
gint value;
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_INT, G_STRFUNC);
if (! param_spec)
return NULL;
g_object_get (config,
property_name, &value,
NULL);
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX,
"model", store,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo_box), value);
g_signal_connect (combo_box, "changed",
G_CALLBACK (gimp_prop_int_combo_box_callback),
config);
/* can't set a tooltip on a combo_box */
if (g_param_spec_get_blurb (param_spec))
{
widget = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (widget), combo_box);
gtk_widget_show (combo_box);
}
else
{
widget = combo_box;
}
set_param_spec (G_OBJECT (combo_box), widget, param_spec);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_int_combo_box_notify),
combo_box);
return widget;
}
GtkWidget *
gimp_prop_enum_combo_box_new (GObject *config,
@ -340,7 +390,7 @@ gimp_prop_enum_combo_box_new (GObject *config,
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo_box), value);
g_signal_connect (combo_box, "changed",
G_CALLBACK (gimp_prop_enum_combo_box_callback),
G_CALLBACK (gimp_prop_int_combo_box_callback),
config);
/* can't set a tooltip on a combo_box */
@ -358,15 +408,15 @@ gimp_prop_enum_combo_box_new (GObject *config,
set_param_spec (G_OBJECT (combo_box), widget, param_spec);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_enum_combo_box_notify),
G_CALLBACK (gimp_prop_int_combo_box_notify),
combo_box);
return widget;
}
static void
gimp_prop_enum_combo_box_callback (GtkWidget *widget,
GObject *config)
gimp_prop_int_combo_box_callback (GtkWidget *widget,
GObject *config)
{
GParamSpec *param_spec;
gint value;
@ -384,9 +434,9 @@ gimp_prop_enum_combo_box_callback (GtkWidget *widget,
}
static void
gimp_prop_enum_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *combo_box)
gimp_prop_int_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *combo_box)
{
gint value;
@ -395,13 +445,13 @@ gimp_prop_enum_combo_box_notify (GObject *config,
NULL);
g_signal_handlers_block_by_func (combo_box,
gimp_prop_enum_combo_box_callback,
gimp_prop_int_combo_box_callback,
config);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo_box), value);
g_signal_handlers_unblock_by_func (combo_box,
gimp_prop_enum_combo_box_callback,
gimp_prop_int_combo_box_callback,
config);
}

View File

@ -39,6 +39,13 @@ GtkWidget * gimp_prop_boolean_radio_frame_new (GObject *config,
const gchar *false_text);
/* GParamInt */
GtkWidget * gimp_prop_int_combo_box_new (GObject *config,
const gchar *property_name,
GimpIntStore *int_store);
/* GParamEnum */
GtkWidget * gimp_prop_enum_combo_box_new (GObject *config,

View File

@ -289,15 +289,65 @@ gimp_prop_enum_check_button_notify (GObject *config,
}
/*********************/
/* enum combo box */
/*********************/
/*************************/
/* int/enum combo box */
/*************************/
static void gimp_prop_enum_combo_box_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_enum_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *widget);
static void gimp_prop_int_combo_box_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_int_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *widget);
GtkWidget *
gimp_prop_int_combo_box_new (GObject *config,
const gchar *property_name,
GimpIntStore *store)
{
GParamSpec *param_spec;
GtkWidget *combo_box;
GtkWidget *widget;
gint value;
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_INT, G_STRFUNC);
if (! param_spec)
return NULL;
g_object_get (config,
property_name, &value,
NULL);
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX,
"model", store,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo_box), value);
g_signal_connect (combo_box, "changed",
G_CALLBACK (gimp_prop_int_combo_box_callback),
config);
/* can't set a tooltip on a combo_box */
if (g_param_spec_get_blurb (param_spec))
{
widget = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (widget), combo_box);
gtk_widget_show (combo_box);
}
else
{
widget = combo_box;
}
set_param_spec (G_OBJECT (combo_box), widget, param_spec);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_int_combo_box_notify),
combo_box);
return widget;
}
GtkWidget *
gimp_prop_enum_combo_box_new (GObject *config,
@ -340,7 +390,7 @@ gimp_prop_enum_combo_box_new (GObject *config,
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo_box), value);
g_signal_connect (combo_box, "changed",
G_CALLBACK (gimp_prop_enum_combo_box_callback),
G_CALLBACK (gimp_prop_int_combo_box_callback),
config);
/* can't set a tooltip on a combo_box */
@ -358,15 +408,15 @@ gimp_prop_enum_combo_box_new (GObject *config,
set_param_spec (G_OBJECT (combo_box), widget, param_spec);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_enum_combo_box_notify),
G_CALLBACK (gimp_prop_int_combo_box_notify),
combo_box);
return widget;
}
static void
gimp_prop_enum_combo_box_callback (GtkWidget *widget,
GObject *config)
gimp_prop_int_combo_box_callback (GtkWidget *widget,
GObject *config)
{
GParamSpec *param_spec;
gint value;
@ -384,9 +434,9 @@ gimp_prop_enum_combo_box_callback (GtkWidget *widget,
}
static void
gimp_prop_enum_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *combo_box)
gimp_prop_int_combo_box_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *combo_box)
{
gint value;
@ -395,13 +445,13 @@ gimp_prop_enum_combo_box_notify (GObject *config,
NULL);
g_signal_handlers_block_by_func (combo_box,
gimp_prop_enum_combo_box_callback,
gimp_prop_int_combo_box_callback,
config);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo_box), value);
g_signal_handlers_unblock_by_func (combo_box,
gimp_prop_enum_combo_box_callback,
gimp_prop_int_combo_box_callback,
config);
}

View File

@ -39,6 +39,13 @@ GtkWidget * gimp_prop_boolean_radio_frame_new (GObject *config,
const gchar *false_text);
/* GParamInt */
GtkWidget * gimp_prop_int_combo_box_new (GObject *config,
const gchar *property_name,
GimpIntStore *int_store);
/* GParamEnum */
GtkWidget * gimp_prop_enum_combo_box_new (GObject *config,