summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@daimi.au.dk>2010-07-18 11:41:54 -0400
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>2010-07-18 11:41:54 -0400
commit479cc491dbb9a2fe8fc09b36cf71e5e3a74d8eee (patch)
tree0715331ce3ac8c45050e3e4c126173f0ad1acb17
parent66c5483745429e4a1322b4df9dc9fe41cf2c2f3a (diff)
Reload the file if it is already loaded when opened from the command line
-rw-r--r--siv.c1
-rw-r--r--siv.h1
-rw-r--r--window.c34
3 files changed, 32 insertions, 4 deletions
diff --git a/siv.c b/siv.c
index e8055b1..9b880bb 100644
--- a/siv.c
+++ b/siv.c
@@ -393,6 +393,7 @@ open_file (App *app,
if (window_matches_file (w, filename))
{
+ window_reload (w);
window_present (w, startup_id);
return TRUE;
}
diff --git a/siv.h b/siv.h
index 463f65e..2f5d480 100644
--- a/siv.h
+++ b/siv.h
@@ -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,
diff --git a/window.c b/window.c
index 2db2d5c..009bdd4 100644
--- a/window.c
+++ b/window.c
@@ -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);
@@ -1090,8 +1091,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;
@@ -1099,8 +1100,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);
@@ -1114,6 +1124,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)
{