diff options
Diffstat (limited to 'app/wlib/gtklib/filesel.c')
-rw-r--r-- | app/wlib/gtklib/filesel.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/app/wlib/gtklib/filesel.c b/app/wlib/gtklib/filesel.c index 4b92389..ca30c7f 100644 --- a/app/wlib/gtklib/filesel.c +++ b/app/wlib/gtklib/filesel.c @@ -28,6 +28,12 @@ #include <unistd.h> #include <string.h> +#define GTK_DISABLE_SINGLE_INCLUDES +#define GDK_DISABLE_DEPRECATED +#define GTK_DISABLE_DEPRECATED +#define GSEAL_ENABLE + +#include <gtk/gtk.h> #include "gtkint.h" #include "i18n.h" @@ -71,9 +77,6 @@ struct wFilSel_t * wFilSelCreate( void * data ) { struct wFilSel_t *fs; - int count; - char * cp; - GtkFileFilter *filter; fs = (struct wFilSel_t*)malloc(sizeof *fs); if (!fs) @@ -88,9 +91,10 @@ struct wFilSel_t * wFilSelCreate( fs->data = data; if (pattList) { + char * cp = strdup(pattList); + int count = 0; + //create filters for the passed filter list - cp = strdup(pattList); - count = 0; // names and patterns are separated by | cp = strtok( cp, "|" ); while ( cp && count < (MAX_ALLOWEDFILTERS - 1)) { @@ -130,15 +134,9 @@ int wFilSelect( struct wFilSel_t * fs, const char * dirName ) char name[1024]; char *host; char *file; - char *namePart; int i; - GSList *fileNameList; GError *err = NULL; - GtkFileFilter *activeFilter; - - char **fileNames; - - char * cp; + if (fs->window == NULL) { fs->window = gtk_file_chooser_dialog_new( fs->title, GTK_WINDOW( fs->parent->gtkwin ), @@ -164,20 +162,25 @@ int wFilSelect( struct wFilSel_t * fs, const char * dirName ) } strcpy( name, dirName ); - cp = name+strlen(name); - if (cp[-1] != '/') { - *cp++ = '/'; - *cp = 0; - } - if( fs->mode == FS_SAVE ) - gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(fs->window), name ); + if( fs->mode == FS_SAVE ) + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(fs->window), name ); + // Add a current folder and a shortcut to it for Load/import dialogs + if( fs->mode == FS_LOAD ) { + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(fs->window), name ); + gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER(fs->window), name, NULL ); + } + if( gtk_dialog_run( GTK_DIALOG( fs->window )) == GTK_RESPONSE_ACCEPT ) { + char **fileNames; + GSList *fileNameList; fileNameList = gtk_file_chooser_get_uris( GTK_FILE_CHOOSER(fs->window) ); fileNames = calloc( sizeof(char *), g_slist_length (fileNameList) ); for (i=0; i < g_slist_length (fileNameList); i++ ) { + char *namePart; + file = g_filename_from_uri( g_slist_nth_data( fileNameList, i ), &host, &err ); // check for presence of file extension @@ -205,7 +208,7 @@ int wFilSelect( struct wFilSel_t * fs, const char * dirName ) } free( fileNames ); g_slist_free (fileNameList); - } + } gtk_widget_hide( GTK_WIDGET( fs->window )); return 1; |