Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


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


Log Message:
make the filedialog work.
 - this converts back to a Ewl_Box base type. This maybe changing again in
   the future back to a ewl_dialog, but we need to figure out whats
   happening to the dialog
 - all the callbacks are hooked up and should work correctly (tho the sizing
   maybe a bit off, but this should just be fill policy stuff)

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_filedialog.c    28 Aug 2004 06:26:33 -0000      1.40
+++ ewl_filedialog.c    31 Aug 2004 18:31:36 -0000      1.41
@@ -15,7 +15,7 @@
  * @return Returns a new filedialog in success, NULL on failure.
  * @brief Create a new filedialog
  */
-Ewl_Widget *ewl_filedialog_new()
+Ewl_Widget *ewl_filedialog_new(Ewl_Filedialog_Type type)
 {
        Ewl_Filedialog *fd;
 
@@ -25,7 +25,7 @@
        if (!fd)
                DRETURN_PTR(NULL, DLEVEL_STABLE);
 
-       ewl_filedialog_init(fd);
+       ewl_filedialog_init(fd, type);
 
        DRETURN_PTR(EWL_WIDGET(fd), DLEVEL_STABLE);
 }
@@ -36,19 +36,20 @@
  * @return Returns no value.
  * @brief Initialize a new filedialog
  */
-void ewl_filedialog_init(Ewl_Filedialog * fd)
+void ewl_filedialog_init(Ewl_Filedialog * fd, Ewl_Filedialog_Type type)
 {
        Ewl_Widget *w;
        Ewl_Widget *button;
+       Ewl_Widget *box;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("fd", fd);
 
        w = EWL_WIDGET(fd);
 
-       ewl_dialog_init(EWL_DIALOG(w), EWL_POSITION_BOTTOM);
-       ewl_widget_appearance_set(w, "window");
+       ewl_box_init(EWL_BOX(fd), EWL_ORIENTATION_VERTICAL);
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_ALL);
+       ewl_widget_appearance_set(w, "filedialog");
 
        /* the file selector */
 
@@ -56,20 +57,33 @@
        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_container_child_append(EWL_CONTAINER(fd), fd->fs);
                ewl_widget_show(fd->fs);
        }
 
-       /* Buttons */
+       box = ewl_hbox_new();
+       ewl_object_alignment_set(EWL_OBJECT(box), EWL_FLAG_ALIGN_RIGHT);
+       ewl_container_child_append(EWL_CONTAINER(fd), box);
+       ewl_widget_show(box);
 
-       button = ewl_button_stock_with_id_new(EWL_STOCK_OPEN,
-                                        EWL_RESPONSE_OPEN);
-       ewl_container_child_append(EWL_CONTAINER(fd), button);
+       /* Buttons */
+       if (type == EWL_FILEDIALOG_TYPE_OPEN) 
+               button = ewl_button_stock_with_id_new(EWL_STOCK_OPEN,
+                                               EWL_RESPONSE_OPEN);
+       else
+               button = ewl_button_stock_with_id_new(EWL_STOCK_SAVE,
+                                               EWL_RESPONSE_SAVE);
+                
+       ewl_callback_append(button, EWL_CALLBACK_CLICKED,
+                                               ewl_filedialog_click_cb, fd);
+       ewl_container_child_append(EWL_CONTAINER(box), 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_callback_append(button, EWL_CALLBACK_CLICKED,
+                                               ewl_filedialog_click_cb, fd);
+       ewl_container_child_append(EWL_CONTAINER(box), button);
        ewl_widget_show(button);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -82,7 +96,7 @@
  */
 char *ewl_filedialog_path_get(Ewl_Filedialog * fd)
 {
-       return EWL_FILESELECTOR(fd->fs)->path;
+       return ewl_fileselector_path_get(fd->fs);
 }
 
 /**
@@ -92,7 +106,7 @@
  */
 char *ewl_filedialog_file_get(Ewl_Filedialog * fd)
 {
-       return EWL_FILESELECTOR(fd->fs)->file;
+       return ewl_fileselector_file_get(EWL_FILESELECTOR(fd->fs));
 }
 
 /**
@@ -109,25 +123,13 @@
 /*
  * Internally used callback, override at your own risk.
  */
-void ewl_filedialog_click_cb(Ewl_Widget * w, void *ev_data, Ewl_Filedialog * fd)
+void ewl_filedialog_click_cb(Ewl_Widget * w, void *ev_data, void* data)
 {
-       char *str = NULL;
+       Ewl_Filedialog *fd = EWL_FILEDIALOG(data);
 
-       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));
-
-                       break;
-               }
-       case (EWL_RESPONSE_CANCEL):
-               {
-                       ewl_widget_destroy(EWL_WIDGET(fd));
-                       break;
-               }
-       }
        ewl_callback_call_with_event_data(EWL_WIDGET(fd),
-                                         EWL_CALLBACK_VALUE_CHANGED, str);
+                                         EWL_CALLBACK_VALUE_CHANGED,
+                                         &EWL_BUTTON_STOCK(w)->response_id);
 }
