This gives freeamp the ability to add directories in the playlist selection window and 
off the gtk main window.  This is different from freeamp's current behavior of just 
adding the directory name to the playlist.  



diff -urN -x corba -x CVS -x config.status -x configure -x config.h -x config.log -x 
Makefile* -x aclocal* -x config.cache 
./freeamp/ui/freeamp/unix/src/GTKFileSelector.cpp 
./freeamp-patched/ui/freeamp/unix/src/GTKFileSelector.cpp
--- ./freeamp/ui/freeamp/unix/src/GTKFileSelector.cpp   Wed May 24 13:08:34 2000
+++ ./freeamp-patched/ui/freeamp/unix/src/GTKFileSelector.cpp   Sun Mar 31 19:23:54 
+2002
@@ -23,6 +23,9 @@
 
 #include "GTKFileSelector.h"
 #include <unistd.h>
+#include <dirent.h>
+
+char old_path[PATH_MAX];
 
 GTKFileSelector::GTKFileSelector(const char *windowtitle)
 {
@@ -51,6 +54,34 @@
     p->CancelEvent();
 }
 
+string GTKrecursive_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 = GTKrecursive_path(temp_subdir,returnpath,sub_rnum);
+            }
+            else {
+                returnpath += "\n";
+                returnpath += subdirs;
+               returnpath += "/";
+                returnpath += current->d_name;
+                sub_rnum++;
+            }
+        }
+    }
+    closedir(dir);
+    return (returnpath);
+}                    
+
 void GTKFileSelector::CancelEvent()
 {
     gtk_widget_destroy(filesel);
@@ -64,6 +95,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;
 
     returnpath = gtk_file_selection_get_filename(gfile);
@@ -78,23 +110,33 @@
         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);
+    strncpy(old_path,path_temp,PATH_MAX);
+    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 = GTKrecursive_path(subdirs,returnpath,&sub_rnum);
     }
+    rownum += sub_rnum;
     gtk_widget_destroy(GTK_WIDGET(gfile));
     free(path_temp);
diff -urN -x corba -x CVS -x config.status -x configure -x config.h -x config.log -x 
Makefile* -x aclocal* -x config.cache 
./freeamp/ui/musicbrowser/unix/src/fileselector.cpp 
./freeamp-patched/ui/musicbrowser/unix/src/fileselector.cpp
--- ./freeamp/ui/musicbrowser/unix/src/fileselector.cpp Thu Sep 28 04:08:03 2000
+++ ./freeamp-patched/ui/musicbrowser/unix/src/fileselector.cpp Sun Mar 31 18:24:01 
+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);
 

_______________________________________________
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev

Reply via email to