Enlightenment CVS committal

Author  : jethomas
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_filelist_model.c 


Log Message:
Patch from Mike Rutter (dancingeek) to allow sorting by modified date in the 
filelist.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist_model.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ewl_filelist_model.c        7 May 2008 13:38:23 -0000       1.14
+++ ewl_filelist_model.c        11 Aug 2008 20:51:05 -0000      1.15
@@ -13,6 +13,8 @@
                                 Ewl_Filelist_File *file2);
 static int ewl_filelist_model_data_size_sort(Ewl_Filelist_File *file1,
                                 Ewl_Filelist_File *file2);
+static int ewl_filelist_model_data_modified_sort(Ewl_Filelist_File *file1,
+                                Ewl_Filelist_File *file2);
 static void free_file(Ewl_Filelist_File *file);
 void ewl_filelist_model_filter(Ewl_Filelist_Directory *dir);
 static unsigned int ewl_filelist_model_filter_main
@@ -130,7 +132,8 @@
                                         unsigned int column)
 {
         DENTER_FUNCTION(DLEVEL_STABLE);
-        DRETURN_INT(((column == 0) || (column == 1)), DLEVEL_STABLE);
+        DRETURN_INT(((column == 0) || (column == 1) ||
+                               (column == 5)), DLEVEL_STABLE);
 }
 
 /**
@@ -267,6 +270,34 @@
                                 ECORE_SORT_MAX);
                 }
         }
+        else if (column == 5)
+        {
+                if (sort == EWL_SORT_DIRECTION_ASCENDING)
+                {
+                        ecore_list_sort(fld->dirs,
+                                ECORE_COMPARE_CB
+                                (ewl_filelist_model_data_modified_sort),
+                                ECORE_SORT_MIN);
+
+                        ecore_list_sort(fld->files,
+                                ECORE_COMPARE_CB
+                                (ewl_filelist_model_data_modified_sort),
+                                ECORE_SORT_MIN);
+                }
+                
+                else if (sort == EWL_SORT_DIRECTION_DESCENDING)
+                {
+                        ecore_list_sort(fld->dirs,
+                                ECORE_COMPARE_CB
+                                (ewl_filelist_model_data_modified_sort),
+                                ECORE_SORT_MAX);
+
+                        ecore_list_sort(fld->files,
+                                ECORE_COMPARE_CB
+                                (ewl_filelist_model_data_modified_sort),
+                                ECORE_SORT_MAX);
+                }
+        }
 
         /* Put .. entry back in */
         if (root)
@@ -304,6 +335,28 @@
         if (file1->size > file2->size)
                 ret = 1;
         else if (file1->size < file2->size)
+                ret = -1;
+        else ret = 0;
+
+        DRETURN_INT(ret, DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ */
+static int
+ewl_filelist_model_data_modified_sort(Ewl_Filelist_File *file1,
+                                      Ewl_Filelist_File *file2)
+{
+        int ret;
+
+        DENTER_FUNCTION(DLEVEL_STABLE);
+        DCHECK_PARAM_PTR_RET(file1, 0);
+        DCHECK_PARAM_PTR_RET(file2, 0);
+
+        if (file1->modtime > file2->modtime)
+                ret = 1;
+        else if (file1->modtime < file2->modtime)
                 ret = -1;
         else ret = 0;
 



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to