diff options
author | raveit65 <[email protected]> | 2016-05-07 18:45:20 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-05-26 16:15:22 +0200 |
commit | f800ce9e483940f5969bf1b29506f149b4a0511e (patch) | |
tree | 7b62ebba9c95401e7bc53587c87d2e66300d5fac | |
parent | d7836989512d27a12c8300fca843bc97995cf65e (diff) | |
download | atril-f800ce9e483940f5969bf1b29506f149b4a0511e.tar.bz2 atril-f800ce9e483940f5969bf1b29506f149b4a0511e.tar.xz |
shell: Create metadata object even for temp files
Metadata won't be saved in those cases, but default settings will
applied.
https://bugzilla.gnome.org/show_bug.cgi?id=680145
taken from:
https://git.gnome.org/browse/evince/commit/shell/ev-window.c?h=gnome-3-6&id=6d25b93
-rw-r--r-- | shell/ev-metadata.c | 13 | ||||
-rw-r--r-- | shell/ev-window.c | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/shell/ev-metadata.c b/shell/ev-metadata.c index dba8e511..4bf49ae8 100644 --- a/shell/ev-metadata.c +++ b/shell/ev-metadata.c @@ -22,6 +22,7 @@ #include <string.h> #include "ev-metadata.h" +#include "ev-file-helpers.h" struct _EvMetadata { GObject base; @@ -129,9 +130,10 @@ ev_metadata_new (GFile *file) g_return_val_if_fail (G_IS_FILE (file), NULL); metadata = EV_METADATA (g_object_new (EV_TYPE_METADATA, NULL)); - metadata->file = g_object_ref (file); - - ev_metadata_load (metadata); + if (!ev_file_is_temp (file)) { + metadata->file = g_object_ref (file); + ev_metadata_load (metadata); + } return metadata; } @@ -178,6 +180,10 @@ ev_metadata_set_string (EvMetadata *metadata, GFileInfo *info; gchar *gio_key; + g_hash_table_insert (metadata->items, g_strdup (key), g_strdup (value)); + if (!metadata->file) + return TRUE; + info = g_file_info_new (); gio_key = g_strconcat (EV_METADATA_NAMESPACE"::", key, NULL); @@ -190,7 +196,6 @@ ev_metadata_set_string (EvMetadata *metadata, } g_free (gio_key); - g_hash_table_insert (metadata->items, g_strdup (key), g_strdup (value)); g_file_set_attributes_async (metadata->file, info, 0, diff --git a/shell/ev-window.c b/shell/ev-window.c index f046f7af..42505b77 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -2204,7 +2204,7 @@ ev_window_open_uri (EvWindow *ev_window, g_object_unref (ev_window->priv->bookmarks); source_file = g_file_new_for_uri (uri); - if (!ev_file_is_temp (source_file) && ev_is_metadata_supported_for_file (source_file)) { + if (ev_is_metadata_supported_for_file (source_file)) { ev_window->priv->metadata = ev_metadata_new (source_file); ev_window_init_metadata_with_default_values (ev_window); } else { |