forked from enlightenment/enlightenment
Better use of label and icon for volumes, now everyone (inside e)
can use the same label and the same icon. Atm the icons in the menu are taken from efreet and thus from your icon theme...maybe icons found in the E17 theme should override the system one? SVN revision: 39337
This commit is contained in:
parent
b19ee965ee
commit
3200fe1b84
|
@ -94,6 +94,11 @@ e_fm2_hal_storage_find(const char *udi)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#define TEBIBYTE_SIZE 1099511627776LL
|
||||
#define GIBIBYTE_SIZE 1073741824
|
||||
#define MEBIBYTE_SIZE 1048576
|
||||
#define KIBIBYTE_SIZE 1024
|
||||
|
||||
EAPI void
|
||||
e_fm2_hal_volume_add(E_Volume *v)
|
||||
{
|
||||
|
@ -129,6 +134,7 @@ e_fm2_hal_volume_add(E_Volume *v)
|
|||
v->mount_point,
|
||||
v->parent);
|
||||
*/
|
||||
/* Check mount point */
|
||||
if ((!v->mount_point) || (v->mount_point[0] == 0))
|
||||
{
|
||||
if (v->mount_point) free(v->mount_point);
|
||||
|
@ -155,6 +161,7 @@ e_fm2_hal_volume_add(E_Volume *v)
|
|||
}
|
||||
}
|
||||
|
||||
/* Search parent storage */
|
||||
if ((s = e_fm2_hal_storage_find(v->parent)))
|
||||
{
|
||||
v->storage = s;
|
||||
|
@ -167,64 +174,29 @@ e_fm2_hal_volume_add(E_Volume *v)
|
|||
strcmp(v->mount_point, "/home") &&
|
||||
strcmp(v->mount_point, "/tmp"))))
|
||||
{
|
||||
_e_fm2_volume_write(v);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_hal_volume_del(E_Volume *v)
|
||||
{
|
||||
// printf("VOL- %s\n", v->udi);
|
||||
if (v->storage)
|
||||
v->storage->volumes = eina_list_remove(v->storage->volumes, v);
|
||||
_e_vols = eina_list_remove(_e_vols, v);
|
||||
_e_fm2_volume_erase(v);
|
||||
_e_volume_free(v);
|
||||
}
|
||||
|
||||
|
||||
#define TEBIBYTE_SIZE 1099511627776LL
|
||||
#define GIBIBYTE_SIZE 1073741824
|
||||
#define MEBIBYTE_SIZE 1048576
|
||||
#define KIBIBYTE_SIZE 1024
|
||||
|
||||
static void
|
||||
_e_fm2_volume_write(E_Volume *v)
|
||||
{
|
||||
char buf[PATH_MAX], buf2[PATH_MAX];
|
||||
FILE *f;
|
||||
const char *id;
|
||||
|
||||
if (!v->storage) return;
|
||||
id = ecore_file_file_get(v->storage->udi);
|
||||
// printf("vol write %s\n", id);
|
||||
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop",
|
||||
e_user_homedir_get(), id, v->partition_number);
|
||||
|
||||
f = fopen(buf, "w");
|
||||
if (f)
|
||||
{
|
||||
char *icon, label[1024] = {0}, size[256] = {0};
|
||||
unsigned long long s;
|
||||
char label[1024] = {0};
|
||||
char size[256] = {0};
|
||||
char *icon = NULL;
|
||||
unsigned long long sz;
|
||||
|
||||
/* Compute the size in a readable form */
|
||||
if (v->size)
|
||||
{
|
||||
if ((s = (v->size / TEBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu TiB"), s);
|
||||
else if ((s = (v->size / GIBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu GiB"), s);
|
||||
else if ((s = (v->size / MEBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu MiB"), s);
|
||||
else if ((s = (v->size / KIBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu KiB"), s);
|
||||
if ((sz = (v->size / TEBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu TiB"), sz);
|
||||
else if ((sz = (v->size / GIBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu GiB"), sz);
|
||||
else if ((sz = (v->size / MEBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu MiB"), sz);
|
||||
else if ((sz = (v->size / KIBIBYTE_SIZE)) > 0)
|
||||
snprintf(size, sizeof(size) - 1, _("%llu KiB"), sz);
|
||||
else
|
||||
snprintf(size, sizeof(size) - 1, _("%llu B"), v->size);
|
||||
}
|
||||
|
||||
/* Choose the label */
|
||||
if ((v->label) && (v->label[0]))
|
||||
snprintf(label, sizeof(label), "%s", v->label);
|
||||
{}
|
||||
else if ((v->partition_label) && (v->partition_label[0]))
|
||||
snprintf(label, sizeof(label) - 1, "%s", v->partition_label);
|
||||
else if (((v->storage->vendor) && (v->storage->vendor[0])) &&
|
||||
|
@ -252,10 +224,17 @@ _e_fm2_volume_write(E_Volume *v)
|
|||
else
|
||||
snprintf(label, sizeof(label), _("Unknown Volume"));
|
||||
|
||||
if ((label) && (label[0]))
|
||||
{
|
||||
if (v->label) free(v->label);
|
||||
v->label = strdup(label);
|
||||
}
|
||||
|
||||
/* Choose the icon */
|
||||
if (v->storage && v->storage->icon.volume)
|
||||
/* http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html */
|
||||
if (v->storage->icon.volume)
|
||||
icon = v->storage->icon.volume;
|
||||
else if (v->storage)
|
||||
else
|
||||
{
|
||||
if (!strcmp(v->storage->drive_type, "disk"))
|
||||
{
|
||||
|
@ -276,6 +255,44 @@ _e_fm2_volume_write(E_Volume *v)
|
|||
|| !strcmp(v->storage->drive_type, "sd_mmc"))
|
||||
icon = "media-flash";
|
||||
}
|
||||
if (icon)
|
||||
{
|
||||
if (v->icon) free(v->icon);
|
||||
v->icon = strdup(icon);
|
||||
}
|
||||
|
||||
_e_fm2_volume_write(v);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_hal_volume_del(E_Volume *v)
|
||||
{
|
||||
// printf("VOL- %s\n", v->udi);
|
||||
if (v->storage)
|
||||
v->storage->volumes = eina_list_remove(v->storage->volumes, v);
|
||||
_e_vols = eina_list_remove(_e_vols, v);
|
||||
_e_fm2_volume_erase(v);
|
||||
_e_volume_free(v);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm2_volume_write(E_Volume *v)
|
||||
{
|
||||
char buf[PATH_MAX], buf2[PATH_MAX];
|
||||
FILE *f;
|
||||
const char *id;
|
||||
|
||||
if (!v->storage) return;
|
||||
id = ecore_file_file_get(v->storage->udi);
|
||||
// printf("vol write %s\n", id);
|
||||
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop",
|
||||
e_user_homedir_get(), id, v->partition_number);
|
||||
|
||||
f = fopen(buf, "w");
|
||||
if (f)
|
||||
{
|
||||
|
||||
|
||||
fprintf(f,
|
||||
"[Desktop Entry]\n"
|
||||
|
@ -288,8 +305,8 @@ _e_fm2_volume_write(E_Volume *v)
|
|||
"Comment=%s\n"
|
||||
"URL=file:/%s\n"
|
||||
,
|
||||
label,
|
||||
icon,
|
||||
v->label,
|
||||
v->icon,
|
||||
_("Removable Device"),
|
||||
v->udi);
|
||||
fclose(f);
|
||||
|
|
|
@ -777,6 +777,7 @@ e_volume_add(const char *udi)
|
|||
if (!v) return NULL;
|
||||
// printf("VOL+ %s\n", udi);
|
||||
v->udi = strdup(udi);
|
||||
v->icon = NULL;
|
||||
_e_vols = eina_list_append(_e_vols, v);
|
||||
e_hal_device_get_all_properties(_e_dbus_conn, v->udi,
|
||||
_e_dbus_cb_vol_prop, v);
|
||||
|
|
|
@ -42,6 +42,7 @@ struct _E_Volume
|
|||
char *udi;
|
||||
char *uuid;
|
||||
char *label;
|
||||
char *icon;
|
||||
char *fstype;
|
||||
unsigned long long size;
|
||||
|
||||
|
@ -93,6 +94,7 @@ _e_volume_free(E_Volume *v)
|
|||
if (v->udi) free(v->udi);
|
||||
if (v->uuid) free(v->uuid);
|
||||
if (v->label) free(v->label);
|
||||
if (v->icon) free(v->icon);
|
||||
if (v->fstype) free(v->fstype);
|
||||
if (v->partition_label) free(v->partition_label);
|
||||
if (v->mount_point) free(v->mount_point);
|
||||
|
|
|
@ -227,7 +227,8 @@ _mount_ok(void *data)
|
|||
static void
|
||||
_mount_fail(void *data)
|
||||
{
|
||||
//TODO alert the user
|
||||
//TODO make a better dialog
|
||||
e_util_dialog_internal(_("Mount error"), _("Mount of device failed"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -265,12 +266,14 @@ _e_mod_fileman_parse_gtk_bookmarks(E_Menu *m)
|
|||
E_Menu_Item *mi;
|
||||
Efreet_Uri *uri;
|
||||
char *alias;
|
||||
char *icon;
|
||||
FILE* fp;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.gtk-bookmarks", e_user_homedir_get());
|
||||
fp = fopen(buf, "r");
|
||||
if (fp)
|
||||
{
|
||||
icon = efreet_icon_path_find(e_config->icon_theme, "folder", 16);
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
alias = NULL;
|
||||
|
@ -289,13 +292,14 @@ _e_mod_fileman_parse_gtk_bookmarks(E_Menu *m)
|
|||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, alias ? alias :
|
||||
ecore_file_file_get(uri->path));
|
||||
e_util_menu_item_edje_icon_set(mi, "fileman/folder");
|
||||
e_menu_item_icon_file_set(mi, icon);
|
||||
e_menu_item_callback_set(mi, _e_mod_menu_gtk_cb,
|
||||
strdup(uri->path));
|
||||
}
|
||||
}
|
||||
if (uri) efreet_uri_free(uri);
|
||||
}
|
||||
if (icon) free(icon);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
@ -305,6 +309,8 @@ void
|
|||
_e_mod_menu_generate(void *data, E_Menu *m)
|
||||
{
|
||||
E_Menu_Item *mi;
|
||||
E_Volume *vol;
|
||||
const Eina_List *l;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
/* Home */
|
||||
|
@ -349,15 +355,17 @@ _e_mod_menu_generate(void *data, E_Menu *m)
|
|||
|
||||
/* Volumes */
|
||||
Eina_Bool volumes_visible = 0;
|
||||
const Eina_List *l;
|
||||
E_Volume *vol;
|
||||
EINA_LIST_FOREACH(e_fm2_hal_volume_list_get(), l, vol)
|
||||
{
|
||||
char *icon;
|
||||
if (vol->mount_point && !strcmp(vol->mount_point, "/")) continue;
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, vol->label);
|
||||
icon = efreet_icon_path_find(e_config->icon_theme, vol->icon, 16);
|
||||
e_menu_item_icon_file_set(mi, icon);
|
||||
e_menu_item_callback_set(mi, _e_mod_menu_volume_cb, vol);
|
||||
volumes_visible = 1;
|
||||
if (icon) free(icon);
|
||||
}
|
||||
|
||||
/* Favorites */
|
||||
|
|
Loading…
Reference in New Issue