parent
8482b27924
commit
145c3fcfb4
122
src/e_mod_main.c
122
src/e_mod_main.c
|
@ -3,9 +3,11 @@
|
|||
*/
|
||||
|
||||
#include "e.h"
|
||||
#include "e_fm_dbus.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "evry_api.h"
|
||||
|
||||
|
||||
/* #undef DBG
|
||||
* #define DBG(...) ERR(__VA_ARGS__) */
|
||||
|
||||
|
@ -24,6 +26,9 @@ static Evry_Module *evry_module = NULL;
|
|||
static Evry_Plugin *_plug = NULL;
|
||||
static const char _module_icon[] = "find";
|
||||
static const char *_mime_dir;
|
||||
static const char *_mime_mount;
|
||||
static Evry_Action *act_mount;
|
||||
static Evry_Action *act_umount;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -39,11 +44,29 @@ _item_free(Evry_Item *it)
|
|||
E_FREE(file);
|
||||
}
|
||||
|
||||
/* taken from fileman module */
|
||||
static void
|
||||
_parse_gtk_bookmarks(Plugin *p)
|
||||
static Evry_Item *
|
||||
_item_add(Plugin *p, const char *label, const char *path, const char *mime, const char *icon)
|
||||
{
|
||||
Evry_Item_File *file;
|
||||
|
||||
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, _item_free);
|
||||
|
||||
if (!path) path = "";
|
||||
file->path = eina_stringshare_add(path);
|
||||
file->mime = eina_stringshare_ref(mime);
|
||||
if (icon) EVRY_ITEM_ICON_SET(file, icon);
|
||||
EVRY_ITEM(file)->id = eina_stringshare_ref(file->path);
|
||||
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
p->files = eina_list_append(p->files, file);
|
||||
|
||||
return EVRY_ITEM(file);
|
||||
}
|
||||
|
||||
/* taken from fileman module */
|
||||
static void
|
||||
_gtk_bookmarks_add(Plugin *p)
|
||||
{
|
||||
char line[PATH_MAX];
|
||||
char buf[PATH_MAX];
|
||||
E_Menu_Item *mi;
|
||||
|
@ -78,17 +101,7 @@ _parse_gtk_bookmarks(Plugin *p)
|
|||
continue;
|
||||
}
|
||||
|
||||
file = EVRY_ITEM_NEW(Evry_Item_File, p,
|
||||
ecore_file_file_get(uri->path),
|
||||
NULL, _item_free);
|
||||
printf("%s\n", uri->path);
|
||||
|
||||
file->path = eina_stringshare_add(uri->path);
|
||||
file->mime = eina_stringshare_ref(_mime_dir);
|
||||
EVRY_ITEM(file)->id = eina_stringshare_ref(file->path);
|
||||
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
p->files = eina_list_append(p->files, file);
|
||||
_item_add(p, ecore_file_file_get(uri->path), uri->path, _mime_dir, NULL);
|
||||
|
||||
efreet_uri_free(uri);
|
||||
}
|
||||
|
@ -96,6 +109,28 @@ _parse_gtk_bookmarks(Plugin *p)
|
|||
|
||||
}
|
||||
|
||||
static void
|
||||
_volume_list_add(Plugin *p)
|
||||
{
|
||||
const Eina_List *l;
|
||||
Evry_Item *it;
|
||||
Eina_Bool volumes_visible = 0;
|
||||
E_Volume *vol;
|
||||
EINA_LIST_FOREACH(e_fm2_dbus_volume_list_get(), l, vol)
|
||||
{
|
||||
if (vol->mount_point && !strcmp(vol->mount_point, "/")) continue;
|
||||
|
||||
it = _item_add(p, vol->label, vol->mount_point, _mime_mount, vol->icon);
|
||||
if (it)
|
||||
{
|
||||
if (!vol->mounted)
|
||||
it->browseable = EINA_FALSE;
|
||||
|
||||
it->data = vol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *item)
|
||||
{
|
||||
|
@ -105,15 +140,11 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
GET_PLUGIN(p, plugin);
|
||||
|
||||
e_user_dir_concat_static(path, "backgrounds");
|
||||
file = EVRY_ITEM_NEW(Evry_Item_File, p, N_("Wallpaper"), NULL, _item_free);
|
||||
file->path = eina_stringshare_add(path);
|
||||
file->mime = eina_stringshare_ref(_mime_dir);
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
EVRY_ITEM(file)->id = eina_stringshare_ref(file->path);
|
||||
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
||||
p->files = eina_list_append(p->files, file);
|
||||
_item_add(p, N_("Wallpaper"), path, _mime_dir, NULL);
|
||||
|
||||
_parse_gtk_bookmarks(p);
|
||||
_gtk_bookmarks_add(p);
|
||||
|
||||
_volume_list_add(p);
|
||||
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
@ -149,6 +180,46 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
return !!(p->base.items);
|
||||
}
|
||||
|
||||
/* static int
|
||||
* _check_mount(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
* {
|
||||
* GET_FILE(file, it);
|
||||
* if (file->mime == _mime_mount)
|
||||
* return 1;
|
||||
*
|
||||
* return 0;
|
||||
* }
|
||||
*
|
||||
* static int
|
||||
* _act_mount(Evry_Action *act)
|
||||
* {
|
||||
* GET_FILE(file, act->it1.item);
|
||||
* GET_ITEM(it, act->it1.item);
|
||||
*
|
||||
* E_Volume *vol = it->data;
|
||||
* if (vol->mounted)
|
||||
* {
|
||||
* if (m->zone)
|
||||
* e_fwin_new(m->zone->container, NULL, vol->mount_point);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* Eina_List *opt = NULL;
|
||||
* char buf[256];
|
||||
*
|
||||
* if (!vol->mount_point)
|
||||
* vol->mount_point = e_fm2_dbus_volume_mountpoint_get(vol);
|
||||
*
|
||||
* if ((!strcmp(vol->fstype, "vfat")) || (!strcmp(vol->fstype, "ntfs")))
|
||||
* {
|
||||
* snprintf(buf, sizeof(buf), "uid=%i", (int)getuid());
|
||||
* opt = eina_list_append(opt, buf);
|
||||
* }
|
||||
*
|
||||
* e_hal_device_volume_mount(conn, vol->udi, vol->mount_point, vol->fstype, opt, NULL, vol);
|
||||
* }
|
||||
* } */
|
||||
|
||||
static int
|
||||
_plugins_init(const Evry_API *api)
|
||||
{
|
||||
|
@ -163,6 +234,7 @@ _plugins_init(const Evry_API *api)
|
|||
return EINA_FALSE;
|
||||
|
||||
_mime_dir = eina_stringshare_add("inode/directory");
|
||||
_mime_mount = eina_stringshare_add("inode/mount-point");
|
||||
|
||||
_plug = EVRY_PLUGIN_NEW(Plugin, N_("Places"), NULL, EVRY_TYPE_FILE,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
|
@ -173,6 +245,11 @@ _plugins_init(const Evry_API *api)
|
|||
* p->config->min_query = 3; */
|
||||
}
|
||||
|
||||
/* act_mount = EVRY_ACTIOn_NEW(N_("Mount Drive"), EVRY_TYPE_FILE, 0, NULL, _act_mount, _check_mount);
|
||||
* EVRY_ITEM_DATA_INT_SET(act_mount, 0);
|
||||
* act_umount = EVRY_ACTIOn_NEW(N_("Unmount Drive"), EVRY_TYPE_FILE, 0, NULL, _act_mount, _check_mount);
|
||||
* EVRY_ITEM_DATA_INT_SET(act_mount, 1); */
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -184,6 +261,7 @@ _plugins_shutdown(void)
|
|||
if (!evry_module->active) return;
|
||||
|
||||
eina_stringshare_del(_mime_dir);
|
||||
eina_stringshare_del(_mime_mount);
|
||||
|
||||
EVRY_PLUGIN_FREE(_plug);
|
||||
|
||||
|
|
Loading…
Reference in New Issue