[evolution] GalViewClass: Replace get_type_code() with "type_code" string.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] GalViewClass: Replace get_type_code() with "type_code" string.
- Date: Fri, 5 Jul 2013 20:41:54 +0000 (UTC)
commit 57a3b819e1b849db7b2e76bcbad84bd551cdd55e
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 2 15:43:03 2013 -0400
GalViewClass: Replace get_type_code() with "type_code" string.
All GalView subclasses return a static string in their get_type_code()
methods, so replace the method with a static string pointer directly in
the class structure, and remove the "type-code" GalView property.
addressbook/gui/widgets/gal-view-minicard.c | 8 +----
calendar/gui/calendar-view.c | 32 ++--------------
.../evolution-util/evolution-util-sections.txt | 1 -
e-util/gal-view-collection.c | 19 ++++++++--
e-util/gal-view-etable.c | 8 +----
e-util/gal-view-instance.c | 6 +++-
e-util/gal-view.c | 39 +-------------------
e-util/gal-view.h | 4 +-
8 files changed, 29 insertions(+), 88 deletions(-)
---
diff --git a/addressbook/gui/widgets/gal-view-minicard.c b/addressbook/gui/widgets/gal-view-minicard.c
index 9abf812..99e8686 100644
--- a/addressbook/gui/widgets/gal-view-minicard.c
+++ b/addressbook/gui/widgets/gal-view-minicard.c
@@ -105,12 +105,6 @@ view_minicard_save (GalView *view,
xmlFreeDoc (doc);
}
-static const gchar *
-view_minicard_get_type_code (GalView *view)
-{
- return "minicard";
-}
-
static GalView *
view_minicard_clone (GalView *view)
{
@@ -136,9 +130,9 @@ gal_view_minicard_class_init (GalViewMinicardClass *class)
object_class->finalize = view_minicard_finalize;
gal_view_class = GAL_VIEW_CLASS (class);
+ gal_view_class->type_code = "minicard";
gal_view_class->load = view_minicard_load;
gal_view_class->save = view_minicard_save;
- gal_view_class->get_type_code = view_minicard_get_type_code;
gal_view_class->clone = view_minicard_clone;
}
diff --git a/calendar/gui/calendar-view.c b/calendar/gui/calendar-view.c
index f373469..88cdd3c 100644
--- a/calendar/gui/calendar-view.c
+++ b/calendar/gui/calendar-view.c
@@ -38,16 +38,10 @@ G_DEFINE_TYPE (
gal_view_calendar_month,
GAL_TYPE_VIEW)
-static const gchar *
-gal_view_calendar_day_get_type_code (GalView *view)
-{
- return "day_view";
-}
-
static void
gal_view_calendar_day_class_init (GalViewClass *class)
{
- class->get_type_code = gal_view_calendar_day_get_type_code;
+ class->type_code = "day_view";
}
static void
@@ -55,16 +49,10 @@ gal_view_calendar_day_init (GalView *view)
{
}
-static const gchar *
-gal_view_calendar_work_week_get_type_code (GalView *view)
-{
- return "work_week_view";
-}
-
static void
gal_view_calendar_work_week_class_init (GalViewClass *class)
{
- class->get_type_code = gal_view_calendar_work_week_get_type_code;
+ class->type_code = "work_week_view";
}
static void
@@ -72,16 +60,10 @@ gal_view_calendar_work_week_init (GalView *view)
{
}
-static const gchar *
-gal_view_calendar_week_get_type_code (GalView *view)
-{
- return "week_view";
-}
-
static void
gal_view_calendar_week_class_init (GalViewClass *class)
{
- class->get_type_code = gal_view_calendar_week_get_type_code;
+ class->type_code = "week_view";
}
static void
@@ -89,16 +71,10 @@ gal_view_calendar_week_init (GalView *view)
{
}
-static const gchar *
-gal_view_calendar_month_get_type_code (GalView *view)
-{
- return "month_view";
-}
-
static void
gal_view_calendar_month_class_init (GalViewClass *class)
{
- class->get_type_code = gal_view_calendar_month_get_type_code;
+ class->type_code = "month_view";
}
static void
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt
b/doc/reference/evolution-util/evolution-util-sections.txt
index e9d1ec2..b622f98 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -4569,7 +4569,6 @@ gal_view_load
gal_view_save
gal_view_get_title
gal_view_set_title
-gal_view_get_type_code
gal_view_clone
gal_view_changed
<SUBSECTION Standard>
diff --git a/e-util/gal-view-collection.c b/e-util/gal-view-collection.c
index 24d70a6..2a48f03 100644
--- a/e-util/gal-view-collection.c
+++ b/e-util/gal-view-collection.c
@@ -642,16 +642,19 @@ gal_view_collection_append (GalViewCollection *collection,
GalView *view)
{
GalViewCollectionItem *item;
+ GalViewClass *view_class;
g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection));
g_return_if_fail (GAL_IS_VIEW (view));
+ view_class = GAL_VIEW_GET_CLASS (view);
+
item = g_new (GalViewCollectionItem, 1);
item->ever_changed = TRUE;
item->changed = TRUE;
item->built_in = FALSE;
item->title = g_strdup (gal_view_get_title (view));
- item->type = g_strdup (gal_view_get_type_code (view));
+ item->type = g_strdup (view_class->type_code);
item->id = gal_view_generate_id (collection, view);
item->filename = g_strdup_printf ("%s.galview", item->id);
item->view = view;
@@ -701,18 +704,20 @@ gal_view_collection_copy_view (GalViewCollection *collection,
{
GalViewCollectionItem *item;
GalView *view;
+ GalViewClass *view_class;
g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection));
g_return_if_fail (i >= 0 && i < collection->view_count);
view = collection->view_data[i]->view;
+ view_class = GAL_VIEW_GET_CLASS (view);
item = g_new (GalViewCollectionItem, 1);
item->ever_changed = TRUE;
item->changed = FALSE;
item->built_in = FALSE;
item->title = g_strdup (gal_view_get_title (view));
- item->type = g_strdup (gal_view_get_type_code (view));
+ item->type = g_strdup (view_class->type_code);
item->id = gal_view_generate_id (collection, view);
item->filename = g_strdup_printf ("%s.galview", item->id);
item->view = gal_view_clone (view);
@@ -741,10 +746,13 @@ gal_view_collection_append_with_title (GalViewCollection *collection,
GalView *view)
{
GalViewCollectionItem *item;
+ GalViewClass *view_class;
g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL);
g_return_val_if_fail (GAL_IS_VIEW (view), NULL);
+ view_class = GAL_VIEW_GET_CLASS (view);
+
gal_view_set_title (view, title);
d (g_print ("%s: %p\n", G_STRFUNC, view));
@@ -754,7 +762,7 @@ gal_view_collection_append_with_title (GalViewCollection *collection,
item->changed = TRUE;
item->built_in = FALSE;
item->title = g_strdup (gal_view_get_title (view));
- item->type = g_strdup (gal_view_get_type_code (view));
+ item->type = g_strdup (view_class->type_code);
item->id = gal_view_generate_id (collection, view);
item->filename = g_strdup_printf ("%s.galview", item->id);
item->view = view;
@@ -779,6 +787,7 @@ gal_view_collection_set_nth_view (GalViewCollection *collection,
GalView *view)
{
GalViewCollectionItem *item;
+ GalViewClass *view_class;
g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL);
g_return_val_if_fail (GAL_IS_VIEW (view), NULL);
@@ -787,6 +796,8 @@ gal_view_collection_set_nth_view (GalViewCollection *collection,
d (g_print ("%s: %p\n", G_STRFUNC, view));
+ view_class = GAL_VIEW_GET_CLASS (view);
+
item = collection->view_data[i];
gal_view_set_title (view, item->title);
@@ -801,7 +812,7 @@ gal_view_collection_set_nth_view (GalViewCollection *collection,
item->ever_changed = TRUE;
item->changed = TRUE;
- item->type = g_strdup (gal_view_get_type_code (view));
+ item->type = g_strdup (view_class->type_code);
item->view_changed_id = g_signal_connect (
item->view, "changed",
diff --git a/e-util/gal-view-etable.c b/e-util/gal-view-etable.c
index 4efdc53..9d54148 100644
--- a/e-util/gal-view-etable.c
+++ b/e-util/gal-view-etable.c
@@ -100,12 +100,6 @@ gal_view_etable_save (GalView *view,
}
}
-static const gchar *
-gal_view_etable_get_type_code (GalView *view)
-{
- return "etable";
-}
-
static GalView *
gal_view_etable_clone (GalView *view)
{
@@ -158,9 +152,9 @@ gal_view_etable_class_init (GalViewEtableClass *class)
object_class->finalize = gal_view_etable_finalize;
gal_view_class = GAL_VIEW_CLASS (class);
+ gal_view_class->type_code = "etable";
gal_view_class->load = gal_view_etable_load;
gal_view_class->save = gal_view_etable_save;
- gal_view_class->get_type_code = gal_view_etable_get_type_code;
gal_view_class->clone = gal_view_etable_clone;
}
diff --git a/e-util/gal-view-instance.c b/e-util/gal-view-instance.c
index 32f8a5f..3eac358 100644
--- a/e-util/gal-view-instance.c
+++ b/e-util/gal-view-instance.c
@@ -139,12 +139,16 @@ static void
connect_view (GalViewInstance *instance,
GalView *view)
{
+ GalViewClass *view_class;
+
if (instance->current_view)
disconnect_view (instance);
instance->current_view = g_object_ref (view);
+ view_class = GAL_VIEW_GET_CLASS (view);
+
instance->current_title = g_strdup (gal_view_get_title (view));
- instance->current_type = g_strdup (gal_view_get_type_code (view));
+ instance->current_type = g_strdup (view_class->type_code);
instance->view_changed_id = g_signal_connect (
instance->current_view, "changed",
G_CALLBACK (view_changed), instance);
diff --git a/e-util/gal-view.c b/e-util/gal-view.c
index 7b3743a..5e13f4c 100644
--- a/e-util/gal-view.c
+++ b/e-util/gal-view.c
@@ -28,8 +28,7 @@ struct _GalViewPrivate {
enum {
PROP_0,
- PROP_TITLE,
- PROP_TYPE_CODE
+ PROP_TITLE
};
enum {
@@ -70,12 +69,6 @@ view_get_property (GObject *object,
value, gal_view_get_title (
GAL_VIEW (object)));
return;
-
- case PROP_TYPE_CODE:
- g_value_set_string (
- value, gal_view_get_type_code (
- GAL_VIEW (object)));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -145,17 +138,6 @@ gal_view_class_init (GalViewClass *class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (
- object_class,
- PROP_TYPE_CODE,
- g_param_spec_string (
- "type-code",
- NULL,
- NULL,
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
signals[CHANGED] = g_signal_new (
"changed",
G_OBJECT_CLASS_TYPE (object_class),
@@ -247,25 +229,6 @@ gal_view_set_title (GalView *view,
}
/**
- * gal_view_get_type_code
- * @view: The view to get.
- *
- * Returns: The type of the view.
- */
-const gchar *
-gal_view_get_type_code (GalView *view)
-{
- GalViewClass *class;
-
- g_return_val_if_fail (GAL_IS_VIEW (view), NULL);
-
- class = GAL_VIEW_GET_CLASS (view);
- g_return_val_if_fail (class->get_type_code != NULL, NULL);
-
- return class->get_type_code (view);
-}
-
-/**
* gal_view_clone
* @view: The view to clone.
*
diff --git a/e-util/gal-view.h b/e-util/gal-view.h
index 94f89b9..d07d8ca 100644
--- a/e-util/gal-view.h
+++ b/e-util/gal-view.h
@@ -58,12 +58,13 @@ struct _GalView {
struct _GalViewClass {
GObjectClass parent_class;
+ const gchar *type_code;
+
/* Methods */
void (*load) (GalView *view,
const gchar *filename);
void (*save) (GalView *view,
const gchar *filename);
- const gchar * (*get_type_code) (GalView *view);
GalView * (*clone) (GalView *view);
/* Signals */
@@ -78,7 +79,6 @@ void gal_view_save (GalView *view,
const gchar * gal_view_get_title (GalView *view);
void gal_view_set_title (GalView *view,
const gchar *title);
-const gchar * gal_view_get_type_code (GalView *view);
GalView * gal_view_clone (GalView *view);
void gal_view_changed (GalView *view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]