Formatting.

SVN revision: 26017
This commit is contained in:
David Walter Seikel 2006-09-22 06:08:42 +00:00
parent f9a0087270
commit e21eff359b
5 changed files with 992 additions and 890 deletions

File diff suppressed because it is too large Load Diff

View File

@ -55,58 +55,61 @@ struct _ecore_desktop_menu_legacy_data
int length, menu_length, level; int length, menu_length, level;
}; };
static int _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level); static int _ecore_desktop_menu_make_apps(const void *data,
static Ecore_Desktop_Tree *_ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level);
static Ecore_Desktop_Tree *_ecore_desktop_menu_create_menu();
static int _ecore_desktop_menu_unxml(const void *data,
Ecore_Desktop_Tree * tree,
int element, int level);
static int _ecore_desktop_menu_check_directory(void *data,
const char *path);
static int _ecore_desktop_menu_check_menu(void *data,
const char *path);
static int _ecore_desktop_menu_legacy_menu_dir(void *data,
const char *path);
static int _ecore_desktop_menu_legacy_menu(void *data,
const char *path);
static void _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
Ecore_Desktop_Tree * tree,
char type, char sub_type);
static void _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu,
Ecore_Desktop_Tree * tree);
static void _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree,
Ecore_List * paths, char *pre,
char *post, char *extra,
int element);
static int _ecore_desktop_menu_expand_apps(struct
_ecore_desktop_menu_unxml_data
*unxml_data, char *app_dir,
Ecore_Hash * pool);
static int _ecore_desktop_menu_check_app(void *data,
const char *path);
static int _ecore_desktop_menu_merge(const void *data,
Ecore_Desktop_Tree * tree,
int element, int level);
static int _ecore_desktop_menu_expand_default_dirs(const void *data,
Ecore_Desktop_Tree
* tree,
int element,
int level);
static int _ecore_desktop_menu_generate(const void *data,
Ecore_Desktop_Tree * tree, Ecore_Desktop_Tree * tree,
int element, int level); int element, int level);
static Ecore_Desktop_Tree *_ecore_desktop_menu_get0(char *file,
Ecore_Desktop_Tree *
merge_stack, int level);
static Ecore_Desktop_Tree *_ecore_desktop_menu_create_menu();
static int _ecore_desktop_menu_unxml(const void *data,
Ecore_Desktop_Tree * tree,
int element, int level);
static int _ecore_desktop_menu_check_directory(void *data,
const char *path);
static int _ecore_desktop_menu_check_menu(void *data,
const char *path);
static int _ecore_desktop_menu_legacy_menu_dir(void *data,
const char *path);
static int _ecore_desktop_menu_legacy_menu(void *data,
const char *path);
static void _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
Ecore_Desktop_Tree * tree,
char type, char sub_type);
static void _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu,
Ecore_Desktop_Tree * tree);
static void _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree,
Ecore_List * paths, char *pre,
char *post, char *extra,
int element);
static int _ecore_desktop_menu_expand_apps(struct
_ecore_desktop_menu_unxml_data
*unxml_data, char *app_dir,
Ecore_Hash * pool);
static int _ecore_desktop_menu_check_app(void *data, const char *path);
static int _ecore_desktop_menu_merge(const void *data,
Ecore_Desktop_Tree * tree,
int element, int level);
static int _ecore_desktop_menu_expand_default_dirs(const void *data,
Ecore_Desktop_Tree
* tree,
int element,
int level);
static int _ecore_desktop_menu_generate(const void *data,
Ecore_Desktop_Tree * tree,
int element, int level);
static void _ecore_desktop_menu_inherit_apps(void *value, static void _ecore_desktop_menu_inherit_apps(void *value,
void *user_data); void *user_data);
static void _ecore_desktop_menu_select_app(void *value, static void _ecore_desktop_menu_select_app(void *value,
void *user_data); void *user_data);
static int _ecore_desktop_menu_apply_rules(struct static int _ecore_desktop_menu_apply_rules(struct
_ecore_desktop_menu_generate_data _ecore_desktop_menu_generate_data
*generate_data, *generate_data,
Ecore_Desktop_Tree * rule, Ecore_Desktop_Tree * rule,
char *key, char *key,
Ecore_Desktop * desktop); Ecore_Desktop * desktop);
/** /**
* @defgroup Ecore_Desktop_Menu_Group menu Functions * @defgroup Ecore_Desktop_Menu_Group menu Functions
@ -114,70 +117,74 @@ static int _ecore_desktop_menu_apply_rules(struct
* Functions that deal with freedesktop.org menus. * Functions that deal with freedesktop.org menus.
*/ */
EAPI void EAPI void
ecore_desktop_menu_for_each(void (*func)(char *name, char *path, Ecore_Hash *apps)) ecore_desktop_menu_for_each(void (*func)
(char *name, char *path, Ecore_Hash * apps))
{ {
char *menu_file; char *menu_file;
/* Find the main menu file. */ /* Find the main menu file. */
menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus,
"applications.menu", -1, NULL, NULL); "applications.menu", -1, NULL,
NULL);
if (!menu_file) if (!menu_file)
{ {
/* Try various quirks of various systems. */ /* Try various quirks of various systems. */
menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus,
"debian-menu.menu", -1, NULL, NULL); "debian-menu.menu", -1, NULL,
/* FIXME: If all else fails, run debians funky menu generator shit. */ NULL);
} /* FIXME: If all else fails, run debians funky menu generator shit. */
}
if (menu_file) if (menu_file)
{ {
Ecore_Desktop_Tree *menus; Ecore_Desktop_Tree *menus;
/* convert the xml into menus */ /* convert the xml into menus */
menus = ecore_desktop_menu_get(menu_file); menus = ecore_desktop_menu_get(menu_file);
if (menus) if (menus)
{ {
/* create the .desktop and order files from the menu */ /* create the .desktop and order files from the menu */
ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps, func); ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps,
func);
// FIXME: Can't free this just yet, causes major memory corruption. // FIXME: Can't free this just yet, causes major memory corruption.
// ecore_desktop_tree_del(menus); // ecore_desktop_tree_del(menus);
} }
free(menu_file); free(menu_file);
} }
} }
static int static int
_ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level) _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree,
int element, int level)
{ {
if (tree->elements[element].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING) if (tree->elements[element].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING)
{ {
if (strncmp((char *)tree->elements[element].element, "<MENU ", 6) == 0) if (strncmp((char *)tree->elements[element].element, "<MENU ", 6) == 0)
{ {
char *path; char *path;
char *name; char *name;
Ecore_Hash *apps; Ecore_Hash *apps;
void (*func)(char *name, char *path, Ecore_Hash *apps); void (*func) (char *name, char *path,
Ecore_Hash * apps);
func = data; func = data;
name = (char *)tree->elements[element].element; name = (char *)tree->elements[element].element;
path = (char *)tree->elements[element + 1].element; path = (char *)tree->elements[element + 1].element;
#ifdef DEBUG #ifdef DEBUG
printf("MAKING MENU - %s \t\t%s\n", path, name); printf("MAKING MENU - %s \t\t%s\n", path, name);
#endif #endif
// pool = (Ecore_Hash *) tree->elements[element + 2].element; // pool = (Ecore_Hash *) tree->elements[element + 2].element;
apps = (Ecore_Hash *) tree->elements[element + 4].element; apps = (Ecore_Hash *) tree->elements[element + 4].element;
path = &path[11]; path = &path[11];
if (func) if (func)
func(name, path, apps); func(name, path, apps);
} }
} }
return 0; return 0;
} }
/** /**
* Decode a freedesktop.org menu XML jungle. * Decode a freedesktop.org menu XML jungle.
* *
@ -192,11 +199,12 @@ _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int e
Ecore_Desktop_Tree * Ecore_Desktop_Tree *
ecore_desktop_menu_get(char *file) ecore_desktop_menu_get(char *file)
{ {
return _ecore_desktop_menu_get0(file, NULL, 0); return _ecore_desktop_menu_get0(file, NULL, 0);
} }
static Ecore_Desktop_Tree * static Ecore_Desktop_Tree *
_ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level) _ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack,
int level)
{ {
Ecore_Desktop_Tree *menu_xml; Ecore_Desktop_Tree *menu_xml;
struct _ecore_desktop_menu_unxml_data data; struct _ecore_desktop_menu_unxml_data data;
@ -314,7 +322,7 @@ _ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level
static int static int
_ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree, _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
int element, int level) int element, int level)
{ {
struct _ecore_desktop_menu_unxml_data *unxml_data; struct _ecore_desktop_menu_unxml_data *unxml_data;
@ -517,9 +525,8 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
"<Menu") == 0) "<Menu") == 0)
{ {
_ecore_desktop_menu_unxml(data, sub, _ecore_desktop_menu_unxml(data, sub,
0, 0,
level + level + 1);
1);
ecore_desktop_tree_add_child(menu, ecore_desktop_tree_add_child(menu,
(Ecore_Desktop_Tree (Ecore_Desktop_Tree
*) *)
@ -551,8 +558,9 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree,
(((char *)sub->elements[1]. (((char *)sub->elements[1].
element)[0] != '<')) element)[0] != '<'))
{ {
char char
temp[PATH_MAX];
temp[PATH_MAX];
sprintf(temp, "%s %s", sprintf(temp, "%s %s",
(char *)sub-> (char *)sub->
@ -717,48 +725,50 @@ _ecore_desktop_menu_legacy_menu_dir(void *data, const char *path)
count = 0; count = 0;
temp_path = strdup(path); temp_path = strdup(path);
if (temp_path) if (temp_path)
{ {
for (i = legacy_data->length; temp_path[i] != '\0'; i++) for (i = legacy_data->length; temp_path[i] != '\0'; i++)
{ {
if (temp_path[i] == '/') if (temp_path[i] == '/')
{ {
if (count >= legacy_data->level) if (count >= legacy_data->level)
{ {
temp_path[i] = '\0'; temp_path[i] = '\0';
menu = _ecore_desktop_menu_create_menu(); menu = _ecore_desktop_menu_create_menu();
if (menu) if (menu)
{ {
char temp[PATH_MAX]; char temp[PATH_MAX];
sprintf(temp, "<MENU < L> <%s> <>", &temp_path[start]); sprintf(temp, "<MENU < L> <%s> <>",
menu->elements[0].element = strdup(temp); &temp_path[start]);
ecore_desktop_tree_track(menu, menu->elements[0].element = strdup(temp);
menu->elements[0].element); ecore_desktop_tree_track(menu,
sprintf(temp, "<MENU_PATH %s/%s", legacy_data->menu, menu->elements[0].element);
&temp_path[legacy_data->length]); sprintf(temp, "<MENU_PATH %s/%s", legacy_data->menu,
menu->elements[1].element = strdup(temp); &temp_path[legacy_data->length]);
ecore_desktop_tree_track(menu, menu->elements[1].element = strdup(temp);
menu->elements[1].element); ecore_desktop_tree_track(menu,
menu->elements[1].element);
ecore_desktop_tree_add_child(legacy_data->current, menu); ecore_desktop_tree_add_child(legacy_data->current,
/* This is not needed, but if it was, this is where it would go. menu);
* sprintf(temp, "<AppDir %s/", temp_path); /* This is not needed, but if it was, this is where it would go.
* ecore_desktop_tree_extend(menu, temp); * sprintf(temp, "<AppDir %s/", temp_path);
*/ * ecore_desktop_tree_extend(menu, temp);
sprintf(temp, "<DirectoryDir %s/", temp_path); */
ecore_desktop_tree_extend(menu, temp); sprintf(temp, "<DirectoryDir %s/", temp_path);
ecore_desktop_tree_extend(menu, temp);
legacy_data->current = menu; legacy_data->current = menu;
legacy_data->level++; legacy_data->level++;
} }
temp_path[i] = '/'; temp_path[i] = '/';
} }
start = i + 1; start = i + 1;
count++; count++;
} }
} }
free(temp_path); free(temp_path);
} }
legacy_data->level = count; legacy_data->level = count;
@ -828,7 +838,7 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path)
menu_count = strlen(menu_path); menu_count = strlen(menu_path);
if (menu_count) if (menu_count)
menu_count++; menu_count++;
file = (char *) &path[legacy_data->length + menu_count]; file = (char *)&path[legacy_data->length + menu_count];
count = strlen(file); count = strlen(file);
if (strcmp(".directory", file) == 0) if (strcmp(".directory", file) == 0)
@ -860,7 +870,9 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path)
sprintf(temp, "%s%s", legacy_data->prefix, file); sprintf(temp, "%s%s", legacy_data->prefix, file);
ecore_hash_set(pool, strdup(temp), strdup(path)); ecore_hash_set(pool, strdup(temp), strdup(path));
#ifdef DEBUG #ifdef DEBUG
printf("POOLING - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s - %s\n", path, file, temp); printf
("POOLING - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s - %s\n",
path, file, temp);
#endif #endif
if (rules->size > 0) if (rules->size > 0)
{ {
@ -871,7 +883,8 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path)
} }
#ifdef DEBUG #ifdef DEBUG
else else
printf("PROBLEM - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s\n", path, file); printf("PROBLEM - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s\n",
path, file);
#endif #endif
return 0; return 0;
@ -879,8 +892,8 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path)
static void static void
_ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules, _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
Ecore_Desktop_Tree * tree, char type, Ecore_Desktop_Tree * tree, char type,
char sub_type) char sub_type)
{ {
int i; int i;
char temp[PATH_MAX]; char temp[PATH_MAX];
@ -911,9 +924,9 @@ _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
else if (strcmp((char *)tree->elements[i].element, "<Or") == 0) else if (strcmp((char *)tree->elements[i].element, "<Or") == 0)
{ {
_ecore_desktop_menu_unxml_rules(rules, _ecore_desktop_menu_unxml_rules(rules,
(Ecore_Desktop_Tree *) tree-> (Ecore_Desktop_Tree *) tree->
elements[i + 1].element, elements[i + 1].element,
type, sub_type); type, sub_type);
} }
else if ((strcmp((char *)tree->elements[i].element, "<And") == 0) else if ((strcmp((char *)tree->elements[i].element, "<And") == 0)
|| (strcmp((char *)tree->elements[i].element, "<Not") == || (strcmp((char *)tree->elements[i].element, "<Not") ==
@ -932,11 +945,11 @@ _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
if (tree->elements[i].type == if (tree->elements[i].type ==
ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE) ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE)
_ecore_desktop_menu_unxml_rules(sub, _ecore_desktop_menu_unxml_rules(sub,
(Ecore_Desktop_Tree (Ecore_Desktop_Tree
*) tree-> *) tree->
elements[i]. elements[i].
element, type, element, type,
this_type); this_type);
} }
} }
} }
@ -944,16 +957,16 @@ _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
else if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE) else if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE)
{ {
_ecore_desktop_menu_unxml_rules(rules, _ecore_desktop_menu_unxml_rules(rules,
(Ecore_Desktop_Tree *) tree-> (Ecore_Desktop_Tree *) tree->
elements[i].element, type, elements[i].element, type,
sub_type); sub_type);
} }
} }
} }
static void static void
_ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu, _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu,
Ecore_Desktop_Tree * tree) Ecore_Desktop_Tree * tree)
{ {
int i; int i;
char *old = NULL; char *old = NULL;
@ -996,7 +1009,7 @@ _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu,
static void static void
_ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, Ecore_List * paths, _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, Ecore_List * paths,
char *pre, char *post, char *extra, int element) char *pre, char *post, char *extra, int element)
{ {
char t[PATH_MAX], *this_path; char t[PATH_MAX], *this_path;
@ -1015,7 +1028,7 @@ _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, Ecore_List * paths,
static int static int
_ecore_desktop_menu_expand_apps(struct _ecore_desktop_menu_unxml_data _ecore_desktop_menu_expand_apps(struct _ecore_desktop_menu_unxml_data
*unxml_data, char *app_dir, Ecore_Hash * pool) *unxml_data, char *app_dir, Ecore_Hash * pool)
{ {
if (pool) if (pool)
{ {
@ -1029,7 +1042,9 @@ _ecore_desktop_menu_expand_apps(struct _ecore_desktop_menu_unxml_data
our_data.path = dir; our_data.path = dir;
our_data.length = strlen(dir); our_data.length = strlen(dir);
#ifdef DEBUG #ifdef DEBUG
printf("EXPANDING - _ecore_desktop_menu_expand_apps(unxml_data, %s) - %s\n", app_dir, dir); printf
("EXPANDING - _ecore_desktop_menu_expand_apps(unxml_data, %s) - %s\n",
app_dir, dir);
#endif #endif
ecore_desktop_paths_recursive_search(dir, NULL, -1, NULL, ecore_desktop_paths_recursive_search(dir, NULL, -1, NULL,
_ecore_desktop_menu_check_app, _ecore_desktop_menu_check_app,
@ -1061,13 +1076,16 @@ _ecore_desktop_menu_check_app(void *data, const char *path)
file[i] = '-'; file[i] = '-';
ecore_hash_set(our_data->pool, file, strdup(path)); ecore_hash_set(our_data->pool, file, strdup(path));
#ifdef DEBUG #ifdef DEBUG
printf("POOLING - _ecore_desktop_menu_check_app(void *data, %s) - %s\n", path, file); printf
("POOLING - _ecore_desktop_menu_check_app(void *data, %s) - %s\n",
path, file);
#endif #endif
} }
} }
#ifdef DEBUG #ifdef DEBUG
else else
printf("PROBLEM - _ecore_desktop_menu_check_app(void *data, %s)\n", path); printf("PROBLEM - _ecore_desktop_menu_check_app(void *data, %s)\n",
path);
#endif #endif
} }
@ -1076,7 +1094,7 @@ _ecore_desktop_menu_check_app(void *data, const char *path)
static int static int
_ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree, _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree,
int element, int level) int element, int level)
{ {
struct _ecore_desktop_menu_unxml_data *unxml_data; struct _ecore_desktop_menu_unxml_data *unxml_data;
Ecore_Desktop_Tree *merge; Ecore_Desktop_Tree *merge;
@ -1093,16 +1111,16 @@ _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree,
{ {
if (unxml_data->base) if (unxml_data->base)
_ecore_desktop_menu_add_dirs(merge, ecore_desktop_paths_menus, _ecore_desktop_menu_add_dirs(merge, ecore_desktop_paths_menus,
"<MergeDir", "</MergeDir", "<MergeDir", "</MergeDir",
unxml_data->base, element); unxml_data->base, element);
result = 1; result = 1;
} }
else if (strcmp(string, "<KDELegacyDirs/") == 0) else if (strcmp(string, "<KDELegacyDirs/") == 0)
{ {
_ecore_desktop_menu_add_dirs(merge, _ecore_desktop_menu_add_dirs(merge,
ecore_desktop_paths_kde_legacy, ecore_desktop_paths_kde_legacy,
"<LegacyDir prefix=\"kde-\"", "<LegacyDir prefix=\"kde-\"",
"</LegacyDir", NULL, element); "</LegacyDir", NULL, element);
result = 1; result = 1;
} }
else if (strncmp(string, "<MergeDir ", 10) == 0) else if (strncmp(string, "<MergeDir ", 10) == 0)
@ -1218,7 +1236,8 @@ _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree,
* Slackware uses them. * Slackware uses them.
*/ */
merge_path[0] = '\0'; merge_path[0] = '\0';
printf("\n### Didn't expect a MergeFile parent type in the FDO menu. onefang must write more code now.\n"); printf
("\n### Didn't expect a MergeFile parent type in the FDO menu. onefang must write more code now.\n");
} }
if (merge_path[0] != '\0') if (merge_path[0] != '\0')
{ {
@ -1226,8 +1245,8 @@ _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree,
new_menu = new_menu =
_ecore_desktop_menu_get0(merge_path, _ecore_desktop_menu_get0(merge_path,
unxml_data->merge_stack, unxml_data->merge_stack,
level + 1); level + 1);
if (new_menu) if (new_menu)
{ {
if (new_menu->size > 1) if (new_menu->size > 1)
@ -1288,8 +1307,8 @@ _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree,
static int static int
_ecore_desktop_menu_expand_default_dirs(const void *data, _ecore_desktop_menu_expand_default_dirs(const void *data,
Ecore_Desktop_Tree * tree, int element, Ecore_Desktop_Tree * tree, int element,
int level) int level)
{ {
struct _ecore_desktop_menu_unxml_data *unxml_data; struct _ecore_desktop_menu_unxml_data *unxml_data;
Ecore_Desktop_Tree *merge; Ecore_Desktop_Tree *merge;
@ -1305,16 +1324,15 @@ _ecore_desktop_menu_expand_default_dirs(const void *data,
if (strcmp(string, "<DefaultAppDirs/") == 0) if (strcmp(string, "<DefaultAppDirs/") == 0)
{ {
_ecore_desktop_menu_add_dirs(merge, ecore_desktop_paths_desktops, _ecore_desktop_menu_add_dirs(merge, ecore_desktop_paths_desktops,
"<AppDir", "</AppDir", NULL, "<AppDir", "</AppDir", NULL, element);
element);
result = 1; result = 1;
} }
else if (strcmp(string, "<DefaultDirectoryDirs/") == 0) else if (strcmp(string, "<DefaultDirectoryDirs/") == 0)
{ {
_ecore_desktop_menu_add_dirs(merge, _ecore_desktop_menu_add_dirs(merge,
ecore_desktop_paths_directories, ecore_desktop_paths_directories,
"<DirectoryDir", "</DirectoryDir", "<DirectoryDir", "</DirectoryDir",
NULL, element); NULL, element);
result = 1; result = 1;
} }
} }
@ -1332,7 +1350,7 @@ _ecore_desktop_menu_expand_default_dirs(const void *data,
static int static int
_ecore_desktop_menu_generate(const void *data, Ecore_Desktop_Tree * tree, _ecore_desktop_menu_generate(const void *data, Ecore_Desktop_Tree * tree,
int element, int level) int element, int level)
{ {
struct _ecore_desktop_menu_unxml_data *unxml_data; struct _ecore_desktop_menu_unxml_data *unxml_data;
@ -1371,9 +1389,9 @@ _ecore_desktop_menu_generate(const void *data, Ecore_Desktop_Tree * tree,
if (strncmp(string, "<AppDir ", 8) == 0) if (strncmp(string, "<AppDir ", 8) == 0)
{ {
_ecore_desktop_menu_expand_apps(unxml_data, _ecore_desktop_menu_expand_apps(unxml_data,
&string[8], &string[8],
generate_data. generate_data.
pool); pool);
result = 1; result = 1;
} }
else if (strncmp(string, "<DirectoryDir ", 14) == 0) else if (strncmp(string, "<DirectoryDir ", 14) == 0)
@ -1555,38 +1573,40 @@ _ecore_desktop_menu_select_app(void *value, void *user_data)
desktop = ecore_desktop_get(app, NULL); desktop = ecore_desktop_get(app, NULL);
if (desktop) if (desktop)
{ {
if ((generate_data->unallocated) && (desktop->allocated)) if ((generate_data->unallocated) && (desktop->allocated))
return; return;
if (_ecore_desktop_menu_apply_rules if (_ecore_desktop_menu_apply_rules
(generate_data, generate_data->rule, key, desktop)) (generate_data, generate_data->rule, key, desktop))
{ {
desktop->allocated = TRUE; desktop->allocated = TRUE;
if (generate_data->include) if (generate_data->include)
{ {
ecore_hash_set(generate_data->apps, key, strdup(app)); ecore_hash_set(generate_data->apps, key, strdup(app));
#ifdef DEBUG #ifdef DEBUG
printf("INCLUDING %s%s - %s\n", printf("INCLUDING %s%s - %s\n",
((generate_data->unallocated) ? "UNALLOCATED " : ""), app, key); ((generate_data->unallocated) ? "UNALLOCATED " : ""),
app, key);
#endif #endif
} }
else else
{ {
ecore_hash_remove(generate_data->apps, key); ecore_hash_remove(generate_data->apps, key);
#ifdef DEBUG #ifdef DEBUG
printf("EXCLUDING %s%s - %s\n", printf("EXCLUDING %s%s - %s\n",
((generate_data->unallocated) ? "UNALLOCATED " : ""), app, key); ((generate_data->unallocated) ? "UNALLOCATED " : ""),
app, key);
#endif #endif
} }
} }
} }
} }
static int static int
_ecore_desktop_menu_apply_rules(struct _ecore_desktop_menu_generate_data _ecore_desktop_menu_apply_rules(struct _ecore_desktop_menu_generate_data
*generate_data, Ecore_Desktop_Tree * rule, *generate_data, Ecore_Desktop_Tree * rule,
char *key, Ecore_Desktop * desktop) char *key, Ecore_Desktop * desktop)
{ {
char type = 'O'; char type = 'O';
int result = FALSE; int result = FALSE;
@ -1598,9 +1618,9 @@ _ecore_desktop_menu_apply_rules(struct _ecore_desktop_menu_generate_data
{ {
result = result =
_ecore_desktop_menu_apply_rules(generate_data, _ecore_desktop_menu_apply_rules(generate_data,
(Ecore_Desktop_Tree *) rule-> (Ecore_Desktop_Tree *) rule->
elements[i].element, key, elements[i].element, key,
desktop); desktop);
} }
else else
{ {

View File

@ -16,10 +16,8 @@
#include <libgen.h> #include <libgen.h>
#include <strings.h> #include <strings.h>
/* FIXME: Add functions to add paths before the user paths, after the user but before the system paths, and at the end. */ /* FIXME: Add functions to add paths before the user paths, after the user but before the system paths, and at the end. */
/* This really slows things down and no doubt drags in some KDE bloat at start up. /* This really slows things down and no doubt drags in some KDE bloat at start up.
* To work around this, I add a few extra things to try in the _ecore_desktop_paths_get() * To work around this, I add a few extra things to try in the _ecore_desktop_paths_get()
* calls below. * calls below.
@ -38,10 +36,8 @@
* and correct those guesses. * and correct those guesses.
*/ */
static Ecore_List *_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type,
char *before, char *env_home,
static Ecore_List *_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type,
char *before, char *env_home,
char *env, char *env_home_default, char *env, char *env_home_default,
char *env_default, char *type, char *env_default, char *type,
char *gnome_extra, char *kde); char *gnome_extra, char *kde);
@ -53,13 +49,13 @@ static void _ecore_desktop_paths_check_and_add(Ecore_List * paths,
static void _ecore_desktop_paths_create(); static void _ecore_desktop_paths_create();
static void _ecore_desktop_paths_destroy(); static void _ecore_desktop_paths_destroy();
static Ecore_List *gnome_data = NULL; static Ecore_List *gnome_data = NULL;
static Ecore_List *prepend_user_paths[ECORE_DESKTOP_PATHS_MAX]; static Ecore_List *prepend_user_paths[ECORE_DESKTOP_PATHS_MAX];
static Ecore_List *prepend_system_paths[ECORE_DESKTOP_PATHS_MAX]; static Ecore_List *prepend_system_paths[ECORE_DESKTOP_PATHS_MAX];
static Ecore_List *append_user_paths[ECORE_DESKTOP_PATHS_MAX]; static Ecore_List *append_user_paths[ECORE_DESKTOP_PATHS_MAX];
static Ecore_List *append_system_paths[ECORE_DESKTOP_PATHS_MAX]; static Ecore_List *append_system_paths[ECORE_DESKTOP_PATHS_MAX];
static char *home; static char *home;
static int init_count = 0; static int init_count = 0;
#if defined GNOME_SUPPORT || defined KDE_SUPPORT #if defined GNOME_SUPPORT || defined KDE_SUPPORT
struct _config_exe_data struct _config_exe_data
@ -80,11 +76,11 @@ static int _ecore_desktop_paths_cb_exe_exit(void *data, int type,
static Ecore_Event_Handler *exit_handler = NULL; static Ecore_Event_Handler *exit_handler = NULL;
#endif #endif
EAPI int EAPI int
ecore_desktop_paths_init(void) ecore_desktop_paths_init(void)
{ {
if (++init_count != 1) return init_count; if (++init_count != 1)
return init_count;
#if defined GNOME_SUPPORT || defined KDE_SUPPORT #if defined GNOME_SUPPORT || defined KDE_SUPPORT
exit_handler = exit_handler =
@ -97,34 +93,33 @@ ecore_desktop_paths_init(void)
home = ecore_desktop_home_get(); home = ecore_desktop_home_get();
if (gnome_data) if (gnome_data)
{ {
#ifdef GNOME_SUPPORT #ifdef GNOME_SUPPORT
if (exit_handler) if (exit_handler)
{ {
ecore_list_set_free_cb(gnome_data, free); ecore_list_set_free_cb(gnome_data, free);
_ecore_desktop_paths_exec_config(gnome_data, home, NULL, _ecore_desktop_paths_exec_config(gnome_data, home, NULL,
"gnome-config --datadir"); "gnome-config --datadir");
} }
#else #else
Ecore_List *config_list; Ecore_List *config_list;
config_list = ecore_desktop_paths_to_list("/opt/gnome/share"); config_list = ecore_desktop_paths_to_list("/opt/gnome/share");
if (config_list) if (config_list)
{
char *this_config;
char path[PATH_MAX];
ecore_list_goto_first(config_list);
while ((this_config = ecore_list_next(config_list)) != NULL)
{ {
char *this_config;
char path[PATH_MAX];
ecore_list_goto_first(config_list); _ecore_desktop_paths_massage_path(path, home,
while ((this_config = ecore_list_next(config_list)) != NULL) this_config, NULL);
{ _ecore_desktop_paths_check_and_add(gnome_data, path);
_ecore_desktop_paths_massage_path(path, home,
this_config,
NULL);
_ecore_desktop_paths_check_and_add(gnome_data, path);
}
E_FN_DEL(ecore_list_destroy, config_list);
} }
E_FN_DEL(ecore_list_destroy, config_list);
}
#endif #endif
} }
@ -135,7 +130,8 @@ ecore_desktop_paths_init(void)
EAPI int EAPI int
ecore_desktop_paths_shutdown(void) ecore_desktop_paths_shutdown(void)
{ {
if (--init_count != 0) return init_count; if (--init_count != 0)
return init_count;
_ecore_desktop_paths_destroy(); _ecore_desktop_paths_destroy();
E_FN_DEL(ecore_list_destroy, gnome_data); E_FN_DEL(ecore_list_destroy, gnome_data);
@ -161,12 +157,13 @@ _ecore_desktop_paths_create(void)
if (!ecore_desktop_paths_desktops) if (!ecore_desktop_paths_desktops)
{ {
ecore_desktop_paths_desktops = ecore_desktop_paths_desktops =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DESKTOPS, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DESKTOPS, NULL,
"~/.local/share:~/.kde/share", "XDG_DATA_HOME", "XDG_DATA_DIRS",
"/usr/local/share:/usr/share", "~/.local/share:~/.kde/share",
"applications:applnk:applications/kde", "/usr/local/share:/usr/share",
"dist/desktop-files:dist/short-menu:gnome/apps", "applications:applnk:applications/kde",
"xdgdata-apps:apps"); "dist/desktop-files:dist/short-menu:gnome/apps",
"xdgdata-apps:apps");
_ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops, _ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops,
"/usr/local/share/update-desktop-files/templates"); "/usr/local/share/update-desktop-files/templates");
_ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops, _ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops,
@ -176,22 +173,21 @@ _ecore_desktop_paths_create(void)
{ {
#ifdef KDE_SUPPORT #ifdef KDE_SUPPORT
ecore_desktop_paths_kde_legacy = ecore_desktop_paths_kde_legacy =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, NULL, NULL, NULL, NULL, NULL, NULL, _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, NULL,
"apps"); NULL, NULL, NULL, NULL, NULL, "apps");
#else #else
ecore_desktop_paths_kde_legacy = ecore_desktop_paths_kde_legacy =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL,
"XDG_DATA_HOME", "XDG_DATA_DIRS",
"~/.local/share:~/.kde/share", "~/.local/share:~/.kde/share",
"/usr/local/share:/usr/share", "/usr/local/share:/usr/share", "applnk",
"applnk", NULL, "apps");
NULL,
"apps");
#endif #endif
if (ecore_desktop_paths_kde_legacy) if (ecore_desktop_paths_kde_legacy)
{ {
char temp[PATH_MAX], *path; char temp[PATH_MAX], *path;
Ecore_List *temp_list; Ecore_List *temp_list;
/* Copy it, cause Ecore_List walks can not be nested. */ /* Copy it, cause Ecore_List walks can not be nested. */
temp_list = ecore_list_new(); temp_list = ecore_list_new();
if (temp_list) if (temp_list)
@ -226,10 +222,12 @@ _ecore_desktop_paths_create(void)
char *gnome; char *gnome;
ecore_desktop_paths_icons = ecore_desktop_paths_icons =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_ICONS, "~/.icons", "XDG_DATA_HOME", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_ICONS, "~/.icons",
"XDG_DATA_DIRS", "~/.local/share:~/.kde/share", "XDG_DATA_HOME", "XDG_DATA_DIRS",
"/usr/local/share:/usr/share:/usr/X11R6/share", "icons:pixmaps", "~/.local/share:~/.kde/share",
"dist/icons", "icon:pixmap"); "/usr/local/share:/usr/share:/usr/X11R6/share",
"icons:pixmaps", "dist/icons",
"icon:pixmap");
_ecore_desktop_paths_check_and_add(ecore_desktop_paths_icons, _ecore_desktop_paths_check_and_add(ecore_desktop_paths_icons,
"/usr/local/share/pixmaps/"); "/usr/local/share/pixmaps/");
_ecore_desktop_paths_check_and_add(ecore_desktop_paths_icons, _ecore_desktop_paths_check_and_add(ecore_desktop_paths_icons,
@ -242,27 +240,30 @@ _ecore_desktop_paths_create(void)
} }
if (!ecore_desktop_paths_menus) if (!ecore_desktop_paths_menus)
ecore_desktop_paths_menus = ecore_desktop_paths_menus =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_MENUS, NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_MENUS, NULL,
"~/.config", "/etc/xdg:/var/lib/menu-xdg", "menus", NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS",
"xdgconf-menu"); "~/.config", "/etc/xdg:/var/lib/menu-xdg",
"menus", NULL, "xdgconf-menu");
if (!ecore_desktop_paths_directories) if (!ecore_desktop_paths_directories)
ecore_desktop_paths_directories = ecore_desktop_paths_directories =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DIRECTORIES, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DIRECTORIES, NULL,
"XDG_DATA_HOME", "XDG_DATA_DIRS",
"~/.local/share:~/.kde/share", "~/.local/share:~/.kde/share",
"/usr/local/share:/usr/share", "/usr/local/share:/usr/share",
"desktop-directories", "gnome/vfolders", "desktop-directories", "gnome/vfolders",
"xdgdata-dirs"); "xdgdata-dirs");
if (!ecore_desktop_paths_config) if (!ecore_desktop_paths_config)
ecore_desktop_paths_config = ecore_desktop_paths_config =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_CONFIG, NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_CONFIG, NULL,
"XDG_CONFIG_HOME", "XDG_CONFIG_DIRS",
"~/.config", "/etc/xdg", "", NULL, NULL); "~/.config", "/etc/xdg", "", NULL, NULL);
if (!ecore_desktop_paths_xsessions) if (!ecore_desktop_paths_xsessions)
ecore_desktop_paths_xsessions = ecore_desktop_paths_xsessions =
_ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_XSESSIONS, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_XSESSIONS, NULL,
"XDG_DATA_HOME", "XDG_DATA_DIRS",
"~/.local/share:~/.kde/share", "~/.local/share:~/.kde/share",
"/usr/local/share:/usr/share", "/usr/local/share:/usr/share", "xsessions",
"xsessions", NULL, NULL, NULL);
NULL);
} }
static void static void
@ -280,55 +281,55 @@ _ecore_desktop_paths_destroy(void)
EAPI void EAPI void
ecore_desktop_paths_extras_clear(void) ecore_desktop_paths_extras_clear(void)
{ {
int i; int i;
for (i = 0; i < ECORE_DESKTOP_PATHS_MAX; i++) for (i = 0; i < ECORE_DESKTOP_PATHS_MAX; i++)
{ {
E_FN_DEL(ecore_list_destroy, prepend_user_paths[i]); E_FN_DEL(ecore_list_destroy, prepend_user_paths[i]);
E_FN_DEL(ecore_list_destroy, prepend_system_paths[i]); E_FN_DEL(ecore_list_destroy, prepend_system_paths[i]);
E_FN_DEL(ecore_list_destroy, append_user_paths[i]); E_FN_DEL(ecore_list_destroy, append_user_paths[i]);
E_FN_DEL(ecore_list_destroy, append_system_paths[i]); E_FN_DEL(ecore_list_destroy, append_system_paths[i]);
prepend_user_paths[i] = ecore_list_new(); prepend_user_paths[i] = ecore_list_new();
if (prepend_user_paths[i]) if (prepend_user_paths[i])
ecore_list_set_free_cb(prepend_user_paths[i], free); ecore_list_set_free_cb(prepend_user_paths[i], free);
prepend_system_paths[i] = ecore_list_new(); prepend_system_paths[i] = ecore_list_new();
if (prepend_system_paths[i]) if (prepend_system_paths[i])
ecore_list_set_free_cb(prepend_system_paths[i], free); ecore_list_set_free_cb(prepend_system_paths[i], free);
append_user_paths[i] = ecore_list_new(); append_user_paths[i] = ecore_list_new();
if (append_user_paths[i]) if (append_user_paths[i])
ecore_list_set_free_cb(append_user_paths[i], free); ecore_list_set_free_cb(append_user_paths[i], free);
append_system_paths[i] = ecore_list_new(); append_system_paths[i] = ecore_list_new();
if (append_system_paths[i]) if (append_system_paths[i])
ecore_list_set_free_cb(append_system_paths[i], free); ecore_list_set_free_cb(append_system_paths[i], free);
} }
} }
EAPI void EAPI void
ecore_desktop_paths_prepend_user(Ecore_Desktop_Paths_Type type, char *paths) ecore_desktop_paths_prepend_user(Ecore_Desktop_Paths_Type type, char *paths)
{ {
if (prepend_user_paths[type]) if (prepend_user_paths[type])
ecore_list_append(prepend_user_paths[type], strdup(paths)); ecore_list_append(prepend_user_paths[type], strdup(paths));
} }
EAPI void EAPI void
ecore_desktop_paths_prepend_system(Ecore_Desktop_Paths_Type type, char *paths) ecore_desktop_paths_prepend_system(Ecore_Desktop_Paths_Type type, char *paths)
{ {
if (prepend_system_paths[type]) if (prepend_system_paths[type])
ecore_list_append(prepend_system_paths[type], strdup(paths)); ecore_list_append(prepend_system_paths[type], strdup(paths));
} }
EAPI void EAPI void
ecore_desktop_paths_append_user(Ecore_Desktop_Paths_Type type, char *paths) ecore_desktop_paths_append_user(Ecore_Desktop_Paths_Type type, char *paths)
{ {
if (append_user_paths[type]) if (append_user_paths[type])
ecore_list_append(append_user_paths[type], strdup(paths)); ecore_list_append(append_user_paths[type], strdup(paths));
} }
EAPI void EAPI void
ecore_desktop_paths_append_system(Ecore_Desktop_Paths_Type type, char *paths) ecore_desktop_paths_append_system(Ecore_Desktop_Paths_Type type, char *paths)
{ {
if (append_system_paths[type]) if (append_system_paths[type])
ecore_list_append(append_system_paths[type], strdup(paths)); ecore_list_append(append_system_paths[type], strdup(paths));
} }
/** Search for a file in fdo compatible locations. /** Search for a file in fdo compatible locations.
@ -348,13 +349,13 @@ ecore_desktop_paths_append_system(Ecore_Desktop_Paths_Type type, char *paths)
*/ */
char * char *
ecore_desktop_paths_file_find(Ecore_List * paths, const char *file, int sub, ecore_desktop_paths_file_find(Ecore_List * paths, const char *file, int sub,
int (*func) (void *data, const char *path), int (*func) (void *data, const char *path),
void *data) void *data)
{ {
char *path = NULL, *this_path; char *path = NULL, *this_path;
char temp[PATH_MAX]; char temp[PATH_MAX];
struct stat path_stat; struct stat path_stat;
if (paths) if (paths)
{ {
ecore_list_goto_first(paths); ecore_list_goto_first(paths);
@ -372,15 +373,15 @@ ecore_desktop_paths_file_find(Ecore_List * paths, const char *file, int sub,
if (func) if (func)
{ {
if (func(data, temp)) if (func(data, temp))
break; break;
} }
} }
else if (sub != 0) else if (sub != 0)
path = path =
ecore_desktop_paths_recursive_search(this_path, file, sub, NULL, ecore_desktop_paths_recursive_search(this_path, file, sub,
func, data); NULL, func, data);
if (path && (!func)) if (path && (!func))
break; break;
} }
} }
@ -396,14 +397,15 @@ icons=pathlist
*/ */
static Ecore_List * static Ecore_List *
_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type,
char *before, char *env_home, char *env, char *before, char *env_home, char *env,
char *env_home_default, char *env_default, char *type, char *env_home_default, char *env_default, char *type,
char *gnome_extra, char *kde) char *gnome_extra, char *kde)
{ {
Ecore_List *paths = NULL; Ecore_List *paths = NULL;
Ecore_List *types = NULL; Ecore_List *types = NULL;
Ecore_List *gnome_extras = NULL; Ecore_List *gnome_extras = NULL;
#ifdef KDE_SUPPORT #ifdef KDE_SUPPORT
Ecore_List *kdes = NULL; Ecore_List *kdes = NULL;
#endif #endif
@ -448,17 +450,19 @@ _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type,
} }
} }
if (prepend_user_paths[path_type]) if (prepend_user_paths[path_type])
{ {
char *this_path; char *this_path;
ecore_list_goto_first(prepend_user_paths[path_type]); ecore_list_goto_first(prepend_user_paths[path_type]);
while ((this_path = ecore_list_next(prepend_user_paths[path_type])) != NULL) while ((this_path =
{ ecore_list_next(prepend_user_paths[path_type])) != NULL)
_ecore_desktop_paths_massage_path(path, home, this_path, NULL); {
_ecore_desktop_paths_check_and_add(paths, path); _ecore_desktop_paths_massage_path(path, home, this_path,
} NULL);
} _ecore_desktop_paths_check_and_add(paths, path);
}
}
if (env_home) if (env_home)
{ {
@ -488,29 +492,33 @@ _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type,
} }
} }
if (append_user_paths[path_type]) if (append_user_paths[path_type])
{ {
char *this_path; char *this_path;
ecore_list_goto_first(append_user_paths[path_type]); ecore_list_goto_first(append_user_paths[path_type]);
while ((this_path = ecore_list_next(append_user_paths[path_type])) != NULL) while ((this_path =
{ ecore_list_next(append_user_paths[path_type])) != NULL)
_ecore_desktop_paths_massage_path(path, home, this_path, NULL); {
_ecore_desktop_paths_check_and_add(paths, path); _ecore_desktop_paths_massage_path(path, home, this_path,
} NULL);
} _ecore_desktop_paths_check_and_add(paths, path);
}
}
if (prepend_system_paths[path_type]) if (prepend_system_paths[path_type])
{ {
char *this_path; char *this_path;
ecore_list_goto_first(prepend_system_paths[path_type]); ecore_list_goto_first(prepend_system_paths[path_type]);
while ((this_path = ecore_list_next(prepend_system_paths[path_type])) != NULL) while ((this_path =
{ ecore_list_next(prepend_system_paths[path_type])) != NULL)
_ecore_desktop_paths_massage_path(path, home, this_path, NULL); {
_ecore_desktop_paths_check_and_add(paths, path); _ecore_desktop_paths_massage_path(path, home, this_path,
} NULL);
} _ecore_desktop_paths_check_and_add(paths, path);
}
}
if (env) if (env)
{ {
@ -540,17 +548,19 @@ _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type,
} }
} }
if (append_system_paths[path_type]) if (append_system_paths[path_type])
{ {
char *this_path; char *this_path;
ecore_list_goto_first(append_system_paths[path_type]); ecore_list_goto_first(append_system_paths[path_type]);
while ((this_path = ecore_list_next(append_system_paths[path_type])) != NULL) while ((this_path =
{ ecore_list_next(append_system_paths[path_type])) != NULL)
_ecore_desktop_paths_massage_path(path, home, this_path, NULL); {
_ecore_desktop_paths_check_and_add(paths, path); _ecore_desktop_paths_massage_path(path, home, this_path,
} NULL);
} _ecore_desktop_paths_check_and_add(paths, path);
}
}
/* /*
* Get the pathlist from the config file - type=pathlist * Get the pathlist from the config file - type=pathlist
@ -682,18 +692,18 @@ _ecore_desktop_paths_check_and_add(Ecore_List * paths, char *path)
} }
char * char *
ecore_desktop_paths_recursive_search(const char *path, const char *file, int sub, ecore_desktop_paths_recursive_search(const char *path, const char *file,
int (*dir_func) (void *data, int sub, int (*dir_func) (void *data,
const char *path), const char
*path),
int (*func) (void *data, const char *path), int (*func) (void *data, const char *path),
void *data) void *data)
{ {
char *fpath = NULL; char *fpath = NULL;
DIR *dir = NULL; DIR *dir = NULL;
if ((sub != 0) && (sub != -1)) if ((sub != 0) && (sub != -1))
sub -= 1; sub -= 1;
dir = opendir(path); dir = opendir(path);
@ -714,16 +724,15 @@ ecore_desktop_paths_recursive_search(const char *path, const char *file, int sub
if ((strcmp(basename(info_text), ".") != 0) if ((strcmp(basename(info_text), ".") != 0)
&& (strcmp(basename(info_text), "..") != 0)) && (strcmp(basename(info_text), "..") != 0))
{ {
snprintf(info_text, PATH_MAX, "%s%s/", path, script->d_name); snprintf(info_text, PATH_MAX, "%s%s/", path,
script->d_name);
if (dir_func) if (dir_func)
if (dir_func(data, info_text)) if (dir_func(data, info_text))
break; break;
if (sub != 0) if (sub != 0)
fpath = fpath =
ecore_desktop_paths_recursive_search(info_text, ecore_desktop_paths_recursive_search
file, sub, (info_text, file, sub, dir_func, func, data);
dir_func,
func, data);
} }
} }
else else
@ -732,7 +741,7 @@ ecore_desktop_paths_recursive_search(const char *path, const char *file, int sub
{ {
if (strcmp(basename(info_text), file) == 0) if (strcmp(basename(info_text), file) == 0)
{ {
if (fpath) if (fpath)
free(fpath); free(fpath);
fpath = strdup(info_text); fpath = strdup(info_text);
if (func) if (func)
@ -890,30 +899,30 @@ ecore_desktop_paths_to_hash(const char *paths)
path = strdup(paths); path = strdup(paths);
if (path) if (path)
{ {
end = path; end = path;
while (!finished) while (!finished)
{ {
start = end; start = end;
do /* FIXME: There is probably a better way to do this. */ do /* FIXME: There is probably a better way to do this. */
{ {
while ((*end != ';') && (*end != ':') && (*end != ',') while ((*end != ';') && (*end != ':')
&& (*end != '\0')) && (*end != ',') && (*end != '\0'))
end++; end++;
} }
while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */ while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */
/* FIXME: We still need to unescape it now. */ /* FIXME: We still need to unescape it now. */
temp = *end; temp = *end;
if (*end == '\0') if (*end == '\0')
finished = 1; finished = 1;
else else
*end = '\0'; *end = '\0';
ecore_hash_set(result, strdup(start), strdup(start)); ecore_hash_set(result, strdup(start), strdup(start));
if ((*end) != temp) if ((*end) != temp)
*end = temp; *end = temp;
end++; end++;
} }
free(path); free(path);
} }
} }
} }
@ -948,52 +957,68 @@ ecore_desktop_paths_to_list(const char *paths)
path = strdup(paths); path = strdup(paths);
if (path) if (path)
{ {
end = path; end = path;
while (!finished) while (!finished)
{ {
start = end; start = end;
do /* FIXME: There is probably a better way to do this. */ do /* FIXME: There is probably a better way to do this. */
{ {
while ((*end != ';') && (*end != ':') && (*end != ',') while ((*end != ';') && (*end != ':')
&& (*end != '\0')) && (*end != ',') && (*end != '\0'))
end++; end++;
} }
while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */ while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */
/* FIXME: We still need to unescape it now. */ /* FIXME: We still need to unescape it now. */
temp = *end; temp = *end;
if (*end == '\0') if (*end == '\0')
finished = 1; finished = 1;
else else
*end = '\0'; *end = '\0';
ecore_list_append(result, strdup(start)); ecore_list_append(result, strdup(start));
if ((*end) != temp) if ((*end) != temp)
*end = temp; *end = temp;
end++; end++;
} }
free(path); free(path);
} }
} }
} }
return result; return result;
} }
EAPI int EAPI int
ecore_desktop_paths_for_each(Ecore_Desktop_Paths_Type type, Ecore_For_Each function, void *user_data) ecore_desktop_paths_for_each(Ecore_Desktop_Paths_Type type,
Ecore_For_Each function, void *user_data)
{ {
Ecore_List *list = NULL; Ecore_List *list = NULL;
switch (type) switch (type)
{ {
case ECORE_DESKTOP_PATHS_CONFIG : list = ecore_desktop_paths_config; break; case ECORE_DESKTOP_PATHS_CONFIG:
case ECORE_DESKTOP_PATHS_MENUS : list = ecore_desktop_paths_menus; break; list = ecore_desktop_paths_config;
case ECORE_DESKTOP_PATHS_DIRECTORIES : list = ecore_desktop_paths_directories; break; break;
case ECORE_DESKTOP_PATHS_DESKTOPS : list = ecore_desktop_paths_desktops; break; case ECORE_DESKTOP_PATHS_MENUS:
case ECORE_DESKTOP_PATHS_ICONS : list = ecore_desktop_paths_icons; break; list = ecore_desktop_paths_menus;
case ECORE_DESKTOP_PATHS_KDE_LEGACY : list = ecore_desktop_paths_kde_legacy; break; break;
case ECORE_DESKTOP_PATHS_XSESSIONS : list = ecore_desktop_paths_xsessions; break; case ECORE_DESKTOP_PATHS_DIRECTORIES:
case ECORE_DESKTOP_PATHS_MAX : break; list = ecore_desktop_paths_directories;
} break;
case ECORE_DESKTOP_PATHS_DESKTOPS:
list = ecore_desktop_paths_desktops;
break;
case ECORE_DESKTOP_PATHS_ICONS:
list = ecore_desktop_paths_icons;
break;
case ECORE_DESKTOP_PATHS_KDE_LEGACY:
list = ecore_desktop_paths_kde_legacy;
break;
case ECORE_DESKTOP_PATHS_XSESSIONS:
list = ecore_desktop_paths_xsessions;
break;
case ECORE_DESKTOP_PATHS_MAX:
break;
}
if (list) if (list)
return ecore_list_for_each(list, function, user_data); return ecore_list_for_each(list, function, user_data);
return 0; return 0;

View File

@ -15,13 +15,13 @@
#define E_NEW_BIG(s, n) (s *)malloc(n * sizeof(s)) #define E_NEW_BIG(s, n) (s *)malloc(n * sizeof(s))
#define E_FREE(p) { if (p) {free(p); p = NULL;} } #define E_FREE(p) { if (p) {free(p); p = NULL;} }
extern Ecore_List *ecore_desktop_paths_config; extern Ecore_List *ecore_desktop_paths_config;
extern Ecore_List *ecore_desktop_paths_menus; extern Ecore_List *ecore_desktop_paths_menus;
extern Ecore_List *ecore_desktop_paths_directories; extern Ecore_List *ecore_desktop_paths_directories;
extern Ecore_List *ecore_desktop_paths_desktops; extern Ecore_List *ecore_desktop_paths_desktops;
extern Ecore_List *ecore_desktop_paths_icons; extern Ecore_List *ecore_desktop_paths_icons;
extern Ecore_List *ecore_desktop_paths_kde_legacy; extern Ecore_List *ecore_desktop_paths_kde_legacy;
extern Ecore_List *ecore_desktop_paths_xsessions; extern Ecore_List *ecore_desktop_paths_xsessions;
# ifdef __cplusplus # ifdef __cplusplus
extern "C" extern "C"

View File

@ -5,7 +5,6 @@
#include <ctype.h> #include <ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
/** xmlame.c Extensively Mocked Language Approximately Mangled for Enlightenment. /** xmlame.c Extensively Mocked Language Approximately Mangled for Enlightenment.
* *
* This is NOT a real XML parser. There were a few ways we could go when it came * This is NOT a real XML parser. There were a few ways we could go when it came