diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-07-23 20:36:33 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-07-23 20:36:33 -0400 |
commit | a14abdcc3a5afc5df871a91f96ad04a3daf0dfb4 (patch) | |
tree | 62e8e26aa56871eaf15aa444fc17e35661b236a7 | |
parent | c2cc3ce535b40d8acf1c2f807059c6cf48203e76 (diff) | |
parent | 479cc491dbb9a2fe8fc09b36cf71e5e3a74d8eee (diff) |
Merge branch 'master' of git+ssh://people.freedesktop.org/home/sandmann/siv
-rw-r--r-- | siv.c | 1 | ||||
-rw-r--r-- | siv.h | 1 | ||||
-rw-r--r-- | window.c | 34 |
3 files changed, 32 insertions, 4 deletions
@@ -393,6 +393,7 @@ open_file (App *app, if (window_matches_file (w, filename)) { + window_reload (w); window_present (w, startup_id); return TRUE; } @@ -73,6 +73,7 @@ SivWindow * window_new (App *app); gboolean window_load_file (SivWindow *window, const char *file, GError **err); +void window_reload (SivWindow *window); void window_present (SivWindow *window, const char *startup_id); void window_show (SivWindow *window, @@ -314,7 +314,8 @@ set_status_bar (SivWindow *window) width = gdk_pixbuf_get_width (window->original); height = gdk_pixbuf_get_height (window->original); - text = g_strdup_printf (" %d x %d %.0f %%", width, height, 100 * get_scale (window)); + text = g_strdup_printf (" %d x %d %.0f %%", + width, height, 100 * get_scale (window)); gtk_statusbar_push (bar, 0, text); @@ -1094,8 +1095,8 @@ apply_meta_data (SivWindow *window, const char *filename) } } -gboolean -window_load_file (SivWindow *window, const char *filename, GError **err) +static gboolean +load_file (SivWindow *window, const char *filename, GError **err) { GdkPixbuf *pixbuf; @@ -1103,8 +1104,17 @@ window_load_file (SivWindow *window, const char *filename, GError **err) if (pixbuf) { + if (window->original) + g_object_unref (window->original); window->original = pixbuf; - window->filename = g_strdup (filename); + + /* Make a copy of filename because it may be the same + * as window->filename which we free below. + */ + filename = g_strdup (filename); + if (window->filename) + g_free (window->filename); + window->filename = (char *)filename; apply_meta_data (window, filename); @@ -1118,6 +1128,22 @@ window_load_file (SivWindow *window, const char *filename, GError **err) } } +void +window_reload (SivWindow *window) +{ + if (window->filename) + { + save_meta_data (window); + load_file (window, window->filename, NULL); + } +} + +gboolean +window_load_file (SivWindow *window, const char *filename, GError **err) +{ + return load_file (window, filename, err); +} + SivWindow * window_new (App *app) { |