Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_dialog.c ewl_filedialog.c ewl_filedialog.h 
        ewl_fileselector.c ewl_fileselector.h 


Log Message:
New filedialog code from caro. Expect this to evolve over the next few weeks.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_dialog.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ewl_dialog.c        27 Aug 2004 06:13:17 -0000      1.11
+++ ewl_dialog.c        28 Aug 2004 06:26:33 -0000      1.12
@@ -61,10 +61,12 @@
 
        if (box) {
                ewl_container_child_append(EWL_CONTAINER(dialog), box);
+               ewl_object_fill_policy_set(EWL_OBJECT(box), EWL_FLAG_FILL_ALL);
                ewl_widget_show(box);
        }
 
        dialog->vbox = ewl_vbox_new();
+       ewl_object_fill_policy_set(EWL_OBJECT(dialog->vbox), EWL_FLAG_FILL_ALL);
        if (dialog->vbox) {
                ewl_container_child_append(EWL_CONTAINER(box),
                                           dialog->vbox);
@@ -226,26 +228,26 @@
        switch (dialog->position) {
        case EWL_POSITION_LEFT:
                {
-                       ewl_container_child_append(EWL_CONTAINER
-                                                  (dialog->vbox), w);
+                       ewl_container_child_append(EWL_CONTAINER(dialog->vbox),
+                                                  w);
                        break;
                }
        case EWL_POSITION_TOP:
                {
-                       ewl_container_child_append(EWL_CONTAINER
-                                                  (dialog->vbox), w);
+                       ewl_container_child_append(EWL_CONTAINER(dialog->vbox),
+                                                  w);
                        break;
                }
        case EWL_POSITION_RIGHT:
                {
-                       ewl_container_child_prepend(EWL_CONTAINER
-                                                   (dialog->vbox), w);
+                       ewl_container_child_prepend(EWL_CONTAINER(dialog->vbox),
+                                                   w);
                        break;
                }
        default:
                {
-                       ewl_container_child_prepend(EWL_CONTAINER
-                                                   (dialog->vbox), w);
+                       ewl_container_child_prepend(EWL_CONTAINER(dialog->vbox),
+                                                   w);
                        break;
                }
        }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- ewl_filedialog.c    19 Aug 2004 20:03:32 -0000      1.39
+++ ewl_filedialog.c    28 Aug 2004 06:26:33 -0000      1.40
@@ -1,12 +1,21 @@
 #include <Ewl.h>
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <string.h>
+
+#include "ewl_fileselector.h"
+#include "ewl_filedialog.h"
+
 
 /**
  * @param type: type of dialog to display
  * @return Returns a new filedialog in success, NULL on failure.
  * @brief Create a new filedialog
  */
-Ewl_Widget     *ewl_filedialog_new(Ewl_Filedialog_Type type)
+Ewl_Widget *ewl_filedialog_new()
 {
        Ewl_Filedialog *fd;
 
@@ -16,240 +25,109 @@
        if (!fd)
                DRETURN_PTR(NULL, DLEVEL_STABLE);
 
-       ewl_filedialog_init(fd, type);
+       ewl_filedialog_init(fd);
 
        DRETURN_PTR(EWL_WIDGET(fd), DLEVEL_STABLE);
 }
 
-
 /**
  * @param fd: the filedialog
  * @param type: the filedialog type
  * @return Returns no value.
  * @brief Initialize a new filedialog
  */
-void
-ewl_filedialog_init(Ewl_Filedialog * fd, Ewl_Filedialog_Type type)
+void ewl_filedialog_init(Ewl_Filedialog * fd)
 {
-       Ewl_Widget     *w;
-       Ewl_Widget     *hbox;
-       Ewl_Widget     *vbox;
-       
+       Ewl_Widget *w;
+       Ewl_Widget *button;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR ("fd", fd);
+       DCHECK_PARAM_PTR("fd", fd);
 
        w = EWL_WIDGET(fd);
 
-       /*
-        * Initialize the widget to have the necessary box and filedialog
-        * attributes.
-        */
-       ewl_box_init(EWL_BOX(w), EWL_ORIENTATION_VERTICAL);
-       ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_SHRINK |
-                                                 EWL_FLAG_FILL_FILL);
-       ewl_widget_appearance_set(EWL_WIDGET (w), "filedialog");
-       fd->type = type;
-
-       /*
-        * Setup the internally used layout and display widgets.
-        */
-       vbox = ewl_vbox_new ();
-       ewl_widget_internal_set(vbox, TRUE);
-       ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_SHRINK |
-                                                    EWL_FLAG_FILL_FILL);
-       ewl_container_child_append(EWL_CONTAINER(fd), vbox);
-       ewl_widget_show (vbox);
-
-       fd->path_label = ewl_text_new ("");
-       ewl_widget_internal_set(fd->path_label, TRUE);
-       ewl_container_child_append(EWL_CONTAINER(vbox), fd->path_label);
-       ewl_object_padding_set(EWL_OBJECT(fd->path_label), 2, 2, 2, 2);
-       ewl_widget_show (fd->path_label);
-
-       hbox = ewl_hbox_new();
-       ewl_box_homogeneous_set(EWL_BOX(hbox), FALSE);
-       ewl_widget_internal_set(hbox, TRUE);
-       ewl_container_child_append(EWL_CONTAINER(vbox), hbox);
-       ewl_widget_show (hbox);
-
-       /*
-        * This box will be redirected to, to allow users to pack additional
-        * buttons and widgets inside the filedialog.
-        */
-       /*
-       fd->decor_box = ewl_vbox_new();
-       ewl_widget_internal_set(fd->decor_box, TRUE);
-       ewl_object_fill_policy_set(EWL_OBJECT(fd->decor_box),
-                       EWL_FLAG_FILL_VFILL);
-       ewl_box_set_spacing(EWL_BOX(fd->decor_box), 4);
-       ewl_object_set_padding(EWL_OBJECT(fd->decor_box), 10, 10, 10, 10);
-       ewl_object_alignment_set(EWL_OBJECT(fd->decor_box), EWL_FLAG_ALIGN_RIGHT);
-       ewl_container_child_append(EWL_CONTAINER(hbox), fd->decor_box);
-       ewl_widget_show(fd->decor_box);
-       */
-
-       /*
-        * Display the lists of directories and files.
-        */
-       fd->selector = ewl_fileselector_new();
-       ewl_widget_internal_set(fd->selector, TRUE);
-       ewl_container_child_append(EWL_CONTAINER(hbox), fd->selector);
-       ewl_callback_append (EWL_WIDGET (fd->selector),
-                       EWL_CALLBACK_VALUE_CHANGED,
-                       ewl_filedialog_change_labels_cb, fd);
-       ewl_widget_show(fd->selector);
-
-       /*
-        * Here we provide an entry for typing in filenames, and buttons for
-        * accepting or canceling the selection.
-        */
-       fd->button_box = ewl_hbox_new();
-       ewl_widget_internal_set(fd->button_box, TRUE);
-       ewl_object_fill_policy_set(EWL_OBJECT(fd->button_box),
-                       EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_HSHRINK);
-       ewl_box_spacing_set(EWL_BOX(fd->button_box), 4);
-       ewl_object_padding_set(EWL_OBJECT(fd->button_box), 10, 10, 10, 10);
-       ewl_object_alignment_set(EWL_OBJECT(fd->button_box), EWL_FLAG_ALIGN_RIGHT);
-       ewl_container_child_append(EWL_CONTAINER(vbox), fd->button_box);
-       ewl_widget_show(fd->button_box);
-
-       fd->entry = ewl_entry_new ("");
-       ewl_widget_internal_set(fd->entry, TRUE);
-       ewl_container_child_append(EWL_CONTAINER(fd->button_box), fd->entry);
-       ewl_callback_append (fd->entry, EWL_CALLBACK_VALUE_CHANGED,
-                       ewl_filedialog_change_path_cb, fd);
-       ewl_widget_show (fd->entry);
-
-
-       if (type == EWL_FILEDIALOG_TYPE_OPEN)
-               fd->ok = ewl_button_new("Open");
-       else
-               fd->ok = ewl_button_new("Save");
-       ewl_widget_internal_set(fd->ok, TRUE);
-       ewl_object_fill_policy_set(EWL_OBJECT(fd->ok), EWL_FLAG_FILL_NONE);
-       ewl_callback_append(fd->ok, EWL_CALLBACK_CLICKED, ewl_filedialog_ok_cb,
-                           fd);
-       ewl_container_child_append(EWL_CONTAINER(fd->button_box), fd->ok);
-       ewl_widget_show(fd->ok);
-
-       fd->cancel = ewl_button_new("Cancel");
-       ewl_widget_internal_set(fd->cancel, TRUE);
-       ewl_object_fill_policy_set(EWL_OBJECT(fd->cancel), EWL_FLAG_FILL_NONE);
-       ewl_callback_append(fd->cancel, EWL_CALLBACK_CLICKED,
-                                   ewl_filedialog_cancel_cb, fd);
-       ewl_container_child_append(EWL_CONTAINER(fd->button_box), fd->cancel);
-       ewl_widget_show(fd->cancel);
-
-       /*
-        * Redirect incoming widgets to the decoration box to allow for
-        * special purpose widgets along the left side.
-        */
-       /*
-       ewl_container_set_redirect(EWL_CONTAINER(fd),
-                                  EWL_CONTAINER(fd->decor_box));
-                                  */
+       ewl_dialog_init(EWL_DIALOG(w), EWL_POSITION_BOTTOM);
+       ewl_widget_appearance_set(w, "window");
+       ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_ALL);
+
+       /* the file selector */
+
+       fd->fs = ewl_fileselector_new();
+       if (fd->fs) {
+               char *tmp = getenv("HOME");
+               ewl_fileselector_configure_cb(EWL_FILESELECTOR(fd->fs), (tmp ? tmp : 
"/"));
+               ewl_dialog_widget_add(EWL_DIALOG(fd), fd->fs);
+               ewl_widget_show(fd->fs);
+       }
+
+       /* Buttons */
+
+       button = ewl_button_stock_with_id_new(EWL_STOCK_OPEN,
+                                        EWL_RESPONSE_OPEN);
+       ewl_container_child_append(EWL_CONTAINER(fd), button);
+       ewl_widget_show(button);
+
+       button = ewl_button_stock_with_id_new(EWL_STOCK_CANCEL,
+                                        EWL_RESPONSE_CANCEL);
+       ewl_container_child_append(EWL_CONTAINER(fd), button);
+       ewl_widget_show(button);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 /**
+ * @param fd: the filedialog
+ * @return Returns the current path of filedialog
+ * @brief Retrieve the current filedialog path
+ */
+char *ewl_filedialog_path_get(Ewl_Filedialog * fd)
+{
+       return EWL_FILESELECTOR(fd->fs)->path;
+}
+
+/**
+ * @param fd: the filedialog
+ * @return Returns the selected filename including its path
+ * @brief Retrieve the selected filename
+ */
+char *ewl_filedialog_file_get(Ewl_Filedialog * fd)
+{
+       return EWL_FILESELECTOR(fd->fs)->file;
+}
+
+/**
  * @param fd: the filedialog to change paths
  * @param path: the new path used for the filedialog
  * @return Returns no value.
  * @brief Changes the current path of a filedialog.
  */
