aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-03 03:43:03 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-06 04:40:49 +0800
commit57a3b819e1b849db7b2e76bcbad84bd551cdd55e (patch)
tree4084fff5f45bde552a798f49f4d234f5a0b7dd49
parent3f5f362e0df717f2aaca8d21c3b3e180904a6897 (diff)
downloadgsoc2013-evolution-57a3b819e1b849db7b2e76bcbad84bd551cdd55e.tar.gz
gsoc2013-evolution-57a3b819e1b849db7b2e76bcbad84bd551cdd55e.tar.zst
gsoc2013-evolution-57a3b819e1b849db7b2e76bcbad84bd551cdd55e.zip
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.
-rw-r--r--addressbook/gui/widgets/gal-view-minicard.c8
-rw-r--r--calendar/gui/calendar-view.c32
-rw-r--r--doc/reference/evolution-util/evolution-util-sections.txt1
-rw-r--r--e-util/gal-view-collection.c19
-rw-r--r--e-util/gal-view-etable.c8
-rw-r--r--e-util/gal-view-instance.c6
-rw-r--r--e-util/gal-view.c39
-rw-r--r--e-util/gal-view.h4
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 9abf8124c4..99e8686675 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 f373469541..88cdd3cb82 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 e9d1ec292c..b622f98587 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 24d70a67b6..2a48f03513 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 4efdc539c3..9d541489b8 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 32f8a5fd26..3eac358515 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 7b3743af72..5e13f4cdc2 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 94f89b989e..d07d8cae79 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);