From bb5f5ad90beabd459e27d7aaac44d92c9b106c00 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Jul 2013 17:17:40 -0400 Subject: GalViewFactoryClass: Remove the get_type_code() method. GalViewFactory can now use its "gal_view_type" class member to peek at the appropriate GalViewClass and return its static "type_code" string. --- e-util/gal-view-factory-etable.c | 7 ------- e-util/gal-view-factory.c | 10 ++++++++-- e-util/gal-view-factory.h | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'e-util') diff --git a/e-util/gal-view-factory-etable.c b/e-util/gal-view-factory-etable.c index 53f58e8c11..f9a6edd9ae 100644 --- a/e-util/gal-view-factory-etable.c +++ b/e-util/gal-view-factory-etable.c @@ -32,12 +32,6 @@ G_DEFINE_TYPE ( gal_view_factory_etable, GAL_TYPE_VIEW_FACTORY) -static const gchar * -view_factory_etable_get_type_code (GalViewFactory *factory) -{ - return "etable"; -} - static GalView * view_factory_etable_new_view (GalViewFactory *factory, const gchar *name) @@ -52,7 +46,6 @@ gal_view_factory_etable_class_init (GalViewFactoryEtableClass *class) view_factory_class = GAL_VIEW_FACTORY_CLASS (class); view_factory_class->gal_view_type = GAL_TYPE_VIEW_ETABLE; - view_factory_class->get_type_code = view_factory_etable_get_type_code; view_factory_class->new_view = view_factory_etable_new_view; } diff --git a/e-util/gal-view-factory.c b/e-util/gal-view-factory.c index c6de38a110..d235a63d86 100644 --- a/e-util/gal-view-factory.c +++ b/e-util/gal-view-factory.c @@ -50,13 +50,19 @@ const gchar * gal_view_factory_get_type_code (GalViewFactory *factory) { GalViewFactoryClass *class; + GalViewClass *view_class; g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); class = GAL_VIEW_FACTORY_GET_CLASS (factory); - g_return_val_if_fail (class->get_type_code != NULL, NULL); - return class->get_type_code (factory); + /* All GalView types are registered statically, so there's no + * harm in dereferencing the class pointer after unreffing it. */ + view_class = g_type_class_ref (class->gal_view_type); + g_return_val_if_fail (GAL_IS_VIEW_CLASS (view_class), NULL); + g_type_class_unref (view_class); + + return view_class->type_code; } /** diff --git a/e-util/gal-view-factory.h b/e-util/gal-view-factory.h index 19f644e966..73cc02251e 100644 --- a/e-util/gal-view-factory.h +++ b/e-util/gal-view-factory.h @@ -64,7 +64,6 @@ struct _GalViewFactoryClass { GType gal_view_type; /* Methods */ - const gchar * (*get_type_code) (GalViewFactory *factory); GalView * (*new_view) (GalViewFactory *factory, const gchar *name); }; -- cgit