-void ewl_filedialog_set_directory(Ewl_Filedialog *fd, char *path)
+void ewl_filedialog_path_set(Ewl_Filedialog * fd, char *path)
 {
-       struct stat          statbuf;
-       Ewl_Fileselector *fs = EWL_FILESELECTOR (fd->selector);
-       int i;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("fd", fd);
-       DCHECK_PARAM_PTR("path", path);
-
-       i = stat (path, &statbuf);
-       if (!i && S_ISDIR(statbuf.st_mode)) {
-               ewl_fileselector_set_directory (EWL_FILESELECTOR (fs), path);
-       }
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       ewl_fileselector_path_set(EWL_FILESELECTOR(fd->fs), path);
 }
 
-void ewl_filedialog_change_labels_cb (Ewl_Widget * w, void *ev_data, 
-               void *user_data) 
+/*
+ * Internally used callback, override at your own risk.
+ */
+void ewl_filedialog_click_cb(Ewl_Widget * w, void *ev_data, Ewl_Filedialog * fd)
 {
-       char *path, *ptr = NULL;
-       char str[PATH_MAX + 50];
-       Ewl_Filedialog *fd = user_data; 
+       char *str = NULL;
 
-       DENTER_FUNCTION(DLEVEL_STABLE);
-
-       if (!ev_data) {
-               path = ewl_fileselector_get_path (EWL_FILESELECTOR (fd->selector));
+       switch (EWL_BUTTON_STOCK(w)->response_id) {
+       case (EWL_RESPONSE_OK):
+               {
+                       str = ewl_fileselector_file_get(EWL_FILESELECTOR(fd->fs));
+                       free(str);
+                       ewl_widget_destroy(EWL_WIDGET(fd));
 
-               snprintf (str, sizeof (str), "Current dir: %s", path);
-               free(path);
-               ewl_text_text_set (EWL_TEXT (fd->path_label), str);
- 
-               path = ewl_fileselector_get_filename(EWL_FILESELECTOR(fd->selector));
-               if (!path) return;
-               ptr = strrchr(path, '/');
-               /* if we have a file */
-               if (ptr)
+                       break;
+               }
+       case (EWL_RESPONSE_CANCEL):
                {
-                 ptr++;
-                 ewl_entry_set_text (EWL_ENTRY(fd->entry), ptr);
+                       ewl_widget_destroy(EWL_WIDGET(fd));
+                       break;
                }
-               /* if we just changed dirs, then clear it out */
-               else
-                 ewl_entry_set_text (EWL_ENTRY(fd->entry), "");
-               free(path);
        }
-       else {
-               ewl_filedialog_ok_cb(w, NULL, fd);
-       }
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-void
-ewl_filedialog_change_path_cb(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       char *dir;
-       Ewl_Filedialog *fd = user_data;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-
-       dir = ewl_entry_get_text (EWL_ENTRY (w));
-       if (dir)
-               ewl_filedialog_set_directory(fd, dir);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-ewl_filedialog_ok_cb(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       char *path1, *path2;
-       char tmp[PATH_MAX];
-       Ewl_Filedialog *fd = user_data;
-
-       path1 = ewl_fileselector_get_path(EWL_FILESELECTOR(fd->selector));
-       path2 = ewl_entry_get_text(EWL_ENTRY(fd->entry));
-       snprintf(tmp, PATH_MAX, "%s/%s", path1, path2);
-       free(path1);
-       free(path2);
-       path1 = strdup(tmp);
        ewl_callback_call_with_event_data(EWL_WIDGET(fd),
-                                         EWL_CALLBACK_VALUE_CHANGED, path1);
-       free(path1);
-}
-
-void
-ewl_filedialog_cancel_cb(Ewl_Widget *w, void *ev_data, void *user_data)
-{
-       Ewl_Widget *fd = user_data;
-       ewl_callback_call(fd, EWL_CALLBACK_VALUE_CHANGED);
+                                         EWL_CALLBACK_VALUE_CHANGED, str);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ewl_filedialog.h    17 Feb 2004 05:18:38 -0000      1.14
+++ ewl_filedialog.h    28 Aug 2004 06:26:33 -0000      1.15
@@ -1,6 +1,10 @@
 #ifndef __EWL_FILEDIALOG_H__
 #define __EWL_FILEDIALOG_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 /**
  * @defgroup Ewl_Filedialog Filedialog: A Dialog For Picking Files
  *
@@ -41,36 +45,32 @@
  */
 struct Ewl_Filedialog
 {
-       Ewl_Box        box;          /**< the box container */
-       Ewl_Filedialog_Type type;    /**< define what type of filedialog */
-       
-       Ewl_Widget     *selector;    /**< Ewl_Fileselector */
-       Ewl_Widget     *path_label;  /**< label to display current path */
-       Ewl_Widget     *entry;       /**< entry for manual input or current selected */
-       
-       Ewl_Widget     *decor_box;   /**< box to hold additional widgets */
-       Ewl_Widget     *button_box;  /**< box to hold the buttons */
-
-       Ewl_Widget     *ok;          /**< open/save button */
-       Ewl_Widget     *cancel;      /**< cancel button */
+       Ewl_Dialog     dialog; /**< the dialog containing the fileselector */
+       Ewl_Widget    *fs;     /**< Ewl_Fileselector */
 };
 
 
-Ewl_Widget *ewl_filedialog_new (Ewl_Filedialog_Type type);
-void ewl_filedialog_init (Ewl_Filedialog * fd, Ewl_Filedialog_Type type);
-void ewl_filedialog_set_directory(Ewl_Filedialog *fd, char *path);
+Ewl_Widget *ewl_filedialog_new      ();
+
+void        ewl_filedialog_init     (Ewl_Filedialog *fd);
+char       *ewl_filedialog_path_get (Ewl_Filedialog *fd);
+char       *ewl_filedialog_file_get (Ewl_Filedialog *fd);
+void        ewl_filedialog_path_set (Ewl_Filedialog *fd,
+                            char   *path);
 
 /*
- * Internally used callback, override at your own risk.
+ * Internally used callbacks, override at your own risk.
  */
-void ewl_filedialog_change_labels_cb (Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_filedialog_change_path_cb (Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_filedialog_ok_cb(Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_filedialog_cancel_cb(Ewl_Widget * w, void *ev_data, void *user_data);
+void ewl_filedialog_click_cb (Ewl_Widget *w, void *ev_data, Ewl_Filedialog *fd);
 
 
 /**
  * @}
  */
 
-#endif /* __EWL_FILEDIALOG_H__ */
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __EWL_FS_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fileselector.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- ewl_fileselector.c  19 Aug 2004 20:03:32 -0000      1.43
+++ ewl_fileselector.c  28 Aug 2004 06:26:33 -0000      1.44
@@ -1,64 +1,33 @@
 #include <Ewl.h>
 
-void ewl_fileselector_directory_adjust (Ewl_Fileselector *fs, char *path);
-void ewl_fileselector_path_down (char *dir);
-int ewl_fileselector_alphasort(const void *a, const void *b);
-
-/** Addition for Solaris compatablity in scandir dep. -benr **/
-/** Code written originally by Joerg-R. Hill for Viewmol used with permission and 
covered by GPL **/
-#ifdef HAVE_SUN
-
-#include<dirent.h>
-#include<stdlib.h>
-#include<string.h>
-#include<sys/types.h>
-
-int scandir(const char *dir, struct dirent ***namelist,
-            int (*select)(const struct dirent *),
-            int (*compar)(const struct dirent **, const struct dirent **))
-{
-  DIR *d;
-  struct dirent *entry;
-  register int i=0;
-  size_t entrysize;
-
-  if ((d=opendir(dir)) == NULL)
-     return(-1);
-
-  *namelist=NULL;
-  while ((entry=readdir(d)) != NULL)
-  {
-    if (select == NULL || (select != NULL && (*select)(entry)))
-    {
-      *namelist=(struct dirent **)realloc((void *)(*namelist),
-                 (size_t)((i+1)*sizeof(struct dirent *)));
-        if (*namelist == NULL) return(-1);
-        entrysize=sizeof(struct dirent)-sizeof(entry->d_name)+strlen(entry->d_name)+1;
-        (*namelist)[i]=(struct dirent *)malloc(entrysize);
-        if ((*namelist)[i] == NULL) return(-1);
-        memcpy((*namelist)[i], entry, entrysize);
-        i++;
-    }
-  }
-  if (closedir(d)) return(-1);
-  if (i == 0) return(-1);
-  if (compar != NULL)
-    qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar);
+#include "../ewl-config.h"
 
-  return(i);
-}
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+#include <regex.h>
 
+#include "ewl_fileselector.h"
 
-#endif
-/* *************************************** */
+/*
+ * Internally used functions
+ */
 
+static void ewl_fileselector_tooltip_add(Ewl_Widget * w, Ewl_Fileselector_Data * d);
+static char *ewl_fileselector_str_append(char *s1, char *s2);
+static char *ewl_fileselector_path_up_get(char *path);
+static char *ewl_fileselector_path_home_get(void);
+static char* ewl_fileselector_size_string_get(off_t st_size);
+static char *ewl_fileselector_perm_string_get(mode_t st_mode);
+static void  ewl_fileselector_file_list_get(char *path, char *filter, Ecore_List 
*flist, Ecore_List *dlist);
 
 
 /**
  * @return Returns NULL on failure, or the new fileselector on success.
  * @brief Create a new fileselector
  */
-Ewl_Widget     *ewl_fileselector_new()
+Ewl_Widget *ewl_fileselector_new()
 {
        Ewl_Fileselector *fs;
 
@@ -80,8 +49,12 @@
  */
 void ewl_fileselector_init(Ewl_Fileselector * fs)
 {
-       Ewl_Widget     *w;
-       char           *home;
+       char *tmp;
+       Ewl_Widget *w;
+       Ewl_Widget *hbox;
+       Ewl_Widget *misc;
+       Ewl_Widget *button;
+
        char *head_dirs[1] = {
                "Directories"
        };
@@ -94,313 +67,616 @@
 
        w = EWL_WIDGET(fs);
 
-       ewl_box_init(EWL_BOX(w), EWL_ORIENTATION_HORIZONTAL);
-       ewl_widget_appearance_set(w, "fileselector");
-       ewl_box_homogeneous_set(EWL_BOX(w), TRUE);
-       ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_SHRINK |
-                                                 EWL_FLAG_FILL_FILL);
-
-       fs->dirs = ewl_tree_new (1);
-       ewl_tree_headers_set (EWL_TREE (fs->dirs), head_dirs);
-       ewl_container_child_append(EWL_CONTAINER(w), fs->dirs);
-       ewl_object_padding_set(EWL_OBJECT(fs->dirs), 2, 2, 2, 2);
-       ewl_widget_show (fs->dirs);
-
-       fs->files = ewl_tree_new (1);
-       ewl_tree_headers_set (EWL_TREE (fs->files), head_files);
-       ewl_container_child_append(EWL_CONTAINER(w), fs->files);
-       ewl_object_padding_set(EWL_OBJECT(fs->files), 2, 2, 2, 2);
-       ewl_widget_show (fs->files);
-
-       ewl_callback_append(w, EWL_CALLBACK_REALIZE,
-                           ewl_fileselector_realize_cb, NULL);
-       ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
-                           ewl_fileselector_configure_cb, NULL);
+       ewl_box_init(EWL_BOX(w), EWL_ORIENTATION_VERTICAL);
+       ewl_object_size_request(EWL_OBJECT(w), 500, 450);
+       ewl_object_fill_policy_set(EWL_OBJECT(w),
+                                  EWL_FLAG_FILL_SHRINK |
+                                  EWL_FLAG_FILL_HFILL);
+
+       /* The entry for the current directory */
+       /* and some icons */
+       hbox = ewl_hbox_new();
+       if (hbox) {
+               ewl_object_fill_policy_set(EWL_OBJECT(hbox),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_HFILL);
+
+               fs->entry_dir = ewl_entry_new(NULL);
+               ewl_object_fill_policy_set(EWL_OBJECT(hbox),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_HFILL);
+               ewl_container_child_prepend(EWL_CONTAINER(hbox),
+                                           fs->entry_dir);
+               ewl_widget_show(fs->entry_dir);
+               // ewl_object_custom_w_set(EWL_OBJECT(fs->entry_dir), 200);
+
+               misc = ewl_spacer_new();
+               ewl_container_child_append(EWL_CONTAINER(hbox), misc);
+               ewl_object_fill_policy_set(EWL_OBJECT(misc),
+                                          EWL_FLAG_FILL_FILL);
+               ewl_widget_show(misc);
+
+               button = ewl_button_new("");
+               ewl_object_fill_policy_set(EWL_OBJECT(button),
+                                          EWL_FLAG_FILL_SHRINK);
+               ewl_callback_append(button, EWL_CALLBACK_CLICKED,
+                                   EWL_CALLBACK_FUNCTION(ewl_fileselector_go_up_cb),
+                                   fs);
+               ewl_container_child_append(EWL_CONTAINER(hbox), button);
+               ewl_widget_show(button);
+
+               misc = ewl_image_new(PACKAGE_DATA_DIR"/arrow_up.png", NULL);
+               ewl_object_fill_policy_set(EWL_OBJECT(misc),
+                                          EWL_FLAG_FILL_SHRINK);
+               ewl_container_child_append(EWL_CONTAINER(button), misc);
+               ewl_widget_show(misc);
+
+               button = ewl_button_new("");
+               ewl_object_fill_policy_set(EWL_OBJECT(button),
+                                          EWL_FLAG_FILL_SHRINK);
+               ewl_callback_append(button, EWL_CALLBACK_CLICKED,
+                                   EWL_CALLBACK_FUNCTION
+                                   (ewl_fileselector_go_home_cb), fs);
+               ewl_container_child_append(EWL_CONTAINER(hbox), button);
+               ewl_widget_show(button);
+
+               misc = ewl_image_new(PACKAGE_DATA_DIR"/home.png", NULL);
+               ewl_object_fill_policy_set(EWL_OBJECT(misc),
+                                          EWL_FLAG_FILL_SHRINK);
+               ewl_container_child_append(EWL_CONTAINER(button), misc);
+               ewl_widget_show(misc);
+
+               ewl_container_child_append(EWL_CONTAINER(fs), hbox);
+               ewl_widget_show(hbox);
+       }
+
+       /* The lists for directories and files */
+       hbox = ewl_hbox_new();
+       if (hbox) {
+               ewl_object_fill_policy_set(EWL_OBJECT(hbox),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_FILL);
+
+               fs->list_dirs = ewl_tree_new(1);
+               ewl_tree_headers_set(EWL_TREE(fs->list_dirs), head_dirs);
+               ewl_object_fill_policy_set(EWL_OBJECT(fs->list_dirs),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_FILL);
+               ewl_container_child_append(EWL_CONTAINER(hbox),
+                                          fs->list_dirs);
+               ewl_widget_show(fs->list_dirs);
+
+               fs->list_files = ewl_tree_new(1);
+               ewl_tree_headers_set(EWL_TREE(fs->list_files), head_files);
+               ewl_object_fill_policy_set(EWL_OBJECT(fs->list_files),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_FILL);
+               ewl_container_child_append(EWL_CONTAINER(hbox),
+                                          fs->list_files);
+               ewl_widget_show(fs->list_files);
+
+               ewl_container_child_append(EWL_CONTAINER(fs), hbox);
+               ewl_widget_show(hbox);
+       }
+
+       /* The file label and entry */
+       hbox = ewl_hbox_new();
+       if (hbox) {
+               ewl_object_fill_policy_set(EWL_OBJECT(hbox),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_HFILL);
+
+               misc = ewl_text_new("File:");
+               ewl_container_child_append(EWL_CONTAINER(hbox), misc);
+               ewl_widget_show(misc);
+
+               fs->entry_file = ewl_entry_new(NULL);
+               ewl_container_child_append(EWL_CONTAINER(hbox),
+                                          fs->entry_file);
+               ewl_widget_show(fs->entry_file);
+
+               ewl_container_child_append(EWL_CONTAINER(fs), hbox);
+               ewl_widget_show(hbox);
+       }
+
+       /* The filter label and entry */
+       hbox = ewl_hbox_new();
+       if (hbox) {
+               ewl_object_fill_policy_set(EWL_OBJECT(hbox),
+                                          EWL_FLAG_FILL_SHRINK |
+                                          EWL_FLAG_FILL_HFILL);
 
-       home = getenv("HOME");
+               misc = ewl_text_new("Filter:");
+               ewl_object_size_request(EWL_OBJECT(misc), 10, 50);
+               ewl_container_child_append(EWL_CONTAINER(hbox), misc);
+               ewl_widget_show(misc);
+
+               fs->entry_filter = ewl_entry_new("^[^\\.]");
+               ewl_callback_append(fs->entry_filter,
+                               EWL_CALLBACK_VALUE_CHANGED, ewl_fileselector_filter_cb,
+                               fs);
+               ewl_container_child_append(EWL_CONTAINER(hbox),
+                                          fs->entry_filter);
+               ewl_widget_show(fs->entry_filter);
 
-       if (home)
-               ewl_fileselector_set_directory(fs, home);
+               ewl_container_child_append(EWL_CONTAINER(fs), hbox);
+               ewl_widget_show(hbox);
+       }
+
+       tmp = getenv("HOME");
+       ewl_fileselector_configure_cb(fs, (tmp ? tmp : "/"));
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 /**
  * @param fs: the fileselector
+ * @return Returns the current path of fileselector
+ * @brief Retrieve the current fileselector path
+ */
+char *ewl_fileselector_path_get(Ewl_Fileselector * fs)
+{
+       return strdup(fs->path);
+}
+
+/**
+ * @param fs: the fileselector
  * @return Returns the selected filename including its path
  * @brief Retrieve the selected filename
  */
-char *ewl_fileselector_get_filename (Ewl_Fileselector *fs) 
+char *ewl_fileselector_file_get(Ewl_Fileselector * fs)
 {
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DRETURN_PTR(fs->item ? strdup(fs->item) : NULL, DLEVEL_STABLE);
+       return ewl_fileselector_str_append(fs->path, fs->file);
 }
 
 /**
- * @param fs: the fileselector
- * @return Returns the current path of fileselector
- * @brief Retrieve the current fileselector path
+ * @param fs: The fileselector
+ * @param path: the directory to process
+ * @return Returns nothing
+ * @brief Prosess the given directory / change the fileselector dir
  */
-char *ewl_fileselector_get_path (Ewl_Fileselector *fs)
+void ewl_fileselector_path_set(Ewl_Fileselector * fs, char *path)
 {
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DRETURN_PTR(fs->path ? strdup(fs->path) : NULL, DLEVEL_STABLE);
+       ewl_fileselector_configure_cb(fs, path);
 }
 
+/*
+ * Internally used functions
+ */
 
-void ewl_fileselector_realize_cb(Ewl_Widget * w, void *ev_data, void *user_data)
+/* if non NULL, result must be freed */
+static char *ewl_fileselector_str_append(char *s1, char *s2)
 {
-       Ewl_Fileselector *fs;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
+       char *s;
+       int l = strlen(s1) + strlen(s2) + 1;
 
-       fs = EWL_FILESELECTOR(w);
+       s = (char *) malloc(sizeof(char) * l);
+       s = memcpy(s, s1, strlen(s1));
+       memcpy(s + strlen(s1), s2, strlen(s2));
+       s[l - 1] = '\0';
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       return s;
 }
 
+/* if non NULL, result must be freed */
+char *ewl_fileselector_path_up_get(char *path)
+{
+       char *new_path;
+       int l;
 
-void
-ewl_fileselector_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data)
+       if ((!path) || (strlen(path) == 0))
+               return NULL;
+
+       l = strlen(path) - 1;
+       if (path[l] == '/')
+               l--;
+
+       if (l < 0)
+               return "/";
+
+       while ((l >= 0) && (path[l] != '/'))
+               l--;
+
+       if (l < 0)
+               return "/";
+       else {
+               l++;
+               new_path = (char *) malloc(sizeof(char) * (l + 1));
+               new_path = memcpy(new_path, path, l);
+               new_path[l] = '\0';
+               return new_path;
+       }
+}
+
+/* if non NULL, result must be freed */
+char *ewl_fileselector_path_home_get()
 {
-       Ewl_Fileselector *fs;
+       char *path;
+       char *new_path;
 
-       DENTER_FUNCTION(DLEVEL_STABLE);
+       path = getenv("HOME");
+       if ((!path) || (strlen(path) == 0))
+               path = "/";
+       if (path[strlen(path)] != '/')
+               new_path = ewl_fileselector_str_append(path, "/");
+       else
+               new_path = path;
 
-       fs = EWL_FILESELECTOR(w);
+       return new_path;
+}
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+char *ewl_fileselector_size_string_get(off_t st_size)
+{
+       double dsize;
+       char size[1024];
+
+       dsize = (double) st_size;
+
+       if (dsize < 1024)
+               sprintf(size, "%'.0f B", dsize);
+       else {
+               dsize /= 1024.0;
+               if (dsize < 1024)
+                       sprintf(size, "%'.1f KB", dsize);
+               else {
+                       dsize /= 1024.0;
+                       if (dsize < 1024)
+                               sprintf(size, "%'.1f MB", dsize);
+                       else {
+                               dsize /= 1024.0;
+                               sprintf(size, "%'.1f GB", dsize);
+                       }
+               }
+       }
+
+       return strdup(size);
 }
 
-/**
- * @param fs: The fileselector
- * @param path: the directory to process
- * @return Returns nothing
- * @brief Prosess the given directory / change the fileselector dir
- */
-void ewl_fileselector_set_directory(Ewl_Fileselector * fs, char *path)
+char *ewl_fileselector_perm_string_get(mode_t st_mode)
 {
-       struct dirent        **dentries;
-       int                  num, i;
-       char                 file[PATH_MAX];
-       struct stat          statbuf;
-       Ewl_Widget           *items[1];
-       Ewl_Widget           *row = NULL;
-       
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("fs", fs);
-       DCHECK_PARAM_PTR("path", path);
+       char *perm;
+       int i;
 
-       if (fs->path && !strcmp(fs->path, path))
-               DRETURN(DLEVEL_STABLE);
+       perm = (char *) malloc(sizeof(char) * 10);
+
+       for (i = 0; i < 9; i++)
+               perm[i] = '-';
+       perm[9] = '\0';
+
+       if ((S_IRUSR & st_mode) == S_IRUSR)
+               perm[0] = 'r';
+       if ((S_IWUSR & st_mode) == S_IWUSR)
+               perm[1] = 'w';
+       if ((S_IXUSR & st_mode) == S_IXUSR)
+               perm[2] = 'x';
+
+       if ((S_IRGRP & st_mode) == S_IRGRP)
+               perm[3] = 'r';
+       if ((S_IWGRP & st_mode) == S_IWGRP)
+               perm[4] = 'w';
+       if ((S_IXGRP & st_mode) == S_IXGRP)
+               perm[5] = 'x';
+
+       if ((S_IROTH & st_mode) == S_IROTH)
+               perm[6] = 'r';
+       if ((S_IWOTH & st_mode) == S_IWOTH)
+               perm[7] = 'w';
+       if ((S_IXOTH & st_mode) == S_IXOTH)
+               perm[8] = 'x';
+
+       return perm;
+}
+
+void ewl_fileselector_file_list_get(char *path, char *filter, Ecore_List * flist, 
Ecore_List * dlist)
+{
+       regex_t preg;
+       Ewl_Fileselector_Data *d;
+       struct dirent *lecture;
+       DIR *rep;
+       struct stat buf;
+       char *name;
+       char *path2;
+       int len;
+
+       if (filter) {
+               if (regcomp(&preg, filter, REG_NOSUB | REG_EXTENDED))
+                       filter = NULL;
+       }
 
-       if ((num = scandir(path, &dentries, 0, ewl_fileselector_alphasort)) < 0) {
-               perror("ewl_fileselector_set_directory - scandir");
-               return;
+       /* Check if path is finished by a / and add it if there's none */
+       if (path[strlen(path) - 1] == '/')
+               path2 = strdup(path);
+       else {
+               path2 = (char *) malloc(sizeof(char) * (strlen(path) + 2));
+               memcpy(path2, path, strlen(path));
+               path2[strlen(path)] = '/';
+               path2[strlen(path) + 1] = '\0';
        }
 
-       /* 
-        * Empty the trees before adding data.
-        */
-       ewl_container_reset (EWL_CONTAINER (fs->dirs));
-       ewl_container_reset (EWL_CONTAINER (fs->files));
+       rep = opendir(path2);
+       if (!rep) {
+               free(path2);
+               DRETURN(DLEVEL_STABLE);
+       }
 
-       fs->path = strdup (path);
-       
-       while (num--) {
-               snprintf(file, PATH_MAX, "%s/%s", path, dentries[num]->d_name);
-
-               i = stat (file, &statbuf);
-               if (i == -1) {
-                       perror("ewl_fileselector_set_directory - stat 1");
-                       continue;
-               }
+       while ((lecture = readdir(rep))) {
+               int match = 0;
 
-               if (dentries[num]->d_name[0] == '.' && 
-                               (strlen(dentries[num]->d_name) > 2 || 
-                                       dentries[num]->d_name[1] != '.'))
-                       continue;
-               
-               items[0] = ewl_text_new (dentries[num]->d_name);
-               ewl_object_fill_policy_set(EWL_OBJECT(items[0]),
-                                          EWL_FLAG_FILL_HFILL);
-               ewl_widget_show (items[0]);
-               
-               if (S_ISDIR(statbuf.st_mode)) {
-                       ewl_callback_append(items[0], EWL_CALLBACK_CLICKED,
-                                           
ewl_fileselector_directory_clicked_single_cb,
-                                           fs);
-                       row = ewl_tree_row_add (EWL_TREE (fs->dirs), NULL,
-                                               items);
-                       ewl_callback_append(items[0],
-                                           EWL_CALLBACK_DOUBLE_CLICKED,
-                                           ewl_fileselector_directory_clicked_cb,
-                                           fs);
-               }
-               else if (S_ISREG(statbuf.st_mode)) {
-                       ewl_callback_append(items[0],
-                                           EWL_CALLBACK_DOUBLE_CLICKED,
-                                           ewl_fileselector_file_open_cb,
-                                           fs);
-                       ewl_callback_append(items[0], EWL_CALLBACK_CLICKED,
-                                           ewl_fileselector_file_clicked_cb,
-                                           fs);
-                       row = ewl_tree_row_add (EWL_TREE (fs->files), NULL, items);
+               if (!(strcmp(lecture->d_name, "..")))
+                       match = 1;
+               else if (strcmp(lecture->d_name, ".")) {
+                       if (filter && !regexec(&preg, lecture->d_name, 0,
+                                               NULL, 0))
+                               match = 1;
                }
 
-               if (!row)
-                       continue;
+               if (match) {
+                       len = strlen(path2) + strlen(lecture->d_name) + 1;
+                       name = (char *) malloc(sizeof(char) * len);
+                       memcpy(name, path2, strlen(path2));
+                       memcpy(name + strlen(path2),
+                              lecture->d_name, strlen(lecture->d_name));
+                       name[len - 1] = '\0';
+                       stat(name, &buf);
+                       if (S_ISDIR(buf.st_mode) && dlist) {
+                               d = ewl_fileselector_data_new(lecture->d_name,
+                                                   buf.st_size,
+                                                   buf.st_mtime,
+                                                   buf.st_mode);
+                               ecore_list_append(dlist, d);
+                       } else if (flist) {
+                               d = ewl_fileselector_data_new(lecture->d_name,
+                                                   buf.st_size,
+                                                   buf.st_mtime,
+                                                   buf.st_mode);
+                               ecore_list_append(flist, d);
+                       }
+
+                       free(name);
+               }
        }
+       closedir(rep);
 
-       ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_VALUE_CHANGED);
-       
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       if (filter)
+               regfree(&preg);
+       free(path2);
+
+       return;
 }
 
-void ewl_fileselector_file_clicked_cb(Ewl_Widget * w, void *ev_data,
-               void *user_data)
+/*
+ * Internally used callbacks, override at your own risk.
+ */
+void
+ewl_fileselector_tooltip_destroy_cb(Ewl_Widget * w, void *ev_data, void *user_data)
 {
-       char *tmp;
-       Ewl_Fileselector *fs;
-       char file[PATH_MAX];
-       
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
+       if (user_data)
+               ewl_widget_destroy(EWL_WIDGET(user_data));
+}
 
-       fs = EWL_FILESELECTOR (user_data);
+void ewl_fileselector_select_file_cb(Ewl_Widget * w, void *ev_data, Ewl_Fileselector 
* fs)
+{
+       char *file;
 
-       tmp = ewl_text_text_get(EWL_TEXT(w));
-       if (!strcmp (tmp, "/"))
-               snprintf (file, PATH_MAX, "/%s", tmp);
-       else
-               snprintf (file, PATH_MAX, "%s/%s", fs->path, tmp);
+       file = (char *) ewl_widget_data_get(EWL_WIDGET(w), "FILE");
+       fs->file = file;
+       ewl_entry_set_text(EWL_ENTRY(fs->entry_file), file);
+}
 
-       fs->item = strdup (file);
-       ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_VALUE_CHANGED);
+void ewl_fileselector_select_dir_cb(Ewl_Widget * w, void *ev_data, Ewl_Fileselector * 
fs)
+{
+       char *path;
+       char *new_path;
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       path = (char *) ewl_widget_data_get(EWL_WIDGET(w), "DIR");
+       if (!strcmp(path, ".."))
+               new_path = ewl_fileselector_path_up_get(fs->path);
+       else
+               new_path = ewl_fileselector_str_append(fs->path, path);
+       path = ewl_fileselector_str_append(new_path, "/");
+       free(new_path);
+       ewl_fileselector_configure_cb(EWL_FILESELECTOR(fs), path);
 }
 
-void ewl_fileselector_file_open_cb(Ewl_Widget * w, void *ev_data,
-               void *user_data)
+void ewl_fileselector_go_up_cb(Ewl_Widget * w, void *ev_data, Ewl_Fileselector * fs)
 {
-       char *tmp;
-       Ewl_Fileselector *fs;
-       char file[PATH_MAX];
-       
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
+       char *path;
 
-       fs = EWL_FILESELECTOR (user_data);
-
-       tmp = ewl_text_text_get(EWL_TEXT(w));
-       if (!strcmp (tmp, "/"))
-               snprintf (file, PATH_MAX, "/%s", tmp);
-       else
-               snprintf (file, PATH_MAX, "%s/%s", fs->path, tmp);
+       path = ewl_fileselector_path_up_get(fs->path);
+       ewl_fileselector_configure_cb(EWL_FILESELECTOR(fs), path);
+}
 
-       fs->item = strdup (file);
-       ewl_callback_call_with_event_data(EWL_WIDGET(fs),
-                       EWL_CALLBACK_VALUE_CHANGED, fs->item);
+void ewl_fileselector_go_home_cb(Ewl_Widget * w, void *ev_data, Ewl_Fileselector * fs)
+{
+       char *path;
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       path = ewl_fileselector_path_home_get();
+       ewl_fileselector_configure_cb(EWL_FILESELECTOR(fs), path);
 }
 
-void ewl_fileselector_directory_adjust (Ewl_Fileselector *fs, char *path)
+void ewl_fileselector_configure_cb(Ewl_Fileselector * fs, char *path)
 {
-       char *ptr;
-       char dir[PATH_MAX];
+       char *filter;
+       Ewl_Fileselector_Data *d;
+       Ewl_Widget *parent_win;
+       Ewl_Container *cont;
+       Ewl_Widget *prow = NULL;
+       Ecore_List *dirs, *files;
+       char *path2;
+       char *title;
 
-       DENTER_FUNCTION(DLEVEL_STABLE);
+       ewl_container_reset(EWL_CONTAINER(fs->list_dirs));
+       ewl_container_reset(EWL_CONTAINER(fs->list_files));
+       ewl_entry_set_text(EWL_ENTRY(fs->entry_file), "");
 
-       dir[0] = '\0';
-       ptr = strrchr(path, '/');
-       if (ptr) {
-               ptr++;
-               if (!strcmp (ptr, "..")) {
-                       ptr--;
-
-                       if (ptr != path) {
-                               *ptr = '\0';
-                               ptr = strrchr(path, '/');
-                               ptr++;
-                               *ptr = '\0';
-
-                               if (strcmp(path, "/")) {
-                                       ptr--;
-                                       *ptr = '\0';
-                               }
-                       } else {
-                               *++ptr = '\0';
-                       }
-               }
-               snprintf (dir, PATH_MAX, "%s", path);
+       /*
+        * Setup a regex for matching files.
+        */
+       filter = ewl_entry_get_text(EWL_ENTRY(fs->entry_filter));
+
+       if (path[strlen(path) - 1] == '/')
+               path2 = strdup(path);
+       else {
+               path2 = (char *) malloc(sizeof(char) * (strlen(path) + 2));
+               memcpy(path2, path, strlen(path));
+               path2[strlen(path)] = '/';
+               path2[strlen(path) + 1] = '\0';
        }
 
-       IF_FREE(fs->item);
-       fs->item = strdup (dir);
+       fs->path = path2;
+       fs->file = NULL;
+       ewl_entry_set_text(EWL_ENTRY(fs->entry_dir), path2);
+
+       files = ecore_list_new();
+       dirs = ecore_list_new();
+       ewl_fileselector_file_list_get(path2, filter, files, dirs);
+
+       parent_win = EWL_WIDGET(ewl_embed_widget_find(EWL_WIDGET(fs)));
+       cont = ewl_container_redirect_get(EWL_CONTAINER(parent_win));
+       if (cont) {
+               ewl_container_redirect_set(EWL_CONTAINER(parent_win), NULL);
+       }
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
+       title = malloc(PATH_MAX);
+       if (!title)
+               DRETURN(DLEVEL_STABLE);
 
-void ewl_fileselector_directory_clicked_single_cb(Ewl_Widget * w, 
-               void *ev_data, void *user_data)
-{
-       Ewl_Fileselector *fs;
-       char *format;
-       char path[PATH_MAX];
+       snprintf(title, PATH_MAX, "Files (%d)", ecore_list_nodes(files));
+       ewl_tree_headers_set(EWL_TREE(fs->list_files), &title);
 
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
+       ecore_list_goto_first(files);
+       while ((d = ecore_list_current(files))) {
+               prow = ewl_tree_text_row_add(EWL_TREE(fs->list_files),
+                                            NULL, &d->name);
 
-       fs = EWL_FILESELECTOR (user_data);
+               ewl_widget_data_set(EWL_WIDGET(prow), "FILE", d);
 
-       if (!strcmp(fs->path, "/"))
-               format = "%s%s";
-       else
-               format = "%s/%s";
+               ewl_fileselector_tooltip_add(EWL_WIDGET(prow), d);
+
+               ewl_callback_append(EWL_WIDGET(prow),
+                                   EWL_CALLBACK_CLICKED,
+                                   EWL_CALLBACK_FUNCTION
+                                   (ewl_fileselector_select_file_cb), fs);
 
-       snprintf(path, PATH_MAX, format, fs->path,
-                ewl_text_text_get(EWL_TEXT(w)));
+               ecore_list_next(files);
+       }
 
-       ewl_fileselector_directory_adjust (fs, path);
+       snprintf(title, PATH_MAX, "Directories (%d)", ecore_list_nodes(dirs));
+       ewl_tree_headers_set(EWL_TREE(fs->list_dirs), &title);
+
+       ecore_list_goto_first(dirs);
+       while ((d = ecore_list_current(dirs))) {
+               Ewl_Widget *hbox;
+               Ewl_Widget *label;
+               Ewl_Widget *image;
+
+               hbox = ewl_hbox_new();
+               ewl_box_spacing_set(EWL_BOX(hbox), 5);
+               label = ewl_text_new(d->name);
+               image = ewl_image_new(PACKAGE_DATA_DIR"/stock_open_24.png",
+                                     NULL);
+               ewl_object_fill_policy_set(EWL_OBJECT(image),
+                                          EWL_FLAG_FILL_SHRINK);
+               ewl_object_fill_policy_set(EWL_OBJECT(label),
+                                          EWL_FLAG_FILL_SHRINK);
+               ewl_container_child_append(EWL_CONTAINER(hbox), image);
+               ewl_container_child_append(EWL_CONTAINER(hbox), label);
+               ewl_widget_show(image);
+               ewl_widget_show(label);
+               ewl_widget_show(hbox);
+
+               prow =
+                   ewl_tree_row_add(EWL_TREE(fs->list_dirs), NULL, &hbox);
+               ewl_widget_data_set(EWL_WIDGET(prow), "DIR", d->name);
+
+               ewl_fileselector_tooltip_add(EWL_WIDGET(prow),
+                                  ecore_list_current(dirs));
+
+               ewl_callback_append(EWL_WIDGET(prow), EWL_CALLBACK_CLICKED,
+                                   EWL_CALLBACK_FUNCTION
+                                   (ewl_fileselector_select_dir_cb), fs);
+
+               ecore_list_next(dirs);
+       }
+
+       if (cont)
+               ewl_container_redirect_set(EWL_CONTAINER(parent_win),
+                                          cont);
+
+       ecore_list_destroy(files);
+       ecore_list_destroy(dirs);
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_fileselector_directory_clicked_cb(Ewl_Widget * w, void *ev_data,
-                                   void *user_data)
+void ewl_fileselector_filter_cb(Ewl_Widget * entry, void *ev_data, void *user_data)
 {
-       char *dir;
-       char path[PATH_MAX];
-       char *format;
-       Ewl_Fileselector *fs;
-       
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-       
-       fs = EWL_FILESELECTOR (user_data);
+       Ewl_Fileselector *fs = user_data;
+       ewl_fileselector_configure_cb(fs, ewl_fileselector_path_get(fs));
+}
 
-       dir = ewl_text_text_get(EWL_TEXT(w));
 
-       if (!strcmp(fs->path, "/"))
-               format = "%s%s";
-       else
-               format = "%s/%s";
-       snprintf(path, PATH_MAX, format, fs->path, dir);
+/* Private: data for a file */
 
-       IF_FREE(dir);
-       ewl_fileselector_directory_adjust (fs, path);
-       ewl_fileselector_set_directory (fs, path);
+/* Allocate a new data. Must be freed after used */
+Ewl_Fileselector_Data
+*ewl_fileselector_data_new(const char *name, off_t size, time_t time, mode_t mode)
+{
+       Ewl_Fileselector_Data *d;
+       char *n;
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       n = strdup(name);
+
+       d = (Ewl_Fileselector_Data *) malloc(sizeof(Ewl_Fileselector_Data));
+       d->name = n;
+       d->size = size;
+       d->time = time;
+       d->mode = mode;
+
+       return d;
 }
 
-int ewl_fileselector_alphasort (const void *a, const void *b)
+/* Free an allocated data */
+void ewl_fileselector_data_free(Ewl_Fileselector_Data * d)
 {
-  struct dirent **ad = (struct dirent **)a;
-  struct dirent **bd = (struct dirent **)b;
-  return (strcmp((*bd)->d_name, (*ad)->d_name));
+       if (d) {
+               if (d->name)
+                       free(d->name);
+               free(d);
+       }
 }
 
+static void ewl_fileselector_tooltip_add(Ewl_Widget * w, Ewl_Fileselector_Data * d)
+{
+       Ewl_Widget *parent_win;
+       Ewl_Widget *tooltip;
+       char *str;
+       char *name, *size, *perm;
+
+       parent_win = EWL_WIDGET(ewl_embed_widget_find(w));
+
+       tooltip = ewl_tooltip_new(w);
+       ewl_tooltip_delay_set(EWL_TOOLTIP(tooltip), 1.0);
+       ewl_container_child_append(EWL_CONTAINER(parent_win), tooltip);
+
+       name = d->name;
+       size = ewl_fileselector_size_string_get(d->size);
+       perm = ewl_fileselector_perm_string_get(d->mode);
+       str = (char *) malloc(sizeof(char) * (strlen(name) +
+                                             strlen(size) +
+                                             strlen(perm) + 3));
+       str = memcpy(str, name, strlen(name));
+       str[strlen(name)] = '\n';
+       memcpy(str + strlen(name) + 1, size, strlen(size));
+       str[strlen(name) + strlen(size) + 1] = '\n';
+       memcpy(str + strlen(name) + strlen(size) + 2, perm, strlen(perm));
+       str[strlen(name) + strlen(size) + strlen(perm) + 2] = '\0';
+       ewl_tooltip_text_set(EWL_TOOLTIP(tooltip), str);
+
+       /* destroy tooltip when the row is destroyed */
+       ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_DESTROY,
+                           EWL_CALLBACK_FUNCTION
+                           (ewl_fileselector_tooltip_destroy_cb), tooltip);
+
+       free(size);
+       free(perm);
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fileselector.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_fileselector.h  17 Feb 2004 05:18:38 -0000      1.16
+++ ewl_fileselector.h  28 Aug 2004 06:26:33 -0000      1.17
@@ -20,6 +20,34 @@
  * @themekey /fileselector/group
  */
 
+
+#include <sys/stat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Private: data for a file */
+
+typedef struct Ewl_Fileselector_Data Ewl_Fileselector_Data;
+
+struct Ewl_Fileselector_Data
+{
+  char  *name; /* name of the file */
+  off_t  size; /* size of the file (bytes) */
+  time_t time; /* last modification */
+  mode_t mode; /* mode of the file (permissions) */
+};
+
+Ewl_Fileselector_Data *ewl_fileselector_data_new(const char *name, off_t  size,
+                                      time_t time, mode_t mode);
+void  ewl_fileselector_data_free (Ewl_Fileselector_Data *d);
+
+
+
+  /* The File Selector */
+
 /**
  * The Ewl_Fileselector provides a fileselector
  */
@@ -37,42 +65,40 @@
  */
 struct Ewl_Fileselector
 {
-       Ewl_Box         box;   /* the vbox containing the trees */
-       Ewl_Widget     *dirs;    /* directory table */
-       Ewl_Widget     *files; /* file table */
-
-       char           *path;  /* current fileselector path */
-       char           *item;  /* current selected item in the fileselector */
+  Ewl_Box        box;         /* the box containing the widgets */
+  Ewl_Widget    *list_dirs;   /* directory table */
+  Ewl_Widget    *list_files;  /* file table */
+  Ewl_Widget    *entry_dir;
+  Ewl_Widget    *entry_file;
+  Ewl_Widget    *entry_filter;
+  
+  char          *path;  /* current fileselector path */
+  char          *file;  /* current selected item in the fileselector */
 };
 
 
 Ewl_Widget *ewl_fileselector_new();
 
-void ewl_fileselector_init(Ewl_Fileselector * fs);
-void ewl_fileselector_set_directory(Ewl_Fileselector * fs, char *path);
-
-char *ewl_fileselector_get_filename (Ewl_Fileselector *fs);
-char *ewl_fileselector_get_path (Ewl_Fileselector *fs);
-
+void ewl_fileselector_init(Ewl_Fileselector *fs);
+char *ewl_fileselector_path_get(Ewl_Fileselector *fs);
+char *ewl_fileselector_file_get(Ewl_Fileselector *fs);
+void ewl_fileselector_path_set(Ewl_Fileselector *fs, char   *path);
 
 /*
  * Internally used callbacks, override at your own risk.
  */
-void ewl_fileselector_realize_cb(Ewl_Widget * w, void *ev_data,
-               void *user_data);
-void ewl_fileselector_configure_cb(Ewl_Widget * w, void *ev_data,
-               void *user_data);
-void ewl_fileselector_file_clicked_cb(Ewl_Widget * w, void *ev_data, 
-               void *user_data);
-void ewl_fileselector_file_open_cb(Ewl_Widget * w, void *ev_data,
-               void *user_data);
-void ewl_fileselector_directory_clicked_single_cb(Ewl_Widget * w, 
-               void *ev_data, void *user_data);
-void ewl_fileselector_directory_clicked_cb(Ewl_Widget * w, void *ev_data, 
-               void *user_data);
 
-/**
- * @}
- */
+void ewl_fileselector_select_file_cb(Ewl_Widget *w, void *ev_data, Ewl_Fileselector 
*fs);
+void ewl_fileselector_select_dir_cb(Ewl_Widget *w, void *ev_data, Ewl_Fileselector 
*fs);
+void ewl_fileselector_go_up_cb(Ewl_Widget *w, void *ev_data, Ewl_Fileselector *fs);
+void ewl_fileselector_go_home_cb(Ewl_Widget *w, void *ev_data, Ewl_Fileselector *fs);
+void ewl_fileselector_configure_cb(Ewl_Fileselector *fs, char *path);
+
+void ewl_fileselector_filter_cb(Ewl_Widget *entry, void *ev_data, void *user_data);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
 
-#endif                         /* __EWL_FILESELECTOR_H__ */
+#endif /* __EWL_FILESELECTOR_H__ */




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to