working on file properties dialog.


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Carsten Haitzler 16 years ago
parent 169ef3607a
commit 79c8864f92
  1. 1
      src/bin/e_fm.h
  2. 64
      src/bin/e_fm_prop.c
  3. 65
      src/bin/e_utils.c
  4. 2
      src/bin/e_utils.h
  5. 60
      src/bin/e_widget_fsel.c

@ -14,6 +14,7 @@ typedef enum _E_Fm2_View_Mode
E_FM2_VIEW_MODE_CUSTOM_SMART_GRID_ICONS, /* icons go anywhere u drop them but try align to icons nearby */
E_FM2_VIEW_MODE_LIST /* vertical fileselector list */
} E_Fm2_View_Mode;
typedef enum _E_Fm2_Menu_Flags
{
E_FM2_MENU_NO_REFRESH = (1 << 0),

@ -6,20 +6,20 @@
/* FIXME:
*
* basic -
* * show file
* * show size
* * show modified date
* * show permissions
* * show preview
* + show file
* + show size
* + show modified date
* + show mimetype
* + show permissions (others read, others write)
* + show preview
* * show icon
* * show symlink/fifo/socket/etc. status
* * show broken link status
* * change icon for mime type
* * change icon for just this file
* * change permissions
* * change permissions (others read, others write)
*
* advanced (extra) -
* * change app to open THIS file with
* * show access date
* * show change date
* * show pseudolink status
@ -29,6 +29,7 @@
* * show mount status
* * show link destination (if symlink or link)
* * change link destination
* * change app to open THIS file with (or dir)
*
*/
@ -46,6 +47,12 @@ struct _E_Config_Dialog_Data
{
E_Fm2_Icon_Info *fi;
/*- BASIC -*/
char *file;
char *size;
char *mod_date;
char *mime;
int others_read;
int others_write;
/*- ADVANCED -*/
};
@ -77,7 +84,15 @@ e_fm_prop_file(E_Container *con, E_Fm2_Icon_Info *fi)
static void
_fill_data(E_Config_Dialog_Data *cfdata, E_Fm2_Icon_Info *fi)
{
char buf[4096];
cfdata->fi = fi;
if (fi->file) cfdata->file = strdup(fi->file);
cfdata->size = e_util_size_string_get(fi->statinfo.st_size);
cfdata->mod_date = e_util_file_time_get(fi->statinfo.st_mtime);
if (fi->mime) cfdata->mime = strdup(fi->mime);
if (fi->statinfo.st_mode & S_IROTH) cfdata->others_read = 1;
if (fi->statinfo.st_mode & S_IWOTH) cfdata->others_write = 1;
}
static void *
@ -98,6 +113,10 @@ static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
/* Free the cfdata */
E_FREE(cfdata->file);
E_FREE(cfdata->size);
E_FREE(cfdata->mod_date);
E_FREE(cfdata->mime);
free(cfdata);
}
@ -119,7 +138,7 @@ static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
/* generate the core widget layout for a basic dialog */
Evas_Object *o, *ot, *ob;
Evas_Object *o, *ot, *ob, *of;
char buf[4096];
snprintf(buf, sizeof(buf), "%s/%s",
@ -130,18 +149,39 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
ob = e_widget_label_add(evas, _("File:"));
e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 0, 1, 0);
ob = e_widget_entry_add(evas, NULL);
e_widget_min_size_set(ob, 80, -1);
ob = e_widget_entry_add(evas, &(cfdata->file));
e_widget_min_size_set(ob, 140, -1);
e_widget_entry_readonly_set(ob, 1);
e_widget_table_object_append(ot, ob, 1, 0, 1, 1, 1, 0, 1, 0);
ob = e_widget_label_add(evas, _("Size:"));
e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 0, 1, 0);
ob = e_widget_entry_add(evas, NULL);
e_widget_min_size_set(ob, 80, -1);
ob = e_widget_entry_add(evas, &(cfdata->size));
e_widget_min_size_set(ob, 140, -1);
e_widget_entry_readonly_set(ob, 1);
e_widget_table_object_append(ot, ob, 1, 1, 1, 1, 1, 0, 1, 0);
ob = e_widget_label_add(evas, _("Last Modified:"));
e_widget_table_object_append(ot, ob, 0, 2, 1, 1, 1, 0, 1, 0);
ob = e_widget_entry_add(evas, &(cfdata->mod_date));
e_widget_min_size_set(ob, 140, -1);
e_widget_entry_readonly_set(ob, 1);
e_widget_table_object_append(ot, ob, 1, 2, 1, 1, 1, 0, 1, 0);
ob = e_widget_label_add(evas, _("File Type:"));
e_widget_table_object_append(ot, ob, 0, 3, 1, 1, 1, 0, 1, 0);
ob = e_widget_entry_add(evas, &(cfdata->mime));
e_widget_min_size_set(ob, 140, -1);
e_widget_entry_readonly_set(ob, 1);
e_widget_table_object_append(ot, ob, 1, 3, 1, 1, 1, 0, 1, 0);
of = e_widget_framelist_add(evas, _("Permissions"), 0);
ob = e_widget_check_add(evas, _("Others can read"), &(cfdata->others_read));
e_widget_framelist_object_append(of, ob);
ob = e_widget_check_add(evas, _("Others can write"), &(cfdata->others_write));
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(ot, of, 0, 4, 2, 1, 1, 0, 1, 0);
e_widget_table_object_append(o, ot, 0, 0, 1, 1, 1, 1, 1, 1);
ot = e_widget_table_add(evas, 0);

