forked from enlightenment/rage
add util funcs (move from browser to be shared) and use from main too
file recursion/listing will now use the same funcs as browser.c did - fast extn checks.
This commit is contained in:
parent
69cab3e815
commit
d682faf9b6
|
@ -6,6 +6,7 @@
|
||||||
#include "videothumb.h"
|
#include "videothumb.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "dnd.h"
|
#include "dnd.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
typedef struct _Message Message;
|
typedef struct _Message Message;
|
||||||
typedef struct _Entry Entry;
|
typedef struct _Entry Entry;
|
||||||
|
@ -120,72 +121,6 @@ _item_size_get(Evas_Object *win, Evas_Coord *w, Evas_Coord *h)
|
||||||
if (*h < sz) *h = sz;
|
if (*h < sz) *h = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_video_ok(const char *path)
|
|
||||||
{
|
|
||||||
const char *exts[] =
|
|
||||||
{
|
|
||||||
".asf", ".avi", ".bdm", ".bdmv", ".clpi", ".cpi", ".dv", ".fla",
|
|
||||||
".flv", ".m1v", ".m2t", ".m2v", ".m4v", ".mkv", ".mov", ".mp2",
|
|
||||||
".mp2ts", ".mp4", ".mpe", ".mpeg", ".mpg", ".mpl", ".mpls", ".mts",
|
|
||||||
".mxf", ".nut", ".nuv", ".ogg", ".ogm", ".ogv", ".qt", ".rm", ".rmj",
|
|
||||||
".rmm", ".rms", ".rmvb", ".rmx", ".rv", ".swf", ".ts", ".weba",
|
|
||||||
".webm", ".wmv", ".3g2", ".3gp", ".3gp2", ".3gpp", ".3gpp2", ".3p2",
|
|
||||||
".264",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
int i;
|
|
||||||
const char *ext = strrchr(path, '.');
|
|
||||||
if (!ext) return EINA_FALSE;
|
|
||||||
for (i = 0; exts[i]; i++)
|
|
||||||
{
|
|
||||||
if (!strcasecmp(ext, exts[i])) return EINA_TRUE;
|
|
||||||
}
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_audio_ok(const char *path)
|
|
||||||
{
|
|
||||||
const char *exts[] =
|
|
||||||
{
|
|
||||||
".mp3", ".m4a", ".oga", ".aac", ".flac", ".wav",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
int i;
|
|
||||||
const char *ext = strrchr(path, '.');
|
|
||||||
if (!ext) return EINA_FALSE;
|
|
||||||
for (i = 0; exts[i]; i++)
|
|
||||||
{
|
|
||||||
if (!strcasecmp(ext, exts[i])) return EINA_TRUE;
|
|
||||||
}
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
_videos_dir_get(void)
|
|
||||||
{
|
|
||||||
char buf[PATH_MAX];
|
|
||||||
const char *vids, *home;
|
|
||||||
char *vidsreal = NULL, *homereal = NULL;
|
|
||||||
|
|
||||||
vids = efreet_videos_dir_get();
|
|
||||||
if (vids) vidsreal = ecore_file_realpath(vids);
|
|
||||||
home = eina_environment_home_get();
|
|
||||||
if (home) homereal = ecore_file_realpath(home);
|
|
||||||
if ((vidsreal) && (homereal))
|
|
||||||
{
|
|
||||||
if (!strcmp(vidsreal, homereal)) vids = NULL;
|
|
||||||
}
|
|
||||||
free(vidsreal);
|
|
||||||
free(homereal);
|
|
||||||
if (vids)
|
|
||||||
snprintf(buf, sizeof(buf), "%s", vids);
|
|
||||||
else
|
|
||||||
snprintf(buf, sizeof(buf), "%s/Videos", eina_environment_home_get());
|
|
||||||
return strdup(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_fill_message(Ecore_Thread *th, Type type, Entry *entry)
|
_fill_message(Ecore_Thread *th, Type type, Entry *entry)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +176,7 @@ _fill_scan(Ecore_Thread *th, Entry *parent, const char *dir)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_video_ok(file) || _audio_ok(file))
|
if (util_video_ok(file) || util_audio_ok(file))
|
||||||
{
|
{
|
||||||
eina_lock_take(&(entry->lock));
|
eina_lock_take(&(entry->lock));
|
||||||
entry->files = eina_list_append
|
entry->files = eina_list_append
|
||||||
|
@ -817,7 +752,7 @@ _fill(Evas_Object *win)
|
||||||
dir_entry = NULL;
|
dir_entry = NULL;
|
||||||
fdat = malloc(sizeof(Fill_Data));
|
fdat = malloc(sizeof(Fill_Data));
|
||||||
if (!fdat) return;
|
if (!fdat) return;
|
||||||
fdat->videos = _videos_dir_get();
|
fdat->videos = util_videos_dir_get();
|
||||||
fdat->win = win;
|
fdat->win = win;
|
||||||
eina_semaphore_new(&step_sema, 0);
|
eina_semaphore_new(&step_sema, 0);
|
||||||
fill_thread = ecore_thread_feedback_run(_fill_thread, _fill_feedback,
|
fill_thread = ecore_thread_feedback_run(_fill_thread, _fill_feedback,
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "browser.h"
|
#include "browser.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "mpris.h"
|
#include "mpris.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#define DEPTH_DEFAULT 99
|
#define DEPTH_DEFAULT 99
|
||||||
|
|
||||||
|
@ -121,7 +122,6 @@ _cb_feedback_recursion(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg)
|
||||||
{
|
{
|
||||||
Recursion_Data *recursion;
|
Recursion_Data *recursion;
|
||||||
Eina_List *list;
|
Eina_List *list;
|
||||||
const char *mime;
|
|
||||||
const char *path;
|
const char *path;
|
||||||
Eina_Bool update_content = EINA_FALSE;
|
Eina_Bool update_content = EINA_FALSE;
|
||||||
|
|
||||||
|
@ -130,10 +130,7 @@ _cb_feedback_recursion(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg)
|
||||||
|
|
||||||
EINA_LIST_FREE(list, path)
|
EINA_LIST_FREE(list, path)
|
||||||
{
|
{
|
||||||
mime = efreet_mime_type_get(path);
|
if (util_video_ok(path) || util_audio_ok(path))
|
||||||
if ((!mime) ||
|
|
||||||
(!strncmp(mime, "audio/", 6)) ||
|
|
||||||
(!strncmp(mime, "video/", 6)))
|
|
||||||
{
|
{
|
||||||
update_content = EINA_TRUE;
|
update_content = EINA_TRUE;
|
||||||
win_list_hide(recursion->win);
|
win_list_hide(recursion->win);
|
||||||
|
|
|
@ -14,7 +14,8 @@ executable('rage', [
|
||||||
'videothumb.c', 'videothumb.h',
|
'videothumb.c', 'videothumb.h',
|
||||||
'albumart.c', 'albumart.h',
|
'albumart.c', 'albumart.h',
|
||||||
'browser.c', 'browser.h',
|
'browser.c', 'browser.h',
|
||||||
'mpris.c', 'mpris.h'
|
'mpris.c', 'mpris.h',
|
||||||
|
'util.c', 'util.h'
|
||||||
],
|
],
|
||||||
include_directories: inc,
|
include_directories: inc,
|
||||||
dependencies : deps,
|
dependencies : deps,
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
#include "main.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
util_video_ok(const char *path)
|
||||||
|
{
|
||||||
|
const char *exts[] =
|
||||||
|
{
|
||||||
|
".asf", ".avi", ".bdm", ".bdmv", ".clpi", ".cpi", ".dv", ".fla",
|
||||||
|
".flv", ".m1v", ".m2t", ".m2v", ".m4v", ".mkv", ".mov", ".mp2",
|
||||||
|
".mp2ts", ".mp4", ".mpe", ".mpeg", ".mpg", ".mpl", ".mpls", ".mts",
|
||||||
|
".mxf", ".nut", ".nuv", ".ogg", ".ogm", ".ogv", ".qt", ".rm", ".rmj",
|
||||||
|
".rmm", ".rms", ".rmvb", ".rmx", ".rv", ".swf", ".ts", ".weba",
|
||||||
|
".webm", ".wmv", ".3g2", ".3gp", ".3gp2", ".3gpp", ".3gpp2", ".3p2",
|
||||||
|
".264",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
const char *ext = strrchr(path, '.');
|
||||||
|
if (!ext) return EINA_FALSE;
|
||||||
|
for (i = 0; exts[i]; i++)
|
||||||
|
{
|
||||||
|
if (!strcasecmp(ext, exts[i])) return EINA_TRUE;
|
||||||
|
}
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
util_audio_ok(const char *path)
|
||||||
|
{
|
||||||
|
const char *exts[] =
|
||||||
|
{
|
||||||
|
".mp3", ".m4a", ".oga", ".aac", ".flac", ".wav",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
const char *ext = strrchr(path, '.');
|
||||||
|
if (!ext) return EINA_FALSE;
|
||||||
|
for (i = 0; exts[i]; i++)
|
||||||
|
{
|
||||||
|
if (!strcasecmp(ext, exts[i])) return EINA_TRUE;
|
||||||
|
}
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
util_videos_dir_get(void)
|
||||||
|
{
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
const char *vids, *home;
|
||||||
|
char *vidsreal = NULL, *homereal = NULL;
|
||||||
|
|
||||||
|
vids = efreet_videos_dir_get();
|
||||||
|
if (vids) vidsreal = ecore_file_realpath(vids);
|
||||||
|
home = eina_environment_home_get();
|
||||||
|
if (home) homereal = ecore_file_realpath(home);
|
||||||
|
if ((vidsreal) && (homereal))
|
||||||
|
{
|
||||||
|
if (!strcmp(vidsreal, homereal)) vids = NULL;
|
||||||
|
}
|
||||||
|
free(vidsreal);
|
||||||
|
free(homereal);
|
||||||
|
if (vids)
|
||||||
|
snprintf(buf, sizeof(buf), "%s", vids);
|
||||||
|
else
|
||||||
|
snprintf(buf, sizeof(buf), "%s/Videos", eina_environment_home_get());
|
||||||
|
return strdup(buf);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _UTIL_H__
|
||||||
|
#define _UTIL_H__ 1
|
||||||
|
|
||||||
|
Eina_Bool util_video_ok(const char *path);
|
||||||
|
Eina_Bool util_audio_ok(const char *path);
|
||||||
|
char *util_videos_dir_get(void);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue