Commit b23b0350 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added new constructor gimp_enum_combo_box_new_with_model(). Also override

2005-06-27  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpenumcombobox.[ch]: added new constructor
	gimp_enum_combo_box_new_with_model(). Also override the "model"
	property to make it clear that GimpEnumComboBox expects to be
	used with GimpEnumStore.

	* libgimpwidgets/gimpwidgets.def: updated.

	* app/tools/gimpcurvestool.c
	* app/tools/gimplevelstool.c
	* app/widgets/gimpwidgets-constructors.c: use the new constructor.

	* libgimpwidgets/gimpenumlabel.h
	* libgimpwidgets/gimpenumstore.h
	* libgimpwidgets/gimpintcombobox.h
	* libgimpwidgets/gimpintstore.h: use "parent_class", not
	"parent_instance" when including the parent struct.
parent 1f5bbe4d
2005-06-27 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpenumcombobox.[ch]: added new constructor
gimp_enum_combo_box_new_with_model(). Also override the "model"
property to make it clear that GimpEnumComboBox expects to be
used with GimpEnumStore.
* libgimpwidgets/gimpwidgets.def: updated.
* app/tools/gimpcurvestool.c
* app/tools/gimplevelstool.c
* app/widgets/gimpwidgets-constructors.c: use the new constructor.
* libgimpwidgets/gimpenumlabel.h
* libgimpwidgets/gimpenumstore.h
* libgimpwidgets/gimpintcombobox.h
* libgimpwidgets/gimpintstore.h: use "parent_class", not
"parent_instance" when including the parent struct.
2005-06-27 Sven Neumann <sven@gimp.org>
* app/actions/debug-commands.c: fixed memory profile debug action.
......
......@@ -475,9 +475,7 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL,
GIMP_HISTOGRAM_VALUE,
GIMP_HISTOGRAM_ALPHA);
menu = g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
"model", store,
NULL);
menu = gimp_enum_combo_box_new_with_model (store);
g_object_unref (store);
g_signal_connect (menu, "changed",
......
......@@ -411,9 +411,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL,
GIMP_HISTOGRAM_VALUE,
GIMP_HISTOGRAM_ALPHA);
menu = g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
"model", store,
NULL);
menu = gimp_enum_combo_box_new_with_model (store);
g_object_unref (store);
g_signal_connect (menu, "changed",
......
......@@ -141,9 +141,7 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode)
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_LIGHTEN_ONLY_MODE, -1);
combo = g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
"model", store,
NULL);
combo = gimp_enum_combo_box_new_with_model (store);
g_object_unref (store);
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
......
......@@ -32,6 +32,25 @@
#include "libgimp/libgimp-intl.h"
enum
{
PROP_0,
PROP_MODEL
};
static void gimp_enum_combo_box_class_init (GimpEnumComboBoxClass *klass);
static void gimp_enum_combo_box_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_enum_combo_box_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
GType
gimp_enum_combo_box_get_type (void)
{
......@@ -44,7 +63,7 @@ gimp_enum_combo_box_get_type (void)
sizeof (GimpEnumComboBoxClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_init */
(GClassInitFunc) gimp_enum_combo_box_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpEnumComboBox),
......@@ -60,6 +79,63 @@ gimp_enum_combo_box_get_type (void)
return enum_combo_box_type;
}
static void
gimp_enum_combo_box_class_init (GimpEnumComboBoxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_enum_combo_box_set_property;
object_class->get_property = gimp_enum_combo_box_get_property;
/* override the "model" property of GtkComboBox */
g_object_class_install_property (object_class,
PROP_MODEL,
g_param_spec_object ("model", NULL, NULL,
GIMP_TYPE_ENUM_STORE,
G_PARAM_READWRITE));
}
static void
gimp_enum_combo_box_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
switch (prop_id)
{
case PROP_MODEL:
gtk_combo_box_set_model (combo_box, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gimp_enum_combo_box_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
switch (prop_id)
{
case PROP_MODEL:
g_value_set_object (value, gtk_combo_box_get_model (combo_box));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* gimp_enum_combo_box_new:
* @enum_type: the #GType of an enum.
......@@ -97,14 +173,33 @@ gimp_enum_combo_box_new (GType enum_type)
return combo_box;
}
/**
* gimp_enum_combo_box_new_with_model
* @enum_store: a #GimpEnumStore to use as the model
*
* Creates a #GtkComboBox for the given @enum_store.
*
* Return value: a new #GimpEnumComboBox.
*
* Since: GIMP 2.4
**/
GtkWidget *
gimp_enum_combo_box_new_with_model (GimpEnumStore *enum_store)
{
g_return_val_if_fail (GIMP_IS_ENUM_STORE (enum_store), NULL);
return g_object_new (GIMP_TYPE_ENUM_COMBO_BOX,
"model", enum_store,
NULL);
}
/**
* gimp_enum_combo_box_set_stock_prefix:
* @combo_box: a #GimpEnumComboBox
* @stock_prefix: a prefix to create icon stock ID from enum values
*
* Attempts to create stock icons for all items in the @combo_box. See
* gimp_enum_store_set_icons() to find out what to use for
* @stock_prefix.
* gimp_enum_store_set_icons() to find out what to use as @stock_prefix.
*
* Since: GIMP 2.4
**/
......
......@@ -43,7 +43,7 @@ struct _GimpEnumComboBox
struct _GimpEnumComboBoxClass
{
GimpIntComboBoxClass parent_instance;
GimpIntComboBoxClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
......@@ -56,6 +56,7 @@ struct _GimpEnumComboBoxClass
GType gimp_enum_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_enum_combo_box_new (GType enum_type);
GtkWidget * gimp_enum_combo_box_new_with_model (GimpEnumStore *enum_store);
void gimp_enum_combo_box_set_stock_prefix (GimpEnumComboBox *combo_box,
const gchar *stock_prefix);
......
......@@ -46,7 +46,7 @@ struct _GimpEnumLabel
struct _GimpEnumLabelClass
{
GtkLabelClass parent_instance;
GtkLabelClass parent_class;
};
......
......@@ -45,7 +45,7 @@ struct _GimpEnumStore
struct _GimpEnumStoreClass
{
GimpIntStoreClass parent_instance;
GimpIntStoreClass parent_class;
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
......
......@@ -51,7 +51,7 @@ struct _GimpIntComboBox
struct _GimpIntComboBoxClass
{
GtkComboBoxClass parent_instance;
GtkComboBoxClass parent_class;
};
......
......@@ -58,7 +58,7 @@ struct _GimpIntStore
struct _GimpIntStoreClass
{
GtkListStoreClass parent_instance;
GtkListStoreClass parent_class;
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
......
......@@ -103,6 +103,7 @@ EXPORTS
gimp_double_adjustment_update
gimp_enum_combo_box_get_type
gimp_enum_combo_box_new
gimp_enum_combo_box_new_with_model
gimp_enum_combo_box_set_stock_prefix
gimp_enum_label_get_type
gimp_enum_label_new
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment