aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
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 /e-util
parentc361af739614d5a4bdc90741128bb25c0907e015 (diff)
downloadgsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.gz
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.tar.zst
gsoc2013-evolution-6db972ab0fd2f223aea07c6a413d39a01c41152b.zip
GalView-related cleanups.
Diffstat (limited to 'e-util')
-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
6 files changed, 76 insertions, 97 deletions
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 \