Commit 8e04fb1b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Some more proper typing instead of using pointers:

2006-09-24  Michael Natterer  <mitch@gimp.org>

	Some more proper typing instead of using pointers:

	* libgimpconfig/gimpconfig-params.h: added macro
	GIMP_CONFIG_INSTALL_PROP_BOXED().

	* app/core/gimpcontainer.c: made "children-type" a GParamSpecGType.

	* app/widgets/gimpcontrollerinfo.c: made "mapping" a
	GParamSpecBoxed and use g_hash_table_unref() instead of destroy().

	* app/widgets/gimppdbdialog.c: made "select-type" a GParamSpecGType.

	* app/dialogs/module-dialog.c
	* app/widgets/gimpcolordisplayeditor.c
	* app/widgets/gimpcontrollerlist.c
	* app/widgets/gimpfileprocview.c
	* app/widgets/gimppluginaction.c: use proper object types, boxed
	types and G_TYPE_GTYPE instead of G_TYPE_POINTER for various list
	stores and signal signatues.
parent 4f415c13
2006-09-24 Michael Natterer <mitch@gimp.org>
Some more proper typing instead of using pointers:
* libgimpconfig/gimpconfig-params.h: added macro
GIMP_CONFIG_INSTALL_PROP_BOXED().
* app/core/gimpcontainer.c: made "children-type" a GParamSpecGType.
* app/widgets/gimpcontrollerinfo.c: made "mapping" a
GParamSpecBoxed and use g_hash_table_unref() instead of destroy().
* app/widgets/gimppdbdialog.c: made "select-type" a GParamSpecGType.
* app/dialogs/module-dialog.c
* app/widgets/gimpcolordisplayeditor.c
* app/widgets/gimpcontrollerlist.c
* app/widgets/gimpfileprocview.c
* app/widgets/gimppluginaction.c: use proper object types, boxed
types and G_TYPE_GTYPE instead of G_TYPE_POINTER for various list
stores and signal signatues.
2006-09-24 Michael Natterer <mitch@gimp.org>
* app/core/gimpimagemap.c (gimp_image_map_apply): don't restore
......
......@@ -185,10 +185,11 @@ gimp_container_class_init (GimpContainerClass *klass)
klass->get_child_index = NULL;
g_object_class_install_property (object_class, PROP_CHILDREN_TYPE,
g_param_spec_pointer ("children-type",
NULL, NULL,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_param_spec_gtype ("children-type",
NULL, NULL,
GIMP_TYPE_OBJECT,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_POLICY,
g_param_spec_enum ("policy",
......@@ -199,6 +200,13 @@ gimp_container_class_init (GimpContainerClass *klass)
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_container_config_iface_init (GimpConfigInterface *iface)
{
iface->serialize = gimp_container_serialize;
iface->deserialize = gimp_container_deserialize;
}
static void
gimp_container_init (GimpContainer *container)
{
......@@ -210,13 +218,6 @@ gimp_container_init (GimpContainer *container)
container->freeze_count = 0;
}
static void
gimp_container_config_iface_init (GimpConfigInterface *iface)
{
iface->serialize = gimp_container_serialize;
iface->deserialize = gimp_container_deserialize;
}
static void
gimp_container_dispose (GObject *object)
{
......@@ -249,7 +250,7 @@ gimp_container_set_property (GObject *object,
switch (property_id)
{
case PROP_CHILDREN_TYPE:
container->children_type = (GType) g_value_get_pointer (value);
container->children_type = g_value_get_gtype (value);
g_type_class_ref (container->children_type);
break;
case PROP_POLICY:
......@@ -272,7 +273,7 @@ gimp_container_get_property (GObject *object,
switch (property_id)
{
case PROP_CHILDREN_TYPE:
g_value_set_pointer (value, (gpointer) container->children_type);
g_value_set_gtype (value, container->children_type);
break;
case PROP_POLICY:
g_value_set_enum (value, container->policy);
......
......@@ -151,8 +151,9 @@ module_dialog_new (Gimp *gimp)
gtk_widget_show (listbox);
dialog->list = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_STRING, G_TYPE_BOOLEAN,
G_TYPE_POINTER);
G_TYPE_STRING,
G_TYPE_BOOLEAN,
GIMP_TYPE_MODULE);
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list));
g_object_unref (dialog->list);
......@@ -274,6 +275,9 @@ dialog_select_callback (GtkTreeSelection *sel,
gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
MODULE_COLUMN, &module, -1);
if (module)
g_object_unref (module);
if (dialog->last_update == module)
return;
......@@ -307,6 +311,8 @@ dialog_autoload_toggled (GtkCellRendererToggle *celltoggle,
if (module)
{
g_object_unref (module);
gimp_module_set_load_inhibit (module, active);
dialog->gimp->write_modulerc = TRUE;
......@@ -383,6 +389,9 @@ dialog_info_remove (GimpModuleDB *db,
MODULE_COLUMN, &module,
-1);
if (module)
g_object_unref (module);
if (module == mod)
{
gtk_list_store_remove (dialog->list, &iter);
......
......@@ -138,7 +138,7 @@ gimp_color_display_editor_init (GimpColorDisplayEditor *editor)
editor->src = gtk_list_store_new (N_SRC_COLUMNS,
G_TYPE_STRING,
G_TYPE_POINTER);
G_TYPE_GTYPE);
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (editor->src));
g_object_unref (editor->src);
......@@ -398,13 +398,11 @@ gimp_color_display_editor_add_clicked (GtkWidget *widget,
if (gtk_tree_selection_get_selected (editor->src_sel, &model, &iter))
{
GimpColorDisplay *display;
GValue val = { 0, };
GType type;
gtk_tree_model_get_value (model, &iter, SRC_COLUMN_TYPE, &val);
gtk_tree_model_get (model, &iter, SRC_COLUMN_TYPE, &type, -1);
display = gimp_color_display_new ((GType) g_value_get_pointer (&val));
g_value_unset (&val);
display = gimp_color_display_new (type);
if (display)
{
......
......@@ -118,9 +118,10 @@ gimp_controller_info_class_init (GimpControllerInfoClass *klass)
"controller", NULL,
GIMP_TYPE_CONTROLLER,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_POINTER (object_class, PROP_MAPPING,
"mapping", NULL,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOXED (object_class, PROP_MAPPING,
"mapping", NULL,
G_TYPE_HASH_TABLE,
GIMP_PARAM_STATIC_STRINGS);
info_signals[EVENT_MAPPED] =
g_signal_new ("event-mapped",
......@@ -158,10 +159,16 @@ gimp_controller_info_finalize (GObject *object)
GimpControllerInfo *info = GIMP_CONTROLLER_INFO (object);
if (info->controller)
g_object_unref (info->controller);
{
g_object_unref (info->controller);
info->controller = NULL;
}
if (info->mapping)
g_hash_table_destroy (info->mapping);
{
g_hash_table_unref (info->mapping);
info->mapping = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -191,7 +198,7 @@ gimp_controller_info_set_property (GObject *object,
g_object_unref (info->controller);
}
info->controller = (GimpController *) g_value_dup_object (value);
info->controller = g_value_dup_object (value);
if (info->controller)
{
......@@ -203,8 +210,8 @@ gimp_controller_info_set_property (GObject *object,
break;
case PROP_MAPPING:
if (info->mapping)
g_hash_table_destroy (info->mapping);
info->mapping = g_value_get_pointer (value);
g_hash_table_unref (info->mapping);
info->mapping = g_value_dup_boxed (value);
break;
default:
......@@ -233,7 +240,7 @@ gimp_controller_info_get_property (GObject *object,
g_value_set_object (value, info->controller);
break;
case PROP_MAPPING:
g_value_set_pointer (value, info->mapping);
g_value_set_boxed (value, info->mapping);
break;
default:
......@@ -269,7 +276,7 @@ gimp_controller_info_serialize_property (GimpConfig *config,
if (property_id != PROP_MAPPING)
return FALSE;
mapping = g_value_get_pointer (value);
mapping = g_value_get_boxed (value);
if (mapping)
{
......@@ -350,7 +357,7 @@ gimp_controller_info_deserialize_property (GimpConfig *config,
if (g_scanner_peek_next_token (scanner) == token)
{
g_value_set_pointer (value, mapping);
g_value_take_boxed (value, mapping);
}
else
{
......@@ -360,7 +367,7 @@ gimp_controller_info_deserialize_property (GimpConfig *config,
else
{
error:
g_hash_table_destroy (mapping);
g_hash_table_unref (mapping);
*expected = token;
}
......
......@@ -173,7 +173,7 @@ gimp_controller_list_init (GimpControllerList *list)
list->src = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_POINTER);
G_TYPE_GTYPE);
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list->src));
g_object_unref (list->src);
......
......@@ -123,10 +123,10 @@ gimp_file_proc_view_new (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
store = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_POINTER, /* COLUMN_PROC */
G_TYPE_STRING, /* COLUMN_LABEL */
G_TYPE_STRING, /* COLUMN_EXTENSIONS */
G_TYPE_STRING); /* COLUMN_HELP_ID */
GIMP_TYPE_PLUG_IN_PROCEDURE, /* COLUMN_PROC */
G_TYPE_STRING, /* COLUMN_LABEL */
G_TYPE_STRING, /* COLUMN_EXTENSIONS */
G_TYPE_STRING); /* COLUMN_HELP_ID */
view = g_object_new (GIMP_TYPE_FILE_PROC_VIEW,
"model", store,
......@@ -252,6 +252,9 @@ gimp_file_proc_view_get_proc (GimpFileProcView *view,
COLUMN_PROC, &proc,
-1);
if (proc)
g_object_unref (proc);
return proc;
}
......@@ -282,6 +285,10 @@ gimp_file_proc_view_set_proc (GimpFileProcView *view,
gtk_tree_model_get (model, &iter,
COLUMN_PROC, &this,
-1);
if (this)
g_object_unref (this);
if (this == proc)
break;
}
......
......@@ -144,10 +144,11 @@ gimp_pdb_dialog_class_init (GimpPdbDialogClass *klass)
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_SELECT_TYPE,
g_param_spec_pointer ("select-type",
NULL, NULL,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_param_spec_gtype ("select-type",
NULL, NULL,
GIMP_TYPE_OBJECT,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_INITIAL_OBJECT,
g_param_spec_object ("initial-object",
......@@ -247,7 +248,7 @@ gimp_pdb_dialog_set_property (GObject *object,
dialog->caller_context = GIMP_CONTEXT (g_value_dup_object (value));
break;
case PROP_SELECT_TYPE:
dialog->select_type = (GType) g_value_get_pointer (value);
dialog->select_type = g_value_get_gtype (value);
break;
case PROP_INITIAL_OBJECT:
/* don't ref, see constructor */
......
......@@ -92,9 +92,9 @@ gimp_plug_in_action_class_init (GimpPlugInActionClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPlugInActionClass, selected),
NULL, NULL,
gimp_marshal_VOID__POINTER,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
GIMP_TYPE_PLUG_IN_PROCEDURE);
}
static void
......
......@@ -133,7 +133,7 @@ G_BEGIN_DECLS
flags | GIMP_CONFIG_PARAM_FLAGS))
/* object and pointer properties are _not_ G_PARAM_CONSTRUCT */
/* object, boxed and pointer properties are _not_ G_PARAM_CONSTRUCT */
#define GIMP_CONFIG_INSTALL_PROP_OBJECT(class, id, name, blurb, object_type, flags)\
g_object_class_install_property (class, id,\
......@@ -143,6 +143,14 @@ G_BEGIN_DECLS
G_PARAM_READWRITE |\
GIMP_CONFIG_PARAM_SERIALIZE))
#define GIMP_CONFIG_INSTALL_PROP_BOXED(class, id, name, blurb, boxed_type, flags)\
g_object_class_install_property (class, id,\
g_param_spec_boxed (name, NULL, blurb,\
boxed_type,\
flags |\
G_PARAM_READWRITE |\
GIMP_CONFIG_PARAM_SERIALIZE))
#define GIMP_CONFIG_INSTALL_PROP_POINTER(class, id, name, blurb, flags)\
g_object_class_install_property (class, id,\
g_param_spec_pointer (name, NULL, blurb,\
......
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