ok. Yes i'm stupid. here's the patch. This is what I get for all
nighters.
--- ./fileselector.cpp Sat Mar 30 14:33:26 2002
+++ ./fileselector.cpp Sat Mar 30 14:32:02 2002
@@ -24,6 +24,7 @@
#include "config.h"
#include <unistd.h>
+#include <dirent.h>
#ifdef __QNX__
#include <strings.h>
@@ -32,6 +33,8 @@
#include "fileselector.h"
#include "utility.h"
+char old_path[PATH_MAX]="/\0";
+
FileSelector::FileSelector(const char *windowtitle)
{
title = windowtitle;
@@ -59,6 +62,34 @@
p->CancelEvent();
}
+string recursive_path(char subdirs[PATH_MAX], string returnpath,int *sub_rnum)
+{
+ DIR *dir=NULL;
+ struct dirent *current=NULL;
+ if ((dir = opendir(subdirs))!=NULL){
+ current = readdir(dir);
+ current = readdir(dir);
+ while((current=readdir(dir))!=NULL){
+ if(current->d_type==DT_DIR){
+ char temp_subdir[PATH_MAX];
+ strncpy(temp_subdir, subdirs,PATH_MAX);
+ strcat(temp_subdir,"/");
+ strncat(temp_subdir,current->d_name,FILENAME_MAX);
+ returnpath = recursive_path(temp_subdir,returnpath,sub_rnum);
+ }
+ else {
+ returnpath += "\n";
+ returnpath += subdirs;
+ returnpath += "/";
+ returnpath += current->d_name;
+ sub_rnum++;
+ }
+ }
+ }
+ closedir(dir);
+ return (returnpath);
+}
+
void FileSelector::CancelEvent()
{
gtk_widget_destroy(filesel);
@@ -72,6 +103,7 @@
char *raw_path = NULL;
GList *row = GTK_CLIST(gfile->file_list)->row_list;
gint rownum = 0;
+ gint sub_rnum = 0;
char *temp, *path_temp;
char *rawtext = gtk_entry_get_text(GTK_ENTRY(gfile->selection_entry));
@@ -79,7 +111,6 @@
!strncasecmp("rtp://", rawtext, 6)) {
returnpath = strdup_new(rawtext);
gtk_widget_destroy(GTK_WIDGET(gfile));
-
ok = true;
done = true;
@@ -88,33 +119,41 @@
returnpath = gtk_file_selection_get_filename(gfile);
path_temp = strdup(returnpath.c_str());
-
+ raw_path = gtk_entry_get_text(GTK_ENTRY(gfile->selection_entry));
char *tempdir = strrchr(path_temp, '/');
+ strncpy(old_path,path_temp,PATH_MAX);
if (!tempdir) {
strcpy(path_temp, "./");
path_temp = (char *)realloc(path_temp, strlen(path_temp) + 1);
}
else
tempdir[0] = '\0';
-
- raw_path = gtk_entry_get_text(GTK_ENTRY(gfile->selection_entry));
- while (row) {
- if (GTK_CLIST_ROW(row)->state == GTK_STATE_SELECTED) {
- if (gtk_clist_get_cell_type(GTK_CLIST(gfile->file_list), rownum, 0)
- == GTK_CELL_TEXT) {
- gtk_clist_get_text(GTK_CLIST(gfile->file_list), rownum, 0, &temp);
- if (!strcmp(temp, raw_path))
- goto next_iter;
- returnpath += "\n";
- returnpath += path_temp;
- returnpath += "/";
- returnpath += temp;
- }
- }
- next_iter:
- rownum++;
- row = g_list_next(row);
+ if(row){
+ while (row) {
+ if (GTK_CLIST_ROW(row)->state == GTK_STATE_SELECTED) {
+ if (gtk_clist_get_cell_type(GTK_CLIST(gfile->file_list), rownum, 0)
+ == GTK_CELL_TEXT) {
+ gtk_clist_get_text(GTK_CLIST(gfile->file_list), rownum, 0, &temp);
+ if (!strcmp(temp, raw_path))
+ goto next_iter;
+ returnpath += "\n";
+ returnpath += path_temp;
+ returnpath += "/";
+ returnpath += temp;
+ }
+ }
+ next_iter:
+ rownum++;
+ row = g_list_next(row);
+ }
+ }
+ else {
+ char subdirs[PATH_MAX];
+ strncpy(subdirs,old_path,PATH_MAX);
+ returnpath="";
+ returnpath = recursive_path(subdirs, returnpath,&sub_rnum);
}
+ rownum += sub_rnum;
gtk_widget_destroy(GTK_WIDGET(gfile));
free(path_temp);
@@ -128,7 +167,7 @@
gdk_threads_enter();
filesel = gtk_file_selection_new(title.c_str());
-
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), old_path);
gtk_window_set_modal(GTK_WINDOW(filesel), TRUE);
gtk_signal_connect(GTK_OBJECT(filesel), "destroy",
GTK_SIGNAL_FUNC(filesel_destroy), (gpointer)runMain);