aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-03 06:44:46 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-06 04:40:49 +0800
commitc6d3ced98a3faeccf4acd180435e5a36005fc4a2 (patch)
treeff5a2c9ee90f53ce56fe37049cfcc342cdd5086b
parent1f84c2af9842a0e3da42abb0d1a02b3b02f6740f (diff)
downloadgsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.tar
gsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.tar.gz
gsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.tar.bz2
gsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.tar.lz
gsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.tar.xz
gsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.tar.zst
gsoc2013-evolution-c6d3ced98a3faeccf4acd180435e5a36005fc4a2.zip
GalViewEtable: Remove ETableSpecification member.
Instead, lazily load the state file once an ETable or ETree is attached, since we need its ETableSpecification to create an ETableState instance. This means GalViewFactoryEtable can lose its ETableSpecification too.
-rw-r--r--doc/reference/evolution-util/evolution-util-sections.txt1
-rw-r--r--e-util/gal-view-etable.c104
-rw-r--r--e-util/gal-view-etable.h6
-rw-r--r--e-util/gal-view-factory-etable.c6
-rw-r--r--mail/e-mail-paned-view.c39
5 files changed, 67 insertions, 89 deletions
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt b/doc/reference/evolution-util/evolution-util-sections.txt
index 8964ff2760..5bfc1858fa 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -4627,7 +4627,6 @@ gal_view_collection_get_type
<TITLE>GalViewEtable</TITLE>
GalViewEtable
gal_view_etable_new
-gal_view_etable_construct
gal_view_etable_set_state
gal_view_etable_attach_table
gal_view_etable_attach_tree
diff --git a/e-util/gal-view-etable.c b/e-util/gal-view-etable.c
index 9421ee1595..adabf930c5 100644
--- a/e-util/gal-view-etable.c
+++ b/e-util/gal-view-etable.c
@@ -23,8 +23,8 @@
((obj), GAL_TYPE_VIEW_ETABLE, GalViewEtablePrivate))
struct _GalViewEtablePrivate {
- ETableSpecification *spec;
ETableState *state;
+ gchar *state_filename;
ETable *table;
guint table_state_changed_id;
@@ -65,16 +65,27 @@ static void
gal_view_etable_load (GalView *view,
const gchar *filename)
{
- e_table_state_load_from_file (
- GAL_VIEW_ETABLE (view)->priv->state, filename);
+ GalViewEtable *view_etable;
+
+ view_etable = GAL_VIEW_ETABLE (view);
+
+ /* Just note the filename. We'll do the actual load
+ * when an ETable or ETree gets attached since we need
+ * its ETableSpecification to create an ETableState. */
+ g_free (view_etable->priv->state_filename);
+ view_etable->priv->state_filename = g_strdup (filename);
}
static void
gal_view_etable_save (GalView *view,
const gchar *filename)
{
- e_table_state_save_to_file (
- GAL_VIEW_ETABLE (view)->priv->state, filename);
+ GalViewEtable *view_etable;
+
+ view_etable = GAL_VIEW_ETABLE (view);
+ g_return_if_fail (view_etable->priv->state != NULL);
+
+ e_table_state_save_to_file (view_etable->priv->state, filename);
}
static const gchar *
@@ -93,10 +104,13 @@ gal_view_etable_clone (GalView *view)
clone = GAL_VIEW_CLASS (gal_view_etable_parent_class)->clone (view);
gve = GAL_VIEW_ETABLE (view);
- GAL_VIEW_ETABLE (clone)->priv->spec =
- g_object_ref (gve->priv->spec);
- GAL_VIEW_ETABLE (clone)->priv->state =
- e_table_state_duplicate (gve->priv->state);
+
+ if (gve->priv->state != NULL)
+ GAL_VIEW_ETABLE (clone)->priv->state =
+ e_table_state_duplicate (gve->priv->state);
+
+ GAL_VIEW_ETABLE (clone)->priv->state_filename =
+ g_strdup (gve->priv->state_filename);
return clone;
}
@@ -108,7 +122,6 @@ gal_view_etable_dispose (GObject *object)
gal_view_etable_detach (view);
- g_clear_object (&view->priv->spec);
g_clear_object (&view->priv->state);
/* Chain up to parent's dispose() method. */
@@ -116,6 +129,17 @@ gal_view_etable_dispose (GObject *object)
}
static void
+gal_view_etable_finalize (GObject *object)
+{
+ GalViewEtable *view = GAL_VIEW_ETABLE (object);
+
+ g_free (view->priv->state_filename);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (gal_view_etable_parent_class)->finalize (object);
+}
+
+static void
gal_view_etable_class_init (GalViewEtableClass *class)
{
GObjectClass *object_class;
@@ -125,6 +149,7 @@ gal_view_etable_class_init (GalViewEtableClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->dispose = gal_view_etable_dispose;
+ object_class->finalize = gal_view_etable_finalize;
gal_view_class = GAL_VIEW_CLASS (class);
gal_view_class->load = gal_view_etable_load;
@@ -141,7 +166,6 @@ gal_view_etable_init (GalViewEtable *view)
/**
* gal_view_etable_new
- * @spec: The ETableSpecification that this view will be based upon.
* @title: The name of the new view.
*
* Returns a new GalViewEtable. This is primarily for use by
@@ -150,41 +174,9 @@ gal_view_etable_init (GalViewEtable *view)
* Returns: The new GalViewEtable.
*/
GalView *
-gal_view_etable_new (ETableSpecification *spec,
- const gchar *title)
-{
- GalViewEtable *view;
-
- g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL);
-
- view = g_object_new (GAL_TYPE_VIEW_ETABLE, "title", title, NULL);
-
- return gal_view_etable_construct (view, spec);
-}
-
-/**
- * gal_view_etable_construct
- * @view: The view to construct.
- * @spec: The ETableSpecification that this view will be based upon.
- *
- * constructs the GalViewEtable. To be used by subclasses and
- * language bindings.
- *
- * Returns: The GalViewEtable.
- */
-GalView *
-gal_view_etable_construct (GalViewEtable *view,
- ETableSpecification *spec)
+gal_view_etable_new (const gchar *title)
{
- g_return_val_if_fail (GAL_IS_VIEW_ETABLE (view), NULL);
- g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (spec), NULL);
-
- view->priv->spec = g_object_ref (spec);
-
- g_clear_object (&view->priv->state);
- view->priv->state = e_table_state_duplicate (spec->state);
-
- return GAL_VIEW (view);
+ return g_object_new (GAL_TYPE_VIEW_ETABLE, "title", title, NULL);
}
void
@@ -229,8 +221,17 @@ gal_view_etable_attach_table (GalViewEtable *view,
gal_view_etable_detach (view);
- view->priv->table = g_object_ref (table);
+ /* Load the state file now, if necessary. */
+ if (view->priv->state == NULL && view->priv->state_filename != NULL) {
+ ETableSpecification *specification;
+ const gchar *filename = view->priv->state_filename;
+ specification = table->spec;
+ view->priv->state = e_table_state_new (specification);
+ e_table_state_load_from_file (view->priv->state, filename);
+ }
+
+ view->priv->table = g_object_ref (table);
e_table_set_state_object (view->priv->table, view->priv->state);
view->priv->table_state_changed_id = g_signal_connect (
@@ -247,8 +248,17 @@ gal_view_etable_attach_tree (GalViewEtable *view,
gal_view_etable_detach (view);
- view->priv->tree = g_object_ref (tree);
+ /* Load the state file now, if necessary. */
+ if (view->priv->state == NULL && view->priv->state_filename != NULL) {
+ ETableSpecification *specification;
+ const gchar *filename = view->priv->state_filename;
+
+ specification = e_tree_get_spec (tree);
+ view->priv->state = e_table_state_new (specification);
+ e_table_state_load_from_file (view->priv->state, filename);
+ }
+ view->priv->tree = g_object_ref (tree);
e_tree_set_state_object (view->priv->tree, view->priv->state);
view->priv->tree_state_changed_id = g_signal_connect (
diff --git a/e-util/gal-view-etable.h b/e-util/gal-view-etable.h
index 7f064942ed..bce1f916f2 100644
--- a/e-util/gal-view-etable.h
+++ b/e-util/gal-view-etable.h
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include <e-util/gal-view.h>
#include <e-util/e-table-state.h>
-#include <e-util/e-table-specification.h>
#include <e-util/e-table.h>
#include <e-util/e-tree.h>
@@ -65,10 +64,7 @@ struct _GalViewEtableClass {
};
GType gal_view_etable_get_type (void);
-GalView * gal_view_etable_new (ETableSpecification *spec,
- const gchar *title);
-GalView * gal_view_etable_construct (GalViewEtable *view,
- ETableSpecification *spec);
+GalView * gal_view_etable_new (const gchar *title);
void gal_view_etable_set_state (GalViewEtable *view,
ETableState *state);
void gal_view_etable_attach_table (GalViewEtable *view,
diff --git a/e-util/gal-view-factory-etable.c b/e-util/gal-view-factory-etable.c
index da6e3c0483..f26a3a3de6 100644
--- a/e-util/gal-view-factory-etable.c
+++ b/e-util/gal-view-factory-etable.c
@@ -116,11 +116,7 @@ static GalView *
view_factory_etable_new_view (GalViewFactory *factory,
const gchar *name)
{
- GalViewFactoryEtablePrivate *priv;
-
- priv = GAL_VIEW_FACTORY_ETABLE_GET_PRIVATE (factory);
-
- return gal_view_etable_new (priv->specification, name);
+ return gal_view_etable_new (name);
}
static void
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index e0c63992c8..2aa602b9b2 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -925,42 +925,19 @@ mail_paned_view_update_view_instance (EMailView *view)
folder, "et-header-");
if (g_file_test (state_filename, G_FILE_TEST_IS_REGULAR)) {
- ETableSpecification *spec;
- ETableState *state;
GalView *view;
- gchar *spec_filename;
- GError *local_error = NULL;
-
- spec_filename = g_build_filename (
- EVOLUTION_ETSPECDIR,
- "message-list.etspec",
- NULL);
- spec = e_table_specification_new (
- spec_filename, &local_error);
-
- /* Failure here is fatal. */
- if (local_error != NULL) {
- g_error (
- "%s: %s", spec_filename,
- local_error->message);
- g_assert_not_reached ();
- }
-
- state = e_table_state_new (spec);
- view = gal_view_etable_new (spec, "");
-
- e_table_state_load_from_file (
- state, state_filename);
- gal_view_etable_set_state (
- GAL_VIEW_ETABLE (view), state);
+
+ view = gal_view_etable_new ("");
+
+ /* XXX This only stashes the filename in the view.
+ * The state file is not actually loaded until
+ * the MessageList is attached to the view. */
+ gal_view_load (view, state_filename);
+
gal_view_instance_set_custom_view (
view_instance, view);
- g_object_unref (state);
g_object_unref (view);
- g_object_unref (spec);
-
- g_free (spec_filename);
}
g_free (state_filename);