From f26aad1916445d25c99878138dfc384de67a2060 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 2 May 2006 23:56:43 +0000 Subject: Boilerplate reduction --- gtk/gtktreestore.c | 85 +++++++----------------------------------------------- 1 file changed, 10 insertions(+), 75 deletions(-) (limited to 'gtk/gtktreestore.c') diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index f4793774da..1534dab795 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -31,8 +31,6 @@ #define GTK_TREE_STORE_IS_SORTED(tree) (((GtkTreeStore*)(tree))->sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID) #define VALID_ITER(iter, tree_store) ((iter)!= NULL && (iter)->user_data != NULL && ((GtkTreeStore*)(tree_store))->stamp == (iter)->stamp) -static void gtk_tree_store_init (GtkTreeStore *tree_store); -static void gtk_tree_store_class_init (GtkTreeStoreClass *tree_store_class); static void gtk_tree_store_tree_model_init (GtkTreeModelIface *iface); static void gtk_tree_store_drag_source_init(GtkTreeDragSourceIface *iface); static void gtk_tree_store_drag_dest_init (GtkTreeDragDestIface *iface); @@ -125,9 +123,6 @@ static void gtk_tree_store_move (GtkTreeStore * gboolean before); -static GObjectClass *parent_class = NULL; - - static inline void validate_tree (GtkTreeStore *tree_store) { @@ -139,81 +134,21 @@ validate_tree (GtkTreeStore *tree_store) } } -GType -gtk_tree_store_get_type (void) -{ - static GType tree_store_type = 0; - - if (!tree_store_type) - { - static const GTypeInfo tree_store_info = - { - sizeof (GtkTreeStoreClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_store_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeStore), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tree_store_init - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) gtk_tree_store_tree_model_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) gtk_tree_store_drag_source_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_dest_info = - { - (GInterfaceInitFunc) gtk_tree_store_drag_dest_init, - NULL, - NULL - }; - - static const GInterfaceInfo sortable_info = - { - (GInterfaceInitFunc) gtk_tree_store_sortable_init, - NULL, - NULL - }; - - tree_store_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTreeStore"), - &tree_store_info, 0); - - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_DRAG_DEST, - &drag_dest_info); - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_SORTABLE, - &sortable_info); - - } - - return tree_store_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkTreeStore, gtk_tree_store, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_tree_store_tree_model_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, + gtk_tree_store_drag_source_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_DEST, + gtk_tree_store_drag_dest_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, + gtk_tree_store_sortable_init)); static void gtk_tree_store_class_init (GtkTreeStoreClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); object_class = (GObjectClass *) class; object_class->finalize = gtk_tree_store_finalize; @@ -480,7 +415,7 @@ gtk_tree_store_finalize (GObject *object) } /* must chain up */ - (* parent_class->finalize) (object); + G_OBJECT_CLASS (gtk_tree_store_parent_class)->finalize (object); } /* fulfill the GtkTreeModel requirements */ -- cgit v1.2.1