aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-04-01 21:33:04 +0800
committerMilan Crha <mcrha@redhat.com>2010-04-01 21:33:04 +0800
commitba1c4eade6a41d285fae59969f2db4b253139041 (patch)
tree4040e61dcb605759ec5e57bcb4cd063af238cddd
parent841fa6274b1390bde05a8327ee026cf91666852f (diff)
downloadgsoc2013-evolution-ba1c4eade6a41d285fae59969f2db4b253139041.tar.gz
gsoc2013-evolution-ba1c4eade6a41d285fae59969f2db4b253139041.tar.zst
gsoc2013-evolution-ba1c4eade6a41d285fae59969f2db4b253139041.zip
Bug #613356 - Calendar doesn't save Task/Memo table state
-rw-r--r--modules/calendar/e-cal-shell-content.c81
-rw-r--r--modules/calendar/e-cal-shell-content.h2
-rw-r--r--modules/calendar/e-cal-shell-view-private.c4
3 files changed, 75 insertions, 12 deletions
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index da1a7ced41..f5cc0162c0 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -140,6 +140,73 @@ cal_shell_content_notify_view_id_cb (ECalShellContent *cal_shell_content)
cal_shell_content->priv->paned_binding_id = binding_id;
}
+static gchar *
+cal_chell_content_get_pad_state_filename (EShellContent *shell_content, ETable *table)
+{
+ EShellBackend *shell_backend;
+ EShellView *shell_view;
+ const gchar *config_dir, *nick = NULL;
+
+ g_return_val_if_fail (shell_content != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+ g_return_val_if_fail (table != NULL, NULL);
+ g_return_val_if_fail (E_IS_TABLE (table), NULL);
+
+ if (E_IS_TASK_TABLE (table))
+ nick = "TaskPad";
+ else if (E_IS_MEMO_TABLE (table))
+ nick = "MemoPad";
+
+ g_return_val_if_fail (nick != NULL, NULL);
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ config_dir = e_shell_backend_get_config_dir (shell_backend);
+
+ return g_build_filename (config_dir, nick, NULL);
+}
+
+static void
+cal_shell_content_save_table_state (EShellContent *shell_content, ETable *table)
+{
+ gchar *filename;
+
+ filename = cal_chell_content_get_pad_state_filename (shell_content, table);
+ g_return_if_fail (filename != NULL);
+
+ e_table_save_state (table, filename);
+ g_free (filename);
+}
+
+static void
+cal_shell_content_load_table_state (EShellContent *shell_content, ETable *table)
+{
+ gchar *filename;
+
+ filename = cal_chell_content_get_pad_state_filename (shell_content, table);
+ g_return_if_fail (filename != NULL);
+
+ e_table_load_state (table, filename);
+ g_free (filename);
+}
+
+void
+e_cal_shell_content_save_state (ECalShellContent *cal_shell_content)
+{
+ ECalShellContentPrivate *priv;
+
+ g_return_if_fail (cal_shell_content != NULL);
+ g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content));
+
+ priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (cal_shell_content);
+
+ if (priv->task_table)
+ cal_shell_content_save_table_state (E_SHELL_CONTENT (cal_shell_content), E_TABLE (priv->task_table));
+
+ if (priv->memo_table != NULL)
+ cal_shell_content_save_table_state (E_SHELL_CONTENT (cal_shell_content), E_TABLE (priv->memo_table));
+}
+
static void
cal_shell_content_set_property (GObject *object,
guint property_id,
@@ -251,7 +318,6 @@ cal_shell_content_constructed (GObject *object)
ECalModel *task_model;
EShell *shell;
EShellContent *shell_content;
- EShellBackend *shell_backend;
EShellSettings *shell_settings;
EShellView *shell_view;
EShellWindow *shell_window;
@@ -262,9 +328,7 @@ cal_shell_content_constructed (GObject *object)
GConfBridge *bridge;
GtkWidget *container;
GtkWidget *widget;
- const gchar *config_dir;
const gchar *key;
- gchar *filename;
gchar *markup;
gint ii;
@@ -277,9 +341,6 @@ cal_shell_content_constructed (GObject *object)
shell_view = e_shell_content_get_shell_view (shell_content);
shell_window = e_shell_view_get_shell_window (shell_view);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
- config_dir = e_shell_backend_get_config_dir (shell_backend);
-
shell = e_shell_window_get_shell (shell_window);
shell_settings = e_shell_get_shell_settings (shell);
@@ -376,9 +437,7 @@ cal_shell_content_constructed (GObject *object)
priv->task_table = g_object_ref (widget);
gtk_widget_show (widget);
- filename = g_build_filename (config_dir, "TaskPad", NULL);
- e_table_load_state (E_TABLE (widget), filename);
- g_free (filename);
+ cal_shell_content_load_table_state (shell_content, E_TABLE (widget));
g_signal_connect_swapped (
widget, "open-component",
@@ -416,9 +475,7 @@ cal_shell_content_constructed (GObject *object)
priv->memo_table = g_object_ref (widget);
gtk_widget_show (widget);
- filename = g_build_filename (config_dir, "MemoPad", NULL);
- e_table_load_state (E_TABLE (widget), filename);
- g_free (filename);
+ cal_shell_content_load_table_state (shell_content, E_TABLE (widget));
e_cal_model_set_default_time_func (
memo_model, gc_get_default_time, calendar);
diff --git a/modules/calendar/e-cal-shell-content.h b/modules/calendar/e-cal-shell-content.h
index 92acbaa3c9..9ef66d968d 100644
--- a/modules/calendar/e-cal-shell-content.h
+++ b/modules/calendar/e-cal-shell-content.h
@@ -97,6 +97,8 @@ EShellSearchbar *
GalViewInstance *
e_cal_shell_content_get_view_instance
(ECalShellContent *cal_shell_content);
+void e_cal_shell_content_save_state
+ (ECalShellContent *cal_shell_content);
G_END_DECLS
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 5fc42feacc..8806ad691b 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -591,6 +591,10 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view)
{
ECalShellViewPrivate *priv = cal_shell_view->priv;
+ /* Calling calendar's save state from here, because it is too late in its dispose */
+ if (priv->cal_shell_content)
+ e_cal_shell_content_save_state (priv->cal_shell_content);
+
DISPOSE (priv->cal_shell_backend);
DISPOSE (priv->cal_shell_content);
DISPOSE (priv->cal_shell_sidebar);