summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-06-20 01:32:46 -0400
committerSøren Sandmann <sandmann@redhat.com>2008-06-20 01:32:46 -0400
commit8111bc0c9600e42a96b01d6f6ad630f4bb06c970 (patch)
tree9cfbd14ed57c09b48e8876ca2811f781a47e9061
parentda0780a4dea14462bfbb6b303c8f27043fc6599f (diff)
TODO; add mimetypes to filechooser; work around gtk+ bug 539227
-rw-r--r--TODO10
-rw-r--r--window.c39
2 files changed, 42 insertions, 7 deletions
diff --git a/TODO b/TODO
index e336d4f..ec000f6 100644
--- a/TODO
+++ b/TODO
@@ -1,18 +1,18 @@
-- Statusbar
- - Size, position, color
-
-- Set mimetypes in open dialog
-
- Icon
- Recent files
+- Statusbar
+ - Size, position, color
+
- Metadata
- Keep track of when files are used
- Limit size to 1000 most recently used files
Done:
+- Set mimetypes in open dialog
+
- Dragging
- Remember position of empty window
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)