2011-08-27 20:22:49 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2008-12-06 10:51:04 -08:00
|
|
|
#include <e.h>
|
2010-01-11 02:23:02 -08:00
|
|
|
#include <sys/statvfs.h>
|
2008-12-06 10:51:04 -08:00
|
|
|
#include "e_mod_main.h"
|
|
|
|
#include "e_mod_places.h"
|
2012-01-22 13:14:47 -08:00
|
|
|
#ifdef HAVE_UDISKS
|
2012-01-21 16:06:46 -08:00
|
|
|
# include "e_mod_udisks.h"
|
2012-01-22 13:14:47 -08:00
|
|
|
#endif
|
2012-01-24 12:59:11 -08:00
|
|
|
#ifdef HAVE_EEZE
|
|
|
|
# include "e_mod_eeze.h"
|
|
|
|
#endif
|
2013-04-18 14:26:06 -07:00
|
|
|
#ifdef HAVE_EDBUS2
|
|
|
|
# include "e_mod_udisks_edbus2.h"
|
|
|
|
#endif
|
2011-08-27 20:22:49 -07:00
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
/* Local Function Prototypes */
|
2010-07-07 17:57:17 -07:00
|
|
|
static Eina_Bool _places_poller(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);
|
2012-01-26 13:20:55 -08:00
|
|
|
static void _places_run_fm(void *data, E_Menu *m, E_Menu_Item *mi);
|
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 */
|
2012-01-21 16:06:46 -08:00
|
|
|
static Ecore_Timer *poller = NULL;
|
2008-12-06 10:51:04 -08:00
|
|
|
static char theme_file[PATH_MAX];
|
2012-01-21 16:06:46 -08:00
|
|
|
Eina_List *volumes = NULL;
|
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
|
|
|
|
2012-01-17 13:46:33 -08:00
|
|
|
printf("PLACES: Init\n");
|
|
|
|
|
2012-01-22 13:14:47 -08:00
|
|
|
#ifdef HAVE_UDISKS
|
2012-01-21 16:06:46 -08:00
|
|
|
places_udisks_init();
|
2012-01-22 13:14:47 -08:00
|
|
|
#endif
|
2012-01-24 12:59:11 -08:00
|
|
|
#ifdef HAVE_EEZE
|
|
|
|
places_eeze_init();
|
|
|
|
#endif
|
2013-04-18 14:26:06 -07:00
|
|
|
#ifdef HAVE_EDBUS2
|
|
|
|
places_udisks_edbus2_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);
|
2010-12-05 01:39:05 -08:00
|
|
|
poller = ecore_timer_add(3.0, _places_poller, 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
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
if (poller) ecore_timer_del(poller);
|
2012-01-17 13:46:33 -08:00
|
|
|
|
2013-04-18 14:26:06 -07:00
|
|
|
while (volumes)
|
|
|
|
places_volume_del((Volume*)volumes->data);
|
|
|
|
|
2012-01-22 13:14:47 -08:00
|
|
|
#ifdef HAVE_UDISKS
|
2012-01-21 16:06:46 -08:00
|
|
|
places_udisks_shutdown();
|
2012-01-24 12:59:11 -08:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_EEZE
|
|
|
|
places_eeze_shutdown();
|
2012-01-22 13:14:47 -08:00
|
|
|
#endif
|
2013-04-18 14:26:06 -07:00
|
|
|
#ifdef HAVE_EDBUS2
|
|
|
|
places_udisks_edbus2_shutdown();
|
|
|
|
#endif
|
2012-01-17 13:46:33 -08:00
|
|
|
}
|
|
|
|
|
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("");
|
2012-01-26 13:20:55 -08:00
|
|
|
v->to_mount = EINA_FALSE;
|
|
|
|
v->force_open = EINA_FALSE;
|
2013-04-18 14:26:06 -07:00
|
|
|
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-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);
|
|
|
|
}
|
|
|
|
|
|
|
|
e_box_unpack(o);
|
|
|
|
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-18 14:26:06 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
free(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
if (!strcmp(v->id, id))
|
|
|
|
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;
|
|
|
|
|
2012-01-17 13:46:33 -08:00
|
|
|
// removable after interal
|
2009-01-25 14:20:23 -08:00
|
|
|
if (v1->removable && !v2->removable) return(1);
|
|
|
|
if (v2->removable && !v1->removable) return(-1);
|
2012-01-17 13:46:33 -08:00
|
|
|
// filesystem root on top
|
|
|
|
if (v1->mount_point && !strcmp(v1->mount_point, "/")) return -1;
|
|
|
|
if (v2->mount_point && !strcmp(v2->mount_point, "/")) return 1;
|
|
|
|
// order by label
|
2008-12-06 10:51:04 -08:00
|
|
|
if(!v1 || !v1->label) return(1);
|
|
|
|
if(!v2 || !v2->label) return(-1);
|
|
|
|
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)
|
|
|
|
places_fill_box(inst->o_box);
|
|
|
|
}
|
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
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
_places_run_fm((void*)vol->mount_point,NULL, NULL);
|
|
|
|
vol->force_open = EINA_FALSE;
|
|
|
|
}
|
2009-02-01 16:35:45 -08:00
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
void
|
|
|
|
places_fill_box(Evas_Object *box)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
places_empty_box(box);
|
|
|
|
|
2009-02-01 16:35:45 -08:00
|
|
|
/*if (places_conf->show_home)
|
|
|
|
_places_custom_volume(box, D_("Home"), "e/icons/fileman/home", "/home/dave");
|
|
|
|
if (places_conf->show_desk)
|
|
|
|
_places_custom_volume(box, D_("Desktop"), "e/icons/fileman/desktop", "/home/dave/Desktop");
|
|
|
|
if (places_conf->show_trash)
|
|
|
|
_places_custom_volume(box, D_("Trash"), "e/icons/fileman/trash", "trash:///");
|
|
|
|
if (places_conf->show_root)
|
|
|
|
_places_custom_volume(box, D_("Filesystem"), "e/icons/fileman/root", "/");
|
|
|
|
if (places_conf->show_temp)
|
|
|
|
_places_custom_volume(box, D_("Temp"), "e/icons/fileman/tmp", "/tmp");
|
|
|
|
*/
|
|
|
|
|
2012-01-24 15:54:10 -08:00
|
|
|
|
|
|
|
o = edje_object_add(evas_object_evas_get(box));
|
|
|
|
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"));
|
2012-01-17 13:46:33 -08:00
|
|
|
if (!e_box_orientation_get(box))
|
2012-01-24 15:54:10 -08:00
|
|
|
edje_object_signal_emit(o, "separator,set,horiz", "places");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(o, "separator,set,vert", "places");
|
|
|
|
edje_object_size_min_get(o, &min_w, &min_h);
|
|
|
|
edje_object_size_max_get(o, &max_w, &max_h);
|
|
|
|
evas_object_show(o);
|
|
|
|
e_box_pack_end(box, o);
|
|
|
|
e_box_pack_options_set(o,
|
|
|
|
1, 0, /* fill */
|
|
|
|
0, 0, /* expand */
|
|
|
|
0.5, 0.0, /* align */
|
|
|
|
min_w, min_h, /* min */
|
|
|
|
max_w, max_h /* max */
|
|
|
|
);
|
|
|
|
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
|
2010-08-25 01:23:59 -07:00
|
|
|
o = edje_object_add(evas_object_evas_get(box));
|
|
|
|
edje_object_file_set(o, theme_file, "modules/places/main");
|
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
|
|
|
|
icon = e_icon_add(evas_object_evas_get(box));
|
|
|
|
f1 = f2 = f3 = NULL;
|
|
|
|
/* optical discs */
|
2012-01-21 16:06:46 -08:00
|
|
|
if (!strcmp(vol->drive_type, "cdrom") ||
|
|
|
|
!strcmp(vol->drive_type, "optical_cd"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
f1 = "media"; f2 = "optical"; // OR media-optical ??
|
2010-12-07 20:05:09 -08:00
|
|
|
}
|
|
|
|
/* flash cards */
|
|
|
|
else if (!strcmp(vol->drive_type, "sd_mmc") ||
|
|
|
|
!strcmp(vol->model, "SD/MMC"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "sdmmc"; // NOTE sd-mmc in Oxigen :(
|
|
|
|
}
|
|
|
|
else if (!strcmp(vol->drive_type, "memory_stick") ||
|
|
|
|
!strcmp(vol->model, "MS/MS-Pro"))
|
|
|
|
{
|
|
|
|
f1 = "media"; f2 = "flash"; f3 = "ms"; // NOTE memory-stick in Oxigen :(
|
|
|
|
}
|
|
|
|
/* iPods */
|
2010-08-25 01:23:59 -07:00
|
|
|
else if (!strcmp(vol->model, "iPod"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
|
|
|
f1 = "multimedia-player"; f2 = "apple"; f3 = "ipod";
|
|
|
|
}
|
|
|
|
/* generic usb drives */
|
2012-01-17 13:46:33 -08:00
|
|
|
else if (!strcmp(vol->bus, "usb"))
|
2010-12-07 20:05:09 -08:00
|
|
|
{
|
|
|
|
f1 = "drive"; f2 = "removable-media"; f3 = "usb";
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if (!strcmp(vol->fstype, "ext2") || !strcmp(vol->fstype, "ext3") ||
|
|
|
|
!strcmp(vol->fstype, "ext4") || !strcmp(vol->fstype, "reiserfs"))
|
|
|
|
edje_object_signal_emit(o, "icon,tag,ext3", "places");
|
2011-02-22 15:08:27 -08:00
|
|
|
else if (!strcmp(vol->fstype, "ufs") || !strcmp(vol->fstype, "zfs"))
|
|
|
|
edje_object_signal_emit(o, "icon,tag,ufs", "places");
|
2010-08-25 01:23:59 -07:00
|
|
|
else if (!strcmp(vol->fstype, "vfat") || !strcmp(vol->fstype, "ntfs") ||
|
|
|
|
!strcmp(vol->fstype, "ntfs-3g"))
|
|
|
|
edje_object_signal_emit(o, "icon,tag,fat", "places");
|
|
|
|
else if (!strcmp(vol->fstype, "hfs") || !strcmp(vol->fstype, "hfsplus"))
|
|
|
|
edje_object_signal_emit(o, "icon,tag,hfs", "places");
|
|
|
|
else if (!strcmp(vol->fstype, "udf"))
|
|
|
|
edje_object_signal_emit(o, "icon,tag,dvd", "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
|
2010-08-25 01:23:59 -07:00
|
|
|
if (!e_box_orientation_get(box))
|
|
|
|
edje_object_signal_emit(o, "separator,set,horiz", "places");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(o, "separator,set,vert", "places");
|
|
|
|
|
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
|
|
|
evas_object_show(o);
|
|
|
|
edje_object_size_min_get(o, &min_w, &min_h);
|
|
|
|
edje_object_size_max_get(o, &max_w, &max_h);
|
2012-01-17 13:46:33 -08:00
|
|
|
e_box_pack_end(box, o);
|
2010-08-25 01:23:59 -07:00
|
|
|
e_box_pack_options_set(o,
|
|
|
|
1, 0, /* fill */
|
|
|
|
1, 0, /* expand */
|
|
|
|
0.5, 0.0, /* align */
|
|
|
|
min_w, min_h, /* min */
|
|
|
|
max_w, max_h /* max */
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
places_empty_box(Evas_Object *box)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
e_box_freeze(box);
|
|
|
|
count = e_box_pack_count_get(box);
|
|
|
|
while (count >= 0)
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
2013-04-18 14:26:06 -07:00
|
|
|
Volume *vol;
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *o, *swal;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2010-08-25 01:23:59 -07:00
|
|
|
o = e_box_pack_object_nth(box, count);
|
|
|
|
swal = edje_object_part_swallow_get(o, "icon");
|
|
|
|
if (swal)
|
|
|
|
{
|
|
|
|
edje_object_part_unswallow(o, swal);
|
|
|
|
evas_object_del(swal);
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2013-04-18 14:26:06 -07:00
|
|
|
EINA_LIST_FOREACH(volumes, l, vol)
|
|
|
|
vol->objs = eina_list_remove(vol->objs, o);
|
|
|
|
|
2010-08-25 01:23:59 -07:00
|
|
|
e_box_unpack(o);
|
|
|
|
evas_object_del(o);
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2010-08-25 01:23:59 -07:00
|
|
|
count--;
|
|
|
|
}
|
2008-12-06 10:51:04 -08:00
|
|
|
e_box_thaw(box);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if ((!strcmp(vol->fstype, "vfat")) || (!strcmp(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));
|
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);
|
|
|
|
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
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
void /* work in progrees */
|
|
|
|
_places_custom_volume(Evas_Object *box, const char *label, const char *icon, const char *uri)
|
|
|
|
{
|
|
|
|
int min_w, min_h, max_w, max_h;
|
|
|
|
Evas_Object *o, *i;
|
2009-02-01 16:35:45 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* volume object */
|
|
|
|
o = edje_object_add(evas_object_evas_get(box));
|
|
|
|
edje_object_file_set(o, theme_file, "modules/places/main");
|
2009-02-01 16:35:45 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* icon */
|
|
|
|
i = edje_object_add(evas_object_evas_get(box));
|
|
|
|
//edje_object_file_set(icon, theme_file, vol->icon);
|
|
|
|
edje_object_file_set(i, e_theme_edje_file_get("base/theme/fileman", icon),
|
|
|
|
icon);
|
|
|
|
edje_object_part_swallow(o, "icon", i);
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* label */
|
|
|
|
edje_object_part_text_set(o, "volume_label", label);
|
2010-08-25 01:23:59 -07:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* gauge */
|
|
|
|
edje_object_signal_emit(o, "gauge,hide", "places");
|
|
|
|
edje_object_part_text_set(o, "size_label", "");
|
2010-12-07 20:05:09 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* orient the separator*/
|
|
|
|
if (!e_box_orientation_get(box))
|
|
|
|
edje_object_signal_emit(o, "separator,set,horiz", "places");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(o, "separator,set,vert", "places");
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* connect signals from edje */
|
|
|
|
edje_object_signal_callback_add(o, "icon,activated", "places",
|
|
|
|
_places_custom_icon_activated_cb, (void*)uri);
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* pack the volume in the box */
|
|
|
|
evas_object_show(o);
|
|
|
|
edje_object_size_min_get(o, &min_w, &min_h);
|
|
|
|
edje_object_size_max_get(o, &max_w, &max_h);
|
|
|
|
e_box_pack_end(box, o);
|
|
|
|
e_box_pack_options_set(o,
|
|
|
|
1, 0, /* fill */
|
|
|
|
1, 0, /* expand */
|
|
|
|
0.5, 0.0, /* align */
|
|
|
|
min_w, min_h, /* min */
|
|
|
|
max_w, max_h /* max */
|
|
|
|
);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* Internals */
|
|
|
|
static unsigned long long
|
|
|
|
_places_free_space_get(const char *mount)
|
|
|
|
{
|
|
|
|
struct statvfs s;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
if (!mount) return 0;
|
|
|
|
if (statvfs(mount, &s) != 0)
|
|
|
|
return 0;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
return (unsigned long long)s.f_bavail * (unsigned long long)s.f_frsize;
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
2010-07-07 17:57:17 -07:00
|
|
|
static Eina_Bool
|
2008-12-06 10:51:04 -08:00
|
|
|
_places_poller(void *data)
|
|
|
|
{
|
2009-08-17 08:53:32 -07:00
|
|
|
Volume *vol;
|
2012-01-21 16:06:46 -08:00
|
|
|
Eina_List *l;
|
|
|
|
long long new;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2009-08-17 08:53:32 -07:00
|
|
|
EINA_LIST_FOREACH(volumes, l, vol)
|
|
|
|
if (vol->valid && vol->mounted)
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
|
|
|
new = _places_free_space_get(vol->mount_point);
|
|
|
|
// redraw only if the size has changed more that 1Mb
|
|
|
|
if (abs(new - vol->free_space) > 1024 * 1024)
|
|
|
|
{
|
|
|
|
vol->free_space = new;
|
|
|
|
places_volume_update(vol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-07 17:57:17 -07:00
|
|
|
return EINA_TRUE;
|
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)
|
2010-08-25 01:23:59 -07:00
|
|
|
snprintf(hum, sizeof(hum), "%.0fb", dsize);
|
2008-12-06 10:51:04 -08:00
|
|
|
else
|
2010-08-25 01:23:59 -07:00
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
|
|
|
if (dsize < 1024)
|
|
|
|
suffix = "KB";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
|
|
|
if (dsize < 1024)
|
|
|
|
suffix = "MB";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dsize /= 1024.0;
|
|
|
|
suffix = "GB";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snprintf(hum, sizeof(hum), "%.1f%s", dsize, suffix);
|
|
|
|
}
|
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);
|
2009-02-01 16:35:45 -08:00
|
|
|
e_exec(NULL, NULL, exec, NULL, NULL);
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_places_run_fm(void *data, E_Menu *m, E_Menu_Item *mi)
|
|
|
|
{
|
|
|
|
const char *directory = data;
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
if (places_conf->fm && places_conf->fm[0])
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2010-08-25 01:23:59 -07:00
|
|
|
_places_run_fm_external(places_conf->fm, directory);
|
|
|
|
return;
|
2008-12-06 10:51:04 -08:00
|
|
|
}
|
|
|
|
else
|
2012-01-21 16:06:46 -08:00
|
|
|
{
|
|
|
|
E_Action *act = e_action_find("fileman");
|
|
|
|
Eina_List *managers = e_manager_list();
|
|
|
|
|
|
|
|
if (act && act->func.go && managers && managers->data)
|
|
|
|
act->func.go(E_OBJECT(managers->data), directory);
|
|
|
|
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."));
|
|
|
|
}
|
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
|
|
|
|
if (vol->mount_point && !strcmp(vol->mount_point, "/"))
|
|
|
|
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
|
|
|
|
if (vol->mounted && vol->mount_point && strcmp(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
|
|
|
}
|
2012-01-21 16:06:46 -08:00
|
|
|
else if (!vol->mounted && (vol->requires_eject || vol->removable))
|
|
|
|
{
|
|
|
|
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)
|
2010-08-25 01:23:59 -07:00
|
|
|
_places_run_fm((void*)vol->mount_point, NULL, NULL);
|
2008-12-06 10:51:04 -08:00
|
|
|
else
|
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
|
|
|
}
|
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
void // work in progress
|
2009-02-01 16:35:45 -08:00
|
|
|
_places_custom_icon_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
//data is char *uri
|
|
|
|
_places_run_fm(data, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
_places_run_fm((char*)e_user_homedir_get(), NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
/* E17 menu augmentation */
|
|
|
|
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];
|
|
|
|
E_Menu_Item *mi;
|
|
|
|
Efreet_Uri *uri;
|
|
|
|
char *alias;
|
|
|
|
FILE* fp;
|
2008-12-06 10:51:04 -08:00
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.gtk-bookmarks", e_user_homedir_get());
|
|
|
|
fp = fopen(buf, "r");
|
|
|
|
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);
|
|
|
|
if (uri && uri->path)
|
|
|
|
{
|
|
|
|
if (ecore_file_exists(uri->path))
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(em);
|
|
|
|
e_menu_item_label_set(mi, alias ? alias :
|
|
|
|
ecore_file_file_get(uri->path));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "folder");
|
|
|
|
e_menu_item_callback_set(mi, _places_run_fm,
|
|
|
|
strdup(uri->path)); //TODO free somewhere
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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_menu_click_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
2008-12-06 10:51:04 -08:00
|
|
|
{
|
2012-01-21 16:06:46 -08:00
|
|
|
_places_icon_activated_cb(data, NULL, NULL, NULL);
|
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;
|
|
|
|
char buf[PATH_MAX];
|
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");
|
|
|
|
e_menu_item_callback_set(mi, _places_run_fm, (char*)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");
|
|
|
|
snprintf(buf, sizeof(buf), "%s/Desktop", (char*)e_user_homedir_get());
|
|
|
|
e_menu_item_callback_set(mi, _places_run_fm, strdup(buf)); //TODO free somewhere
|
|
|
|
}
|
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");
|
2012-01-21 16:06:46 -08:00
|
|
|
e_menu_item_callback_set(mi, _places_run_fm, "trash:///");
|
|
|
|
}
|
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");
|
|
|
|
e_menu_item_callback_set(mi, _places_run_fm, "/");
|
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");
|
|
|
|
e_menu_item_callback_set(mi, _places_run_fm, "/tmp");
|
|
|
|
}
|
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;
|
|
|
|
if (vol->mount_point && !strcmp(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
|
|
|
|
2012-01-21 16:06:46 -08:00
|
|
|
e_menu_item_callback_set(mi, places_menu_click_cb, vol);
|
|
|
|
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
|
|
|
}
|