+
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_filedialog.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- ewl_filedialog.h    28 Aug 2004 06:26:33 -0000      1.15
+++ ewl_filedialog.h    31 Aug 2004 18:31:36 -0000      1.16
@@ -45,14 +45,15 @@
  */
 struct Ewl_Filedialog
 {
-       Ewl_Dialog     dialog; /**< the dialog containing the fileselector */
+       Ewl_Box     box; /**< the overlay containing the fileselector */
        Ewl_Widget    *fs;     /**< Ewl_Fileselector */
 };
 
 
-Ewl_Widget *ewl_filedialog_new      ();
+Ewl_Widget *ewl_filedialog_new      (Ewl_Filedialog_Type type);
 
-void        ewl_filedialog_init     (Ewl_Filedialog *fd);
+void        ewl_filedialog_init     (Ewl_Filedialog *fd, 
+                                           Ewl_Filedialog_Type type);
 char       *ewl_filedialog_path_get (Ewl_Filedialog *fd);
 char       *ewl_filedialog_file_get (Ewl_Filedialog *fd);
 void        ewl_filedialog_path_set (Ewl_Filedialog *fd,
@@ -61,7 +62,7 @@
 /*
  * Internally used callbacks, override at your own risk.
  */
-void ewl_filedialog_click_cb (Ewl_Widget *w, void *ev_data, Ewl_Filedialog *fd);
+void ewl_filedialog_click_cb (Ewl_Widget *w, void *ev_data, void *data);
 
 
 /**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_fileselector.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- ewl_fileselector.c  29 Aug 2004 02:47:39 -0000      1.45
+++ ewl_fileselector.c  31 Aug 2004 18:31:36 -0000      1.46
@@ -226,6 +226,9 @@
  */
 char *ewl_fileselector_file_get(Ewl_Fileselector * fs)
 {
+    if (!fs->file || !fs->path)
+        return NULL;
+
        return ewl_fileselector_str_append(fs->path, fs->file);
 }
 
@@ -248,7 +251,13 @@
 static char *ewl_fileselector_str_append(char *s1, char *s2)
 {
        char *s;
-       int l = strlen(s1) + strlen(s2) + 1;
+       int l;
+ 
+       /* if either the path or the file is null return null */
+       if (!s1 || !s2)
+               return NULL;
+
+       l = strlen(s1) + strlen(s2) + 1;
 
        s = (char *) malloc(sizeof(char) * l);
        s = memcpy(s, s1, strlen(s1));
@@ -456,11 +465,11 @@
 
 void ewl_fileselector_select_file_cb(Ewl_Widget * w, void *ev_data, Ewl_Fileselector 
* fs)
 {
-       char *file;
+       Ewl_Fileselector_Data *d = NULL;
 
-       file = (char *) ewl_widget_data_get(EWL_WIDGET(w), "FILE");
-       fs->file = file;
-       ewl_entry_text_set(EWL_ENTRY(fs->entry_file), file);
+       d = (Ewl_Fileselector_Data *) ewl_widget_data_get(EWL_WIDGET(w), "FILE");
+       fs->file = d->name;
+       ewl_entry_text_set(EWL_ENTRY(fs->entry_file), d->name);
 }
 
 void ewl_fileselector_select_dir_cb(Ewl_Widget * w, void *ev_data, Ewl_Fileselector * 
fs)




-------------------------------------------------------
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