[evince/gnome-2-30] Take default settings from last document opened
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/gnome-2-30] Take default settings from last document opened
- Date: Tue, 20 Apr 2010 09:28:01 +0000 (UTC)
commit 1c265473114e0123a7cf4386d18186fc98aae6ae
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Tue Apr 20 11:26:42 2010 +0200
Take default settings from last document opened
Workaround to fix regression caused by migration to gio metadata. See
bug #606090.
shell/ev-window.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 7 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 1a40b7c..27c225c 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -187,6 +187,7 @@ struct _EvWindowPrivate {
EvWindowPageMode page_mode;
EvWindowTitle *title;
EvMetadata *metadata;
+ EvMetadata *last_settings;
/* Load params */
EvLinkDest *dest;
@@ -903,8 +904,9 @@ setup_chrome_from_metadata (EvWindow *window)
EvChrome chrome = EV_CHROME_NORMAL;
gboolean show_toolbar;
- if (window->priv->metadata &&
- ev_metadata_get_boolean (window->priv->metadata, "show_toolbar", &show_toolbar)) {
+ if ((window->priv->metadata &&
+ ev_metadata_get_boolean (window->priv->metadata, "show_toolbar", &show_toolbar)) ||
+ ev_metadata_get_boolean (window->priv->last_settings, "show_toolbar", &show_toolbar)) {
if (!show_toolbar)
chrome &= ~EV_CHROME_TOOLBAR;
}
@@ -953,7 +955,8 @@ setup_sidebar_from_metadata (EvWindow *window)
}
}
- if (ev_metadata_get_boolean (window->priv->metadata, "sidebar_visibility", &sidebar_visibility)) {
+ if (ev_metadata_get_boolean (window->priv->metadata, "sidebar_visibility", &sidebar_visibility) ||
+ ev_metadata_get_boolean (window->priv->last_settings, "sidebar_visibility", &sidebar_visibility)) {
update_chrome_flag (window, EV_CHROME_SIDEBAR, sidebar_visibility);
update_chrome_visibility (window);
}
@@ -1064,8 +1067,8 @@ setup_document_from_metadata (EvWindow *window)
ev_metadata_get_int (window->priv->metadata, "window_height", &height))
return; /* size was already set in setup_size_from_metadata */
- if (ev_metadata_get_double (window->priv->metadata, "window_width_ratio", &width_ratio) &&
- ev_metadata_get_double (window->priv->metadata, "window_height_ratio", &height_ratio)) {
+ if (ev_metadata_get_double (window->priv->last_settings, "window_width_ratio", &width_ratio) &&
+ ev_metadata_get_double (window->priv->last_settings, "window_height_ratio", &height_ratio)) {
gdouble document_width;
gdouble document_height;
GdkScreen *screen;
@@ -4290,6 +4293,7 @@ ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
update_chrome_visibility (ev_window);
if (ev_window->priv->metadata)
ev_metadata_set_boolean (ev_window->priv->metadata, "show_toolbar", active);
+ ev_metadata_set_boolean (ev_window->priv->last_settings, "show_toolbar", active);
}
static void
@@ -4347,6 +4351,8 @@ ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
if (ev_window->priv->metadata)
ev_metadata_set_boolean (ev_window->priv->metadata, "sidebar_visibility",
GTK_WIDGET_VISIBLE (ev_sidebar));
+ ev_metadata_set_boolean (ev_window->priv->last_settings, "sidebar_visibility",
+ GTK_WIDGET_VISIBLE (ev_sidebar));
}
}
@@ -4782,6 +4788,11 @@ ev_window_dispose (GObject *object)
priv->metadata = NULL;
}
+ if (priv->last_settings) {
+ g_object_unref (priv->last_settings);
+ priv->last_settings = NULL;
+ }
+
if (priv->setup_document_idle > 0) {
g_source_remove (priv->setup_document_idle);
priv->setup_document_idle = 0;
@@ -5458,9 +5469,9 @@ window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer
if (!ev_window_is_empty (window) && window->priv->document) {
ev_document_get_max_page_size (window->priv->document,
&document_width, &document_height);
- ev_metadata_set_double (window->priv->metadata, "window_width_ratio",
+ ev_metadata_set_double (window->priv->last_settings, "window_width_ratio",
(double)event->width / document_width);
- ev_metadata_set_double (window->priv->metadata, "window_height_ratio",
+ ev_metadata_set_double (window->priv->last_settings, "window_height_ratio",
(double)event->height / document_height);
ev_metadata_set_int (window->priv->metadata, "window_x", event->x);
ev_metadata_set_int (window->priv->metadata, "window_y", event->y);
@@ -6087,6 +6098,36 @@ get_toolbars_model (void)
}
static void
+ev_window_create_last_settings_metadata (EvWindow *window)
+{
+ GFile *file;
+ gchar *path;
+
+ path = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE), "last_settings", NULL);
+ file = g_file_new_for_path (path);
+ g_free (path);
+
+ if (!g_file_query_exists (file, NULL)) {
+ GFileOutputStream *out;
+ GError *error = NULL;
+
+ out = g_file_create (file, G_FILE_CREATE_NONE, NULL, &error);
+ if (error) {
+ g_warning ("Error creating last_settings file: %s\n", error->message);
+ g_error_free (error);
+ g_object_unref (file);
+
+ return;
+ }
+
+ g_output_stream_close (G_OUTPUT_STREAM (out), NULL, NULL);
+ }
+
+ window->priv->last_settings = ev_metadata_new (file);
+ g_object_unref (file);
+}
+
+static void
ev_window_init (EvWindow *ev_window)
{
GtkActionGroup *action_group;
@@ -6433,6 +6474,11 @@ ev_window_init (EvWindow *ev_window)
/* Give focus to the document view */
gtk_widget_grab_focus (ev_window->priv->view);
+ /* This a workaround for regression caused by migration to
+ * gio metadata that made us loose the last used settings.
+ * We use a dummy file just to store last used settings */
+ ev_window_create_last_settings_metadata (ev_window);
+
/* Set it user interface params */
ev_window_setup_recent (ev_window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]