Enlightenment CVS committal

Author  : titan
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_filelist.h ewl_filelist.c ewl_filelist_list.c 


Log Message:

Add function for getting the modtime of a file. Make the file preview widget 
and the list view use it.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_filelist.h      29 Apr 2006 23:57:52 -0000      1.7
+++ ewl_filelist.h      30 Apr 2006 00:50:35 -0000      1.8
@@ -100,6 +100,7 @@
 char           *ewl_filelist_perms_get(mode_t st_mode);
 char           *ewl_filelist_username_get(uid_t st_uid);
 char           *ewl_filelist_groupname_get(gid_t st_gid);
+char           *ewl_filelist_modtime_get(time_t modtime);
 Ewl_Widget     *ewl_filelist_selected_file_preview_get(Ewl_Filelist *fl, 
                                                        const char *path);
 void            ewl_filelist_selected_files_set(Ewl_Filelist *fl,
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_filelist.c      29 Apr 2006 23:57:52 -0000      1.9
+++ ewl_filelist.c      30 Apr 2006 00:50:35 -0000      1.10
@@ -228,13 +228,6 @@
        DRETURN_PTR((file ? strdup(file) : NULL), DLEVEL_STABLE);
 }
 
-/**
- * @param fl: Filelist that asked for the preview.
- * @param path: Path of the file which was clicked.
- * @return Returns a box with a preview of the file.
- * @brief Creates a preview of the selected file.
- **/
-
 char *
 ewl_filelist_size_get(off_t st_size)
 {
@@ -330,6 +323,20 @@
        DRETURN_PTR(strdup(name), DLEVEL_STABLE);
 }
 
+char *
+ewl_filelist_modtime_get(time_t st_modtime)
+{
+       char *time;
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       time = ctime(&st_modtime);
+       if (time)
+               time = strdup(time);
+       else {
+               time = strdup("Ctime Failure");
+       }
+       DRETURN_PTR(strdup(time), DLEVEL_STABLE);
+}
+
 Ewl_Widget *
 ewl_filelist_selected_file_preview_get(Ewl_Filelist *fl, const char *path)
 {
@@ -341,9 +348,9 @@
        char *perms;
        char *username;
        char *groupname;
+       char *time;
        struct stat buf;
-       struct tm *time_struct;
-       
+               
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("fl", fl, NULL);
        DCHECK_PARAM_PTR_RET("path", path, NULL);
@@ -353,12 +360,12 @@
        snprintf(path3, PATH_MAX, "%s/%s", path2, path);        
 
        stat(path3, &buf);
-       time_struct = localtime(&buf.st_mtime);
 
        size = ewl_filelist_size_get(buf.st_size);
        perms = ewl_filelist_perms_get(buf.st_mode);
        username = ewl_filelist_username_get(buf.st_uid);
        groupname = ewl_filelist_groupname_get(buf.st_gid);
+       time = ewl_filelist_modtime_get(buf.st_mtime);
 
        snprintf(file_info, PATH_MAX, 
                                "Size: %s\n"
@@ -367,7 +374,7 @@
                                "Permissions: %s\n"
                                "Last Modified: %s\n", 
                        size, username, groupname,
-                       perms, asctime(time_struct));
+                       perms, time);
        
        box = ewl_vbox_new();
        ewl_widget_show(box);
@@ -396,6 +403,7 @@
        free(perms);
        free(username);
        free(groupname);
+       free(time);
 
        DRETURN_PTR(box, DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist_list.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_filelist_list.c 29 Apr 2006 23:57:52 -0000      1.7
+++ ewl_filelist_list.c 30 Apr 2006 00:50:35 -0000      1.8
@@ -218,15 +218,9 @@
 
                vals[0] = file;
                vals[1] = ewl_filelist_size_get(buf.st_size);
-
-               tm = localtime(&buf.st_mtime);
-               strftime(date, sizeof(date), nl_langinfo(D_T_FMT), tm);
-               vals[2] = strdup(date);
-
+               vals[2] = ewl_filelist_modtime_get(buf.st_mtime);
                vals[3] = ewl_filelist_perms_get(buf.st_mode);
-
                vals[4] = ewl_filelist_username_get(buf.st_uid);
-
                vals[5] = ewl_filelist_groupname_get(buf.st_gid);
 
                row = ewl_tree_text_row_add(EWL_TREE(list->tree), NULL, vals);




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to