Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
ewl_container.c ewl_embed.c ewl_embed.h ewl_filedialog.c
ewl_filedialog.h ewl_fileselector.c ewl_fileselector.h
ewl_object.h ewl_widget.c ewl_widget.h
Log Message:
New API for the fileselector and filedialog widgets. This will hopefully make
things more consistent, and easier in the long term. Still a couple known bugs
with traversing the directory structure.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -3 -r1.59 -r1.60
--- ewl_container.c 27 Jan 2004 06:08:35 -0000 1.59
+++ ewl_container.c 17 Feb 2004 05:18:38 -0000 1.60
@@ -138,7 +138,7 @@
while (pc->redirect)
pc = pc->redirect;
- if (!ewd_list_is_empty(pc->children) && pc->clip_box)
+ if (ewd_list_is_empty(pc->children) && pc->clip_box)
evas_object_show(pc->clip_box);
ewd_list_append(pc->children, child);
@@ -170,7 +170,7 @@
while (pc->redirect)
pc = pc->redirect;
- if (!ewd_list_is_empty(pc->children) && pc->clip_box)
+ if (ewd_list_is_empty(pc->children) && pc->clip_box)
evas_object_show(pc->clip_box);
ewd_list_prepend(pc->children, child);
@@ -205,7 +205,7 @@
while (pc->redirect)
pc = pc->redirect;
- if (!ewd_list_is_empty(pc->children) && pc->clip_box)
+ if (ewd_list_is_empty(pc->children) && pc->clip_box)
evas_object_show(pc->clip_box);
ewd_list_goto_index(pc->children, index);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_embed.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- ewl_embed.c 12 Feb 2004 06:34:12 -0000 1.22
+++ ewl_embed.c 17 Feb 2004 05:18:38 -0000 1.23
@@ -93,7 +93,7 @@
ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_DESTROY,
ewl_embed_destroy_cb, NULL);
- LAYER(w) = -1000;
+ w->max_layer = LAYER(w) = -1000;
ewd_list_append(ewl_embed_list, w);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_embed.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ewl_embed.h 12 Feb 2004 06:34:12 -0000 1.13
+++ ewl_embed.h 17 Feb 2004 05:18:38 -0000 1.14
@@ -40,6 +40,7 @@
Evas_Object *smart; /**< Object to manipulate Ewl_Embed from evas */
Ewd_List *tab_order; /**< Order of widgets to send focus on tab */
+ int max_layer; /**< The highest layer used by sub-widget */
};
Ewl_Widget *ewl_embed_new(void);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- ewl_filedialog.c 13 Feb 2004 06:25:20 -0000 1.30
+++ ewl_filedialog.c 17 Feb 2004 05:18:38 -0000 1.31
@@ -39,14 +39,20 @@
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_set_fill_policy(EWL_OBJECT(w), EWL_FLAG_FILL_SHRINK |
EWL_FLAG_FILL_FILL);
- fd->type = type;
-
ewl_widget_set_appearance (EWL_WIDGET (w), "filedialog");
+ fd->type = type;
+ /*
+ * Setup the internally used layout and display widgets.
+ */
vbox = ewl_vbox_new ();
ewl_widget_set_internal(vbox, TRUE);
ewl_object_set_fill_policy(EWL_OBJECT(vbox), EWL_FLAG_FILL_SHRINK |
@@ -76,33 +82,31 @@
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_set_fill_policy(EWL_OBJECT(fd->decor_box), EWL_FLAG_FILL_NONE);
- */
ewl_object_set_alignment(EWL_OBJECT(fd->decor_box), EWL_FLAG_ALIGN_RIGHT);
ewl_container_append_child(EWL_CONTAINER(hbox), fd->decor_box);
ewl_widget_show(fd->decor_box);
- fd->selector = ewl_fileselector_new(ewl_filedialog_fs_ok_cb);
+ /*
+ * Display the lists of directories and files.
+ */
+ fd->selector = ewl_fileselector_new();
ewl_widget_set_internal(fd->selector, TRUE);
ewl_container_append_child(EWL_CONTAINER(hbox), fd->selector);
ewl_callback_append (EWL_WIDGET (fd->selector),
EWL_CALLBACK_VALUE_CHANGED,
ewl_filedialog_change_labels_cb, fd);
- ewl_callback_append (EWL_WIDGET (fd->selector),
- EWL_CALLBACK_CLICKED, ewl_filedialog_change_entry_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_set_internal(fd->button_box, TRUE);
ewl_object_set_fill_policy(EWL_OBJECT(fd->button_box),
EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_HSHRINK);
ewl_box_set_spacing(EWL_BOX(fd->button_box), 4);
ewl_object_set_padding(EWL_OBJECT(fd->button_box), 10, 10, 10, 10);
- /*
- ewl_object_set_fill_policy(EWL_OBJECT(fd->button_box), EWL_FLAG_FILL_NONE);
- */
ewl_object_set_alignment(EWL_OBJECT(fd->button_box), EWL_FLAG_ALIGN_RIGHT);
ewl_container_append_child(EWL_CONTAINER(vbox), fd->button_box);
ewl_widget_show(fd->button_box);
@@ -134,39 +138,60 @@
ewl_container_append_child(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));
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-void ewl_filedialog_change_labels_cb (Ewl_Widget * w, void *ev_data,
- void *user_data)
+/**
+ * @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)
{
- char *ptr;
- char str[PATH_MAX + 50];
- Ewl_Filedialog *fd = user_data;
+ struct stat statbuf;
+ Ewl_Fileselector *fs = EWL_FILESELECTOR (fd->selector);
+ int i;
DENTER_FUNCTION(DLEVEL_STABLE);
-
- ptr = ewl_fileselector_get_path (EWL_FILESELECTOR (fd->selector));
-
- snprintf (str, sizeof (str), "Current dir: %s", ptr);
+ DCHECK_PARAM_PTR("fd", fd);
+ DCHECK_PARAM_PTR("path", path);
- ewl_text_set_text (EWL_TEXT (fd->path_label), str);
+ i = stat (path, &statbuf);
+ if (!i && S_ISDIR(statbuf.st_mode)) {
+ printf ("Changing path to: %s\n", path);
+ ewl_fileselector_set_directory (EWL_FILESELECTOR (fs), path);
+ }
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-void
-ewl_filedialog_change_entry_cb(Ewl_Widget * w, void *ev_data, void *user_data)
+void ewl_filedialog_change_labels_cb (Ewl_Widget * w, void *ev_data,
+ void *user_data)
{
- Ewl_Filedialog *fd = user_data;
- Ewl_Fileselector *fs = EWL_FILESELECTOR (fd->selector);
+ char *ptr;
+ char str[PATH_MAX + 50];
+ Ewl_Filedialog *fd = user_data;
DENTER_FUNCTION(DLEVEL_STABLE);
- ewl_entry_set_text (EWL_ENTRY (fd->entry), fs->item);
+ if (!ev_data) {
+ ptr = ewl_fileselector_get_path (EWL_FILESELECTOR (fd->selector));
+
+ snprintf (str, sizeof (str), "Current dir: %s", ptr);
+
+ ewl_text_set_text (EWL_TEXT (fd->path_label), str);
+ }
+ else {
+ ewl_filedialog_ok_cb(w, NULL, fd);
+ }
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -175,19 +200,16 @@
void
ewl_filedialog_change_path_cb(Ewl_Widget * w, void *ev_data, void *user_data)
{
- struct stat statbuf;
- Ewl_Filedialog *fd = user_data;
- Ewl_Fileselector *fs = EWL_FILESELECTOR (fd->selector);
char *dir;
- int i;
+ Ewl_Filedialog *fd = user_data;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
dir = ewl_entry_get_text (EWL_ENTRY (w));
-
- i = stat (dir, &statbuf);
- if (S_ISDIR(statbuf.st_mode)) {
- printf ("Changing path to: %s\n", dir);
- ewl_fileselector_process_directory (EWL_FILESELECTOR (fs), dir);
- }
+ if (dir)
+ ewl_filedialog_set_directory(fd, dir);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
void
@@ -204,8 +226,8 @@
free(path1);
free(path2);
path1 = strdup(tmp);
- ewl_callback_call_with_event_data(fd, EWL_CALLBACK_VALUE_CHANGED,
- path1);
+ ewl_callback_call_with_event_data(EWL_WIDGET(fd),
+ EWL_CALLBACK_VALUE_CHANGED, path1);
free(path1);
}
@@ -215,12 +237,3 @@
Ewl_Widget *fd = user_data;
ewl_callback_call(fd, EWL_CALLBACK_VALUE_CHANGED);
}
-
-void
-ewl_filedialog_fs_ok_cb(Ewl_Widget * w, void *ev_data, void *user_data)
-{
- Ewl_Widget *fs = user_data;
- Ewl_Widget *fd = fs->parent->parent;
-
- ewl_filedialog_ok_cb(w, ev_data, fd);
-}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ewl_filedialog.h 11 Feb 2004 18:17:32 -0000 1.13
+++ ewl_filedialog.h 17 Feb 2004 05:18:38 -0000 1.14
@@ -2,7 +2,20 @@
#define __EWL_FILEDIALOG_H__
/**
- * @defgroup Ewl_Filedialog Filedialog: a filedialog
+ * @defgroup Ewl_Filedialog Filedialog: A Dialog For Picking Files
+ *
+ * The filedialog is intended to be used for a simple file chooser. It can be
+ * placed inside any other container, and provides the ability to pack extra
+ * buttons or widgets along the left side. It currently supports two types, an
+ * Open and a Save dialog.
+ *
+ * The normal use of the filedialog is to create a new one the first time an
+ * event occurs that requires one. Setting a callback for
+ * EWL_CALLBACK_VALUE_CHANGED, allows the programmer to determine when the
+ * Open/Save buttons were chosen. If the event data on the callback is NULL,
+ * Cancel was clicked, otherwise, the event data is a pointer to the chosen
+ * file(s).
+ *
* @{
*/
@@ -45,21 +58,15 @@
Ewl_Widget *ewl_filedialog_new (Ewl_Filedialog_Type type);
void ewl_filedialog_init (Ewl_Filedialog * fd, Ewl_Filedialog_Type type);
-void ewl_filedialog_open_init (Ewl_Filedialog * fd, Ewl_Callback_Function cb,
- Ewl_Callback_Function cancel_cb);
-void ewl_filedialog_save_init (Ewl_Filedialog * fd, Ewl_Callback_Function cb,
- Ewl_Callback_Function cancel_cb);
-
+void ewl_filedialog_set_directory(Ewl_Filedialog *fd, char *path);
/*
* Internally used callback, override at your own risk.
*/
void ewl_filedialog_change_labels_cb (Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_filedialog_change_entry_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_fs_ok_cb(Ewl_Widget * w, void *ev_data, void *user_data);
/**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fileselector.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ewl_fileselector.c 14 Jan 2004 20:42:54 -0000 1.31
+++ ewl_fileselector.c 17 Feb 2004 05:18:38 -0000 1.32
@@ -1,5 +1,9 @@
#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
@@ -51,11 +55,10 @@
/**
- * @param clicked: callback for file clicked event
- * @return Returns NULL on failure, or a pointer to the new fileselector on success.
- * @brief create a new fileselector
+ * @return Returns NULL on failure, or the new fileselector on success.
+ * @brief Create a new fileselector
*/
-Ewl_Widget *ewl_fileselector_new(Ewl_Callback_Function clicked)
+Ewl_Widget *ewl_fileselector_new()
{
Ewl_Fileselector *fs;
@@ -65,18 +68,17 @@
if (!fs)
DRETURN_PTR(NULL, DLEVEL_STABLE);
- ewl_fileselector_init(fs, clicked);
+ ewl_fileselector_init(fs);
DRETURN_PTR(EWL_WIDGET(fs), DLEVEL_STABLE);
}
/**
* @param fs: the fileselector
- * @param fc: your select file callback function
* @return Returns no value.
* @brief Initalize the fileselector
*/
-void ewl_fileselector_init(Ewl_Fileselector * fs, Ewl_Callback_Function fc)
+void ewl_fileselector_init(Ewl_Fileselector * fs)
{
Ewl_Widget *w;
char *head_dirs[1] = {
@@ -109,9 +111,6 @@
ewl_object_set_padding(EWL_OBJECT(fs->files), 2, 2, 2, 2);
ewl_widget_show (fs->files);
- /* Set what callback the user has defined */
- fs->file_clicked = fc;
-
ewl_callback_append(w, EWL_CALLBACK_REALIZE,
ewl_fileselector_realize_cb, NULL);
ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
@@ -157,9 +156,8 @@
fs = EWL_FILESELECTOR(w);
home = getenv("HOME");
-
if (home)
- ewl_fileselector_process_directory(fs, home);
+ ewl_fileselector_set_directory(fs, home);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -183,19 +181,26 @@
* @return Returns nothing
* @brief Prosess the given directory / change the fileselector dir
*/
-void ewl_fileselector_process_directory(Ewl_Fileselector * fs, char *path)
+void ewl_fileselector_set_directory(Ewl_Fileselector * fs, char *path)
{
struct dirent **dentries;
int num, i;
- char dir[PATH_MAX];
char file[PATH_MAX];
struct stat statbuf;
Ewl_Widget *items[1];
Ewl_Widget *row = NULL;
- Ewl_Fileselector_Row *f_row;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("fs", fs);
+ DCHECK_PARAM_PTR("path", path);
+
+ if (fs->path && !strcmp(fs->path, path))
+ DRETURN(DLEVEL_STABLE);
+
+ if ((num = scandir(path, &dentries, 0, ewl_fileselector_alphasort)) < 0) {
+ perror("ewl_fileselector_set_directory - scandir");
+ return;
+ }
/*
* Empty the trees before adding data.
@@ -203,24 +208,14 @@
ewl_container_reset (EWL_CONTAINER (fs->dirs));
ewl_container_reset (EWL_CONTAINER (fs->files));
- strncpy (dir, path, PATH_MAX);
-
fs->path = strdup (path);
- ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_VALUE_CHANGED);
-
- if ((num = scandir(dir, &dentries, 0, ewl_fileselector_alphasort)) < 0) {
- perror("ewl_fileselector_process_directory - scandir");
- return;
- }
-
- printf ("Prosessing %d elements in %s\n", num, dir);
while (num--) {
- snprintf(file, PATH_MAX, "%s/%s", dir, dentries[num]->d_name);
+ snprintf(file, PATH_MAX, "%s/%s", path, dentries[num]->d_name);
i = stat (file, &statbuf);
if (i == -1) {
- perror("ewl_fileselector_process_directory - stat 1");
+ perror("ewl_fileselector_set_directory - stat 1");
continue;
}
@@ -230,34 +225,37 @@
continue;
items[0] = ewl_text_new (dentries[num]->d_name);
+ ewl_object_set_fill_policy(EWL_OBJECT(items[0]),
+ EWL_FLAG_FILL_HFILL);
ewl_widget_show (items[0]);
if (S_ISDIR(statbuf.st_mode)) {
- row = ewl_tree_add_row (EWL_TREE (fs->dirs), NULL, items);
-
- ewl_callback_append(row, EWL_CALLBACK_DOUBLE_CLICKED,
- ewl_fileselector_directory_clicked_cb, fs);
- ewl_callback_append(row, EWL_CALLBACK_CLICKED,
- ewl_fileselector_directory_clicked_single_cb,
fs);
-
- } else if (S_ISREG(statbuf.st_mode)) {
+ ewl_callback_append(items[0], EWL_CALLBACK_CLICKED,
+
ewl_fileselector_directory_clicked_single_cb,
+ fs);
+ row = ewl_tree_add_row (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_add_row (EWL_TREE (fs->files), NULL, items);
-
- ewl_callback_append (row, EWL_CALLBACK_DOUBLE_CLICKED,
- fs->file_clicked, fs);
- ewl_callback_append(row, EWL_CALLBACK_CLICKED,
- ewl_fileselector_file_clicked_cb, fs);
-
}
if (!row)
continue;
-
- f_row = NEW (Ewl_Fileselector_Row, 1);
- f_row->name = strdup (dentries[num]->d_name);
- f_row->path = strdup (dir);
- ewl_widget_set_data (EWL_WIDGET (row), "filedialog_info", f_row);
}
+
+ ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_VALUE_CHANGED);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -265,90 +263,103 @@
void ewl_fileselector_file_clicked_cb(Ewl_Widget * w, void *ev_data,
void *user_data)
{
+ char *tmp;
Ewl_Fileselector *fs;
- char *file;
- Ewl_Fileselector_Row *f_info = ewl_widget_get_data (EWL_WIDGET (w),
- "filedialog_info");
+ char file[PATH_MAX];
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
fs = EWL_FILESELECTOR (user_data);
- file = malloc (PATH_MAX);
-
- if (!strcmp (f_info->path, "/"))
- snprintf (file, PATH_MAX, "/%s", f_info->name);
+ tmp = ewl_text_get_text(EWL_TEXT(w));
+ if (!strcmp (tmp, "/"))
+ snprintf (file, PATH_MAX, "/%s", tmp);
else
- snprintf (file, PATH_MAX, "%s/%s", f_info->path, f_info->name);
+ snprintf (file, PATH_MAX, "%s/%s", fs->path, tmp);
fs->item = strdup (file);
-
- ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_CLICKED);
+ ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_VALUE_CHANGED);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-char *ewl_fileselector_path_down (char *dir)
+void ewl_fileselector_file_open_cb(Ewl_Widget * w, void *ev_data,
+ void *user_data)
{
- char *ptr;
char *tmp;
+ Ewl_Fileselector *fs;
+ char file[PATH_MAX];
+
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
- ptr = strdup(dir);
- tmp = strrchr(ptr, '/');
- if (tmp)
- *tmp = '\0';
- tmp = ptr;
-
- if (!(*ptr)) {
- ptr = malloc (2);
- strcpy (ptr, "/");
- }
+ fs = EWL_FILESELECTOR (user_data);
- DRETURN_PTR(ptr, DLEVEL_STABLE);
-}
+ tmp = ewl_text_get_text(EWL_TEXT(w));
+ if (!strcmp (tmp, "/"))
+ snprintf (file, PATH_MAX, "/%s", tmp);
+ else
+ snprintf (file, PATH_MAX, "%s/%s", fs->path, tmp);
+ fs->item = strdup (file);
+ ewl_callback_call_with_event_data(EWL_WIDGET(fs),
+ EWL_CALLBACK_VALUE_CHANGED, fs->item);
-char *ewl_fileselector_directory_adjust (Ewl_Fileselector *fs,
- Ewl_Fileselector_Row *d_info)
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void ewl_fileselector_directory_adjust (Ewl_Fileselector *fs, char *path)
{
- char *dir;
char *ptr;
+ char dir[PATH_MAX];
DENTER_FUNCTION(DLEVEL_STABLE);
- dir = malloc (PATH_MAX);
-
- if (!strcmp (d_info->name, "..")) {
- ptr = ewl_fileselector_path_down (d_info->path);
+ dir[0] = '\0';
+ ptr = strrchr(path, '/');
+ if (ptr) {
+ ptr++;
+ if (!strcmp (ptr, "..")) {
+ ptr--;
+ *ptr = '\0';
+ ptr = strrchr(path, '/');
+ if (!ptr) {
+ *path = '/';
+ ptr = path + 1;
+ }
- snprintf (dir, PATH_MAX, "%s", ptr);
- } else {
- if (!strcmp (d_info->path, "/"))
- snprintf (dir, PATH_MAX, "/%s", d_info->name);
- else
- snprintf (dir, PATH_MAX, "%s/%s", d_info->path, d_info->name);
+ *ptr = '\0';
+ snprintf (dir, PATH_MAX, "%s", path);
+ }
+ else {
+ if (!strcmp (ptr, "/"))
+ snprintf (dir, PATH_MAX, "/%s", ptr);
+ else
+ snprintf (dir, PATH_MAX, "%s", ptr);
+ }
}
+ IF_FREE(fs->item);
fs->item = strdup (dir);
- ewl_callback_call(EWL_WIDGET(fs), EWL_CALLBACK_CLICKED);
- DRETURN_PTR(dir, DLEVEL_STABLE);
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
void ewl_fileselector_directory_clicked_single_cb(Ewl_Widget * w,
void *ev_data, void *user_data)
{
Ewl_Fileselector *fs;
- Ewl_Fileselector_Row *d_info = ewl_widget_get_data (EWL_WIDGET (w),
- "filedialog_info");
+ char path[PATH_MAX];
+
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
fs = EWL_FILESELECTOR (user_data);
+ snprintf(path, PATH_MAX, "%s/%s", fs->path,
+ ewl_text_get_text(EWL_TEXT(w)));
- ewl_fileselector_directory_adjust (fs, d_info);
+ ewl_fileselector_directory_adjust (fs, path);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -357,18 +368,20 @@
void *user_data)
{
char *dir;
+ char path[PATH_MAX];
Ewl_Fileselector *fs;
- Ewl_Fileselector_Row *d_info = ewl_widget_get_data (EWL_WIDGET (w),
- "filedialog_info");
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
fs = EWL_FILESELECTOR (user_data);
- dir = ewl_fileselector_directory_adjust (fs, d_info);
-
- ewl_fileselector_process_directory (fs, dir);
+ dir = ewl_text_get_text(EWL_TEXT(w));
+ snprintf(path, PATH_MAX, "%s/%s", fs->path, dir);
+
+ IF_FREE(dir);
+ ewl_fileselector_directory_adjust (fs, path);
+ ewl_fileselector_set_directory (fs, path);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fileselector.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- ewl_fileselector.h 29 Jan 2004 04:26:18 -0000 1.15
+++ ewl_fileselector.h 17 Feb 2004 05:18:38 -0000 1.16
@@ -2,7 +2,16 @@
#define __EWL_FILESELECTOR_H__
/**
- * @defgroup Ewl_Fileselector Fileselector: a fileselector
+ * @defgroup Ewl_Fileselector Fileselector: Basic File And Directory Listing
+ *
+ * Displays a list of directories and a list of files for the user to choose.
+ * The selector triggers a EWL_CALLBACK_VALUE_CHANGED callback when either a
+ * click causes the selected file to change, when a double click causes the
+ * currently displayed directory to change, or when a double click on a file
+ * occurs to signal an open. The event data passed to the callback is NULL,
+ * unless the double click event occurred on a file, in which case it is the
+ * file's path.
+ *
* @{
*/
@@ -12,31 +21,9 @@
*/
/**
- * The Ewl_Fileselector_Row provides data for a single row
- */
-typedef struct _ewl_fileselector_row Ewl_Fileselector_Row;
-
-/**
- * @def EWL_FILESELECTOR_ROW(row)
- * Typecasts a pointer to an Ewl_Fileselector_Row pointer.
- */
-#define EWL_FILESELECTOR_ROW(row) ((Ewl_Fileselector_Row *))
-
-/**
- * @struct Ewl_Fileselector_Row
- * Internally used struct for storing the filename as a
- * datapointer inside each tree row
- */
-struct _ewl_fileselector_row
-{
- char *name; /* directory name */
- char *path; /* path to directory */
-};
-
-/**
* The Ewl_Fileselector provides a fileselector
*/
-typedef struct _ewl_fileselector Ewl_Fileselector;
+typedef struct Ewl_Fileselector Ewl_Fileselector;
/**
* @def EWL_FILESELECTOR(fd)
@@ -48,7 +35,7 @@
* @struct Ewl_Fileselector
* Creates a fileselector with one tree for dirs and one for files
*/
-struct _ewl_fileselector
+struct Ewl_Fileselector
{
Ewl_Box box; /* the vbox containing the trees */
Ewl_Widget *dirs; /* directory table */
@@ -56,16 +43,13 @@
char *path; /* current fileselector path */
char *item; /* current selected item in the fileselector */
-
- Ewl_Callback_Function file_clicked; /* use callback for open file */
};
-Ewl_Widget *ewl_fileselector_new(Ewl_Callback_Function file_clicked);
+Ewl_Widget *ewl_fileselector_new();
-void ewl_fileselector_init(Ewl_Fileselector * fs,
- Ewl_Callback_Function fc);
-void ewl_fileselector_process_directory(Ewl_Fileselector * fs, char *path);
+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);
@@ -78,19 +62,14 @@
void *user_data);
void ewl_fileselector_configure_cb(Ewl_Widget * w, void *ev_data,
void *user_data);
-void ewl_fileselector_directory_clicked(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);
-char *ewl_fileselector_directory_adjust (Ewl_Fileselector *fs,
- Ewl_Fileselector_Row *d_info);
-char *ewl_fileselector_path_down (char *dir);
-int ewl_fileselector_alphasort(const void *a, const void *b);
-
/**
* @}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_object.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- ewl_object.h 3 Jan 2004 21:23:11 -0000 1.39
+++ ewl_object.h 17 Feb 2004 05:18:38 -0000 1.40
@@ -31,7 +31,7 @@
#define EWL_OBJECT(object) ((Ewl_Object *) object)
/**
- * @struct Ewl_Object
+ * @class Ewl_Object
* @brief Provides facilities for sizing, position, alignment and fill policy.
*
* The fields of the object, while their explanations are fairly clear, can be
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -3 -r1.98 -r1.99
--- ewl_widget.c 28 Jan 2004 05:09:30 -0000 1.98
+++ ewl_widget.c 17 Feb 2004 05:18:38 -0000 1.99
@@ -629,10 +629,13 @@
int ewl_widget_get_layer_sum(Ewl_Widget *w)
{
int sum = 0;
+ Ewl_Widget *emb = NULL;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR_RET("w", w, 0);
+ emb = ewl_embed_find_by_widget(w);
+
while (!REALIZED(w) && w->parent) {
sum += LAYER(w);
w = w->parent;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_widget.h 3 Jan 2004 21:23:11 -0000 1.40
+++ ewl_widget.h 17 Feb 2004 05:18:38 -0000 1.41
@@ -5,6 +5,11 @@
* @defgroup Ewl_Widget Widget: The Parent Widget Class Common to All Widgets
* @brief Defines the Ewl_Widget class and it's accessor/modifier functions.
*
+ * The Ewl_Widget extends the Ewl_Object to provide the basic facilities
+ * necessary for widgets to interact with the end user. This includes basic
+ * callbacks for input events, window information changes, and drawing to the
+ * display.
+ *
* @{
*/
@@ -21,7 +26,7 @@
#define EWL_WIDGET(widget) ((Ewl_Widget *) widget)
/**
- * @struct Ewl_Widget
+ * @class Ewl_Widget
* The class inheriting from Ewl_Object that provides appearance, parent, and
* callback capabilities.
*/
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs