Enlightenment CVS committal

Author  : lok
Project : e17
Module  : libs/etk

Dir     : e17/libs/etk/src/lib


Modified Files:
        etk_filechooser_widget.c etk_filechooser_widget.h 


Log Message:
Enhancement (bug 211) mcalamelli's patch.
Better check when saving with the filechooser.

===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_filechooser_widget.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- etk_filechooser_widget.c    19 Sep 2007 20:16:26 -0000      1.28
+++ etk_filechooser_widget.c    21 Sep 2007 11:14:02 -0000      1.29
@@ -372,6 +372,48 @@
       return ETK_FALSE;
    return filechooser_widget->is_save;
 }
+
+/**
+ * @brief Set a filename if Etk_Filechooser_Widget is for save
+ * @param filechooser_widget a filechooser widget
+ * @param filename the current name of file
+ * @return Return ETK_TRUE if filename can be saved, ETK_FALSE if filename is 
malformed (like full pathname instead of filename)
+ */
+Etk_Bool etk_filechooser_widget_selected_file_set(Etk_Filechooser_Widget 
*filechooser_widget, const char *filename)
+{
+   if (!filechooser_widget)
+      return ETK_FALSE;
+   if (filechooser_widget->is_save == ETK_FALSE)
+      return ETK_FALSE;
+   
+   if (strchr(filename, '/') == NULL)
+     {
+       // filename doesn't contains slashes, then i can use it directly 
+       etk_entry_text_set(ETK_ENTRY(filechooser_widget->name_entry), filename);
+       return ETK_TRUE;
+     } 
+   else
+     {
+       // filename contains slashes, now i've to check if path is right
+       char *path;
+
+       path = ecore_file_dir_get(filename);
+       if (ecore_file_exists(path) == 0) 
+         {
+           // the extracted path doesn't exists, error
+           return ETK_FALSE; 
+         } 
+       else 
+         {
+           // the extracted path exists, sync current folder and set filename
+           etk_filechooser_widget_current_folder_set(filechooser_widget, path);
+           etk_entry_text_set(ETK_ENTRY(filechooser_widget->name_entry), 
ecore_file_file_get(filename));
+           return ETK_TRUE;         
+         }
+       free(path);
+     }
+}
+
 /**************************
  *
  * Etk specific functions
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_filechooser_widget.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- etk_filechooser_widget.h    19 Sep 2007 20:16:26 -0000      1.9
+++ etk_filechooser_widget.h    21 Sep 2007 11:14:02 -0000      1.10
@@ -71,6 +71,7 @@
 const char *etk_filechooser_widget_selected_file_get(Etk_Filechooser_Widget 
*widget);
 Evas_List  *etk_filechooser_widget_selected_files_get(Etk_Filechooser_Widget 
*widget);
 
+Etk_Bool    etk_filechooser_widget_selected_file_set(Etk_Filechooser_Widget 
*filechooser_widget, const char *filename);
 /** @} */
 
 #ifdef __cplusplus



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to