aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-03 00:09:28 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-06 04:40:49 +0800
commit6db972ab0fd2f223aea07c6a413d39a01c41152b (patch)
treea2901db1062e6c72c82aeacec802faeed40206ae
parentc361af739614d5a4bdc90741128bb25c0907e015 (diff)
downloadgsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.gz
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.bz2
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.lz
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.xz
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.zst
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.zip
GalView-related cleanups.
-rw-r--r--addressbook/gui/widgets/gal-view-minicard.c15
-rw-r--r--calendar/gui/calendar-view.c38
-rw-r--r--e-util/gal-view-etable.c102
-rw-r--r--e-util/gal-view-etable.h7
-rw-r--r--e-util/gal-view-factory-etable.c6
-rw-r--r--e-util/gal-view-factory-etable.h3
-rw-r--r--e-util/gal-view.c47
-rw-r--r--e-util/gal-view.h8
8 files changed, 91 insertions, 135 deletions
diff --git a/addressbook/gui/widgets/gal-view-minicard.c b/addressbook/gui/widgets/gal-view-minicard.c
index fcc99b3395..61cd1444ac 100644
--- a/addressbook/gui/widgets/gal-view-minicard.c
+++ b/addressbook/gui/widgets/gal-view-minicard.c
@@ -141,15 +141,16 @@ static GalView *
view_minicard_clone (GalView *view)
{
GalViewMinicard *view_minicard;
- GalViewMinicard *clone;
+ GalView *clone;
- view_minicard = GAL_VIEW_MINICARD (view);
+ /* Chain up to parent's clone() method. */
+ clone = GAL_VIEW_CLASS (gal_view_minicard_parent_class)->clone (view);
- clone = g_object_new (GAL_TYPE_VIEW_MINICARD, NULL);
- clone->column_width = view_minicard->column_width;
- clone->title = g_strdup (view_minicard->title);
+ view_minicard = GAL_VIEW_MINICARD (view);
+ GAL_VIEW_MINICARD (clone)->column_width = view_minicard->column_width;
+ GAL_VIEW_MINICARD (clone)->title = g_strdup (view_minicard->title);
- return GAL_VIEW (clone);
+ return clone;
}
static void
@@ -159,7 +160,7 @@ gal_view_minicard_class_init (GalViewMinicardClass *class)
GalViewClass *gal_view_class;
object_class = G_OBJECT_CLASS (class);
- object_class->dispose = view_minicard_finalize;
+ object_class->finalize = view_minicard_finalize;
gal_view_class = GAL_VIEW_CLASS (class);
gal_view_class->load = view_minicard_load;
diff --git a/calendar/gui/calendar-view.c b/calendar/gui/calendar-view.c
index 8ef24ef9f9..08bac07590 100644
--- a/calendar/gui/calendar-view.c
+++ b/calendar/gui/calendar-view.c
@@ -42,8 +42,6 @@ struct _CalendarViewPrivate {
static void calendar_view_finalize (GObject *object);
-static void calendar_view_load (GalView *view, const gchar *filename);
-static void calendar_view_save (GalView *view, const gchar *filename);
static const gchar *calendar_view_get_title (GalView *view);
static void calendar_view_set_title (GalView *view, const gchar *title);
static const gchar *calendar_view_get_type_code (GalView *view);
@@ -63,8 +61,6 @@ calendar_view_class_init (CalendarViewClass *class)
gal_view_class = (GalViewClass *) class;
object_class = (GObjectClass *) class;
- gal_view_class->load = calendar_view_load;
- gal_view_class->save = calendar_view_save;
gal_view_class->get_title = calendar_view_get_title;
gal_view_class->set_title = calendar_view_set_title;
gal_view_class->get_type_code = calendar_view_get_type_code;
@@ -94,22 +90,6 @@ calendar_view_finalize (GObject *object)
G_OBJECT_CLASS (calendar_view_parent_class)->finalize (object);
}
-/* load method of the calendar view */
-static void
-calendar_view_load (GalView *view,
- const gchar *filename)
-{
- /* nothing */
-}
-
-/* save method of the calendar view */
-static void
-calendar_view_save (GalView *view,
- const gchar *filename)
-{
- /* nothing */
-}
-
/* get_title method of the calendar view */
static const gchar *
calendar_view_get_title (GalView *view)
@@ -173,20 +153,16 @@ static GalView *
calendar_view_clone (GalView *view)
{
CalendarView *cal_view;
- CalendarViewPrivate *priv;
- CalendarView *new_view;
- CalendarViewPrivate *new_priv;
-
- cal_view = CALENDAR_VIEW (view);
- priv = cal_view->priv;
+ GalView *clone;
- new_view = g_object_new (TYPE_CALENDAR_VIEW, NULL);
- new_priv = new_view->priv;
+ /* Chain up to parent's clone() method. */
+ clone = GAL_VIEW_CLASS (calendar_view_parent_class)->clone (view);
- new_priv->view_type = priv->view_type;
- new_priv->title = g_strdup (priv->title);
+ cal_view = CALENDAR_VIEW (view);
+ CALENDAR_VIEW (clone)->priv->view_type = cal_view->priv->view_type;
+ CALENDAR_VIEW (clone)->priv->title = g_strdup (cal_view->priv->title);
- return GAL_VIEW (new_view);
+ return clone;
}
/**
diff --git a/e-util/gal-view-etable.c b/e-util/gal-view-etable.c
index 0615fe07b5..53782eefca 100644
--- a/e-util/gal-view-etable.c
+++ b/e-util/gal-view-etable.c
@@ -1,4 +1,6 @@
/*
+ * gal-view-etable.c
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -12,18 +14,8 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "gal-view-etable.h"
G_DEFINE_TYPE (GalViewEtable, gal_view_etable, GAL_TYPE_VIEW)
@@ -31,31 +23,27 @@ G_DEFINE_TYPE (GalViewEtable, gal_view_etable, GAL_TYPE_VIEW)
static void
detach_table (GalViewEtable *view)
{
- if (view->table == NULL)
- return;
- if (view->table_state_changed_id) {
+ if (view->table_state_changed_id > 0) {
g_signal_handler_disconnect (
view->table,
view->table_state_changed_id);
view->table_state_changed_id = 0;
}
- g_object_unref (view->table);
- view->table = NULL;
+
+ g_clear_object (&view->table);
}
static void
detach_tree (GalViewEtable *view)
{
- if (view->tree == NULL)
- return;
- if (view->tree_state_changed_id) {
+ if (view->tree_state_changed_id > 0) {
g_signal_handler_disconnect (
view->tree,
view->tree_state_changed_id);
view->tree_state_changed_id = 0;
}
- g_object_unref (view->tree);
- view->tree = NULL;
+
+ g_clear_object (&view->tree);
}
static void
@@ -95,16 +83,18 @@ gal_view_etable_get_type_code (GalView *view)
static GalView *
gal_view_etable_clone (GalView *view)
{
- GalViewEtable *gve, *new;
+ GalViewEtable *gve;
+ GalView *clone;
- gve = GAL_VIEW_ETABLE (view);
+ /* Chain up to parent's clone() method. */
+ clone = GAL_VIEW_CLASS (gal_view_etable_parent_class)->clone (view);
- new = g_object_new (GAL_TYPE_VIEW_ETABLE, NULL);
- new->spec = g_object_ref (gve->spec);
- new->title = g_strdup (gve->title);
- new->state = e_table_state_duplicate (gve->state);
+ gve = GAL_VIEW_ETABLE (view);
+ GAL_VIEW_ETABLE (clone)->spec = g_object_ref (gve->spec);
+ GAL_VIEW_ETABLE (clone)->state = e_table_state_duplicate (gve->state);
+ GAL_VIEW_ETABLE (clone)->title = g_strdup (gve->title);
- return GAL_VIEW (new);
+ return clone;
}
static void
@@ -117,13 +107,8 @@ gal_view_etable_dispose (GObject *object)
g_free (view->title);
view->title = NULL;
- if (view->spec)
- g_object_unref (view->spec);
- view->spec = NULL;
-
- if (view->state)
- g_object_unref (view->state);
- view->state = NULL;
+ g_clear_object (&view->spec);
+ g_clear_object (&view->state);
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (gal_view_etable_parent_class)->dispose (object);
@@ -132,17 +117,19 @@ gal_view_etable_dispose (GObject *object)
static void
gal_view_etable_class_init (GalViewEtableClass *class)
{
- GalViewClass *gal_view_class = GAL_VIEW_CLASS (class);
- GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GObjectClass *object_class;
+ GalViewClass *gal_view_class;
- gal_view_class->load = gal_view_etable_load;
- gal_view_class->save = gal_view_etable_save;
- gal_view_class->get_title = gal_view_etable_get_title;
- gal_view_class->set_title = gal_view_etable_set_title;
- gal_view_class->get_type_code = gal_view_etable_get_type_code;
- gal_view_class->clone = gal_view_etable_clone;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = gal_view_etable_dispose;
- object_class->dispose = gal_view_etable_dispose;
+ gal_view_class = GAL_VIEW_CLASS (class);
+ gal_view_class->load = gal_view_etable_load;
+ gal_view_class->save = gal_view_etable_save;
+ gal_view_class->get_title = gal_view_etable_get_title;
+ gal_view_class->set_title = gal_view_etable_set_title;
+ gal_view_class->get_type_code = gal_view_etable_get_type_code;
+ gal_view_class->clone = gal_view_etable_clone;
}
static void
@@ -193,10 +180,8 @@ gal_view_etable_construct (GalViewEtable *view,
g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL);
view->spec = g_object_ref (spec);
- view->state = e_table_state_new (spec);
- if (view->state)
- g_object_unref (view->state);
+ g_clear_object (&view->state);
view->state = e_table_state_duplicate (spec->state);
view->title = g_strdup (title);
@@ -211,8 +196,7 @@ gal_view_etable_set_state (GalViewEtable *view,
g_return_if_fail (GAL_IS_VIEW_ETABLE (view));
g_return_if_fail (E_IS_TABLE_STATE (state));
- if (view->state)
- g_object_unref (view->state);
+ g_clear_object (&view->state);
view->state = e_table_state_duplicate (state);
gal_view_changed (GAL_VIEW (view));
@@ -222,11 +206,8 @@ static void
table_state_changed (ETable *table,
GalViewEtable *view)
{
- ETableState *state;
-
- state = e_table_get_state_object (table);
- g_object_unref (view->state);
- view->state = state;
+ g_clear_object (&view->state);
+ view->state = e_table_get_state_object (table);
gal_view_changed (GAL_VIEW (view));
}
@@ -235,11 +216,8 @@ static void
tree_state_changed (ETree *tree,
GalViewEtable *view)
{
- ETableState *state;
-
- state = e_tree_get_state_object (tree);
- g_object_unref (view->state);
- view->state = state;
+ g_clear_object (&view->state);
+ view->state = e_tree_get_state_object (tree);
gal_view_changed (GAL_VIEW (view));
}
@@ -253,10 +231,10 @@ gal_view_etable_attach_table (GalViewEtable *view,
gal_view_etable_detach (view);
- view->table = table;
+ view->table = g_object_ref (table);
e_table_set_state_object (view->table, view->state);
- g_object_ref (view->table);
+
view->table_state_changed_id = g_signal_connect (
view->table, "state_change",
G_CALLBACK (table_state_changed), view);
@@ -271,10 +249,10 @@ gal_view_etable_attach_tree (GalViewEtable *view,
gal_view_etable_detach (view);
- view->tree = tree;
+ view->tree = g_object_ref (tree);
e_tree_set_state_object (view->tree, view->state);
- g_object_ref (view->tree);
+
view->tree_state_changed_id = g_signal_connect (
view->tree, "state_change",
G_CALLBACK (tree_state_changed), view);
diff --git a/e-util/gal-view-etable.h b/e-util/gal-view-etable.h
index 92f7e64efb..e304ec00f0 100644
--- a/e-util/gal-view-etable.h
+++ b/e-util/gal-view-etable.h
@@ -1,4 +1,5 @@
/*
+ * gal-view-etable.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,12 +14,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
diff --git a/e-util/gal-view-factory-etable.c b/e-util/gal-view-factory-etable.c
index 06082881cb..da6e3c0483 100644
--- a/e-util/gal-view-factory-etable.c
+++ b/e-util/gal-view-factory-etable.c
@@ -21,10 +21,7 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <glib/gi18n.h>
#include "gal-view-etable.h"
@@ -45,7 +42,8 @@ enum {
G_DEFINE_TYPE (
GalViewFactoryEtable,
- gal_view_factory_etable, GAL_TYPE_VIEW_FACTORY)
+ gal_view_factory_etable,
+ GAL_TYPE_VIEW_FACTORY)
static void
view_factory_etable_set_specification (GalViewFactoryEtable *factory,
diff --git a/e-util/gal-view-factory-etable.h b/e-util/gal-view-factory-etable.h
index b26fa4e768..4edddda691 100644
--- a/e-util/gal-view-factory-etable.h
+++ b/e-util/gal-view-factory-etable.h
@@ -66,7 +66,8 @@ struct _GalViewFactoryEtableClass {
GalViewFactoryClass parent_class;
};
-GType gal_view_factory_etable_get_type (void);
+GType gal_view_factory_etable_get_type
+ (void) G_GNUC_CONST;
GalViewFactory *gal_view_factory_etable_new (ETableSpecification *specification);
ETableSpecification *
gal_view_factory_etable_get_specification
diff --git a/e-util/gal-view.c b/e-util/gal-view.c
index f0e3e66436..9bf2e16320 100644
--- a/e-util/gal-view.c
+++ b/e-util/gal-view.c
@@ -1,4 +1,5 @@
/*
+ * gal-view.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,22 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "gal-view.h"
-#define d(x)
-
enum {
PROP_0,
PROP_TITLE,
@@ -85,23 +74,46 @@ view_get_property (GObject *object,
}
static void
+view_load (GalView *view,
+ const gchar *filename)
+{
+}
+
+static void
+view_save (GalView *view,
+ const gchar *filename)
+{
+}
+
+static GalView *
+view_clone (GalView *view)
+{
+ return g_object_new (G_OBJECT_TYPE (view), NULL);
+}
+
+static void
gal_view_class_init (GalViewClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GObjectClass *object_class;
object_class = G_OBJECT_CLASS (class);
object_class->set_property = view_set_property;
object_class->get_property = view_get_property;
+ class->load = view_load;
+ class->save = view_save;
+ class->clone = view_clone;
+
g_object_class_install_property (
object_class,
PROP_TITLE,
g_param_spec_string (
"title",
+ "Title",
+ "View Title",
NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property (
object_class,
@@ -111,7 +123,8 @@ gal_view_class_init (GalViewClass *class)
NULL,
NULL,
NULL,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
signals[CHANGED] = g_signal_new (
"changed",
diff --git a/e-util/gal-view.h b/e-util/gal-view.h
index 1d271356e6..62a41ff406 100644
--- a/e-util/gal-view.h
+++ b/e-util/gal-view.h
@@ -1,4 +1,5 @@
/*
+ * gal-view.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,12 +14,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- *
- * Authors:
- * Chris Lahey <clahey@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
@@ -29,7 +24,6 @@
#define GAL_VIEW_H
#include <gtk/gtk.h>
-#include <libxml/tree.h>
/* Standard GObject macros */
#define GAL_TYPE_VIEW \