@ -716,6 +716,71 @@ e_util_shell_env_path_eval(char *path)
return strdup(buf);
}
EAPI char *
e_util_size_string_get(off_t size)
{
double dsize;
char buf[256];
dsize = (double)size;
if (dsize < 1024.0) snprintf(buf, sizeof(buf), _("%'.0f Bytes"), dsize);
else
{
dsize /= 1024.0;
if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.0f KB"), dsize);
else
{
dsize /= 1024.0;
if (dsize < 1024) snprintf(buf, sizeof(buf), _("%'.0f MB"), dsize);
else
{
dsize /= 1024.0;
snprintf(buf, sizeof(buf), _("%'.1f GB"), dsize);
}
}
}
return strdup(buf);
}
EAPI char *
e_util_file_time_get(time_t ftime)
{
time_t diff;
time_t ltime;
char buf[256];
char *s = NULL;
ltime = time(NULL);
diff = ltime - ftime;
if (ftime > ltime)
{
snprintf(buf, sizeof(buf), _("In the Future"));
}
else
{
if (diff <= 60)
snprintf(buf, sizeof(buf), _("In the last Minute"));
else if (diff >= 31526000)
snprintf(buf, sizeof(buf), _("%li Years ago"), (diff / 31526000));
else if (diff >= 2592000)
snprintf(buf, sizeof(buf), _("%li Months ago"), (diff / 2592000));
else if (diff >= 604800)
snprintf(buf, sizeof(buf), _("%li Weeks ago"), (diff / 604800));
else if (diff >= 86400)
snprintf(buf, sizeof(buf), _("%li Days ago"), (diff / 86400));
else if (diff >= 3600)
snprintf(buf, sizeof(buf), _("%li Hours ago"), (diff / 3600));
else if (diff > 60)
snprintf(buf, sizeof(buf), _("%li Minutes ago"), (diff / 60));
}
if (buf)
s = strdup(buf);
else
s = strdup(_("Unknown"));
return s;
}
/* local subsystem functions */
static void
_e_util_container_fake_mouse_up_cb(void *data)

@ -45,6 +45,8 @@ EAPI void e_util_dialog_internal(const char *title, const char *txt);
EAPI const char *e_util_filename_escape(const char *filename);
EAPI int e_util_icon_save(Ecore_X_Icon *icon, const char *filename);
EAPI char *e_util_shell_env_path_eval(char *path);
EAPI char *e_util_size_string_get(off_t size);
EAPI char *e_util_file_time_get(time_t ftime);
#endif
#endif

@ -603,30 +603,7 @@ _e_wid_fsel_preview_file(E_Widget_Data *wd)
static char *
_e_wid_file_size_get(off_t st_size)
{
double dsize;
char size[256];
dsize = (double)st_size;
if (dsize < 1024.0)
snprintf(size, sizeof(size), _("%'.0f Bytes"), dsize);
else
{
dsize /= 1024.0;
if (dsize < 1024)
snprintf(size, sizeof(size), _("%'.0f KB"), dsize);
else
{
dsize /= 1024.0;
if (dsize < 1024)
snprintf(size, sizeof(size), _("%'.0f MB"), dsize);
else
{
dsize /= 1024.0;
snprintf(size, sizeof(size), _("%'.1f GB"), dsize);
}
}
}
return strdup(size);
return e_util_size_string_get(st_size);
}
static char *
@ -718,40 +695,7 @@ _e_wid_file_perms_get(mode_t st_mode, uid_t st_uid, gid_t st_gid)
static char *
_e_wid_file_time_get(time_t st_modtime)
{
time_t diff;
time_t ltime;
char modtime[256];
char *motime;
ltime = time(NULL);
diff = ltime - st_modtime;
if (st_modtime > ltime)
{
snprintf(modtime, sizeof(modtime), _("In the Future"));
}
else
{
if (diff <= 60)
snprintf(modtime, sizeof(modtime), _("In the last Minute"));
else if (diff >= 31526000)
snprintf(modtime, sizeof(modtime), _("%li Years ago"), (diff / 31526000));
else if (diff >= 2592000)
snprintf(modtime, sizeof(modtime), _("%li Months ago"), (diff / 2592000));
else if (diff >= 604800)
snprintf(modtime, sizeof(modtime), _("%li Weeks ago"), (diff / 604800));
else if (diff >= 86400)
snprintf(modtime, sizeof(modtime), _("%li Days ago"), (diff / 86400));
else if (diff >= 3600)
snprintf(modtime, sizeof(modtime), _("%li Hours ago"), (diff / 3600));
else if (diff > 60)
snprintf(modtime, sizeof(modtime), _("%li Minutes ago"), (diff / 60));
}
if (modtime)
motime = strdup(modtime);
else
motime = strdup(_("Unknown"));
return motime;
return e_util_file_time_get(st_modtime);
}
static void

Loading…
Cancel
Save