Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
ewl_filedialog.c ewl_filedialog.h ewl_fileselector.h
Log Message:
File dialog update. Allow for a cancel callback. Hides the filedialog on OK
and Cancel by default.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- ewl_filedialog.c 7 Jan 2004 17:04:58 -0000 1.23
+++ ewl_filedialog.c 29 Jan 2004 04:26:17 -0000 1.24
@@ -4,13 +4,15 @@
/**
* @param follows: the widget this dialog follows
* @param type: type of dialog to display
- * @param cb: callback to be called when open/save button is pushed
+ * @param ok_cb: callback to be called when open/save button is pushed
+ * @param cancel_cb: callback to be called when cancel button is pushed
* @return Returns a new filedialog in success, NULL on failure.
* @brief Create a new filedialog
*/
Ewl_Widget *ewl_filedialog_new(Ewl_Widget * follows,
Ewl_Filedialog_Type type,
- Ewl_Callback_Function cb)
+ Ewl_Callback_Function ok_cb,
+ Ewl_Callback_Function cancel_cb)
{
Ewl_Filedialog *fd;
@@ -20,7 +22,7 @@
if (!fd)
DRETURN_PTR(NULL, DLEVEL_STABLE);
- ewl_filedialog_init(fd, follows, type, cb);
+ ewl_filedialog_init(fd, follows, type, ok_cb, cancel_cb);
DRETURN_PTR(EWL_WIDGET(fd), DLEVEL_STABLE);
}
@@ -30,13 +32,15 @@
* @param fd: the filedialog
* @param follows: widget to follow for the floater
* @param type: the filedialog type
- * @param cb: the callback to call when open/save button is pushed
+ * @param ok_cb: the callback to call when open/save button is pushed
+ * @param cancel_cb: the callback to call when cancel button is pushed
* @return Returns no value.
* @brief Initialize a new filedialog
*/
void
ewl_filedialog_init(Ewl_Filedialog * fd, Ewl_Widget * follows,
- Ewl_Filedialog_Type type, Ewl_Callback_Function cb)
+ Ewl_Filedialog_Type type, Ewl_Callback_Function ok_cb,
+ Ewl_Callback_Function cancel_cb)
{
Ewl_Widget *w;
@@ -53,9 +57,9 @@
ewl_widget_set_appearance (EWL_WIDGET (w), "filedialog");
if (type == EWL_FILEDIALOG_TYPE_OPEN)
- ewl_filedialog_open_init(EWL_FILEDIALOG (fd), cb);
+ ewl_filedialog_open_init(EWL_FILEDIALOG (fd), ok_cb, cancel_cb);
else
- ewl_filedialog_save_init(EWL_FILEDIALOG (fd), cb);
+ ewl_filedialog_save_init(EWL_FILEDIALOG (fd), ok_cb, cancel_cb);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -93,7 +97,9 @@
}
-void ewl_filedialog_open_init(Ewl_Filedialog * fd, Ewl_Callback_Function cb)
+void
+ewl_filedialog_open_init(Ewl_Filedialog * fd, Ewl_Callback_Function ok_cb,
+ Ewl_Callback_Function cancel_cb)
{
Open_Dialog *od;
Ewl_Widget *vbox;
@@ -116,10 +122,11 @@
ewl_object_set_padding(EWL_OBJECT(fd->path_label), 2, 2, 2, 2);
ewl_widget_show (fd->path_label);
- fd->selector = ewl_fileselector_new(cb);
+ fd->selector = ewl_fileselector_new(ok_cb);
ewl_container_append_child(EWL_CONTAINER(vbox), fd->selector);
ewl_callback_append (EWL_WIDGET (fd->selector),
- EWL_CALLBACK_VALUE_CHANGED, ewl_filedialog_change_labels, fd);
+ EWL_CALLBACK_VALUE_CHANGED,
+ ewl_filedialog_change_labels, fd);
ewl_callback_append (EWL_WIDGET (fd->selector),
EWL_CALLBACK_CLICKED, ewl_filedialog_change_entry, fd);
ewl_widget_show(fd->selector);
@@ -144,14 +151,23 @@
od->open = ewl_button_new("Open");
ewl_object_set_fill_policy(EWL_OBJECT(od->open), EWL_FLAG_FILL_NONE);
- ewl_callback_append(od->open, EWL_CALLBACK_CLICKED, cb, fd->selector);
+ ewl_callback_append(od->open, EWL_CALLBACK_CLICKED,
+ ewl_filedialog_hide_cb, fd);
+ if (ok_cb) {
+ ewl_callback_append(od->open, EWL_CALLBACK_CLICKED, ok_cb,
+ fd->selector);
+ }
ewl_container_append_child(EWL_CONTAINER(od->box), od->open);
ewl_widget_show(od->open);
od->cancel = ewl_button_new("Cancel");
ewl_object_set_fill_policy(EWL_OBJECT(od->cancel), EWL_FLAG_FILL_NONE);
ewl_callback_append(od->cancel, EWL_CALLBACK_CLICKED,
- ewl_filedialog_destroy_cb, NULL);
+ ewl_filedialog_hide_cb, fd);
+ if (cancel_cb) {
+ ewl_callback_append(od->cancel, EWL_CALLBACK_CLICKED,
+ cancel_cb, fd->selector);
+ }
ewl_container_append_child(EWL_CONTAINER(od->box), od->cancel);
ewl_widget_show(od->cancel);
@@ -164,7 +180,7 @@
{
struct stat statbuf;
Ewl_Filedialog *fd = user_data;
- Ewl_Fileselector *fs = EWL_FILESELECTOR (fd->selector);
+ Ewl_Fileselector *fs = EWL_FILESELECTOR (fd->selector);
char *dir;
int i;
@@ -177,7 +193,9 @@
}
}
-void ewl_filedialog_save_init(Ewl_Filedialog * fd, Ewl_Callback_Function cb)
+void
+ewl_filedialog_save_init(Ewl_Filedialog * fd, Ewl_Callback_Function ok_cb,
+ Ewl_Callback_Function cancel_cb)
{
Save_Dialog *sd;
@@ -187,18 +205,15 @@
if (!sd)
return;
- fd->selector = ewl_fileselector_new(cb);
+ fd->selector = ewl_fileselector_new(ok_cb);
ewl_container_append_child(EWL_CONTAINER(fd), fd->selector);
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-void ewl_filedialog_destroy_cb(Ewl_Widget * w, void *ev_data, void *user_data)
+void ewl_filedialog_hide_cb(Ewl_Widget * w, void *ev_data, void *user_data)
{
- Ewl_Widget *fd;
+ Ewl_Widget *fd = user_data;
- /* Destroy the filedialog */
- fd = w->parent->parent;
- ewl_widget_destroy(fd);
+ ewl_widget_hide(fd);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_filedialog.h 14 Jan 2004 20:42:54 -0000 1.9
+++ ewl_filedialog.h 29 Jan 2004 04:26:18 -0000 1.10
@@ -47,11 +47,12 @@
* @struct Open_Dialog
*
*/
-struct _open_dialog {
- Ewl_Widget *box; /* box to hold the buttons */
+struct _open_dialog
+{
+ Ewl_Widget *box; /**< box to hold the buttons */
- Ewl_Widget *open; /* open button */
- Ewl_Widget *cancel; /* cancel button */
+ Ewl_Widget *open; /**< open button */
+ Ewl_Widget *cancel; /**< cancel button */
};
/**
@@ -63,22 +64,25 @@
* @struct Save_Dialog
*
*/
-struct _save_dialog {
- Ewl_Widget *inputbox; /* box to hold text input widgets */
- Ewl_Widget *buttonbox; /* box to hold buttons */
+struct _save_dialog
+{
+ Ewl_Widget *inputbox; /**< box to hold text input widgets */
+ Ewl_Widget *buttonbox; /**< box to hold buttons */
- Ewl_Widget *save; /* save button */
- Ewl_Widget *cancel; /* cancel button */
+ Ewl_Widget *save; /**< save button */
+ Ewl_Widget *cancel; /**< cancel button */
};
Ewl_Widget *ewl_filedialog_new (Ewl_Widget * follows, Ewl_Filedialog_Type type,
- Ewl_Callback_Function cb);
+ Ewl_Callback_Function ok_cb, Ewl_Callback_Function cancel_cb);
void ewl_filedialog_init (Ewl_Filedialog * fd, Ewl_Widget * follows,
- Ewl_Filedialog_Type type, Ewl_Callback_Function cb);
-void ewl_filedialog_open_init (Ewl_Filedialog * fd, Ewl_Callback_Function cb);
-
-void ewl_filedialog_save_init (Ewl_Filedialog * fd, Ewl_Callback_Function cb);
+ Ewl_Filedialog_Type type, Ewl_Callback_Function cb,
+ Ewl_Callback_Function cancel_cb);
+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);
/*
@@ -87,7 +91,7 @@
void ewl_filedialog_change_labels (Ewl_Widget * w, void *ev_data, void *user_data);
void ewl_filedialog_change_entry (Ewl_Widget * w, void *ev_data, void *user_data);
void ewl_filedialog_change_path (Ewl_Widget * w, void *ev_data, void *user_data);
-void ewl_filedialog_destroy_cb (Ewl_Widget * w, void *ev_data, void *user_data);
+void ewl_filedialog_hide_cb (Ewl_Widget * w, void *ev_data, void *user_data);
/**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fileselector.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ewl_fileselector.h 14 Jan 2004 20:42:54 -0000 1.14
+++ ewl_fileselector.h 29 Jan 2004 04:26:18 -0000 1.15
@@ -27,7 +27,8 @@
* Internally used struct for storing the filename as a
* datapointer inside each tree row
*/
-struct _ewl_fileselector_row {
+struct _ewl_fileselector_row
+{
char *name; /* directory name */
char *path; /* path to directory */
};
@@ -47,7 +48,8 @@
* @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 */
Ewl_Widget *files; /* file table */
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs