[evolution] GalViewFactoryClass: Remove the get_type_code() method.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] GalViewFactoryClass: Remove the get_type_code() method.
- Date: Fri, 5 Jul 2013 20:42:09 +0000 (UTC)
commit bb5f5ad90beabd459e27d7aaac44d92c9b106c00
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 2 17:17:40 2013 -0400
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.
.../gui/widgets/gal-view-factory-minicard.c | 7 -----
calendar/gui/calendar-view-factory.c | 28 --------------------
e-util/gal-view-factory-etable.c | 7 -----
e-util/gal-view-factory.c | 10 +++++-
e-util/gal-view-factory.h | 1 -
5 files changed, 8 insertions(+), 45 deletions(-)
---
diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.c
b/addressbook/gui/widgets/gal-view-factory-minicard.c
index f9c78f9..915bc03 100644
--- a/addressbook/gui/widgets/gal-view-factory-minicard.c
+++ b/addressbook/gui/widgets/gal-view-factory-minicard.c
@@ -32,12 +32,6 @@ G_DEFINE_TYPE (
GalViewFactoryMinicard,
gal_view_factory_minicard, GAL_TYPE_VIEW_FACTORY)
-static const gchar *
-gal_view_factory_minicard_get_type_code (GalViewFactory *factory)
-{
- return "minicard";
-}
-
static GalView *
gal_view_factory_minicard_new_view (GalViewFactory *factory,
const gchar *name)
@@ -52,7 +46,6 @@ gal_view_factory_minicard_class_init (GalViewFactoryMinicardClass *minicard_clas
view_factory_class = GAL_VIEW_FACTORY_CLASS (minicard_class);
view_factory_class->gal_view_type = GAL_TYPE_VIEW_MINICARD;
- view_factory_class->get_type_code = gal_view_factory_minicard_get_type_code;
view_factory_class->new_view = gal_view_factory_minicard_new_view;
}
diff --git a/calendar/gui/calendar-view-factory.c b/calendar/gui/calendar-view-factory.c
index ca4a117..706f5ea 100644
--- a/calendar/gui/calendar-view-factory.c
+++ b/calendar/gui/calendar-view-factory.c
@@ -43,12 +43,6 @@ G_DEFINE_TYPE (
gal_view_factory_calendar_month,
GAL_TYPE_VIEW_FACTORY)
-static const gchar *
-gal_view_factory_calendar_day_get_type_code (GalViewFactory *factory)
-{
- return "day_view";
-}
-
static GalView *
gal_view_factory_calendar_day_new_view (GalViewFactory *factory,
const gchar *title)
@@ -62,7 +56,6 @@ static void
gal_view_factory_calendar_day_class_init (GalViewFactoryClass *class)
{
class->gal_view_type = GAL_TYPE_VIEW_CALENDAR_DAY;
- class->get_type_code = gal_view_factory_calendar_day_get_type_code;
class->new_view = gal_view_factory_calendar_day_new_view;
}
@@ -71,12 +64,6 @@ gal_view_factory_calendar_day_init (GalViewFactory *factory)
{
}
-static const gchar *
-gal_view_factory_calendar_work_week_get_type_code (GalViewFactory *factory)
-{
- return "work_week_view";
-}
-
static GalView *
gal_view_factory_calendar_work_week_new_view (GalViewFactory *factory,
const gchar *title)
@@ -90,7 +77,6 @@ static void
gal_view_factory_calendar_work_week_class_init (GalViewFactoryClass *class)
{
class->gal_view_type = GAL_TYPE_VIEW_CALENDAR_WORK_WEEK;
- class->get_type_code = gal_view_factory_calendar_work_week_get_type_code;
class->new_view = gal_view_factory_calendar_work_week_new_view;
}
@@ -99,12 +85,6 @@ gal_view_factory_calendar_work_week_init (GalViewFactory *factory)
{
}
-static const gchar *
-gal_view_factory_calendar_week_get_type_code (GalViewFactory *factory)
-{
- return "week_view";
-}
-
static GalView *
gal_view_factory_calendar_week_new_view (GalViewFactory *factory,
const gchar *title)
@@ -118,7 +98,6 @@ static void
gal_view_factory_calendar_week_class_init (GalViewFactoryClass *class)
{
class->gal_view_type = GAL_TYPE_VIEW_CALENDAR_WEEK;
- class->get_type_code = gal_view_factory_calendar_week_get_type_code;
class->new_view = gal_view_factory_calendar_week_new_view;
}
@@ -127,12 +106,6 @@ gal_view_factory_calendar_week_init (GalViewFactory *factory)
{
}
-static const gchar *
-gal_view_factory_calendar_month_get_type_code (GalViewFactory *factory)
-{
- return "month_view";
-}
-
static GalView *
gal_view_factory_calendar_month_new_view (GalViewFactory *factory,
const gchar *title)
@@ -146,7 +119,6 @@ static void
gal_view_factory_calendar_month_class_init (GalViewFactoryClass *class)
{
class->gal_view_type = GAL_TYPE_VIEW_CALENDAR_MONTH;
- class->get_type_code = gal_view_factory_calendar_month_get_type_code;
class->new_view = gal_view_factory_calendar_month_new_view;
}
diff --git a/e-util/gal-view-factory-etable.c b/e-util/gal-view-factory-etable.c
index 53f58e8..f9a6edd 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 c6de38a..d235a63 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 19f644e..73cc022 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);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]