[evolution] GalView-related cleanups.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] GalView-related cleanups.
- Date: Fri, 5 Jul 2013 20:41:08 +0000 (UTC)
commit 6db972ab0fd2f223aea07c6a413d39a01c41152b
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jul 2 12:09:28 2013 -0400
GalView-related cleanups.
addressbook/gui/widgets/gal-view-minicard.c | 15 ++--
calendar/gui/calendar-view.c | 38 ++--------
e-util/gal-view-etable.c | 102 +++++++++++----------------
e-util/gal-view-etable.h | 7 +--
e-util/gal-view-factory-etable.c | 6 +-
e-util/gal-view-factory-etable.h | 3 +-
e-util/gal-view.c | 47 ++++++++-----
e-util/gal-view.h | 8 +--
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 fcc99b3..61cd144 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 8ef24ef..08bac07 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 0615fe0..53782ee 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 92f7e64..e304ec0 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 0608288..da6e3c0 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 b26fa4e..4edddda 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 f0e3e66..9bf2e16 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 1d27135..62a41ff 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 \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]