summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'window.c')
-rw-r--r--window.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/window.c b/window.c
index b2c4e37..cdaf7fb 100644
--- a/window.c
+++ b/window.c
@@ -729,6 +729,23 @@ set_busy (GtkWidget *widget,
}
static void
+add_image_filters (GtkWidget *dialog)
+{
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
+ GtkFileFilter *filter;
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pixbuf_formats (filter);
+ gtk_file_filter_set_name (filter, "Images");
+ gtk_file_chooser_add_filter (chooser, filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, "All Files");
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (chooser, filter);
+}
+
+static void
on_open (GtkWidget *widget, gpointer data)
{
SivWindow *window = data;
@@ -743,6 +760,8 @@ on_open (GtkWidget *widget, gpointer data)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
+
+ add_image_filters (dialog);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
@@ -754,18 +773,35 @@ retry:
GError *err = NULL;
SivWindow *target;
gboolean success;
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
if (window->original)
target = window_new (window->app);
else
target = window;
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ filename = gtk_file_chooser_get_filename (chooser);
+
+ /* This broke in GTK+ 2.13 */
+ if (!g_path_is_absolute (filename))
+ {
+ char *folder, *tmp;
+
+ folder = gtk_file_chooser_get_current_folder (chooser);
+ tmp = g_build_filename (folder, filename, NULL);
+
+ g_free (folder);
+ g_free (filename);
+
+ filename = tmp;
+ }
set_busy (dialog, TRUE);
success = window_load_file (target, filename, &err);
+ set_busy (dialog, FALSE);
+
if (success)
{
if (target != window)
@@ -782,7 +818,6 @@ retry:
window_free (target);
}
- set_busy (dialog, FALSE);
g_free (filename);
if (!success)