diff options
author | Søren Sandmann <sandmann@redhat.com> | 2008-06-20 01:32:46 -0400 |
---|---|---|
committer | Søren Sandmann <sandmann@redhat.com> | 2008-06-20 01:32:46 -0400 |
commit | 8111bc0c9600e42a96b01d6f6ad630f4bb06c970 (patch) | |
tree | 9cfbd14ed57c09b48e8876ca2811f781a47e9061 | |
parent | da0780a4dea14462bfbb6b303c8f27043fc6599f (diff) |
TODO; add mimetypes to filechooser; work around gtk+ bug 539227
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | window.c | 39 |
2 files changed, 42 insertions, 7 deletions
@@ -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 @@ -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) |