2008-12-06 10:51:04 -08:00
|
|
|
#include <e.h>
|
2010-01-11 02:23:02 -08:00
|
|
|
#include <sys/statvfs.h>
|
2020-04-19 01:06:07 -07:00
|
|
|
#include "places_config.h"
|
2008-12-06 10:51:04 -08:00
|
|
|
#include "e_mod_main.h"
|
|
|
|
#include "e_mod_places.h"
|
2020-04-19 01:06:07 -07:00
|
|
|
|
2021-04-21 22:58:40 -07:00
|
|
|
|
|
|
|
#ifdef PLACES_HAVE_SYSTEMD
|
2021-04-23 00:11:24 -07:00
|
|
|
# include "backend_systemd.h"
|
2021-04-21 22:58:40 -07:00
|
|
|
#endif
|
|
|
|
|
2019-06-02 10:01:41 -07:00
|
|
|
#ifdef PLACES_HAVE_EEZE
|
2021-04-23 00:11:24 -07:00
|
|
|
# include "backend_eeze.h"
|
2012-01-24 12:59:11 -08:00
|
|
|
#endif
|
2020-04-19 01:06:07 -07:00
|
|
|
|
2021-04-23 00:11:24 -07:00
|
|
|
#ifdef PLACES_HAVE_UDISKS1
|
|
|
|
# include "backend_udisks1.h"
|
2013-04-18 14:26:06 -07:00
|
|
|
#endif
|
2020-04-19 01:06:07 -07:00
|
|
|
|
2021-04-18 04:38:58 -07:00
|
|
|
#ifdef PLACES_HAVE_UDISKS2
|
2021-04-23 00:11:24 -07:00
|
|
|
# include "backend_udisks2.h"
|
2021-04-18 04:38:58 -07:00
|
|
|
#endif
|
|
|
|
|
2019-06-02 10:01:41 -07:00
|
|
|
#ifdef PLACES_HAVE_MOUNT
|
2021-04-23 00:11:24 -07:00
|
|
|
# include "backend_mount.h"
|
2015-01-11 11:12:32 -08:00
|
|
|
#endif
|
|
|
|
|
2011-08-27 20:22:49 -07:00
|
|
|
|
2021-04-23 23:39:18 -07:00
|
|
|
|
|
|
|
/* Enable/Disable debug messages */
|
|
|
|
// #define PDBG(...) do {} while (0)
|
|
|
|
#define PDBG(...) printf("PLACES: "__VA_ARGS__)
|
|
|
|
|
|
|
|
|
2020-11-11 22:07:28 -08:00
|
|
|
/* Local Typedefs */
|
|
|
|
typedef struct _FreespaceThreadData FreespaceThreadData;
|
|
|
|
struct _FreespaceThreadData
|
|
|
|
{
|
|
|
|
const char *id;
|
|
|
|
const char *mount_point;
|
|
|
|
unsigned long long size;
|
|
|
|
unsigned long long free_space;
|
|
|
|
};
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
/* Local Function Prototypes */
|
2020-11-11 22:07:28 -08:00
|
|
|
static Eina_Bool _places_freespace_timer_cb(void *data);
|
2008-12-06 10:51:04 -08:00
|
|
|
static const char *_places_human_size_get(unsigned long long size);
|
2012-01-21 16:06:46 -08:00
|
|
|
static void _places_volume_object_update(Volume *vol, Evas_Object *obj);
|
2013-04-29 12:56:44 -07:00
|
|
|
static void _places_run_fm_external(const char *fm, const char *directory);
|
2012-01-21 16:06:46 -08:00
|
|
|
|
2020-11-11 23:08:46 -08:00
|
|
|
/* EcoreEvent callbacks */
|
|
|
|
static Eina_Bool _places_screensaver_on_cb(void *data, int type, void *event);
|
|
|
|
static Eina_Bool _places_screensaver_off_cb(void *data, int type, void *event);
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* Edje callbacks */
|
2008-12-06 10:51:04 -08:00
|
|
|
void _places_icon_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source);
|
2009-02-01 16:35:45 -08:00
|
|
|
void _places_custom_icon_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source);
|
2008-12-06 10:51:04 -08:00
|
|
|
void _places_eject_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source);
|
2012-01-24 13:59:50 -08:00
|
|
|
void _places_header_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source);
|
2008-12-06 10:51:04 -08:00
|
|
|
|
|
|
|
/* Local Variables */
|
|
|
|
static char theme_file[PATH_MAX];
|
2020-11-11 22:07:28 -08:00
|
|
|
static Eina_List *volumes = NULL;
|
|
|
|
static Ecore_Timer *freespace_timer = NULL;
|
|
|
|
static Ecore_Thread *freespace_thread = NULL;
|
2020-11-11 23:08:46 -08:00
|
|
|
static Ecore_Event_Handler *places_screensaver_on_handler = NULL;
|
|
|
|
static Ecore_Event_Handler *places_screensaver_off_handler = NULL;
|
|
|
|
#define PLACES_FREESPACE_INTERVAL 3.0
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2011-08-27 20:22:49 -07:00
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
/* Implementation */
|
|
|
|
void
|
|
|
|
places_init(void)
|
|
|
|
{
|
|
|
|
volumes = NULL;
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2021-04-23 23:39:18 -07:00
|
|
|
PDBG("module init\n");
|
2012-01-17 13:46:33 -08:00
|
|
|
|
2021-04-21 22:58:40 -07:00
|
|
|
#ifdef PLACES_HAVE_SYSTEMD
|
|
|
|
places_systemd_init();
|
|
|
|
#endif
|
2019-06-02 10:01:41 -07:00
|
|
|
#ifdef PLACES_HAVE_EEZE
|
2012-01-24 12:59:11 -08:00
|
|
|
places_eeze_init();
|
|
|
|
#endif
|
2021-04-23 00:11:24 -07:00
|
|
|
#ifdef PLACES_HAVE_UDISKS1
|
|
|
|
places_udisks1_init();
|
2013-04-18 14:26:06 -07:00
|
|
|
#endif
|
2021-04-18 04:38:58 -07:00
|
|
|
#ifdef PLACES_HAVE_UDISKS2
|
|
|
|
places_udisks2_init();
|
|
|
|
#endif
|
2019-06-02 10:01:41 -07:00
|
|
|
#ifdef PLACES_HAVE_MOUNT
|
2015-01-11 11:12:32 -08:00
|
|
|
places_mount_init();
|
|
|
|
#endif
|
2012-01-17 13:46:33 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
snprintf(theme_file, PATH_MAX, "%s/e-module-places.edj",
|
|
|
|
places_conf->module->dir);
|
2020-11-11 23:08:46 -08:00
|
|
|
|
|
|
|
places_screensaver_on_handler =
|
|
|
|
ecore_event_handler_add(E_EVENT_SCREENSAVER_ON,
|
|
|
|
_places_screensaver_on_cb, NULL);
|
|
|
|
places_screensaver_off_handler =
|
|
|
|
ecore_event_handler_add(E_EVENT_SCREENSAVER_OFF,
|
|
|
|
_places_screensaver_off_cb, NULL);
|
|
|
|
|
|
|
|
freespace_timer = ecore_timer_add(PLACES_FREESPACE_INTERVAL,
|
|
|
|
_places_freespace_timer_cb, NULL);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
void
|
|
|
|
places_shutdown(void)
|
2012-01-17 13:46:33 -08:00
|
|
|
{
|
2020-11-11 23:08:46 -08:00
|
|
|
if (places_screensaver_on_handler)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(places_screensaver_on_handler);
|
|
|
|
places_screensaver_on_handler = NULL;
|
|
|
|
}
|
|
|
|
if (places_screensaver_off_handler)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(places_screensaver_off_handler);
|
|
|
|
places_screensaver_off_handler = NULL;
|
|
|
|
}
|
2020-11-11 22:07:28 -08:00
|
|
|
if (freespace_timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(freespace_timer);
|
|
|
|
freespace_timer = NULL;
|
|
|
|
}
|
|
|
|
if (freespace_thread)
|
|
|
|
{
|
|
|
|
ecore_thread_cancel(freespace_thread);
|
|
|
|
freespace_thread = NULL;
|
|
|
|
}
|
2012-01-17 13:46:33 -08:00
|
|
|
|
2013-04-18 14:26:06 -07:00
|
|
|
while (volumes)
|
|
|
|
places_volume_del((Volume*)volumes->data);
|
|
|
|
|
2021-04-21 22:58:40 -07:00
|
|
|
#ifdef PLACES_HAVE_SYSTEMD
|
|
|
|
places_systemd_shutdown();
|
|
|
|
#endif
|
2019-06-02 10:01:41 -07:00
|
|
|
#ifdef PLACES_HAVE_EEZE
|
2012-01-24 12:59:11 -08:00
|
|
|
places_eeze_shutdown();
|
2012-01-22 13:14:47 -08:00
|
|
|
#endif
|
2021-04-23 00:11:24 -07:00
|
|
|
#ifdef PLACES_HAVE_UDISKS1
|
|
|
|
places_udisks1_shutdown();
|
2013-04-18 14:26:06 -07:00
|
|
|
#endif
|
2021-04-18 04:38:58 -07:00
|
|
|
#ifdef PLACES_HAVE_UDISKS2
|
|
|
|
places_udisks2_shutdown();
|
|
|
|
#endif
|
2019-06-02 10:01:41 -07:00
|
|
|
#ifdef PLACES_HAVE_MOUNT
|
2015-01-11 11:12:32 -08:00
|
|
|
places_mount_shutdown();
|
|
|
|
#endif
|
2012-01-17 13:46:33 -08:00
|
|
|
}
|
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
Evas_Object *
|
|
|
|
places_main_obj_create(Evas *canvas)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
o = edje_object_add(canvas);
|
|
|
|
edje_object_file_set(o, theme_file, "modules/places/main");
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
Eina_List *
|
|
|
|
places_volume_list_get(void)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
return volumes;
|
|
|
|
}
|
2012-07-26 14:08:02 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
Volume *
|
2012-07-26 14:08:02 -07:00
|
|
|
places_volume_add(const char *id, Eina_Bool first_time)
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
|
|
|
Volume *v;
|
|
|
|
if (!id) return NULL;
|
|
|
|
|
|
|
|
v = E_NEW(Volume, 1);
|
|
|
|
if (!v) return NULL;
|
|
|
|
|
|
|
|
// safe defaults
|
|
|
|
v->id = eina_stringshare_add(id);
|
2012-01-26 13:20:55 -08:00
|
|
|
v->valid = EINA_FALSE;
|
2012-01-21 16:06:46 -08:00
|
|
|
v->objs = NULL;
|
2013-04-18 14:26:06 -07:00
|
|
|
v->icon = eina_stringshare_add("");
|
|
|
|
v->device = eina_stringshare_add("");
|
|
|
|
v->label = eina_stringshare_add("");
|
|
|
|
v->mount_point = eina_stringshare_add("");
|
|
|
|
v->fstype = eina_stringshare_add("");
|
|
|
|
v->drive_type = eina_stringshare_add("");
|
|
|
|
v->model = eina_stringshare_add("");
|
|
|
|
v->serial = eina_stringshare_add("");
|
|
|
|
v->vendor = eina_stringshare_add("");
|
|
|
|
v->bus = eina_stringshare_add("");
|
2012-07-26 15:04:51 -07:00
|
|
|
v->to_mount = ((places_conf->auto_mount && !first_time) ||
|
|
|
|
(first_time && places_conf->boot_mount));
|
2012-07-26 14:08:02 -07:00
|
|
|
v->force_open = (places_conf->auto_open && !first_time);
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
volumes = eina_list_append(volumes, v);
|
2011-11-06 02:17:03 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
return v;
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-21 16:06:46 -08:00
|
|
|
places_volume_del(Volume *v)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Evas_Object *swal;
|
2013-04-20 09:36:01 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Instance *inst;
|
2012-01-21 16:06:46 -08:00
|
|
|
|
2013-04-18 14:26:06 -07:00
|
|
|
if (v->free_func)
|
|
|
|
v->free_func(v);
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
volumes = eina_list_remove(volumes, v);
|
|
|
|
EINA_LIST_FREE(v->objs, o)
|
|
|
|
{
|
|
|
|
swal = edje_object_part_swallow_get(o, "icon");
|
|
|
|
if (swal)
|
|
|
|
{
|
|
|
|
edje_object_part_unswallow(o, swal);
|
|
|
|
evas_object_del(swal);
|
|
|
|
}
|
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
EINA_LIST_FOREACH(instances, l, inst)
|
|
|
|
edje_object_part_box_remove(inst->o_main, "box", o);
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
evas_object_del(o);
|
|
|
|
}
|
2013-04-18 14:26:06 -07:00
|
|
|
if (v->id) eina_stringshare_del(v->id);
|
2012-01-21 16:06:46 -08:00
|
|
|
if (v->label) eina_stringshare_del(v->label);
|
|
|
|
if (v->icon) eina_stringshare_del(v->icon);
|
|
|
|
if (v->mount_point) eina_stringshare_del(v->mount_point);
|
|
|
|
if (v->device) eina_stringshare_del(v->device);
|
|
|
|
if (v->fstype) eina_stringshare_del(v->fstype);
|
|
|
|
if (v->bus) eina_stringshare_del(v->bus);
|
|
|
|
if (v->drive_type) eina_stringshare_del(v->drive_type);
|
|
|
|
if (v->model) eina_stringshare_del(v->model);
|
|
|
|
if (v->vendor) eina_stringshare_del(v->vendor);
|
|
|
|
if (v->serial) eina_stringshare_del(v->serial);
|
2013-04-20 09:36:01 -07:00
|
|
|
E_FREE(v);
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Volume *
|
|
|
|
places_volume_by_id_get(const char *id)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
Volume *v;
|
2008-12-06 10:51:04 -08:00
|
|
|
Eina_List *l;
|
2009-08-17 08:53:32 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
EINA_LIST_FOREACH(volumes, l, v)
|
2021-04-18 22:14:34 -07:00
|
|
|
if (eina_streq(v->id, id))
|
2012-01-21 16:06:46 -08:00
|
|
|
return v;
|
|
|
|
|
|
|
|
return NULL;
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
static int
|
2008-12-06 10:51:04 -08:00
|
|
|
_places_volume_sort_cb(const void *d1, const void *d2)
|
|
|
|
{
|
|
|
|
const Volume *v1 = d1;
|
|
|
|
const Volume *v2 = d2;
|
|
|
|
|
2021-04-18 05:33:13 -07:00
|
|
|
if(!v1) return 1;
|
|
|
|
if(!v2) return -1;
|
2019-05-12 12:52:13 -07:00
|
|
|
|
2012-01-17 13:46:33 -08:00
|
|
|
// removable after interal
|
2021-04-18 05:33:13 -07:00
|
|
|
if (v1->removable && !v2->removable) return 1;
|
|
|
|
if (v2->removable && !v1->removable) return -1;
|
|
|
|
// network after local
|
|
|
|
if (v1->remote && !v2->remote) return 1;
|
|
|
|
if (v2->remote && !v1->remote) return -1;
|
2012-01-17 13:46:33 -08:00
|
|
|
// filesystem root on top
|
2021-04-18 05:33:13 -07:00
|
|
|
if (eina_streq(v1->mount_point, "/")) return -1;
|
|
|
|
if (eina_streq(v2->mount_point, "/")) return 1;
|
2012-01-17 13:46:33 -08:00
|
|
|
// order by label
|
2021-04-18 05:33:13 -07:00
|
|
|
if(!v1->label) return 1;
|
|
|
|
if(!v2->label) return -1;
|
2008-12-06 10:51:04 -08:00
|
|
|
return strcmp(v1->label, v2->label);
|
|
|
|
}
|
|
|
|
|
2009-02-01 16:35:45 -08:00
|
|
|
void
|
2012-01-21 16:06:46 -08:00
|
|
|
places_update_all_gadgets(void)
|
2009-02-01 16:35:45 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Instance *inst;
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
volumes = eina_list_sort(volumes, 0, _places_volume_sort_cb);
|
|
|
|
EINA_LIST_FOREACH(instances, l, inst)
|
2013-04-20 09:36:01 -07:00
|
|
|
places_fill_box(inst->o_main, inst->horiz);
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
void
|
|
|
|
places_volume_update(Volume *vol)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Eina_List *l;
|
2009-02-01 16:35:45 -08:00
|
|
|
|
2021-04-21 22:58:40 -07:00
|
|
|
if (eina_str_has_prefix(vol->fstype, "nfs") || // nfs, nfs3, nfs4, etc..
|
2021-04-18 05:33:13 -07:00
|
|
|
eina_streq(vol->fstype, "cifs"))
|
|
|
|
vol->remote = EINA_TRUE;
|
|
|
|
else
|
|
|
|
vol->remote = EINA_FALSE;
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
EINA_LIST_FOREACH(vol->objs, l, obj)
|
|
|
|
_places_volume_object_update(vol, obj);
|
2012-01-26 13:20:55 -08:00
|
|
|
|
2012-07-26 14:08:02 -07:00
|
|
|
// mount the volume if needed
|
|
|
|
if (vol->to_mount && !vol->mounted)
|
|
|
|
{
|
|
|
|
places_volume_mount(vol);
|
|
|
|
vol->to_mount = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-01-26 13:20:55 -08:00
|
|
|
// the volume has been mounted as requested, open the fm
|
|
|
|
if (vol->force_open && vol->mounted && vol->mount_point)
|
|
|
|
{
|
2013-04-29 12:56:44 -07:00
|
|
|
places_run_fm(vol->mount_point);
|
2012-01-26 13:20:55 -08:00
|
|
|
vol->force_open = EINA_FALSE;
|
|
|
|
}
|
2013-04-29 11:45:27 -07:00
|
|
|
|
|
|
|
// debug:
|
|
|
|
// places_print_volume(vol);
|
2009-02-01 16:35:45 -08:00
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
void
|
2013-04-20 09:36:01 -07:00
|
|
|
places_fill_box(Evas_Object *main, Eina_Bool horiz)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
2010-12-07 20:05:09 -08:00
|
|
|
int min_w, min_h, max_w, max_h, found;
|
2012-01-17 13:46:33 -08:00
|
|
|
Evas_Object *o, *icon;
|
2010-12-07 20:05:09 -08:00
|
|
|
char *f1, *f2, *f3;
|
|
|
|
char buf[128];
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-21 03:16:49 -07:00
|
|
|
if (!main) return;
|
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
places_empty_box(main);
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
// orient the edje box
|
|
|
|
if (horiz)
|
|
|
|
edje_object_signal_emit(main, "box,set,horiz", "places");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(main, "box,set,vert", "places");
|
2012-01-24 15:54:10 -08:00
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
// header (or just a separator if header is not wanted)
|
|
|
|
o = edje_object_add(evas_object_evas_get(main));
|
2012-01-24 15:54:10 -08:00
|
|
|
if (places_conf->hide_header)
|
|
|
|
edje_object_file_set(o, theme_file, "modules/places/separator");
|
|
|
|
else
|
|
|
|
edje_object_file_set(o, theme_file, "modules/places/header");
|
|
|
|
|
|
|
|
edje_object_part_text_set(o, "label", D_("Places"));
|
2013-04-20 09:36:01 -07:00
|
|
|
if (horiz)
|
2012-01-24 15:54:10 -08:00
|
|
|
edje_object_signal_emit(o, "separator,set,vert", "places");
|
2013-04-20 09:36:01 -07:00
|
|
|
else
|
|
|
|
edje_object_signal_emit(o, "separator,set,horiz", "places");
|
|
|
|
|
2012-01-24 15:54:10 -08:00
|
|
|
edje_object_size_min_get(o, &min_w, &min_h);
|
|
|
|
edje_object_size_max_get(o, &max_w, &max_h);
|
2013-04-20 09:36:01 -07:00
|
|
|
evas_object_size_hint_min_set(o, min_w, min_h);
|
|
|
|
evas_object_size_hint_max_set(o, max_w, max_h);
|
2013-04-21 03:16:49 -07:00
|
|
|
// evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
|
2013-04-20 09:36:01 -07:00
|
|
|
edje_object_part_box_append(main, "box", o);
|
2012-01-24 15:54:10 -08:00
|
|
|
evas_object_show(o);
|
2013-04-20 09:36:01 -07:00
|
|
|
|
2012-01-24 15:54:10 -08:00
|
|
|
edje_object_signal_callback_add(o, "header,activated", "places",
|
|
|
|
_places_header_activated_cb, NULL);
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// volume objects
|
2008-12-06 10:51:04 -08:00
|
|
|
for (l = volumes; l; l = l->next)
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
|
|
|
Volume *vol = l->data;
|
|
|
|
|
|
|
|
if (!vol->valid) continue;
|
|
|
|
|
2010-12-07 20:05:09 -08:00
|
|
|
//volume object
|
2013-04-20 09:36:01 -07:00
|
|
|
o = edje_object_add(evas_object_evas_get(main));
|
|
|
|
edje_object_file_set(o, theme_file, "modules/places/volume");
|
2012-01-21 16:06:46 -08:00
|
|
|
vol->objs = eina_list_append(vol->objs, o);
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2010-12-07 20:05:09 -08:00
|
|
|
//choose the right icon
|
2013-04-20 09:36:01 -07:00
|
|
|
icon = e_icon_add(evas_object_evas_get(main));
|
2010-12-07 20:05:09 -08:00
|
|
|
f1 = f2 = f3 = NULL;
|
|
|
|
/* optical discs */
|
2021-04-24 22:55:18 -07:00
|
|
|
if (eina_str_has_prefix(vol->drive_type, "optical_bd"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
2021-04-24 22:55:18 -07:00
|
|
|
f1 = "media"; f2 = "optical"; f3 = "bd";
|
|
|
|
}
|
|
|
|
else if (eina_str_has_prefix(vol->drive_type, "optical_dvd"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "optical"; f3 = "dvd";
|
|
|
|
}
|
|
|
|
else if (eina_str_has_prefix(vol->drive_type, "optical_cd") &&
|
|
|
|
!eina_streq(vol->fstype, "iso9660"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "optical"; f3 = "audio";
|
|
|
|
}
|
|
|
|
else if (eina_str_has_prefix(vol->drive_type, "cdrom") ||
|
|
|
|
eina_str_has_prefix(vol->drive_type, "optical"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "optical";
|
2010-12-07 20:05:09 -08:00
|
|
|
}
|
|
|
|
/* flash cards */
|
2021-04-25 22:01:35 -07:00
|
|
|
else if (eina_streq(vol->drive_type, "flash_mmc") ||
|
|
|
|
eina_streq(vol->drive_type, "sd_mmc") ||
|
2021-04-18 22:14:34 -07:00
|
|
|
eina_streq(vol->model, "SD/MMC"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "sdmmc"; // NOTE sd-mmc in Oxigen :(
|
|
|
|
}
|
2021-04-25 22:01:35 -07:00
|
|
|
else if (eina_streq(vol->drive_type, "flash_ms") ||
|
|
|
|
eina_streq(vol->drive_type, "memory_stick") ||
|
2021-04-18 22:14:34 -07:00
|
|
|
eina_streq(vol->model, "MS/MS-Pro"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "ms"; // NOTE memory-stick in Oxigen :(
|
|
|
|
}
|
2021-04-25 22:01:35 -07:00
|
|
|
else if (eina_streq(vol->drive_type, "flash_cf"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "cf";
|
|
|
|
}
|
|
|
|
else if (eina_streq(vol->drive_type, "flash_sd"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "sd";
|
|
|
|
}
|
|
|
|
else if (eina_streq(vol->drive_type, "flash_sm"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "sm";
|
|
|
|
}
|
|
|
|
else if (eina_str_has_prefix(vol->drive_type, "flash"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash";
|
|
|
|
}
|
2010-12-07 20:05:09 -08:00
|
|
|
/* iPods */
|
2021-04-18 22:14:34 -07:00
|
|
|
else if (eina_streq(vol->model, "iPod"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
|
|
|
f1 = "multimedia-player"; f2 = "apple"; f3 = "ipod";
|
|
|
|
}
|
2021-04-25 22:01:35 -07:00
|
|
|
/* Floppy disks */
|
|
|
|
else if (eina_str_has_prefix(vol->drive_type, "floppy"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "floppy";
|
|
|
|
}
|
2010-12-07 20:05:09 -08:00
|
|
|
/* generic usb drives */
|
2021-04-18 22:14:34 -07:00
|
|
|
else if (eina_streq(vol->bus, "usb"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
|
|
|
f1 = "drive"; f2 = "removable-media"; f3 = "usb";
|
|
|
|
}
|
2015-01-10 12:42:02 -08:00
|
|
|
/* network filesystem */
|
2021-04-18 22:14:34 -07:00
|
|
|
else if (eina_streq(vol->fstype, "nfs") ||
|
|
|
|
eina_streq(vol->fstype, "cifs"))
|
2015-01-10 12:42:02 -08:00
|
|
|
{
|
|
|
|
f1 = "folder"; f2 = "remote";
|
|
|
|
}
|
2010-12-07 20:05:09 -08:00
|
|
|
|
|
|
|
// search the icon, following freedesktop fallback system
|
|
|
|
found = 0;
|
|
|
|
if (f1 && f2 && f3)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s-%s-%s", f1, f2, f3);
|
|
|
|
found = e_util_icon_theme_set(icon, buf);
|
|
|
|
}
|
|
|
|
if (!found && f1 && f2)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s-%s", f1, f2);
|
|
|
|
found = e_util_icon_theme_set(icon, buf);
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "drive-harddisk");
|
|
|
|
found = e_util_icon_theme_set(icon, buf);
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
edje_object_part_swallow(o, "icon", icon);
|
|
|
|
vol->icon = eina_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
else evas_object_del(icon);
|
|
|
|
|
2010-08-25 01:23:59 -07:00
|
|
|
//set partition type tag
|
2021-04-18 22:14:34 -07:00
|
|
|
if (eina_streq(vol->fstype, "ext2") ||
|
|
|
|
eina_streq(vol->fstype, "ext3") ||
|
|
|
|
eina_streq(vol->fstype, "ext4") ||
|
|
|
|
eina_streq(vol->fstype, "reiserfs") ||
|
|
|
|
eina_streq(vol->fstype, "nfs"))
|
2010-08-25 01:23:59 -07:00
|
|
|
edje_object_signal_emit(o, "icon,tag,ext3", "places");
|
2021-04-18 22:14:34 -07:00
|
|
|
else if (eina_streq(vol->fstype, "ufs") ||
|
|
|
|
eina_streq(vol->fstype, "zfs"))
|
2011-02-22 15:08:27 -08:00
|
|
|
edje_object_signal_emit(o, "icon,tag,ufs", "places");
|
2021-04-18 22:14:34 -07:00
|
|
|
else if (eina_streq(vol->fstype, "vfat") ||
|
|
|
|
eina_streq(vol->fstype, "ntfs") ||
|
|
|
|
eina_streq(vol->fstype, "ntfs-3g") ||
|
|
|
|
eina_streq(vol->fstype, "cifs"))
|
2010-08-25 01:23:59 -07:00
|
|
|
edje_object_signal_emit(o, "icon,tag,fat", "places");
|
2021-04-18 22:14:34 -07:00
|
|
|
else if (eina_streq(vol->fstype, "hfs") ||
|
|
|
|
eina_streq(vol->fstype, "hfsplus"))
|
2010-08-25 01:23:59 -07:00
|
|
|
edje_object_signal_emit(o, "icon,tag,hfs", "places");
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// update labels, gauge and button
|
|
|
|
_places_volume_object_update(vol, o);
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-17 13:46:33 -08:00
|
|
|
// orient the separator
|
2013-04-20 09:36:01 -07:00
|
|
|
if (horiz)
|
2010-08-25 01:23:59 -07:00
|
|
|
edje_object_signal_emit(o, "separator,set,vert", "places");
|
2013-04-20 09:36:01 -07:00
|
|
|
else
|
|
|
|
edje_object_signal_emit(o, "separator,set,horiz", "places");
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-17 13:46:33 -08:00
|
|
|
// connect signals from edje
|
2010-08-25 01:23:59 -07:00
|
|
|
edje_object_signal_callback_add(o, "icon,activated", "places",
|
|
|
|
_places_icon_activated_cb, vol);
|
|
|
|
edje_object_signal_callback_add(o, "eject,activated", "places",
|
|
|
|
_places_eject_activated_cb, vol);
|
|
|
|
|
2012-01-17 13:46:33 -08:00
|
|
|
// pack the volume in the box
|
2010-08-25 01:23:59 -07:00
|
|
|
edje_object_size_min_get(o, &min_w, &min_h);
|
|
|
|
edje_object_size_max_get(o, &max_w, &max_h);
|
2013-04-20 09:36:01 -07:00
|
|
|
evas_object_size_hint_min_set(o, min_w, min_h);
|
|
|
|
evas_object_size_hint_max_set(o, max_w, max_h);
|
2013-04-21 03:16:49 -07:00
|
|
|
// evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
|
|
|
|
// evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2013-04-20 09:36:01 -07:00
|
|
|
edje_object_part_box_append(main, "box", o);
|
|
|
|
evas_object_show(o);
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2013-04-21 03:16:49 -07:00
|
|
|
|
|
|
|
edje_object_calc_force(main);
|
|
|
|
edje_object_size_min_restricted_calc(main, &min_w, &min_h, 99, 1);
|
2021-04-23 23:39:18 -07:00
|
|
|
// PDBG("SIZE: %d %d\n", min_w, min_h);
|
2013-04-21 03:16:49 -07:00
|
|
|
evas_object_size_hint_min_set(main, min_w, min_h);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-20 09:36:01 -07:00
|
|
|
places_empty_box(Evas_Object *main)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2013-04-20 09:36:01 -07:00
|
|
|
Evas_Object *o;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
while ((o = edje_object_part_box_remove_at(main, "box", 0)))
|
|
|
|
{
|
|
|
|
Volume *vol;
|
|
|
|
Evas_Object *swal;
|
|
|
|
Eina_List *l;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
swal = edje_object_part_swallow_get(o, "icon");
|
|
|
|
if (swal)
|
|
|
|
{
|
|
|
|
edje_object_part_unswallow(o, swal);
|
|
|
|
evas_object_del(swal);
|
|
|
|
}
|
2013-04-18 14:26:06 -07:00
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
EINA_LIST_FOREACH(volumes, l, vol)
|
|
|
|
vol->objs = eina_list_remove(vol->objs, o);
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-20 09:36:01 -07:00
|
|
|
evas_object_del(o);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2009-01-26 00:29:20 -08:00
|
|
|
void
|
2012-07-26 14:08:02 -07:00
|
|
|
places_volume_mount(Volume *vol)
|
2009-01-26 00:29:20 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
Eina_List *opts = NULL;
|
|
|
|
char buf[256];
|
2009-01-26 00:29:20 -08:00
|
|
|
|
2012-07-26 15:04:51 -07:00
|
|
|
if (!vol || !vol->mount_func || vol->mounted)
|
2012-01-21 16:06:46 -08:00
|
|
|
return;
|
|
|
|
|
2021-04-18 22:14:34 -07:00
|
|
|
if ((eina_streq(vol->fstype, "vfat")) || (eina_streq(vol->fstype, "ntfs")))
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
snprintf(buf, sizeof(buf), "uid=%i", (int)getuid());
|
|
|
|
opts = eina_list_append(opts, buf);
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2012-01-21 16:06:46 -08:00
|
|
|
|
|
|
|
vol->mount_func(vol, opts);
|
2012-01-26 13:20:55 -08:00
|
|
|
vol->to_mount = EINA_FALSE;
|
2012-01-21 16:06:46 -08:00
|
|
|
|
|
|
|
eina_list_free(opts);
|
2009-01-26 00:29:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-21 16:06:46 -08:00
|
|
|
places_volume_unmount(Volume *vol)
|
2009-01-26 00:29:20 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
if (vol && vol->unmount_func)
|
|
|
|
vol->unmount_func(vol, NULL);
|
2009-01-26 00:29:20 -08:00
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
void
|
2012-01-21 16:06:46 -08:00
|
|
|
places_volume_eject(Volume *vol)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
if (vol && vol->eject_func)
|
|
|
|
vol->eject_func(vol, NULL);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
void
|
|
|
|
places_print_volume(Volume *v)
|
|
|
|
{
|
|
|
|
const char *size, *free;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-18 14:26:06 -07:00
|
|
|
printf("Got volume %s (totals: %d)\n", v->id, eina_list_count(volumes));
|
2021-04-18 04:38:58 -07:00
|
|
|
printf(" valid: %d\n", v->valid);
|
2012-01-21 16:06:46 -08:00
|
|
|
printf(" label: %s\n",v->label);
|
|
|
|
printf(" mounted: %d\n", v->mounted);
|
|
|
|
printf(" m_point: %s\n", v->mount_point);
|
|
|
|
printf(" device: %s\n", v->device);
|
|
|
|
printf(" fstype: %s\n", v->fstype);
|
|
|
|
printf(" bus: %s\n", v->bus);
|
|
|
|
printf(" drive_type: %s\n", v->drive_type);
|
|
|
|
printf(" model: %s\n", v->model);
|
|
|
|
printf(" vendor: %s\n", v->vendor);
|
|
|
|
printf(" serial: %s\n", v->serial);
|
|
|
|
printf(" removable: %d\n", v->removable);
|
|
|
|
printf(" requires eject: %d\n", v->requires_eject);
|
2021-04-18 04:38:58 -07:00
|
|
|
printf(" media_available: %d\n", v->media_available);
|
2021-04-18 05:33:13 -07:00
|
|
|
printf(" remote: %d\n", v->remote);
|
2012-01-21 16:06:46 -08:00
|
|
|
size = _places_human_size_get(v->size);
|
|
|
|
free = _places_human_size_get(v->free_space);
|
|
|
|
printf(" size: %s\n", size);
|
|
|
|
printf(" free_space: %s\n", free);
|
|
|
|
eina_stringshare_del(size);
|
|
|
|
eina_stringshare_del(free);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2009-01-26 00:29:20 -08:00
|
|
|
|
2013-04-29 12:56:44 -07:00
|
|
|
void
|
|
|
|
places_run_fm(const char *directory)
|
|
|
|
{
|
|
|
|
if (places_conf->fm && places_conf->fm[0])
|
|
|
|
{
|
|
|
|
_places_run_fm_external(places_conf->fm, directory);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
E_Action *act = e_action_find("fileman");
|
|
|
|
|
2015-03-21 04:59:35 -07:00
|
|
|
if (act && act->func.go)
|
|
|
|
act->func.go(E_OBJECT(e_comp), directory);
|
2013-04-29 12:56:44 -07:00
|
|
|
else
|
|
|
|
e_util_dialog_internal(D_("Warning"),
|
|
|
|
D_("<b>Cannot run the Enlightenment FileManager.</b><br>"
|
|
|
|
"Please choose a custom file manager in<br>"
|
|
|
|
"the gadget configuration."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (places_conf->autoclose_popup)
|
|
|
|
places_popups_close();
|
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* Internals */
|
2020-11-11 22:07:28 -08:00
|
|
|
static void
|
|
|
|
_places_freespace_thread_run(void *data, Ecore_Thread *thread)
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
2020-11-11 22:07:28 -08:00
|
|
|
/* statvfs can block, so we run it in a thread to not stall the E mainloop */
|
|
|
|
Eina_List *l;
|
|
|
|
FreespaceThreadData *td = NULL;
|
2012-01-21 16:06:46 -08:00
|
|
|
struct statvfs s;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2021-04-23 23:39:18 -07:00
|
|
|
// PDBG("THIS RUN IN THREAD %p\n", thread);
|
2020-11-11 22:07:28 -08:00
|
|
|
|
|
|
|
if (ecore_thread_check(thread) == EINA_TRUE) // thread cancelled
|
|
|
|
return;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(data, l, td)
|
|
|
|
{
|
|
|
|
if (td->mount_point && (statvfs(td->mount_point, &s) == 0))
|
|
|
|
{
|
|
|
|
td->size = (unsigned long long)s.f_blocks * (unsigned long long)s.f_frsize;
|
|
|
|
td->free_space = (unsigned long long)s.f_bavail * (unsigned long long)s.f_frsize;
|
|
|
|
}
|
|
|
|
if (ecore_thread_check(thread) == EINA_TRUE)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_places_freespace_thread_done(void *data, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
FreespaceThreadData *td = NULL;
|
|
|
|
Volume *vol;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(data, td)
|
|
|
|
{
|
|
|
|
vol = places_volume_by_id_get(td->id);
|
|
|
|
if (vol)
|
|
|
|
{
|
|
|
|
// redraw only if size or free_space has changed more than 1Mb
|
|
|
|
if ((abs(td->free_space - vol->free_space) > 1024 * 1024) ||
|
|
|
|
(abs(td->size - vol->size) > 1024 * 1024))
|
|
|
|
{
|
|
|
|
vol->size = td->size;
|
|
|
|
vol->free_space = td->free_space;
|
|
|
|
places_volume_update(vol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eina_stringshare_del(td->id);
|
|
|
|
eina_stringshare_del(td->mount_point);
|
|
|
|
E_FREE(td);
|
|
|
|
}
|
|
|
|
|
2021-04-23 23:39:18 -07:00
|
|
|
// PDBG(" THREAD DONE %p\n", thread);
|
2020-11-11 22:07:28 -08:00
|
|
|
freespace_thread = NULL;
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2020-11-11 22:07:28 -08:00
|
|
|
static void
|
|
|
|
_places_freespace_thread_cancel(void *data, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
FreespaceThreadData *td = NULL;
|
2015-01-10 12:10:38 -08:00
|
|
|
|
2020-11-11 22:07:28 -08:00
|
|
|
EINA_LIST_FREE(data, td)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(td->id);
|
|
|
|
eina_stringshare_del(td->mount_point);
|
|
|
|
E_FREE(td);
|
|
|
|
}
|
|
|
|
freespace_thread = NULL;
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2010-07-07 17:57:17 -07:00
|
|
|
static Eina_Bool
|
2020-11-11 22:07:28 -08:00
|
|
|
_places_freespace_timer_cb(void *data EINA_UNUSED)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2009-08-17 08:53:32 -07:00
|
|
|
Volume *vol;
|
2020-11-11 22:07:28 -08:00
|
|
|
Eina_List *l, *tdl = NULL;
|
|
|
|
FreespaceThreadData *td = NULL;
|
|
|
|
|
2021-04-23 23:39:18 -07:00
|
|
|
// PDBG("TIMER %.1f\n", ecore_time_get());
|
2020-11-11 22:07:28 -08:00
|
|
|
if (freespace_thread)
|
|
|
|
{
|
2021-04-23 23:39:18 -07:00
|
|
|
// PDBG("*** SOMETHING WRONG *** thread:%p still running...\n", freespace_thread);
|
2020-11-11 22:07:28 -08:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2009-08-17 08:53:32 -07:00
|
|
|
EINA_LIST_FOREACH(volumes, l, vol)
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
2020-11-11 22:07:28 -08:00
|
|
|
if (vol->valid && vol->mounted)
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
2020-11-11 22:07:28 -08:00
|
|
|
td = E_NEW(FreespaceThreadData, 1);
|
|
|
|
if (!td) return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
td->id = eina_stringshare_add(vol->id);
|
|
|
|
td->mount_point = eina_stringshare_add(vol->mount_point);
|
|
|
|
tdl = eina_list_append(tdl, td);
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
2020-11-11 22:07:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tdl)
|
|
|
|
freespace_thread = ecore_thread_run(_places_freespace_thread_run,
|
|
|
|
_places_freespace_thread_done,
|
|
|
|
_places_freespace_thread_cancel,
|
|
|
|
tdl);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2020-11-11 23:08:46 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_places_screensaver_on_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (freespace_timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(freespace_timer);
|
|
|
|
freespace_timer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_places_screensaver_off_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (!freespace_timer)
|
|
|
|
freespace_timer = ecore_timer_add(PLACES_FREESPACE_INTERVAL,
|
|
|
|
_places_freespace_timer_cb, NULL);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
static const char *
|
|
|
|
_places_human_size_get(unsigned long long size)
|
|
|
|
{
|
|
|
|
double dsize;
|
|
|
|
char hum[32], *suffix;
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
dsize = (double)size;
|
|
|
|
if (dsize < 1024)
|
2014-07-03 15:12:40 -07:00
|
|
|
snprintf(hum, sizeof(hum), "%.0f%s", dsize, D_("b"));
|
2008-12-06 10:51:04 -08:00
|
|
|
else
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
|
|
|
if (dsize < 1024)
|
2014-07-03 15:12:40 -07:00
|
|
|
suffix = N_("KB");
|
2010-08-25 01:23:59 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
|
|
|
if (dsize < 1024)
|
2014-07-03 15:12:40 -07:00
|
|
|
suffix = N_("MB");
|
2010-08-25 01:23:59 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
2014-07-03 15:07:22 -07:00
|
|
|
if(dsize < 1024)
|
2014-07-03 15:12:40 -07:00
|
|
|
suffix = N_("GB");
|
2014-07-03 15:07:22 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
2014-07-03 15:12:40 -07:00
|
|
|
suffix = N_("TB");
|
2014-07-03 15:07:22 -07:00
|
|
|
}
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
|
|
|
}
|
2014-07-03 15:12:40 -07:00
|
|
|
snprintf(hum, sizeof(hum), "%.1f%s", dsize, D_(suffix));
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
|
|
|
return eina_stringshare_add(hum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_places_run_fm_external(const char *fm, const char *directory)
|
|
|
|
{
|
2009-02-01 16:35:45 -08:00
|
|
|
char exec[PATH_MAX];
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2009-02-13 05:15:43 -08:00
|
|
|
snprintf(exec, PATH_MAX, "%s \"%s\"", (char*)fm, (char*)directory);
|
2015-03-15 06:00:08 -07:00
|
|
|
e_exec(e_zone_current_get(), NULL, exec, NULL, NULL);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-01-21 16:06:46 -08:00
|
|
|
_places_volume_object_update(Volume *vol, Evas_Object *obj)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
const char *tot_h;
|
|
|
|
const char *free_h;
|
2008-12-06 10:51:04 -08:00
|
|
|
char buf[256];
|
|
|
|
char buf2[16];
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// printf("PLACES: Object update for vol %s\n", vol->id);
|
|
|
|
|
|
|
|
// the volume label
|
2021-04-18 22:14:34 -07:00
|
|
|
if (eina_streq(vol->mount_point, "/"))
|
2012-01-21 16:06:46 -08:00
|
|
|
edje_object_part_text_set(obj, "volume_label", D_("Filesystem"));
|
2013-04-18 14:26:06 -07:00
|
|
|
else if (vol->label && vol->label[0])
|
2012-01-21 16:06:46 -08:00
|
|
|
edje_object_part_text_set(obj, "volume_label", vol->label);
|
|
|
|
else
|
|
|
|
edje_object_part_text_set(obj, "volume_label", D_("No Name"));
|
|
|
|
|
|
|
|
// the free label
|
2008-12-06 10:51:04 -08:00
|
|
|
tot_h = _places_human_size_get(vol->size);
|
|
|
|
if (vol->mounted)
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
free_h = _places_human_size_get(vol->free_space);
|
2010-08-25 01:23:59 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s %s %s", free_h, D_("free of"), tot_h);
|
|
|
|
edje_object_part_text_set(obj, "size_label", buf);
|
|
|
|
eina_stringshare_del(free_h);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
else
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), D_("%s Not Mounted"), tot_h);
|
|
|
|
edje_object_part_text_set(obj, "size_label", buf);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
eina_stringshare_del(tot_h);
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// the gauge
|
2008-12-06 10:51:04 -08:00
|
|
|
int percent;
|
|
|
|
Edje_Message_Float msg_float;
|
|
|
|
if (vol->mounted)
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
percent = 100 - (((long double)vol->free_space / (long double)vol->size) * 100);
|
2010-08-25 01:23:59 -07:00
|
|
|
snprintf(buf2, sizeof(buf2), "%d%%", percent);
|
|
|
|
edje_object_part_text_set(obj, "percent_label", buf2);
|
|
|
|
msg_float.val = (float)percent / 100;
|
|
|
|
edje_object_message_send(obj, EDJE_MESSAGE_FLOAT, 1, &msg_float);
|
2012-01-21 16:06:46 -08:00
|
|
|
edje_object_signal_emit(obj, "gauge,show", "places");
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
else
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
|
|
|
edje_object_signal_emit(obj, "gauge,hide", "places");
|
|
|
|
edje_object_part_text_set(obj, "percent_label", "");
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// the mount/eject icon
|
2015-01-11 14:01:28 -08:00
|
|
|
if (vol->mounted && vol->mount_point && vol->unmount_func &&
|
2021-04-18 22:14:34 -07:00
|
|
|
!eina_streq(vol->mount_point, "/"))
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
edje_object_signal_emit(obj, "icon,eject,show", "places");
|
|
|
|
edje_object_part_text_set(obj, "eject_label", D_("unmount"));
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2015-01-10 11:54:12 -08:00
|
|
|
else if (!vol->mounted && vol->eject_func &&
|
|
|
|
(vol->requires_eject || vol->removable))
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
|
|
|
edje_object_signal_emit(obj, "icon,eject,show", "places");
|
|
|
|
edje_object_part_text_set(obj, "eject_label", D_("eject"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(obj, "icon,eject,hide", "places");
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
|
|
|
|
/* EDJE Callbacks */
|
2008-12-06 10:51:04 -08:00
|
|
|
void
|
|
|
|
_places_icon_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source)
|
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
Volume *vol = data;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
|
|
|
if (vol->mounted)
|
2013-04-29 12:56:44 -07:00
|
|
|
places_run_fm(vol->mount_point);
|
2015-01-11 14:01:28 -08:00
|
|
|
else if (vol->mount_func)
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2012-01-26 13:20:55 -08:00
|
|
|
vol->force_open = EINA_TRUE;
|
2012-07-26 14:08:02 -07:00
|
|
|
places_volume_mount(vol);
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_places_eject_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Volume *vol = data;
|
|
|
|
|
|
|
|
if (vol->mounted)
|
2012-01-21 16:06:46 -08:00
|
|
|
places_volume_unmount(vol);
|
2008-12-06 10:51:04 -08:00
|
|
|
else
|
2012-01-21 16:06:46 -08:00
|
|
|
places_volume_eject(vol);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2012-01-24 13:59:50 -08:00
|
|
|
void
|
|
|
|
_places_header_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source)
|
|
|
|
{
|
2013-04-29 12:56:44 -07:00
|
|
|
places_run_fm(e_user_homedir_get());
|
2012-01-24 13:59:50 -08:00
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* E17 menu augmentation */
|
2021-04-24 08:17:07 -07:00
|
|
|
static Eina_List *_menu_strings = NULL;
|
|
|
|
|
2013-04-29 11:26:32 -07:00
|
|
|
void
|
2015-01-11 14:19:19 -08:00
|
|
|
_places_menu_folder_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
2013-04-29 11:26:32 -07:00
|
|
|
{
|
2015-01-11 14:19:19 -08:00
|
|
|
const char *folder = data;
|
|
|
|
|
|
|
|
places_run_fm(folder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_places_menu_volume_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|
|
|
{
|
|
|
|
Volume *vol = data;
|
|
|
|
|
|
|
|
if (vol->mounted)
|
|
|
|
places_run_fm(vol->mount_point);
|
|
|
|
else if (vol->mount_func)
|
|
|
|
{
|
|
|
|
vol->force_open = EINA_TRUE;
|
|
|
|
places_volume_mount(vol);
|
|
|
|
}
|
2013-04-29 11:26:32 -07:00
|
|
|
}
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
static void
|
|
|
|
_places_bookmarks_parse(E_Menu *em)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
char line[PATH_MAX];
|
|
|
|
char buf[PATH_MAX];
|
2021-04-24 08:17:07 -07:00
|
|
|
const char *s;
|
2012-01-21 16:06:46 -08:00
|
|
|
E_Menu_Item *mi;
|
|
|
|
Efreet_Uri *uri;
|
|
|
|
char *alias;
|
|
|
|
FILE* fp;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2021-04-24 08:17:07 -07:00
|
|
|
EINA_LIST_FREE(_menu_strings, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
|
2015-01-11 15:09:49 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/gtk-3.0/bookmarks", efreet_config_home_get());
|
2012-01-21 16:06:46 -08:00
|
|
|
fp = fopen(buf, "r");
|
2015-01-11 15:09:49 -08:00
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.gtk-bookmarks", e_user_homedir_get());
|
|
|
|
fp = fopen(buf, "r");
|
|
|
|
}
|
2012-01-21 16:06:46 -08:00
|
|
|
if (fp)
|
|
|
|
{
|
|
|
|
while(fgets(line, sizeof(line), fp))
|
|
|
|
{
|
|
|
|
alias = NULL;
|
|
|
|
line[strlen(line) - 1] = '\0';
|
|
|
|
alias = strchr(line, ' ');
|
|
|
|
if (alias)
|
|
|
|
{
|
|
|
|
line[alias-line] = '\0';
|
|
|
|
alias++;
|
|
|
|
}
|
|
|
|
uri = efreet_uri_decode(line);
|
2013-04-29 11:26:32 -07:00
|
|
|
if (uri && uri->path && ecore_file_exists(uri->path))
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
2013-04-29 11:26:32 -07:00
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, alias ? alias :
|
|
|
|
ecore_file_file_get(uri->path));
|
2021-04-23 23:55:04 -07:00
|
|
|
e_util_menu_item_theme_icon_set(mi, "user-bookmarks");
|
2021-04-24 08:17:07 -07:00
|
|
|
s = eina_stringshare_add(uri->path);
|
|
|
|
e_menu_item_callback_set(mi, _places_menu_folder_cb, s);
|
|
|
|
_menu_strings = eina_list_append(_menu_strings, s);
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
|
|
|
if (uri) efreet_uri_free(uri);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-21 16:06:46 -08:00
|
|
|
places_generate_menu(void *data, E_Menu *em)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
E_Menu_Item *mi;
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Home
|
|
|
|
if (places_conf->show_home)
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, D_("Home"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "user-home");
|
2015-01-11 14:19:19 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_menu_folder_cb, e_user_homedir_get());
|
2010-08-25 01:23:59 -07:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Desktop
|
|
|
|
if (places_conf->show_desk)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, D_("Desktop"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "user-desktop");
|
2015-01-11 14:19:19 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_menu_folder_cb, efreet_desktop_dir_get());
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Trash
|
|
|
|
if (places_conf->show_trash)
|
2012-01-17 13:46:33 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, D_("Trash"));
|
2012-07-26 15:28:09 -07:00
|
|
|
e_util_menu_item_theme_icon_set(mi, "user-trash");
|
2015-01-11 14:19:19 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_menu_folder_cb, "trash:///");
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// File System
|
|
|
|
if (places_conf->show_root)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, D_("Filesystem"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "drive-harddisk");
|
2015-01-11 14:19:19 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_menu_folder_cb, "/");
|
2012-01-17 13:46:33 -08:00
|
|
|
}
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Temp
|
|
|
|
if (places_conf->show_temp)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, D_("Temp"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "user-temp");
|
2015-01-11 14:19:19 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_menu_folder_cb, "/tmp");
|
2012-01-21 16:06:46 -08:00
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Separator
|
|
|
|
if (places_conf->show_home || places_conf->show_desk ||
|
|
|
|
places_conf->show_trash || places_conf->show_root ||
|
|
|
|
places_conf->show_temp)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_separator_set(mi, 1);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Volumes
|
|
|
|
Eina_Bool volumes_visible = 0;
|
|
|
|
const Eina_List *l;
|
|
|
|
Volume *vol;
|
|
|
|
EINA_LIST_FOREACH(volumes, l, vol)
|
2011-08-27 20:22:49 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
if (!vol->valid) continue;
|
2021-04-18 22:14:34 -07:00
|
|
|
if (eina_streq(vol->mount_point, "/")) continue;
|
2011-08-27 20:22:49 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
if ((vol->label) && (vol->label[0] != '\0'))
|
|
|
|
e_menu_item_label_set(mi, vol->label);
|
|
|
|
else
|
|
|
|
e_menu_item_label_set(mi, ecore_file_file_get(vol->mount_point));
|
|
|
|
|
|
|
|
if (vol->icon)
|
|
|
|
e_util_menu_item_theme_icon_set(mi, vol->icon);
|
2011-08-27 20:22:49 -07:00
|
|
|
|
2015-01-11 14:19:19 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_menu_volume_cb, vol);
|
2012-01-21 16:06:46 -08:00
|
|
|
volumes_visible = 1;
|
|
|
|
}
|
2011-08-27 20:22:49 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
// Favorites
|
|
|
|
if (places_conf->show_bookm)
|
|
|
|
{
|
|
|
|
if (volumes_visible)
|
2011-08-27 20:22:49 -07:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_separator_set(mi, 1);
|
2011-08-27 20:22:49 -07:00
|
|
|
}
|
2012-01-21 16:06:46 -08:00
|
|
|
_places_bookmarks_parse(em);
|
2011-08-27 20:22:49 -07:00
|
|
|
}
|
2011-02-22 15:08:27 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
e_menu_pre_activate_callback_set(em, NULL, NULL);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-21 16:06:46 -08:00
|
|
|
places_augmentation(void *data, E_Menu *em)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
E_Menu_Item *mi;
|
|
|
|
E_Menu *m;
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, D_("Places"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "system-file-manager");
|
2009-03-18 13:31:35 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
m = e_menu_new();
|
|
|
|
e_menu_item_submenu_set(mi, m);
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
e_menu_pre_activate_callback_set(m, places_generate_menu, NULL);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
2021-04-23 23:39:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
#undef PDBG
|