Enlightenment CVS committal
Author : onefang
Project : e17
Module : apps/e_utils
Dir : e17/apps/e_utils/src/bin/e17genmenu/src/bin
Modified Files:
.indent.pro category.c dumb_tree.c dumb_tree.h dumb_tree.o
eaps.c fdo_menus.c fdo_menus.h fdo_paths.c global.c global.h
icons.c main.c menus.c order.h parse.c parse.h sort.c xmlame.c
Log Message:
Mass formatting.
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/.indent.pro,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- .indent.pro 31 Jan 2006 19:12:13 -0000 1.1
+++ .indent.pro 22 Feb 2006 04:30:52 -0000 1.2
@@ -1,4 +1,4 @@
--i3 -bl -bad -nbap -sob -ncdb -di1 -nbc -lp -nce -npcs -sc -ncs -l80 -nut
+-i3 -bl -bad -nbap -sob -ncdb -di1 -nbc -lp -nce -npcs -sc -ncs -l160 -nut
-T G_Eap
-T Ecore_List
-T Eet_File
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/category.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- category.c 1 Feb 2006 09:41:25 -0000 1.4
+++ category.c 22 Feb 2006 04:30:53 -0000 1.5
@@ -29,9 +29,7 @@
}
else if ((strstr(token, "AudioVideo") != NULL) ||
- (strstr(token, "Sound") != NULL) ||
- (strstr(token, "Video") != NULL) ||
- (strstr(token, "Multimedia") != NULL))
+ (strstr(token, "Sound") != NULL) ||
(strstr(token, "Video") != NULL) ||
(strstr(token, "Multimedia") != NULL))
{
cat = "Multimedia";
@@ -61,17 +59,13 @@
cat = "System";
}
- else if ((strstr(token, "Shells") != NULL) ||
- (strstr(token, "Utility") != NULL) ||
- (strstr(token, "Tools") != NULL))
+ else if ((strstr(token, "Shells") != NULL) ||
(strstr(token, "Utility") != NULL) ||
(strstr(token, "Tools") != NULL))
{
cat = "Utilities";
}
- else if ((strstr(token, "Viewers") != NULL) ||
- (strstr(token, "Editors") != NULL) ||
- (strstr(token, "Text") != NULL))
+ else if ((strstr(token, "Viewers") != NULL) ||
(strstr(token, "Editors") != NULL) ||
(strstr(token, "Text") != NULL))
{
cat = "Editors";
@@ -83,15 +77,13 @@
cat = "Graphics";
}
- else if ((strstr(token, "WindowManagers") != NULL) ||
- (strstr(token, "Core") != NULL))
+ else if ((strstr(token, "WindowManagers") != NULL) ||
(strstr(token, "Core") != NULL))
{
cat = "Core";
}
- else if ((strstr(token, "Settings") != NULL) ||
- (strstr(token, "Accessibility") != NULL))
+ else if ((strstr(token, "Settings") != NULL) ||
(strstr(token, "Accessibility") != NULL))
{
cat = "Settings";
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/dumb_tree.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- dumb_tree.c 22 Feb 2006 04:19:42 -0000 1.1
+++ dumb_tree.c 22 Feb 2006 04:30:53 -0000 1.2
@@ -7,7 +7,6 @@
static void dumb_tree_dump_each_hash_node(void *value, void *user_data);
-
/** Split a list of paths into a Dumb_Tree.
*
* The list of paths can use any one of ;:, to seperate the paths.
@@ -32,13 +31,13 @@
while (!finished)
{
start = end;
- do /* FIXME: There is probably a better way to do this. */
- {
- while ((*end != ';') && (*end != ':') && (*end != ',') && (*end != '\0'))
- end++;
- }
- while ((end != tree->buffers[0]) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */
- /* FIXME: We still need to unescape it now. */
+ do /* FIXME: There is probably a better way to do this. */
+ {
+ while ((*end != ';') && (*end != ':') && (*end != ',') && (*end != '\0'))
+ end++;
+ }
+ while ((end != tree->buffers[0]) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */
+ /* FIXME: We still need to unescape it now. */
if (*end == '\0')
finished = 1;
*end = '\0';
@@ -50,7 +49,6 @@
return tree;
}
-
/* Just a quick and dirty tree implemtation that will likely get replaced by
* something much saner at a later date. I wrote most of this while falling
* asleep. It will probably scare me when I wake up. B-)
@@ -79,7 +77,6 @@
* The tree may allow duplicates.
*/
-
Dumb_Tree *
dumb_tree_new(char *buffer)
{
@@ -88,14 +85,14 @@
tree = E_NEW(Dumb_Tree, 1);
if ((tree) && (buffer))
{
- tree->buffers = (char **) realloc(tree->buffers, (tree->buffers_size + 1) * sizeof(char *));
+ tree->buffers = (char **)realloc(tree->buffers, (tree->buffers_size + 1) * sizeof(char *));
tree->buffers[tree->buffers_size++] = strdup(buffer);
}
return tree;
}
Dumb_Tree *
-dumb_tree_add(Dumb_Tree *tree, char *element)
+dumb_tree_add(Dumb_Tree * tree, char *element)
{
tree->elements = (Dumb_Tree_Element *) realloc(tree->elements, (tree->size + 1) * sizeof(Dumb_Tree_Element));
tree->elements[tree->size].element = element;
@@ -104,9 +101,9 @@
}
Dumb_Tree *
-dumb_tree_extend(Dumb_Tree *tree, char *element)
+dumb_tree_extend(Dumb_Tree * tree, char *element)
{
- tree->buffers = (char **) realloc(tree->buffers, (tree->buffers_size + 1) * sizeof(char *));
+ tree->buffers = (char **)realloc(tree->buffers, (tree->buffers_size + 1) * sizeof(char *));
tree->buffers[tree->buffers_size++] = strdup(element);
tree = dumb_tree_add(tree, tree->buffers[tree->buffers_size - 1]);
@@ -114,35 +111,33 @@
}
void
-dumb_tree_track(Dumb_Tree *tree, void *element)
+dumb_tree_track(Dumb_Tree * tree, void *element)
{
- tree->buffers = (char **) realloc(tree->buffers, (tree->buffers_size + 1) * sizeof(char *));
+ tree->buffers = (char **)realloc(tree->buffers, (tree->buffers_size + 1) * sizeof(char *));
tree->buffers[tree->buffers_size++] = element;
}
-
/* OK, so we need an insert after all, and it falls into the dumb category. */
Dumb_Tree *
-dumb_tree_insert(Dumb_Tree *tree, int before, void *element, Dumb_Tree_Element_Type type)
+dumb_tree_insert(Dumb_Tree * tree, int before, void *element, Dumb_Tree_Element_Type type)
{
int i;
tree->elements = (Dumb_Tree_Element *) realloc(tree->elements, (tree->size + 1) * sizeof(Dumb_Tree_Element));
tree->size++;
for (i = tree->size - 1; i > before; i--)
- {
- tree->elements[i].element = tree->elements[i - 1].element;
- tree->elements[i].type = tree->elements[i - 1].type;
- }
+ {
+ tree->elements[i].element = tree->elements[i - 1].element;
+ tree->elements[i].type = tree->elements[i - 1].type;
+ }
tree->elements[before].element = element;
tree->elements[before].type = type;
return tree;
}
-
/* OK, so we need a tree insert after all, and it falls into the dumb category. */
Dumb_Tree *
-dumb_tree_insert_tree(Dumb_Tree *tree, int before, Dumb_Tree *element)
+dumb_tree_insert_tree(Dumb_Tree * tree, int before, Dumb_Tree * element)
{
int i, size;
@@ -150,15 +145,15 @@
tree->elements = (Dumb_Tree_Element *) realloc(tree->elements, (tree->size + size) * sizeof(Dumb_Tree_Element));
tree->size += size;
for (i = tree->size - 1; i > before; i--)
- {
- tree->elements[i].element = tree->elements[i - size].element;
- tree->elements[i].type = tree->elements[i - size].type;
- }
+ {
+ tree->elements[i].element = tree->elements[i - size].element;
+ tree->elements[i].type = tree->elements[i - size].type;
+ }
for (i = 0; i < size; i++)
- {
- tree->elements[before + i].element = element->elements[i].element;
- tree->elements[before + i].type = element->elements[i].type;
- }
+ {
+ tree->elements[before + i].element = element->elements[i].element;
+ tree->elements[before + i].type = element->elements[i].type;
+ }
/* Careful, this might screw up the freeing order if that is important. */
/*
@@ -177,9 +172,8 @@
return tree;
}
-
Dumb_Tree *
-dumb_tree_add_child(Dumb_Tree *tree, Dumb_Tree *element)
+dumb_tree_add_child(Dumb_Tree * tree, Dumb_Tree * element)
{
tree->elements = (Dumb_Tree_Element *) realloc(tree->elements, (tree->size + 1) * sizeof(Dumb_Tree_Element));
tree->elements[tree->size].element = element;
@@ -189,7 +183,7 @@
}
Dumb_Tree *
-dumb_tree_add_hash(Dumb_Tree *tree, Ecore_Hash *element)
+dumb_tree_add_hash(Dumb_Tree * tree, Ecore_Hash * element)
{
tree->elements = (Dumb_Tree_Element *) realloc(tree->elements, (tree->size + 1) * sizeof(Dumb_Tree_Element));
tree->elements[tree->size].element = element;
@@ -198,7 +192,7 @@
}
int
-dumb_tree_exist(Dumb_Tree *tree, char *element)
+dumb_tree_exist(Dumb_Tree * tree, char *element)
{
int exist = 0;
int i;
@@ -206,8 +200,7 @@
/* This is the dumb part of the tree, a linear search. */
for (i = 0; i < tree->size; i++)
{
- if ((tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING) &&
- (strcmp((char *) tree->elements[i].element, element) == 0))
+ if ((tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING) && (strcmp((char *)tree->elements[i].element, element) == 0))
{
exist = 1;
break;
@@ -217,115 +210,116 @@
}
int
-dumb_tree_foreach(Dumb_Tree *tree, int level, int (*func) (const void *data, Dumb_Tree *tree, int element, int level), const void *data)
+dumb_tree_foreach(Dumb_Tree * tree, int level, int (*func) (const void *data, Dumb_Tree * tree, int element, int level), const void *data)
{
int result = 0;
int i;
for (i = 0; i < tree->size; i++)
- {
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- {
- if (dumb_tree_foreach((Dumb_Tree *) tree->elements[i].element, level + 1, func, data))
- result = 1;
- }
- else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_NULL)
- {
- /* This falls into the dumb category. */
- int j = i;
- int k = i;
- int moved = 0;
-
- /* Find the next non NULL element. */
- while ((j < tree->size) && (tree->elements[j].type == DUMB_TREE_ELEMENT_TYPE_NULL))
- j++;
- /* Move the next batch of non NULL up. */
- while ((j < tree->size) && (tree->elements[j].type != DUMB_TREE_ELEMENT_TYPE_NULL))
- {
- moved = 1;
- tree->elements[k].type = tree->elements[j].type;
- tree->elements[k].element = tree->elements[j].element;
- tree->elements[j].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- tree->elements[j].element = NULL;
- j++;
- k++;
- }
- if (moved)
- i--;
- else
- tree->size = i;
- }
- else
- {
- if (func(data, tree, i, level))
- result = 1;
- }
- }
+ {
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ {
+ if (dumb_tree_foreach((Dumb_Tree *) tree->elements[i].element, level + 1, func, data))
+ result = 1;
+ }
+ else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_NULL)
+ {
+ /* This falls into the dumb category. */
+ int j = i;
+ int k = i;
+ int moved = 0;
+
+ /* Find the next non NULL element. */
+ while ((j < tree->size) && (tree->elements[j].type == DUMB_TREE_ELEMENT_TYPE_NULL))
+ j++;
+ /* Move the next batch of non NULL up. */
+ while ((j < tree->size) && (tree->elements[j].type != DUMB_TREE_ELEMENT_TYPE_NULL))
+ {
+ moved = 1;
+ tree->elements[k].type = tree->elements[j].type;
+ tree->elements[k].element = tree->elements[j].element;
+ tree->elements[j].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ tree->elements[j].element = NULL;
+ j++;
+ k++;
+ }
+ if (moved)
+ i--;
+ else
+ tree->size = i;
+ }
+ else
+ {
+ if (func(data, tree, i, level))
+ result = 1;
+ }
+ }
return result;
}
void
-dumb_tree_dump(Dumb_Tree *tree, int level)
+dumb_tree_dump(Dumb_Tree * tree, int level)
{
int i;
for (i = 0; i < tree->size; i++)
- {
- int j;
+ {
+ int j;
- for (j = 0; j < level; j++)
- printf(".");
- switch (tree->elements[i].type)
- {
- case DUMB_TREE_ELEMENT_TYPE_NULL :
- {
- printf("NULL\n");
- }
- break;
-
- case DUMB_TREE_ELEMENT_TYPE_STRING :
- {
- printf("%s\n", (char *) tree->elements[i].element);
- }
- break;
-
- case DUMB_TREE_ELEMENT_TYPE_TREE :
- {
- printf("TREE ELEMENT TYPE\n");
- dumb_tree_dump((Dumb_Tree *) tree->elements[i].element, level + 1);
- }
- break;
-
- case DUMB_TREE_ELEMENT_TYPE_HASH :
- {
- int lev;
-
- lev = level + 1;
- printf("HASH ELEMENT TYPE\n");
- ecore_hash_for_each_node((Ecore_Hash *) tree->elements[i].element, dumb_tree_dump_each_hash_node, &lev);
- }
- break;
-
- default :
- {
- printf("UNKNOWN ELEMENT TYPE!\n");
- }
- break;
- }
- }
+ for (j = 0; j < level; j++)
+ printf(".");
+ switch (tree->elements[i].type)
+ {
+ case DUMB_TREE_ELEMENT_TYPE_NULL:
+ {
+ printf("NULL\n");
+ }
+ break;
+
+ case DUMB_TREE_ELEMENT_TYPE_STRING:
+ {
+ printf("%s\n", (char *)tree->elements[i].element);
+ }
+ break;
+
+ case DUMB_TREE_ELEMENT_TYPE_TREE:
+ {
+ printf("TREE ELEMENT TYPE\n");
+ dumb_tree_dump((Dumb_Tree *) tree->elements[i].element, level + 1);
+ }
+ break;
+
+ case DUMB_TREE_ELEMENT_TYPE_HASH:
+ {
+ int lev;
+
+ lev = level + 1;
+ printf("HASH ELEMENT TYPE\n");
+ ecore_hash_for_each_node((Ecore_Hash *) tree->elements[i].element, dumb_tree_dump_each_hash_node, &lev);
+ }
+ break;
+
+ default:
+ {
+ printf("UNKNOWN ELEMENT TYPE!\n");
+ }
+ break;
+ }
+ }
}
-static void dumb_tree_dump_each_hash_node(void *value, void *user_data)
+static void
+dumb_tree_dump_each_hash_node(void *value, void *user_data)
{
Ecore_Hash_Node *node;
int level;
int j;
node = (Ecore_Hash_Node *) value;
- level = *((int *) user_data);
+ level = *((int *)user_data);
for (j = 0; j < level; j++)
printf(".");
- printf("%s = %s\n", (char *) node->key, (char *) node->value);
+ printf("%s = %s\n", (char *)node->key, (char *)node->value);
}
void
@@ -334,12 +328,12 @@
int i;
for (i = tree->size - 1; i >= 0; i--)
- {
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- dumb_tree_del((Dumb_Tree *) tree->elements[i].element);
- else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_HASH)
- ecore_hash_destroy((Ecore_Hash *) tree->elements[i].element);
- }
+ {
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ dumb_tree_del((Dumb_Tree *) tree->elements[i].element);
+ else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_HASH)
+ ecore_hash_destroy((Ecore_Hash *) tree->elements[i].element);
+ }
E_FREE(tree->elements);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/dumb_tree.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- dumb_tree.h 22 Feb 2006 04:19:42 -0000 1.1
+++ dumb_tree.h 22 Feb 2006 04:30:53 -0000 1.2
@@ -9,7 +9,6 @@
#include <Ecore_Data.h>
-
typedef enum _Dumb_Tree_Element_Type Dumb_Tree_Element_Type;
enum _Dumb_Tree_Element_Type
{
@@ -22,18 +21,18 @@
typedef struct _Dumb_Tree_Element Dumb_Tree_Element;
struct _Dumb_Tree_Element
{
- void *element; /* A pointer to the element. */
- Dumb_Tree_Element_Type type; /* The type of the element. */
+ void *element; /* A pointer to the element. */
+ Dumb_Tree_Element_Type type; /* The type of the element. */
};
typedef struct _Dumb_Tree Dumb_Tree;
struct _Dumb_Tree
{
- Dumb_Tree_Element *elements; /* An array of elements. */
- int size; /* The size of the array. */
- char **buffers; /* An array of pointers to the bits of data. */
- int buffers_size; /* The size of the array. */
- Dumb_Tree *parent; /* Parent if this is a child. */
+ Dumb_Tree_Element *elements; /* An array of elements. */
+ int size; /* The size of the array. */
+ char **buffers; /* An array of pointers to the bits of data. */
+ int buffers_size; /* The size of the array. */
+ Dumb_Tree *parent; /* Parent if this is a child. */
};
# ifdef __cplusplus
@@ -43,17 +42,17 @@
Dumb_Tree *dumb_tree_from_paths(char *paths);
Dumb_Tree *dumb_tree_new(char *buffer);
- Dumb_Tree *dumb_tree_add(Dumb_Tree *tree, char *element);
- void dumb_tree_track(Dumb_Tree *tree, void *element);
- Dumb_Tree *dumb_tree_extend(Dumb_Tree *tree, char *element);
- Dumb_Tree *dumb_tree_insert(Dumb_Tree *tree, int before, void *element, Dumb_Tree_Element_Type type);
- Dumb_Tree *dumb_tree_insert_tree(Dumb_Tree *tree, int before, Dumb_Tree *element);
- Dumb_Tree *dumb_tree_add_child(Dumb_Tree *tree, Dumb_Tree *element);
- Dumb_Tree *dumb_tree_add_hash(Dumb_Tree *tree, Ecore_Hash *element);
- int dumb_tree_exist(Dumb_Tree *tree, char *element);
- int dumb_tree_foreach(Dumb_Tree *tree, int level, int (*func) (const void *data, Dumb_Tree *tree, int element, int level), const void *data);
- void dumb_tree_dump(Dumb_Tree *tree, int level);
- void dumb_tree_del(Dumb_Tree *tree);
+ Dumb_Tree *dumb_tree_add(Dumb_Tree * tree, char *element);
+ void dumb_tree_track(Dumb_Tree * tree, void *element);
+ Dumb_Tree *dumb_tree_extend(Dumb_Tree * tree, char *element);
+ Dumb_Tree *dumb_tree_insert(Dumb_Tree * tree, int before, void *element, Dumb_Tree_Element_Type type);
+ Dumb_Tree *dumb_tree_insert_tree(Dumb_Tree * tree, int before, Dumb_Tree * element);
+ Dumb_Tree *dumb_tree_add_child(Dumb_Tree * tree, Dumb_Tree * element);
+ Dumb_Tree *dumb_tree_add_hash(Dumb_Tree * tree, Ecore_Hash * element);
+ int dumb_tree_exist(Dumb_Tree * tree, char *element);
+ int dumb_tree_foreach(Dumb_Tree * tree, int level, int (*func) (const void *data, Dumb_Tree * tree, int element, int level), const void *data);
+ void dumb_tree_dump(Dumb_Tree * tree, int level);
+ void dumb_tree_del(Dumb_Tree * tree);
# ifdef __cplusplus
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/dumb_tree.o,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
Binary files /tmp/cvsPhtxVo and /tmp/cvsECZ3tD differ
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/eaps.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- eaps.c 4 Feb 2006 00:36:48 -0000 1.5
+++ eaps.c 22 Feb 2006 04:30:53 -0000 1.6
@@ -149,11 +149,9 @@
eet_delete(ef, section);
if (value)
{
- i = eet_write(ef, strdup(section), strdup(value), strlen(value),
- 0);
+ i = eet_write(ef, strdup(section), strdup(value), strlen(value), 0);
if (i == 0)
- fprintf(stderr, "Failed To Write %s To %s Of %s\n", value,
- section, file);
+ fprintf(stderr, "Failed To Write %s To %s Of %s\n", value, section, file);
}
}
eet_close(ef);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/fdo_menus.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- fdo_menus.c 22 Feb 2006 04:15:44 -0000 1.16
+++ fdo_menus.c 22 Feb 2006 04:30:53 -0000 1.17
@@ -50,22 +50,21 @@
int include;
};
-static int _fdo_menus_unxml(const void *data, Dumb_Tree *tree, int element, int level);
+static int _fdo_menus_unxml(const void *data, Dumb_Tree * tree, int element, int level);
static int _fdo_menus_check_directory(const void *data, char *path);
static int _fdo_menus_check_menu(const void *data, char *path);
-static void _fdo_menus_unxml_rules(Dumb_Tree *rules, Dumb_Tree *tree, char type, char sub_type);
-static void _fdo_menus_unxml_moves(Dumb_Tree *menu, Dumb_Tree *tree);
-static void _fdo_menus_add_dirs(Dumb_Tree *tree, Dumb_Tree *paths, char *pre, char *post, char *extra, int element);
-static int _fdo_menus_expand_apps(struct _fdo_menus_unxml_data *unxml_data, char *app_dir, Ecore_Hash *pool);
+static void _fdo_menus_unxml_rules(Dumb_Tree * rules, Dumb_Tree * tree, char type, char sub_type);
+static void _fdo_menus_unxml_moves(Dumb_Tree * menu, Dumb_Tree * tree);
+static void _fdo_menus_add_dirs(Dumb_Tree * tree, Dumb_Tree * paths, char *pre, char *post, char *extra, int element);
+static int _fdo_menus_expand_apps(struct _fdo_menus_unxml_data *unxml_data, char *app_dir, Ecore_Hash * pool);
static int _fdo_menus_check_app(const void *data, char *path);
-static int _fdo_menus_generate(const void *data, Dumb_Tree *tree, int element, int level);
+static int _fdo_menus_generate(const void *data, Dumb_Tree * tree, int element, int level);
static void _fdo_menus_inherit_apps(void *value, void *user_data);
static void _fdo_menus_select_app(void *value, void *user_data);
-static int _fdo_menus_apply_rules(struct _fdo_menus_generate_data *generate_data, Dumb_Tree *rule, char *key, Desktop *desktop);
-
+static int _fdo_menus_apply_rules(struct _fdo_menus_generate_data *generate_data, Dumb_Tree * rule, char *key, Desktop * desktop);
Dumb_Tree *
-fdo_menus_get(char *file, Dumb_Tree *xml)
+fdo_menus_get(char *file, Dumb_Tree * xml)
{
struct _fdo_menus_unxml_data data;
@@ -73,354 +72,356 @@
data.menus = dumb_tree_new(NULL);
data.stack = dumb_tree_new(NULL);
if ((data.menus) && (data.stack))
- {
- data.base = ecore_file_strip_ext(ecore_file_get_file(file));
- data.path = ecore_file_get_dir(file);
- if ((data.base) && (data.path))
- {
- dumb_tree_foreach(xml, 0, _fdo_menus_unxml, &data);
- dumb_tree_dump(xml, 0);
- printf("\n\n");
- data.unallocated = FALSE;
- dumb_tree_foreach(xml, 0, _fdo_menus_generate, &data);
- data.unallocated = TRUE;
- dumb_tree_foreach(xml, 0, _fdo_menus_generate, &data);
- dumb_tree_dump(xml, 0);
- printf("\n\n");
- }
- E_FREE(data.path);
- E_FREE(data.base);
- }
+ {
+ data.base = ecore_file_strip_ext(ecore_file_get_file(file));
+ data.path = ecore_file_get_dir(file);
+ if ((data.base) && (data.path))
+ {
+ dumb_tree_foreach(xml, 0, _fdo_menus_unxml, &data);
+ dumb_tree_dump(xml, 0);
+ printf("\n\n");
+ data.unallocated = FALSE;
+ dumb_tree_foreach(xml, 0, _fdo_menus_generate, &data);
+ data.unallocated = TRUE;
+ dumb_tree_foreach(xml, 0, _fdo_menus_generate, &data);
+ dumb_tree_dump(xml, 0);
+ printf("\n\n");
+ }
+ E_FREE(data.path);
+ E_FREE(data.base);
+ }
else
- {
- E_FN_DEL(dumb_tree_del, (data.stack));
- E_FN_DEL(dumb_tree_del, (data.menus));
- }
+ {
+ E_FN_DEL(dumb_tree_del, (data.stack));
+ E_FN_DEL(dumb_tree_del, (data.menus));
+ }
return data.menus;
}
-
static int
-_fdo_menus_unxml(const void *data, Dumb_Tree *tree, int element, int level)
+_fdo_menus_unxml(const void *data, Dumb_Tree * tree, int element, int level)
{
struct _fdo_menus_unxml_data *unxml_data;
Dumb_Tree *menus;
- unxml_data = (struct _fdo_menus_unxml_data *) data;
+ unxml_data = (struct _fdo_menus_unxml_data *)data;
menus = (Dumb_Tree *) unxml_data->menus;
if (tree->elements[element].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strncmp((char *) tree->elements[element].element, "<!", 2) == 0)
- {
- tree->elements[element].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- tree->elements[element].element = NULL;
- }
- else if (strcmp((char *) tree->elements[element].element, "<Menu") == 0)
- {
- Dumb_Tree *menu, *rules;
- Ecore_Hash *pool, *apps;
-
- menu = dumb_tree_new(NULL);
- rules = dumb_tree_new(NULL);
- pool = ecore_hash_new(ecore_str_hash, ecore_str_compare);
- apps = ecore_hash_new(ecore_str_hash, ecore_str_compare);
- if ((menu) && (rules) && (pool) && (apps))
- {
- int i;
- char *flags = " ", *name = "", *directory = "", *menu_path = "";
- char temp[MAX_PATH];
-
- ecore_hash_set_free_key(pool, free);
- ecore_hash_set_free_value(pool, free);
- ecore_hash_set_free_key(apps, free);
- ecore_hash_set_free_value(apps, free);
- sprintf(temp, "<MENU <%.3s> <%s> <%s>", flags, name, directory);
- dumb_tree_extend(menu, temp);
- sprintf(temp, "<MENU_PATH %s", menu_path);
- dumb_tree_extend(menu, temp);
- flags = (char *) menu->elements[0].element;
- flags += 7;
- dumb_tree_add_hash(menu, pool);
- dumb_tree_add_child(menu, rules);
- dumb_tree_add_hash(menu, apps);
- tree->elements[element].element = menu;
- tree->elements[element].type = DUMB_TREE_ELEMENT_TYPE_TREE;
- for (i = element + 1; i < tree->size; i++)
- {
- int result = 0;
-
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strncmp((char *) tree->elements[i].element, "<!", 2) == 0)
- {
- tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- tree->elements[i].element = NULL;
- }
- else if (strcmp((char *) tree->elements[i].element, "<Deleted/") == 0)
- {
- flags[1] = 'D';
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "<NotDeleted/") == 0)
- {
- flags[1] = ' ';
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "<OnlyUnallocated/") == 0)
- {
- flags[2] = 'O';
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "<NotOnlyUnallocated/") == 0)
- {
- flags[2] = ' ';
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "<DefaultAppDirs/") == 0)
- {
- _fdo_menus_add_dirs(menu, fdo_paths_desktops, "<AppDir", "</AppDir", NULL, i);
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "<DefaultDirectoryDirs/") == 0)
- {
- _fdo_menus_add_dirs(menu, fdo_paths_directories, "<DirectoryDir", "</DirectoryDir", NULL, i);
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "<DefaultMergeDirs/") == 0)
- {
- if (unxml_data->base)
- {
- _fdo_menus_add_dirs(menu, fdo_paths_menus, "<MergeDir", "</MergeDir", unxml_data->base, i);
- result = 1;
- }
- }
- else if (strcmp((char *) tree->elements[i].element, "<KDELegacyDirs/") == 0)
- {
- _fdo_menus_add_dirs(menu, fdo_paths_kde_legacy, "<LegacyDir prefix=\"kde-\"", "</LegacyDir", NULL, i);
- result = 1;
- }
- else if (strcmp((char *) tree->elements[i].element, "</Menu") == 0)
- {
- result = 1;
- }
- else
- {
- dumb_tree_extend(menu, (char *) tree->elements[i].element);
- result = 1;
- }
- }
- else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- {
- Dumb_Tree *sub;
-
- sub = (Dumb_Tree *) tree->elements[i].element;
- if ((sub) && (sub->size))
- {
- if (sub->elements[0].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strcmp((char *) sub->elements[0].element, "<Name") == 0)
- {
- int i, length = 0;
-
- name = strdup((char *) sub->elements[1].element);
- sprintf(temp, "<MENU <%.3s> <%s> <%s>", flags, name, directory);
- menu->elements[0].element = strdup(temp);
- dumb_tree_track(menu, name);
- dumb_tree_track(menu, menu->elements[0].element);
- flags = (char *) menu->elements[0].element;
- flags += 7;
- /* The rest of this is probably not needed, except to ease debugging. */
- if (unxml_data->stack->size <= level)
- {
- while (unxml_data->stack->size < level)
- dumb_tree_add(unxml_data->stack, "");
- dumb_tree_add(unxml_data->stack, name);
- }
- else
- unxml_data->stack->elements[level].element = name;
- temp[0] = '\0';
- for (i = 0; i <= level; i++)
- {
- char *text;
-
- /* I can safely assume that they are all strings. */
- text = (char *) unxml_data->stack->elements[i].element;
- if (text[0] != '\0')
- {
- sprintf(&temp[length], "%s%s", ((length) ? "/" : ""), text);
- length += strlen(text) + ((length) ? 1 : 0);
- }
- }
- menu_path = strdup(temp);
- sprintf(temp, "<MENU_PATH %s", menu_path);
- menu->elements[1].element = strdup(temp);
- dumb_tree_track(menu, menu_path);
- dumb_tree_track(menu, menu->elements[1].element);
- result = 1;
- }
- else if (strcmp((char *) sub->elements[0].element, "<Directory") == 0)
- {
- directory = strdup((char *) sub->elements[1].element);
- sprintf(temp, "<MENU <%.3s> <%s> <%s>", flags, name, directory);
- menu->elements[0].element = strdup(temp);
- dumb_tree_track(menu, directory);
- dumb_tree_track(menu, menu->elements[0].element);
- flags = (char *) menu->elements[0].element;
- flags += 7;
- result = 1;
- }
- else if ((strcmp((char *) sub->elements[0].element, "<Include") == 0) ||
- (strcmp((char *) sub->elements[0].element, "<Exclude") == 0))
- {
- Dumb_Tree *new_sub;
-
- new_sub = dumb_tree_new(NULL);
- if (new_sub)
- {
- dumb_tree_add_child(rules, new_sub);
- _fdo_menus_unxml_rules(new_sub, sub, ((char *) sub->elements[0].element)[1], 'O');
- result = 1;
- }
- }
- else if (strcmp((char *) sub->elements[0].element, "<Menu") == 0)
- {
- _fdo_menus_unxml(data, sub, 0, level + 1);
- dumb_tree_add_child(menu, (Dumb_Tree *) sub->elements[0].element);
- /* FIXME: Dunno if this causes a memory leak, but for now we play it safe. */
- tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- tree->elements[i].element = NULL;
-// result = 1;
- }
- else if (strcmp((char *) sub->elements[0].element, "<Move") == 0)
- {
- _fdo_menus_unxml_moves(menu, sub);
- result = 1;
- }
- else
- {
- if ((sub->size == 3) && (sub->elements[1].type == DUMB_TREE_ELEMENT_TYPE_STRING))
- {
- char temp[MAX_PATH];
-
- sprintf(temp, "%s %s", (char *) sub->elements[0].element, (char *) sub->elements[1].element);
- dumb_tree_extend(menu, temp);
- result = 1;
- }
- else
- {
- dumb_tree_add_child(menu, sub);
- tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- tree->elements[i].element = NULL;
- }
- }
- }
- }
- }
- if (result)
- {
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- dumb_tree_del((Dumb_Tree *) tree->elements[i].element);
+ {
+ if (strncmp((char *)tree->elements[element].element, "<!", 2) == 0)
+ {
+ tree->elements[element].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ tree->elements[element].element = NULL;
+ }
+ else if (strcmp((char *)tree->elements[element].element, "<Menu") == 0)
+ {
+ Dumb_Tree *menu, *rules;
+ Ecore_Hash *pool, *apps;
+
+ menu = dumb_tree_new(NULL);
+ rules = dumb_tree_new(NULL);
+ pool = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ apps = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ if ((menu) && (rules) && (pool) && (apps))
+ {
+ int i;
+ char *flags = " ", *name = "", *directory = "", *menu_path = "";
+ char temp[MAX_PATH];
+
+ ecore_hash_set_free_key(pool, free);
+ ecore_hash_set_free_value(pool, free);
+ ecore_hash_set_free_key(apps, free);
+ ecore_hash_set_free_value(apps, free);
+ sprintf(temp, "<MENU <%.3s> <%s> <%s>", flags, name, directory);
+ dumb_tree_extend(menu, temp);
+ sprintf(temp, "<MENU_PATH %s", menu_path);
+ dumb_tree_extend(menu, temp);
+ flags = (char *)menu->elements[0].element;
+ flags += 7;
+ dumb_tree_add_hash(menu, pool);
+ dumb_tree_add_child(menu, rules);
+ dumb_tree_add_hash(menu, apps);
+ tree->elements[element].element = menu;
+ tree->elements[element].type = DUMB_TREE_ELEMENT_TYPE_TREE;
+ for (i = element + 1; i < tree->size; i++)
+ {
+ int result = 0;
+
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
+ {
+ if (strncmp((char *)tree->elements[i].element, "<!", 2) == 0)
+ {
tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
tree->elements[i].element = NULL;
- }
- }
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<Deleted/") == 0)
+ {
+ flags[1] = 'D';
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<NotDeleted/") == 0)
+ {
+ flags[1] = ' ';
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<OnlyUnallocated/") == 0)
+ {
+ flags[2] = 'O';
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<NotOnlyUnallocated/") == 0)
+ {
+ flags[2] = ' ';
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<DefaultAppDirs/") == 0)
+ {
+ _fdo_menus_add_dirs(menu, fdo_paths_desktops, "<AppDir", "</AppDir", NULL, i);
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<DefaultDirectoryDirs/") == 0)
+ {
+ _fdo_menus_add_dirs(menu, fdo_paths_directories, "<DirectoryDir", "</DirectoryDir", NULL, i);
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<DefaultMergeDirs/") == 0)
+ {
+ if (unxml_data->base)
+ {
+ _fdo_menus_add_dirs(menu, fdo_paths_menus, "<MergeDir", "</MergeDir", unxml_data->base, i);
+ result = 1;
+ }
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<KDELegacyDirs/") == 0)
+ {
+ _fdo_menus_add_dirs(menu, fdo_paths_kde_legacy, "<LegacyDir prefix=\"kde-\"", "</LegacyDir", NULL, i);
+ result = 1;
+ }
+ else if (strcmp((char *)tree->elements[i].element, "</Menu") == 0)
+ {
+ result = 1;
+ }
+ else
+ {
+ dumb_tree_extend(menu, (char *)tree->elements[i].element);
+ result = 1;
+ }
+ }
+ else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ {
+ Dumb_Tree *sub;
+
+ sub = (Dumb_Tree *) tree->elements[i].element;
+ if ((sub) && (sub->size))
+ {
+ if (sub->elements[0].type == DUMB_TREE_ELEMENT_TYPE_STRING)
+ {
+ if (strcmp((char *)sub->elements[0].element, "<Name") == 0)
+ {
+ int i, length = 0;
+
+ name = strdup((char *)sub->elements[1].element);
+ sprintf(temp, "<MENU <%.3s> <%s> <%s>", flags, name, directory);
+ menu->elements[0].element = strdup(temp);
+ dumb_tree_track(menu, name);
+ dumb_tree_track(menu, menu->elements[0].element);
+ flags = (char *)menu->elements[0].element;
+ flags += 7;
+ /* The rest of this is probably not needed, except to ease debugging. */
+ if (unxml_data->stack->size <= level)
+ {
+ while (unxml_data->stack->size < level)
+ dumb_tree_add(unxml_data->stack, "");
+ dumb_tree_add(unxml_data->stack, name);
+ }
+ else
+ unxml_data->stack->elements[level].element = name;
+ temp[0] = '\0';
+ for (i = 0; i <= level; i++)
+ {
+ char *text;
+
+ /* I can safely assume that they are all strings. */
+ text = (char *)unxml_data->stack->elements[i].element;
+ if (text[0] != '\0')
+ {
+ sprintf(&temp[length], "%s%s", ((length) ? "/" : ""), text);
+ length += strlen(text) + ((length) ? 1 : 0);
+ }
+ }
+ menu_path = strdup(temp);
+ sprintf(temp, "<MENU_PATH %s", menu_path);
+ menu->elements[1].element = strdup(temp);
+ dumb_tree_track(menu, menu_path);
+ dumb_tree_track(menu, menu->elements[1].element);
+ result = 1;
+ }
+ else if (strcmp((char *)sub->elements[0].element, "<Directory") == 0)
+ {
+ directory = strdup((char *)sub->elements[1].element);
+ sprintf(temp, "<MENU <%.3s> <%s> <%s>", flags, name, directory);
+ menu->elements[0].element = strdup(temp);
+ dumb_tree_track(menu, directory);
+ dumb_tree_track(menu, menu->elements[0].element);
+ flags = (char *)menu->elements[0].element;
+ flags += 7;
+ result = 1;
+ }
+ else if ((strcmp((char *)sub->elements[0].element, "<Include") == 0) ||
+ (strcmp((char *)sub->elements[0].element, "<Exclude") == 0))
+ {
+ Dumb_Tree *new_sub;
+
+ new_sub = dumb_tree_new(NULL);
+ if (new_sub)
+ {
+ dumb_tree_add_child(rules, new_sub);
+ _fdo_menus_unxml_rules(new_sub, sub, ((char *)sub->elements[0].element)[1], 'O');
+ result = 1;
+ }
+ }
+ else if (strcmp((char *)sub->elements[0].element, "<Menu") == 0)
+ {
+ _fdo_menus_unxml(data, sub, 0, level + 1);
+ dumb_tree_add_child(menu, (Dumb_Tree *) sub->elements[0].element);
+ /* FIXME: Dunno if this causes a memory leak, but for now we play it safe. */
+ tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ tree->elements[i].element = NULL;
+// result = 1;
+ }
+ else if (strcmp((char *)sub->elements[0].element, "<Move") == 0)
+ {
+ _fdo_menus_unxml_moves(menu, sub);
+ result = 1;
+ }
+ else
+ {
+ if ((sub->size == 3) && (sub->elements[1].type == DUMB_TREE_ELEMENT_TYPE_STRING))
+ {
+ char temp[MAX_PATH];
+
+ sprintf(temp, "%s %s", (char *)sub->elements[0].element, (char *)sub->elements[1].element);
+ dumb_tree_extend(menu, temp);
+ result = 1;
+ }
+ else
+ {
+ dumb_tree_add_child(menu, sub);
+ tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ tree->elements[i].element = NULL;
+ }
+ }
+ }
+ }
+ }
+ if (result)
+ {
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ dumb_tree_del((Dumb_Tree *) tree->elements[i].element);
+ tree->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ tree->elements[i].element = NULL;
+ }
+ }
+
+ for (i = 4; i < menu->size; i++)
+ {
+ int result = 0;
+
+ if (menu->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
+ {
+ char *string;
+
+ string = (char *)menu->elements[i].element;
+ if (strncmp(string, "<DirectoryDir ", 14) == 0)
+ {
+ char merge_path[MAX_PATH];
+ Dumb_Tree *merge;
+
+ if (string[14] == '/')
+ sprintf(merge_path, "%s", &string[14]);
+ else
+ sprintf(merge_path, "%s%s", unxml_data->path, &string[14]);
+ merge = dumb_tree_new(NULL);
+ if (merge)
+ {
+ fdo_paths_recursive_search(merge_path, NULL, _fdo_menus_check_directory, merge);
+ dumb_tree_insert_tree(menu, i + 1, merge);
+ }
+ result = 1;
+ }
+ else if (strncmp(string, "<LegacyDir ", 11) == 0)
+ {
+ }
+ else if (strncmp(string, "<MergeDir ", 10) == 0)
+ {
+ char merge_path[MAX_PATH];
+ Dumb_Tree *merge;
- for (i = 4; i < menu->size; i++)
- {
- int result = 0;
-
- if (menu->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- char *string;
-
- string = (char *) menu->elements[i].element;
- if (strncmp(string, "<DirectoryDir ", 14) == 0)
- {
- char merge_path[MAX_PATH];
- Dumb_Tree *merge;
-
- if (string[14] == '/')
- sprintf(merge_path, "%s", &string[14]);
- else
- sprintf(merge_path, "%s%s", unxml_data->path, &string[14]);
- merge = dumb_tree_new(NULL);
- if (merge)
- {
- fdo_paths_recursive_search(merge_path, NULL, _fdo_menus_check_directory, merge);
- dumb_tree_insert_tree(menu, i + 1, merge);
- }
- result = 1;
- }
- else if (strncmp(string, "<LegacyDir ", 11) == 0)
- {
- }
- else if (strncmp(string, "<MergeDir ", 10) == 0)
- {
- char merge_path[MAX_PATH];
- Dumb_Tree *merge;
-
- if (string[10] == '/')
- sprintf(merge_path, "%s", &string[10]);
- else
- sprintf(merge_path, "%s%s", unxml_data->path, &string[10]);
- merge = dumb_tree_new(NULL);
- if (merge)
- {
- fdo_paths_recursive_search(merge_path, NULL, _fdo_menus_check_menu, merge);
- dumb_tree_insert_tree(menu, i + 1, merge);
- }
- result = 1;
- }
- else if (strncmp(string, "<MergeFile ", 8) == 0)
- {
- }
- }
- if (result)
- {
- menu->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- menu->elements[i].element = NULL;
- }
- }
-
- for (i = 4; i < menu->size; i++)
- {
- int result = 0;
-
- if (menu->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- char *string;
-
- string = (char *) menu->elements[i].element;
- if (strncmp(string, "<AppDir ", 8) == 0)
- {
- _fdo_menus_expand_apps(unxml_data, &string[8], pool);
- result = 1;
- }
- }
- if (result)
- {
- menu->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
- menu->elements[i].element = NULL;
- }
- }
-
-
- /* Add it if it has not been deleted. */
- if (flags[1] != 'D')
- {
- tree->elements[element].element = menu;
- tree->elements[element].type = DUMB_TREE_ELEMENT_TYPE_TREE;
- }
- }
- else
- {
- if (apps) ecore_hash_destroy(apps);
- if (pool) ecore_hash_destroy(pool);
- if (rules) dumb_tree_del(rules);
- if (menu) dumb_tree_del(menu);
- }
- }
- }
+ if (string[10] == '/')
+ sprintf(merge_path, "%s", &string[10]);
+ else
+ sprintf(merge_path, "%s%s", unxml_data->path, &string[10]);
+ merge = dumb_tree_new(NULL);
+ if (merge)
+ {
+ fdo_paths_recursive_search(merge_path, NULL, _fdo_menus_check_menu, merge);
+ dumb_tree_insert_tree(menu, i + 1, merge);
+ }
+ result = 1;
+ }
+ else if (strncmp(string, "<MergeFile ", 8) == 0)
+ {
+ }
+ }
+ if (result)
+ {
+ menu->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ menu->elements[i].element = NULL;
+ }
+ }
+
+ for (i = 4; i < menu->size; i++)
+ {
+ int result = 0;
+
+ if (menu->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
+ {
+ char *string;
+
+ string = (char *)menu->elements[i].element;
+ if (strncmp(string, "<AppDir ", 8) == 0)
+ {
+ _fdo_menus_expand_apps(unxml_data, &string[8], pool);
+ result = 1;
+ }
+ }
+ if (result)
+ {
+ menu->elements[i].type = DUMB_TREE_ELEMENT_TYPE_NULL;
+ menu->elements[i].element = NULL;
+ }
+ }
+
+ /* Add it if it has not been deleted. */
+ if (flags[1] != 'D')
+ {
+ tree->elements[element].element = menu;
+ tree->elements[element].type = DUMB_TREE_ELEMENT_TYPE_TREE;
+ }
+ }
+ else
+ {
+ if (apps)
+ ecore_hash_destroy(apps);
+ if (pool)
+ ecore_hash_destroy(pool);
+ if (rules)
+ dumb_tree_del(rules);
+ if (menu)
+ dumb_tree_del(menu);
+ }
+ }
+ }
return 0;
}
@@ -433,15 +434,15 @@
merge = (Dumb_Tree *) data;
p = strrchr(path, '.');
if (p)
- {
- if (strcmp(p, ".directory") == 0)
- {
- char merge_file[MAX_PATH];
-
- sprintf(merge_file, "<Directory %s", path);
- dumb_tree_extend(merge, merge_file);
- }
- }
+ {
+ if (strcmp(p, ".directory") == 0)
+ {
+ char merge_file[MAX_PATH];
+
+ sprintf(merge_file, "<Directory %s", path);
+ dumb_tree_extend(merge, merge_file);
+ }
+ }
return 0;
}
@@ -455,147 +456,145 @@
merge = (Dumb_Tree *) data;
p = strrchr(path, '.');
if (p)
- {
- if (strcmp(p, ".menu") == 0)
- {
- char merge_file[MAX_PATH];
-
- sprintf(merge_file, "<MergeFile type=\"path\" %s", path);
- dumb_tree_extend(merge, merge_file);
- }
- }
+ {
+ if (strcmp(p, ".menu") == 0)
+ {
+ char merge_file[MAX_PATH];
+
+ sprintf(merge_file, "<MergeFile type=\"path\" %s", path);
+ dumb_tree_extend(merge, merge_file);
+ }
+ }
return 0;
}
-
static void
-_fdo_menus_unxml_rules(Dumb_Tree *rules, Dumb_Tree *tree, char type, char sub_type)
+_fdo_menus_unxml_rules(Dumb_Tree * rules, Dumb_Tree * tree, char type, char sub_type)
{
int i;
char temp[MAX_PATH];
for (i = 0; i < tree->size; i++)
- {
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strcmp((char *) tree->elements[i].element, "<All/") == 0)
- {
- sprintf(temp, "%c%cA", type, sub_type);
- dumb_tree_extend(rules, temp);
- }
- else if (strcmp((char *) tree->elements[i].element, "<Filename") == 0)
- {
- sprintf(temp, "%c%cF %s", type, sub_type, (char *) tree->elements[i + 1].element);
- dumb_tree_extend(rules, temp);
- }
- else if (strcmp((char *) tree->elements[i].element, "<Category") == 0)
- {
- sprintf(temp, "%c%cC %s", type, sub_type, (char *) tree->elements[i + 1].element);
- dumb_tree_extend(rules, temp);
- }
- else if (strcmp((char *) tree->elements[i].element, "<Or") == 0)
- {
- _fdo_menus_unxml_rules(rules, (Dumb_Tree *) tree->elements[i + 1].element, type, sub_type);
- }
- else if ((strcmp((char *) tree->elements[i].element, "<And") == 0) ||
- (strcmp((char *) tree->elements[i].element, "<Not") == 0))
- {
- char this_type;
- Dumb_Tree *sub;
-
- this_type = ((char *) tree->elements[i].element)[1];
- sub = dumb_tree_new(NULL);
- if (sub)
- {
- dumb_tree_add_child(rules, sub);
- for (i++; i < tree->size; i++)
- {
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- _fdo_menus_unxml_rules(sub, (Dumb_Tree *) tree->elements[i].element, type, this_type);
- }
- }
- }
- }
- else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- {
- _fdo_menus_unxml_rules(rules, (Dumb_Tree *) tree->elements[i].element, type, sub_type);
- }
- }
+ {
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_STRING)
+ {
+ if (strcmp((char *)tree->elements[i].element, "<All/") == 0)
+ {
+ sprintf(temp, "%c%cA", type, sub_type);
+ dumb_tree_extend(rules, temp);
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<Filename") == 0)
+ {
+ sprintf(temp, "%c%cF %s", type, sub_type, (char *)tree->elements[i + 1].element);
+ dumb_tree_extend(rules, temp);
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<Category") == 0)
+ {
+ sprintf(temp, "%c%cC %s", type, sub_type, (char *)tree->elements[i + 1].element);
+ dumb_tree_extend(rules, temp);
+ }
+ else if (strcmp((char *)tree->elements[i].element, "<Or") == 0)
+ {
+ _fdo_menus_unxml_rules(rules, (Dumb_Tree *) tree->elements[i + 1].element, type, sub_type);
+ }
+ else if ((strcmp((char *)tree->elements[i].element, "<And") == 0) || (strcmp((char *)tree->elements[i].element, "<Not") == 0))
+ {
+ char this_type;
+ Dumb_Tree *sub;
+
+ this_type = ((char *)tree->elements[i].element)[1];
+ sub = dumb_tree_new(NULL);
+ if (sub)
+ {
+ dumb_tree_add_child(rules, sub);
+ for (i++; i < tree->size; i++)
+ {
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ _fdo_menus_unxml_rules(sub, (Dumb_Tree *) tree->elements[i].element, type, this_type);
+ }
+ }
+ }
+ }
+ else if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ {
+ _fdo_menus_unxml_rules(rules, (Dumb_Tree *) tree->elements[i].element, type, sub_type);
+ }
+ }
}
static void
-_fdo_menus_unxml_moves(Dumb_Tree *menu, Dumb_Tree *tree)
+_fdo_menus_unxml_moves(Dumb_Tree * menu, Dumb_Tree * tree)
{
int i;
char *old = NULL;
char *new = NULL;
for (i = 0; i < tree->size; i++)
- {
- if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- {
- Dumb_Tree *sub;
-
- sub = (Dumb_Tree *) tree->elements[i].element;
- if ((sub) && (sub->size))
- {
- if (sub->elements[0].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strcmp((char *) sub->elements[0].element, "<Old") == 0)
- old = strdup((char *) sub->elements[1].element);
- if (strcmp((char *) sub->elements[0].element, "<New") == 0)
- new = strdup((char *) sub->elements[1].element);
- }
- }
- }
- if ((old) && (new))
- {
- char temp[MAX_PATH * 2];
-
- sprintf(temp, "<MOVE <%s> <%s>", old, new);
- dumb_tree_extend(menu, temp);
- free(old);
- old = NULL;
- free(new);
- new = NULL;
- }
- }
+ {
+ if (tree->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ {
+ Dumb_Tree *sub;
+
+ sub = (Dumb_Tree *) tree->elements[i].element;
+ if ((sub) && (sub->size))
+ {
+ if (sub->elements[0].type == DUMB_TREE_ELEMENT_TYPE_STRING)
+ {
+ if (strcmp((char *)sub->elements[0].element, "<Old") == 0)
+ old = strdup((char *)sub->elements[1].element);
+ if (strcmp((char *)sub->elements[0].element, "<New") == 0)
+ new = strdup((char *)sub->elements[1].element);
+ }
+ }
+ }
+ if ((old) && (new))
+ {
+ char temp[MAX_PATH * 2];
+
+ sprintf(temp, "<MOVE <%s> <%s>", old, new);
+ dumb_tree_extend(menu, temp);
+ free(old);
+ old = NULL;
+ free(new);
+ new = NULL;
+ }
+ }
}
static void
-_fdo_menus_add_dirs(Dumb_Tree *tree, Dumb_Tree *paths, char *pre, char *post, char *extra, int element)
+_fdo_menus_add_dirs(Dumb_Tree * tree, Dumb_Tree * paths, char *pre, char *post, char *extra, int element)
{
int i;
char t[MAX_PATH];
/* reverse the order of the dirs. */
for (i = paths->size - 1; i >= 0; i--)
- {
- if (extra)
- sprintf(t, "%s %s%s-merged/", pre, (char *) paths->elements[i].element, extra);
- else
- sprintf(t, "%s %s", pre, (char *) paths->elements[i].element);
- dumb_tree_extend(tree, t);
- }
+ {
+ if (extra)
+ sprintf(t, "%s %s%s-merged/", pre, (char *)paths->elements[i].element, extra);
+ else
+ sprintf(t, "%s %s", pre, (char *)paths->elements[i].element);
+ dumb_tree_extend(tree, t);
+ }
}
static int
-_fdo_menus_expand_apps(struct _fdo_menus_unxml_data *unxml_data, char *app_dir, Ecore_Hash *pool)
+_fdo_menus_expand_apps(struct _fdo_menus_unxml_data *unxml_data, char *app_dir, Ecore_Hash * pool)
{
if (pool)
- {
- struct _fdo_menus_expand_apps_data our_data;
- char dir[MAX_PATH];
-
- our_data.pool = pool;
- sprintf(dir, "%s", app_dir);
- if (dir[0] != '/')
+ {
+ struct _fdo_menus_expand_apps_data our_data;
+ char dir[MAX_PATH];
+
+ our_data.pool = pool;
+ sprintf(dir, "%s", app_dir);
+ if (dir[0] != '/')
sprintf(dir, "%s/%s", unxml_data->path, app_dir);
- our_data.path = dir;
- our_data.length = strlen(dir);
- fdo_paths_recursive_search(dir, NULL, _fdo_menus_check_app, &our_data);
- }
+ our_data.path = dir;
+ our_data.length = strlen(dir);
+ fdo_paths_recursive_search(dir, NULL, _fdo_menus_check_app, &our_data);
+ }
return 0;
}
@@ -605,107 +604,106 @@
char *p;
struct _fdo_menus_expand_apps_data *our_data;
- our_data = (struct _fdo_menus_expand_apps_data *) data;
+ our_data = (struct _fdo_menus_expand_apps_data *)data;
p = strrchr(path, '.');
if (p)
- {
- if (strcmp(p, ".desktop") == 0)
- {
- int i;
- char *file;
-
- file = strdup(path + our_data->length);
- if ((file) && (path))
- {
- for (i = 0; file[i] != '\0'; i++ )
- if (file[i] == '/')
- file[i] = '-';
- ecore_hash_set(our_data->pool, file, strdup(path));
- }
- }
- }
+ {
+ if (strcmp(p, ".desktop") == 0)
+ {
+ int i;
+ char *file;
+
+ file = strdup(path + our_data->length);
+ if ((file) && (path))
+ {
+ for (i = 0; file[i] != '\0'; i++)
+ if (file[i] == '/')
+ file[i] = '-';
+ ecore_hash_set(our_data->pool, file, strdup(path));
+ }
+ }
+ }
return 1;
}
-
static int
-_fdo_menus_generate(const void *data, Dumb_Tree *tree, int element, int level)
+_fdo_menus_generate(const void *data, Dumb_Tree * tree, int element, int level)
{
struct _fdo_menus_unxml_data *unxml_data;
Dumb_Tree *menus;
- unxml_data = (struct _fdo_menus_unxml_data *) data;
+ unxml_data = (struct _fdo_menus_unxml_data *)data;
menus = (Dumb_Tree *) unxml_data->menus;
if (tree->elements[element].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strncmp((char *) tree->elements[element].element, "<MENU ", 6) == 0)
- {
- int i;
- struct _fdo_menus_generate_data generate_data;
-
- generate_data.unallocated = unxml_data->unallocated;
- generate_data.name = (char *) tree->elements[element].element;
- generate_data.path = (char *) tree->elements[element + 1].element;
- generate_data.pool = (Ecore_Hash *) tree->elements[element + 2].element;
- generate_data.rules = (Dumb_Tree *) tree->elements[element + 3].element;
- generate_data.apps = (Ecore_Hash *) tree->elements[element + 4].element;
-
- /* Inherit the pools on the first pass. */
- if (!generate_data.unallocated)
- {
- if (unxml_data->stack->size <= level)
- {
- while (unxml_data->stack->size < level)
- dumb_tree_add_hash(unxml_data->stack, generate_data.pool);
- dumb_tree_add_hash(unxml_data->stack, generate_data.pool);
- }
- else
- {
- unxml_data->stack->elements[level].type = DUMB_TREE_ELEMENT_TYPE_HASH;
- unxml_data->stack->elements[level].element = generate_data.pool;
- }
- for (i = level - 1; i >= 0; i--)
- {
- if (unxml_data->stack->elements[i].type == DUMB_TREE_ELEMENT_TYPE_HASH)
- {
- Ecore_Hash *ancestor;
-
- ancestor = (Ecore_Hash *) unxml_data->stack->elements[i].element;
- ecore_hash_for_each_node(ancestor, _fdo_menus_inherit_apps, generate_data.pool);
- }
- }
- }
-
- /* Process the rules. */
- if (generate_data.name[9] == (generate_data.unallocated ? 'O' : ' '))
- {
- printf("MAKING MENU - %s \t\t%s\n", generate_data.path, generate_data.name);
- for (i = 0; i < generate_data.rules->size; i++)
- {
- if (generate_data.rules->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- {
- generate_data.rule = (Dumb_Tree *) generate_data.rules->elements[i].element;
- if (generate_data.rule->size > 0)
- {
- if ( ((char *) generate_data.rule->elements[0].element)[0] == 'I' )
- {
- generate_data.include = TRUE;
- ecore_hash_for_each_node(generate_data.pool, _fdo_menus_select_app, &generate_data);
- }
- else
- {
- generate_data.include = FALSE;
- ecore_hash_for_each_node(generate_data.apps, _fdo_menus_select_app, &generate_data);
- }
- }
- }
- else
- printf("Fuck, a bug in _fdo_menus.\n");
- }
- }
- }
- }
+ {
+ if (strncmp((char *)tree->elements[element].element, "<MENU ", 6) == 0)
+ {
+ int i;
+ struct _fdo_menus_generate_data generate_data;
+
+ generate_data.unallocated = unxml_data->unallocated;
+ generate_data.name = (char *)tree->elements[element].element;
+ generate_data.path = (char *)tree->elements[element + 1].element;
+ generate_data.pool = (Ecore_Hash *) tree->elements[element + 2].element;
+ generate_data.rules = (Dumb_Tree *) tree->elements[element + 3].element;
+ generate_data.apps = (Ecore_Hash *) tree->elements[element + 4].element;
+
+ /* Inherit the pools on the first pass. */
+ if (!generate_data.unallocated)
+ {
+ if (unxml_data->stack->size <= level)
+ {
+ while (unxml_data->stack->size < level)
+ dumb_tree_add_hash(unxml_data->stack, generate_data.pool);
+ dumb_tree_add_hash(unxml_data->stack, generate_data.pool);
+ }
+ else
+ {
+ unxml_data->stack->elements[level].type = DUMB_TREE_ELEMENT_TYPE_HASH;
+ unxml_data->stack->elements[level].element = generate_data.pool;
+ }
+ for (i = level - 1; i >= 0; i--)
+ {
+ if (unxml_data->stack->elements[i].type == DUMB_TREE_ELEMENT_TYPE_HASH)
+ {
+ Ecore_Hash *ancestor;
+
+ ancestor = (Ecore_Hash *) unxml_data->stack->elements[i].element;
+ ecore_hash_for_each_node(ancestor, _fdo_menus_inherit_apps, generate_data.pool);
+ }
+ }
+ }
+
+ /* Process the rules. */
+ if (generate_data.name[9] == (generate_data.unallocated ? 'O' : ' '))
+ {
+ printf("MAKING MENU - %s \t\t%s\n", generate_data.path, generate_data.name);
+ for (i = 0; i < generate_data.rules->size; i++)
+ {
+ if (generate_data.rules->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ {
+ generate_data.rule = (Dumb_Tree *) generate_data.rules->elements[i].element;
+ if (generate_data.rule->size > 0)
+ {
+ if (((char *)generate_data.rule->elements[0].element)[0] == 'I')
+ {
+ generate_data.include = TRUE;
+ ecore_hash_for_each_node(generate_data.pool, _fdo_menus_select_app, &generate_data);
+ }
+ else
+ {
+ generate_data.include = FALSE;
+ ecore_hash_for_each_node(generate_data.apps, _fdo_menus_select_app, &generate_data);
+ }
+ }
+ }
+ else
+ printf("Fuck, a bug in _fdo_menus.\n");
+ }
+ }
+ }
+ }
return 0;
}
@@ -718,8 +716,8 @@
pool = (Ecore_Hash *) user_data;
node = (Ecore_Hash_Node *) value;
- key = (char *) node->key;
- app = (char *) node->value;
+ key = (char *)node->key;
+ app = (char *)node->value;
if (!ecore_hash_get(pool, key))
ecore_hash_set(pool, strdup(key), strdup(app));
}
@@ -733,9 +731,9 @@
char *key, *app;
node = (Ecore_Hash_Node *) value;
- generate_data = (struct _fdo_menus_generate_data *) user_data;
- key = (char *) node->key;
- app = (char *) node->value;
+ generate_data = (struct _fdo_menus_generate_data *)user_data;
+ key = (char *)node->key;
+ app = (char *)node->value;
desktop = parse_desktop_ini_file(app);
@@ -743,109 +741,108 @@
return;
if (_fdo_menus_apply_rules(generate_data, generate_data->rule, key, desktop))
- {
- desktop->allocated = TRUE;
- if (generate_data->include)
- {
- ecore_hash_set(generate_data->apps, key, strdup(app));
- printf("INCLUDING %s%s\n", ((generate_data->unallocated) ? "UNALLOCATED " : ""), key);
- }
- else
- {
- ecore_hash_remove(generate_data->apps, key);
- printf("EXCLUDING %s%s\n", ((generate_data->unallocated) ? "UNALLOCATED " : ""), key);
- }
- }
+ {
+ desktop->allocated = TRUE;
+ if (generate_data->include)
+ {
+ ecore_hash_set(generate_data->apps, key, strdup(app));
+ printf("INCLUDING %s%s\n", ((generate_data->unallocated) ? "UNALLOCATED " : ""), key);
+ }
+ else
+ {
+ ecore_hash_remove(generate_data->apps, key);
+ printf("EXCLUDING %s%s\n", ((generate_data->unallocated) ? "UNALLOCATED " : ""), key);
+ }
+ }
}
static int
-_fdo_menus_apply_rules(struct _fdo_menus_generate_data *generate_data, Dumb_Tree *rule, char *key, Desktop *desktop)
+_fdo_menus_apply_rules(struct _fdo_menus_generate_data *generate_data, Dumb_Tree * rule, char *key, Desktop * desktop)
{
char type = 'O';
int result = FALSE;
int i;
for (i = 0; i < rule->size; i++)
- {
- if (rule->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
- {
- result = _fdo_menus_apply_rules(generate_data, (Dumb_Tree *) rule->elements[i].element, key, desktop);
- }
- else
- {
- char *rul;
- char match;
- int sub_result = FALSE;
-
- rul = (char *) rule->elements[i].element;
- type = rul[1];
- match = rul[2];
- switch (match)
- {
- case 'A' :
- {
- sub_result = TRUE;
- break;
- }
-
- case 'F' :
- {
- if (strcmp(key, &rul[4]) == 0)
- sub_result = TRUE;
- break;
- }
-
- case 'C' :
- {
- /* Try to match a category. */
- if (desktop->Categories)
- {
- int j;
-
- for (j = 0; j < desktop->Categories->size; j++)
- {
- if (strcmp((char *) (desktop->Categories->elements[j].element), &rul[4]) == 0)
- {
- sub_result = TRUE;
- break;
- }
- }
- }
- break;
- }
- }
- switch (type)
- {
- case 'A' :
- {
- result = TRUE;
- if (!sub_result)
- return FALSE;
- break;
- }
-
- case 'N' :
- {
- result = TRUE;
- if (sub_result)
- return FALSE;
- break;
- }
-
- default :
- {
- if (sub_result)
- return TRUE;
- break;
- }
- }
- }
- }
+ {
+ if (rule->elements[i].type == DUMB_TREE_ELEMENT_TYPE_TREE)
+ {
+ result = _fdo_menus_apply_rules(generate_data, (Dumb_Tree *) rule->elements[i].element, key, desktop);
+ }
+ else
+ {
+ char *rul;
+ char match;
+ int sub_result = FALSE;
+
+ rul = (char *)rule->elements[i].element;
+ type = rul[1];
+ match = rul[2];
+ switch (match)
+ {
+ case 'A':
+ {
+ sub_result = TRUE;
+ break;
+ }
+
+ case 'F':
+ {
+ if (strcmp(key, &rul[4]) == 0)
+ sub_result = TRUE;
+ break;
+ }
+
+ case 'C':
+ {
+ /* Try to match a category. */
+ if (desktop->Categories)
+ {
+ int j;
+
+ for (j = 0; j < desktop->Categories->size; j++)
+ {
+ if (strcmp((char *)(desktop->Categories->elements[j].element), &rul[4]) == 0)
+ {
+ sub_result = TRUE;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+ switch (type)
+ {
+ case 'A':
+ {
+ result = TRUE;
+ if (!sub_result)
+ return FALSE;
+ break;
+ }
+
+ case 'N':
+ {
+ result = TRUE;
+ if (sub_result)
+ return FALSE;
+ break;
+ }
+
+ default:
+ {
+ if (sub_result)
+ return TRUE;
+ break;
+ }
+ }
+ }
+ }
return result;
}
-
/*
OR (implied)
loop through the rules
@@ -878,7 +875,6 @@
otherwise return false.
*/
-
/*
merge menus
expand <KDELegacyDirs> to <LegacyDir>.
@@ -928,7 +924,6 @@
* remove .desktop from menu.
* leave it as allocated.
-
<Menu (tree)
name
flags = " " or "MDO" the first letter of - Marked, Deleted, OnlyUnallocated
@@ -949,11 +944,9 @@
and/not (tree)
include/exclude and/not all/file/category x
-
*generate unallocated menus
* Same as for menus, but only the <OnlyUnallocated> ones.
* Only the unallocated .desktop entries can be used.
generate menu layout
*/
-
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/fdo_menus.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- fdo_menus.h 22 Feb 2006 04:15:44 -0000 1.2
+++ fdo_menus.h 22 Feb 2006 04:30:53 -0000 1.3
@@ -8,7 +8,7 @@
{
# endif
- Dumb_Tree *fdo_menus_get(char *file, Dumb_Tree *xml);
+ Dumb_Tree *fdo_menus_get(char *file, Dumb_Tree * xml);
# ifdef __cplusplus
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/fdo_paths.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- fdo_paths.c 22 Feb 2006 04:15:44 -0000 1.17
+++ fdo_paths.c 22 Feb 2006 04:30:53 -0000 1.18
@@ -23,14 +23,10 @@
int done;
};
-static Dumb_Tree *_fdo_paths_get(char *before, char *env_home, char *env,
- char *env_home_default, char *env_default,
- char *type, char *gnome_extra, char *kde);
-static void _fdo_paths_massage_path(char *path, char *home, char *first,
- char *second);
+static Dumb_Tree *_fdo_paths_get(char *before, char *env_home, char *env, char *env_home_default, char *env_default, char *type, char *gnome_extra, char *kde);
+static void _fdo_paths_massage_path(char *path, char *home, char *first, char *second);
static void _fdo_paths_check_and_add(Dumb_Tree * paths, char *path);
-static void _fdo_paths_exec_config(char *home, Dumb_Tree * extras,
- char *cmd);
+static void _fdo_paths_exec_config(char *home, Dumb_Tree * extras, char *cmd);
static int _fdo_paths_cb_exe_exit(void *data, int type, void *event);
@@ -38,22 +34,15 @@
fdo_paths_init()
{
if (!fdo_paths_menus)
- fdo_paths_menus =
- _fdo_paths_get(NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", "~/.config",
- "/etc/xdg", "menus", NULL, "xdgconf-menu");
+ fdo_paths_menus = _fdo_paths_get(NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", "~/.config", "/etc/xdg", "menus", NULL, "xdgconf-menu");
if (!fdo_paths_directories)
fdo_paths_directories =
_fdo_paths_get(NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS",
- "~/.local/share", "/usr/local/share:/usr/share",
- "desktop-directories", "gnome/vfolders",
- "xdgdata-dirs");
+ "~/.local/share", "/usr/local/share:/usr/share", "desktop-directories", "gnome/vfolders", "xdgdata-dirs");
if (!fdo_paths_desktops)
fdo_paths_desktops =
_fdo_paths_get(NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS",
- "~/.local/share", "/usr/local/share:/usr/share",
- "applications",
- "dist/desktop-files:dist/short-menu:gnome/apps",
- "xdgdata-apps:apps");
+ "~/.local/share", "/usr/local/share:/usr/share", "applications", "dist/desktop-files:dist/short-menu:gnome/apps", "xdgdata-apps:apps");
if (!fdo_paths_kde_legacy)
fdo_paths_kde_legacy = _fdo_paths_get(NULL, NULL, NULL, NULL, NULL, NULL, NULL, "apps");
if (!fdo_paths_icons)
@@ -61,9 +50,7 @@
char *gnome;
fdo_paths_icons =
- _fdo_paths_get("~/.icons", "XDG_DATA_HOME", "XDG_DATA_DIRS",
- "~/.local/share", "/usr/local/share:/usr/share",
- "icons", "dist/icons", "icon:pixmap");
+ _fdo_paths_get("~/.icons", "XDG_DATA_HOME", "XDG_DATA_DIRS", "~/.local/share", "/usr/local/share:/usr/share", "icons", "dist/icons", "icon:pixmap");
_fdo_paths_check_and_add(fdo_paths_icons, "/usr/share/pixmaps/");
gnome = getenv("$GNOME_ICON_PATH");
if (gnome)
@@ -94,9 +81,7 @@
* @param data A pointer to pass on to func.
*/
char *
-fdo_paths_search_for_file(Fdo_Paths_Type type, char *file, int sub,
- int (*func) (const void *data, char *path),
- const void *data)
+fdo_paths_search_for_file(Fdo_Paths_Type type, char *file, int sub, int (*func) (const void *data, char *path), const void *data)
{
int i;
char *path = NULL;
@@ -122,7 +107,7 @@
for (i = 0; i < paths->size; i++)
{
- sprintf(temp, "%s%s", (char *) paths->elements[i].element, file);
+ sprintf(temp, "%s%s", (char *)paths->elements[i].element, file);
if (stat(temp, &path_stat) == 0)
{
path = strdup(temp);
@@ -139,7 +124,6 @@
return path;
}
-
/* We need -
config file full of paths
menus=pathlist
@@ -148,10 +132,8 @@
icons=pathlist
*/
-
static Dumb_Tree *
-_fdo_paths_get(char *before, char *env_home, char *env, char *env_home_default,
- char *env_default, char *type, char *gnome_extra, char *kde)
+_fdo_paths_get(char *before, char *env_home, char *env, char *env_home_default, char *env_default, char *type, char *gnome_extra, char *kde)
{
char *home;
Dumb_Tree *paths = NULL;
@@ -194,8 +176,7 @@
{
for (i = 0; i < befores->size; i++)
{
- _fdo_paths_massage_path(path, home,
- befores->elements[i].element, NULL);
+ _fdo_paths_massage_path(path, home, befores->elements[i].element, NULL);
_fdo_paths_check_and_add(paths, path);
}
E_FN_DEL(dumb_tree_del, befores);
@@ -216,9 +197,7 @@
{
for (j = 0; j < types->size; j++)
{
- _fdo_paths_massage_path(path, home,
- env_list->elements[i].element,
- types->elements[j].element);
+ _fdo_paths_massage_path(path, home, env_list->elements[i].element, types->elements[j].element);
_fdo_paths_check_and_add(paths, path);
}
}
@@ -240,9 +219,7 @@
{
for (j = 0; j < types->size; j++)
{
- _fdo_paths_massage_path(path, home,
- env_list->elements[i].element,
- types->elements[j].element);
+ _fdo_paths_massage_path(path, home, env_list->elements[i].element, types->elements[j].element);
_fdo_paths_check_and_add(paths, path);
}
}
@@ -258,9 +235,7 @@
* if it exists, add it to end of paths
*/
- exit_handler =
- ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _fdo_paths_cb_exe_exit,
- paths);
+ exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _fdo_paths_cb_exe_exit, paths);
if (exit_handler)
{
int i;
@@ -272,7 +247,7 @@
{
char cmd[128];
- sprintf(cmd, "kde-config --path %s", (char *) kdes->elements[i].element);
+ sprintf(cmd, "kde-config --path %s", (char *)kdes->elements[i].element);
_fdo_paths_exec_config(home, NULL, cmd);
}
@@ -308,8 +283,7 @@
if (second)
{
if (first[0] == '~')
- sprintf(path, "%s%s/%s/",
- home, &first[1], &second[(second[0] == '/') ? 1 : 0]);
+ sprintf(path, "%s%s/%s/", home, &first[1], &second[(second[0] == '/') ? 1 : 0]);
else
sprintf(path, "%s/%s/", first, &second[(second[0] == '/') ? 1 : 0]);
}
@@ -347,7 +321,7 @@
}
static void
-_fdo_paths_exec_config(char *home, Dumb_Tree *extras, char *cmd)
+_fdo_paths_exec_config(char *home, Dumb_Tree * extras, char *cmd)
{
Ecore_Exe *exe;
struct _config_exe_data ced;
@@ -355,18 +329,15 @@
ced.home = home;
ced.types = extras;
ced.done = 0;
- exe =
- ecore_exe_pipe_run(cmd,
- ECORE_EXE_PIPE_AUTO | ECORE_EXE_PIPE_READ |
- ECORE_EXE_PIPE_READ_LINE_BUFFERED, &ced);
+ exe = ecore_exe_pipe_run(cmd, ECORE_EXE_PIPE_AUTO | ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_READ_LINE_BUFFERED, &ced);
if (exe)
{
ecore_exe_tag_set(exe, "genmenu/fdo");
while (ced.done == 0)
{
- /* FIXME: raster is paranoid. If too much time passes, give up.
- * Or find a way to let the usual event loop shit do this without spinning our wheels.
- */
+ /* FIXME: raster is paranoid. If too much time passes, give up.
+ * Or find a way to let the usual event loop shit do this without spinning our wheels.
+ */
ecore_main_loop_iterate();
usleep(10);
}
@@ -374,9 +345,7 @@
}
char *
-fdo_paths_recursive_search(char *path, char *file,
- int (*func) (const void *data, char *path),
- const void *data)
+fdo_paths_recursive_search(char *path, char *file, int (*func) (const void *data, char *path), const void *data)
{
char *fpath = NULL;
DIR *dir = NULL;
@@ -397,33 +366,30 @@
{
if (S_ISDIR(script_stat.st_mode))
{
- if ((strcmp(basename(info_text), ".") != 0)
- && (strcmp(basename(info_text), "..") != 0))
+ if ((strcmp(basename(info_text), ".") != 0) && (strcmp(basename(info_text), "..") != 0))
{
sprintf(info_text, "%s%s/", path, script->d_name);
- fpath =
- fdo_paths_recursive_search(info_text, file,
- func, data);
+ fpath = fdo_paths_recursive_search(info_text, file, func, data);
}
}
else
{
- if (file)
- {
- if (strcmp(basename(info_text), file) == 0)
- {
- fpath = strdup(info_text);
- if (func)
- if (func(data, path))
- break;
- }
- }
- else
- {
- if (func)
- if (func(data, info_text))
- break;
- }
+ if (file)
+ {
+ if (strcmp(basename(info_text), file) == 0)
+ {
+ fpath = strdup(info_text);
+ if (func)
+ if (func(data, path))
+ break;
+ }
+ }
+ else
+ {
+ if (func)
+ if (func(data, info_text))
+ break;
+ }
}
if (fpath && (!func))
break;
@@ -461,38 +427,35 @@
read = ecore_exe_event_data_get(ev->exe, ECORE_EXE_PIPE_READ);
if ((read) && (read->lines[0].line))
- {
- value = read->lines[0].line;
- if (value)
- {
- config_list = dumb_tree_from_paths(value);
- if (config_list)
- {
- int i, j;
-
- for (i = 0; i < config_list->size; i++)
- {
- if (ced->types)
- {
- for (j = 0; j < ced->types->size; j++)
- {
- _fdo_paths_massage_path(path, ced->home,
- config_list->elements[i].element,
- ced->types->elements[j].element);
- _fdo_paths_check_and_add(paths, path);
- }
- }
- else
+ {
+ value = read->lines[0].line;
+ if (value)
+ {
+ config_list = dumb_tree_from_paths(value);
+ if (config_list)
+ {
+ int i, j;
+
+ for (i = 0; i < config_list->size; i++)
+ {
+ if (ced->types)
+ {
+ for (j = 0; j < ced->types->size; j++)
{
- _fdo_paths_massage_path(path, ced->home, config_list->elements[i].element,
- NULL);
+ _fdo_paths_massage_path(path, ced->home, config_list->elements[i].element, ced->types->elements[j].element);
_fdo_paths_check_and_add(paths, path);
}
- }
- E_FN_DEL(dumb_tree_del, config_list);
- }
- }
- }
+ }
+ else
+ {
+ _fdo_paths_massage_path(path, ced->home, config_list->elements[i].element, NULL);
+ _fdo_paths_check_and_add(paths, path);
+ }
+ }
+ E_FN_DEL(dumb_tree_del, config_list);
+ }
+ }
+ }
ced->done = 1;
return 1;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/global.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- global.c 16 Feb 2006 09:19:25 -0000 1.8
+++ global.c 22 Feb 2006 04:30:53 -0000 1.9
@@ -33,16 +33,13 @@
ecore_app_args_get(&argc, &argv);
for (i = 1; i < argc; i++)
{
- if ((strncmp(argv[i], "-d", 2) == 0) ||
- (strncmp(argv[i], "--desktop-dir", 13) == 0))
+ if ((strncmp(argv[i], "-d", 2) == 0) || (strncmp(argv[i], "--desktop-dir", 13) == 0))
{
c = strstr(argv[i], "=");
c = strtok(c, "=");
if (c)
return strdup(c);
- fprintf(stderr,
- "You must specify a directory for the %s argument\n",
- argv[i]);
+ fprintf(stderr, "You must specify a directory for the %s argument\n", argv[i]);
exit(1);
}
}
@@ -88,8 +85,7 @@
ecore_app_args_get(&argc, &argv);
for (i = 1; i < argc; i++)
{
- if ((strncmp(argv[i], "--lossy", 11) == 0)
- || (strncmp(argv[i], "-l", 2) == 0))
+ if ((strncmp(argv[i], "--lossy", 11) == 0) || (strncmp(argv[i], "-l", 2) == 0))
return strdup("LOSSY");
}
return strdup("COMP");
@@ -125,8 +121,7 @@
ecore_app_args_get(&argc, &argv);
for (i = 1; i < argc; i++)
{
- if ((strncmp(argv[i], "--icon-size", 11) == 0)
- || (strncmp(argv[i], "-s", 2) == 0))
+ if ((strncmp(argv[i], "--icon-size", 11) == 0) || (strncmp(argv[i], "-s", 2) == 0))
{
c = strstr(argv[i], "=");
c = strtok(c, "=");
@@ -146,8 +141,7 @@
ecore_app_args_get(&argc, &argv);
for (i = 1; i < argc; i++)
{
- if ((strncmp(argv[i], "--icon-theme", 12) == 0)
- || (strncmp(argv[i], "-t", 2) == 0))
+ if ((strncmp(argv[i], "--icon-theme", 12) == 0) || (strncmp(argv[i], "-t", 2) == 0))
{
c = strstr(argv[i], "=");
c = strtok(c, "=");
@@ -185,8 +179,7 @@
snprintf(path, sizeof(path), "%s" EAPPDIR, get_home());
if (!ecore_file_exists(path))
{
- fprintf(stderr, "ERROR: %s doesn't exist. Where are the eapps ?\n",
- path);
+ fprintf(stderr, "ERROR: %s doesn't exist. Where are the eapps ?\n", path);
return;
}
@@ -240,8 +233,7 @@
fprintf(stderr, "ERROR: Cannot Open Mapping File\n");
return;
}
- snprintf(buff, sizeof(buff), "%s|!%s|!%s|!%s\n", eap->icon, eap->name,
- eap->window_class, eap->exec);
+ snprintf(buff, sizeof(buff), "%s|!%s|!%s|!%s\n", eap->icon, eap->name, eap->window_class, eap->exec);
fwrite(buff, sizeof(char), strlen(buff), f);
fclose(f);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/global.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- global.h 9 Feb 2006 09:34:11 -0000 1.3
+++ global.h 22 Feb 2006 04:30:53 -0000 1.4
@@ -16,16 +16,16 @@
typedef struct _G_Eap G_Eap;
struct _G_Eap
{
- char *eap_name;
- char *name;
- char *generic;
- char *comment;
- char *categories;
- char *exec;
- char *icon;
- char *startup;
- char *type;
- char *window_class;
+ char *eap_name;
+ char *name;
+ char *generic;
+ char *comment;
+ char *categories;
+ char *exec;
+ char *icon;
+ char *startup;
+ char *type;
+ char *window_class;
};
/* Function Prototypes */
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/icons.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- icons.c 22 Feb 2006 04:15:44 -0000 1.20
+++ icons.c 22 Feb 2006 04:30:53 -0000 1.21
@@ -7,15 +7,13 @@
#include "icons.h"
#include "parse.h"
-
extern double icon_time;
/* FIXME: Ideally this should be -
* {".png", ".svg", ".xpm", "", NULL}
* Add them in when they are supported in .eaps.
- */
-static const char *ext[] = {".png", "", NULL};
-
+ */
+static const char *ext[] = { ".png", "", NULL };
char *
set_icon(char *token)
@@ -45,14 +43,11 @@
return TOYSICON;
if (strstr(token, "Utilities") != NULL)
return UTILITYICON;
- if ((strstr(token, "Accessories") != NULL) ||
- (strstr(token, "Applications") != NULL))
+ if ((strstr(token, "Accessories") != NULL) || (strstr(token, "Applications") != NULL))
return APPLICATIONICON;
- if ((strstr(token, "Multimedia") != NULL) ||
- (strstr(token, "Sound_Video") != NULL))
+ if ((strstr(token, "Multimedia") != NULL) || (strstr(token, "Sound_Video") != NULL))
return MULTIMEDIAICON;
- if ((strstr(token, "Preferences") != NULL) ||
- (strstr(token, "Settings") != NULL))
+ if ((strstr(token, "Preferences") != NULL) || (strstr(token, "Settings") != NULL))
return SETTINGSICON;
if (strstr(token, "System") != NULL)
return SYSTEMICON;
@@ -76,9 +71,7 @@
#endif
/* Check For Unsupported Extension */
- if ((!strcmp(icon + strlen(icon) - 4, ".svg"))
- || (!strcmp(icon + strlen(icon) - 4, ".ico"))
- || (!strcmp(icon + strlen(icon) - 4, ".xpm")))
+ if ((!strcmp(icon + strlen(icon) - 4, ".svg")) || (!strcmp(icon + strlen(icon) - 4, ".ico")) || (!strcmp(icon + strlen(icon) - 4, ".xpm")))
return strdup(DEFAULTICON);
/* Check For An Extension, Append PNG If Missing */
@@ -89,20 +82,20 @@
icon_size = get_icon_size();
icon_theme = get_icon_theme();
- if (!icon_theme)
+ if (!icon_theme)
{
-
- /* Check If Dir Supplied In Desktop File */
- dir = ecore_file_get_dir(icn);
- if (!strcmp(dir, icn) == 0)
- {
- snprintf(path, MAX_PATH, "%s", icn);
- /* Check Supplied Dir For Icon */
- if (ecore_file_exists(path))
- return strdup(icn);
- }
+
+ /* Check If Dir Supplied In Desktop File */
+ dir = ecore_file_get_dir(icn);
+ if (!strcmp(dir, icn) == 0)
+ {
+ snprintf(path, MAX_PATH, "%s", icn);
+ /* Check Supplied Dir For Icon */
+ if (ecore_file_exists(path))
+ return strdup(icn);
+ }
}
-
+
return strdup(find_fdo_icon(icon, icon_size, icon_theme));
}
@@ -149,10 +142,10 @@
begin = ecore_time_get();
if (icon == NULL)
- {
- icon_time += ecore_time_get() - begin;
- return DEFAULTICON;
- }
+ {
+ icon_time += ecore_time_get() - begin;
+ return DEFAULTICON;
+ }
#ifdef DEBUG
fprintf(stderr, "\tTrying To Find Icon %s (%s) in theme %s\n", icon, icon_size, icon_theme);
@@ -165,184 +158,187 @@
#endif
theme_path = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, icn, 1, NULL, NULL);
if (theme_path)
- {
- Ecore_Hash *theme;
+ {
+ Ecore_Hash *theme;
- /* Parse the theme description file. */
+ /* Parse the theme description file. */
#ifdef DEBUG
- printf("Path to %s is %s\n", icn, theme_path);
+ printf("Path to %s is %s\n", icn, theme_path);
#endif
- theme = parse_ini_file(theme_path);
- if (theme)
- {
- Ecore_Hash *icon_group;
-
- /* Grab the themes directory list, and what it inherits. */
- icon_group = (Ecore_Hash *) ecore_hash_get(theme, "Icon Theme");
- if (icon_group)
- {
- char *directories, *inherits;
-
- directories = (char *) ecore_hash_get(icon_group, "Directories");
- inherits = (char *) ecore_hash_get(icon_group, "Inherits");
- if (directories)
- {
- Dumb_Tree *directory_paths;
+ theme = parse_ini_file(theme_path);
+ if (theme)
+ {
+ Ecore_Hash *icon_group;
+
+ /* Grab the themes directory list, and what it inherits. */
+ icon_group = (Ecore_Hash *) ecore_hash_get(theme, "Icon Theme");
+ if (icon_group)
+ {
+ char *directories, *inherits;
+
+ directories = (char *)ecore_hash_get(icon_group, "Directories");
+ inherits = (char *)ecore_hash_get(icon_group, "Inherits");
+ if (directories)
+ {
+ Dumb_Tree *directory_paths;
- /* Split the directory list. */
+ /* Split the directory list. */
#ifdef DEBUG
- printf("Inherits %s Directories %s\n", inherits, directories);
+ printf("Inherits %s Directories %s\n", inherits, directories);
#endif
- directory_paths = dumb_tree_from_paths(directories);
- if (directory_paths)
- {
- int wanted_size;
- int minimal_size = INT_MAX;
- int i;
- char *closest = NULL;
-
- wanted_size = atoi(icon_size);
- /* Loop through the themes directories. */
- for (i = 0; i < directory_paths->size; i++)
- {
- Ecore_Hash *sub_group;
+ directory_paths = dumb_tree_from_paths(directories);
+ if (directory_paths)
+ {
+ int wanted_size;
+ int minimal_size = INT_MAX;
+ int i;
+ char *closest = NULL;
+
+ wanted_size = atoi(icon_size);
+ /* Loop through the themes directories. */
+ for (i = 0; i < directory_paths->size; i++)
+ {
+ Ecore_Hash *sub_group;
#ifdef DEBUG
- printf("FDO icon path = %s\n", directory_paths->elements[i].element);
+ printf("FDO icon path = %s\n", directory_paths->elements[i].element);
#endif
- /* Get the details for this theme directory. */
- sub_group = (Ecore_Hash *) ecore_hash_get(theme, directory_paths->elements[i].element);
- if (sub_group)
- {
- char *size, *type, *minsize, *maxsize, *threshold;
- int j;
-
- size = (char *) ecore_hash_get(sub_group, "Size");
- type = (char *) ecore_hash_get(sub_group, "Type");
- minsize = (char *) ecore_hash_get(sub_group, "MinSize");
- maxsize = (char *) ecore_hash_get(sub_group, "MaxSize");
- threshold = (char *) ecore_hash_get(sub_group, "Threshold");
- if (size)
- {
- int match = 0;
- int this_size, result_size = 0, min_size, max_size, thresh_size;
-
- if (!minsize) minsize = size;
- if (!maxsize) maxsize = size;
- if (!threshold) threshold = "2";
- min_size = atoi(minsize);
- max_size = atoi(maxsize);
- thresh_size = atoi(threshold);
-
- /* Does this theme directory match the required icon size? */
- this_size = atoi(size);
- if (!type)
- type = "Threshold";
- switch (type[0])
- {
- case 'F' : /* Fixed. */
- {
- match = (wanted_size == this_size);
- result_size = abs(this_size - wanted_size);
- break;
- }
- case 'S' : /* Scaled. */
- {
- match = ((min_size <= wanted_size) && (wanted_size <= max_size));
- if (wanted_size < min_size)
- result_size = min_size - wanted_size;
- if (wanted_size > max_size)
- result_size = wanted_size - max_size;
- break;
- }
- default : /* Threshold. */
- {
- match = ( ((this_size - thresh_size) <= wanted_size) && (wanted_size <= (this_size + thresh_size)) );
- if (wanted_size < (this_size - thresh_size))
- result_size = min_size - wanted_size;
- if (wanted_size > (this_size + thresh_size))
- result_size = wanted_size - max_size;
- break;
- }
- }
-
- /* Look for icon with all extensions. */
- for (j = 0; ext[j] != NULL; j++)
- {
- snprintf(path, MAX_PATH, "%s/%s/%s%s", icon_theme, (char *) directory_paths->elements[i].element, icon, ext[j]);
+ /* Get the details for this theme directory. */
+ sub_group = (Ecore_Hash *) ecore_hash_get(theme, directory_paths->elements[i].element);
+ if (sub_group)
+ {
+ char *size, *type, *minsize, *maxsize, *threshold;
+ int j;
+
+ size = (char *)ecore_hash_get(sub_group, "Size");
+ type = (char *)ecore_hash_get(sub_group, "Type");
+ minsize = (char *)ecore_hash_get(sub_group, "MinSize");
+ maxsize = (char *)ecore_hash_get(sub_group, "MaxSize");
+ threshold = (char *)ecore_hash_get(sub_group, "Threshold");
+ if (size)
+ {
+ int match = 0;
+ int this_size, result_size = 0, min_size, max_size, thresh_size;
+
+ if (!minsize)
+ minsize = size;
+ if (!maxsize)
+ maxsize = size;
+ if (!threshold)
+ threshold = "2";
+ min_size = atoi(minsize);
+ max_size = atoi(maxsize);
+ thresh_size = atoi(threshold);
+
+ /* Does this theme directory match the required icon size? */
+ this_size = atoi(size);
+ if (!type)
+ type = "Threshold";
+ switch (type[0])
+ {
+ case 'F': /* Fixed. */
+ {
+ match = (wanted_size == this_size);
+ result_size = abs(this_size - wanted_size);
+ break;
+ }
+ case 'S': /* Scaled. */
+ {
+ match = ((min_size <= wanted_size) && (wanted_size <= max_size));
+ if (wanted_size < min_size)
+ result_size = min_size - wanted_size;
+ if (wanted_size > max_size)
+ result_size = wanted_size - max_size;
+ break;
+ }
+ default: /* Threshold. */
+ {
+ match = (((this_size - thresh_size) <= wanted_size) && (wanted_size <= (this_size + thresh_size)));
+ if (wanted_size < (this_size - thresh_size))
+ result_size = min_size - wanted_size;
+ if (wanted_size > (this_size + thresh_size))
+ result_size = wanted_size - max_size;
+ break;
+ }
+ }
+
+ /* Look for icon with all extensions. */
+ for (j = 0; ext[j] != NULL; j++)
+ {
+ snprintf(path, MAX_PATH, "%s/%s/%s%s", icon_theme, (char *)directory_paths->elements[i].element, icon, ext[j]);
#ifdef DEBUG
- printf("FDO icon = %s\n", path);
+ printf("FDO icon = %s\n", path);
#endif
- found = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, path, 0, NULL, NULL);
- if (found)
- {
- if (match) /* If there is a match in sizes, return the icon. */
- {
- icon_time += ecore_time_get() - begin;
- return found;
- }
- if (result_size < minimal_size) /* While we are here, figure out our next fallback strategy. */
- {
- minimal_size = result_size;
- closest = found;
- }
- }
- }
-
- }
- }
- } /* for (i = 0; i < directory_paths->size; i++) */
-
- /* Fall back strategy #1, look for closest size in this theme. */
- if (closest)
- {
- icon_time += ecore_time_get() - begin;
- return closest;
- }
-
- /* Fall back strategy #2, Try again with the parent theme. */
- if ((inherits) && (inherits[0] != '\0') && (strcmp(icon_theme, "hicolor") != 0))
- {
- found = find_fdo_icon(icon, icon_size, inherits);
- if (found != DEFAULTICON)
- {
- icon_time += ecore_time_get() - begin;
- return found;
- }
- }
-
- /* Fall back strategy #3, Try the default hicolor theme. */
- if ( (! ((inherits) && (inherits[0] != '\0')) ) && (strcmp(icon_theme, "hicolor") != 0))
- {
- found = find_fdo_icon(icon, icon_size, "hicolor");
- if (found != DEFAULTICON)
- {
- icon_time += ecore_time_get() - begin;
- return found;
- }
- }
-
- /* Fall back strategy #4, Just search in the base of the icon directories. */
- for (i = 0; ext[i] != NULL; i++)
- {
- snprintf(path, MAX_PATH, "%s%s", icon, ext[i]);
+ found = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, path, 0, NULL, NULL);
+ if (found)
+ {
+ if (match) /* If there is a match in sizes, return the icon. */
+ {
+ icon_time += ecore_time_get() - begin;
+ return found;
+ }
+ if (result_size < minimal_size) /* While we are here, figure out our next fallback strategy. */
+ {
+ minimal_size = result_size;
+ closest = found;
+ }
+ }
+ }
+
+ }
+ }
+ } /* for (i = 0; i < directory_paths->size; i++) */
+
+ /* Fall back strategy #1, look for closest size in this theme. */
+ if (closest)
+ {
+ icon_time += ecore_time_get() - begin;
+ return closest;
+ }
+
+ /* Fall back strategy #2, Try again with the parent theme. */
+ if ((inherits) && (inherits[0] != '\0') && (strcmp(icon_theme, "hicolor") != 0))
+ {
+ found = find_fdo_icon(icon, icon_size, inherits);
+ if (found != DEFAULTICON)
+ {
+ icon_time += ecore_time_get() - begin;
+ return found;
+ }
+ }
+
+ /* Fall back strategy #3, Try the default hicolor theme. */
+ if ((!((inherits) && (inherits[0] != '\0'))) && (strcmp(icon_theme, "hicolor") != 0))
+ {
+ found = find_fdo_icon(icon, icon_size, "hicolor");
+ if (found != DEFAULTICON)
+ {
+ icon_time += ecore_time_get() - begin;
+ return found;
+ }
+ }
+
+ /* Fall back strategy #4, Just search in the base of the icon directories. */
+ for (i = 0; ext[i] != NULL; i++)
+ {
+ snprintf(path, MAX_PATH, "%s%s", icon, ext[i]);
#ifdef DEBUG
- printf("FDO icon = %s\n", path);
+ printf("FDO icon = %s\n", path);
#endif
- found = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, path, 0, NULL, NULL);
- if (found)
- {
- icon_time += ecore_time_get() - begin;
- return found;
- }
- }
-
- }
- }
- }
- }
- free(theme_path);
- }
+ found = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, path, 0, NULL, NULL);
+ if (found)
+ {
+ icon_time += ecore_time_get() - begin;
+ return found;
+ }
+ }
+
+ }
+ }
+ }
+ }
+ free(theme_path);
+ }
icon_time += ecore_time_get() - begin;
return DEFAULTICON;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/main.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- main.c 22 Feb 2006 04:15:44 -0000 1.28
+++ main.c 22 Feb 2006 04:30:53 -0000 1.29
@@ -40,78 +40,78 @@
/* You can iterate through the various path lists as needed. */
for (i = 0; i < fdo_paths_menus->size; i++)
- printf("FDO menu path = %s\n", (char *) fdo_paths_menus->elements[i].element);
+ printf("FDO menu path = %s\n", (char *)fdo_paths_menus->elements[i].element);
for (i = 0; i < fdo_paths_directories->size; i++)
- printf("FDO directory path = %s\n", (char *) fdo_paths_directories->elements[i].element);
+ printf("FDO directory path = %s\n", (char *)fdo_paths_directories->elements[i].element);
for (i = 0; i < fdo_paths_desktops->size; i++)
- printf("FDO desktop path = %s\n", (char *) fdo_paths_desktops->elements[i].element);
+ printf("FDO desktop path = %s\n", (char *)fdo_paths_desktops->elements[i].element);
for (i = 0; i < fdo_paths_icons->size; i++)
- printf("FDO icon path = %s\n", (char *) fdo_paths_icons->elements[i].element);
+ printf("FDO icon path = %s\n", (char *)fdo_paths_icons->elements[i].element);
for (i = 0; i < fdo_paths_kde_legacy->size; i++)
- printf("FDO kde legacy path = %s\n", (char *) fdo_paths_kde_legacy->elements[i].element);
+ printf("FDO kde legacy path = %s\n", (char *)fdo_paths_kde_legacy->elements[i].element);
/* First, find the main menu file. */
path = fdo_paths_search_for_file(FDO_PATHS_TYPE_MENU, menu, 1, NULL, NULL);
if (path)
- {
- char *directory = "Applications.directory";
- char *desktop = "xterm.desktop";
- char *icon = "tux.png";
- Dumb_Tree *menu_xml = NULL;
-
- printf("\n\nPath to %s is %s\n", menu, path);
- menu_xml = xmlame_get(path);;
- if (menu_xml)
- {
- Dumb_Tree *menus = NULL;
-
- /* convert the xml into menus */
- menus = fdo_menus_get(path, menu_xml);
- }
- free(path);
-
- /* During the processing of the menu file, you will need to search for
- * .directory files, .desktop files, and icons.
- */
- path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DIRECTORY, directory, 1, NULL, NULL);
- if (path)
- {
- printf("Path to %s is %s\n", directory, path);
- free(path);
- }
-
- path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DESKTOP, desktop, 1, NULL, NULL);
- if (path)
- {
- Ecore_Hash *desktop_hash;
-
- printf("Path to %s is %s\n", desktop, path);
- desktop_hash = parse_ini_file(path);
- if (desktop_hash)
- {
- }
- free(path);
- }
-
- path = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, icon, 1, NULL, NULL);
- if (path)
- {
- printf("Path to %s is %s\n", icon, path);
- free(path);
- }
- }
+ {
+ char *directory = "Applications.directory";
+ char *desktop = "xterm.desktop";
+ char *icon = "tux.png";
+ Dumb_Tree *menu_xml = NULL;
+
+ printf("\n\nPath to %s is %s\n", menu, path);
+ menu_xml = xmlame_get(path);;
+ if (menu_xml)
+ {
+ Dumb_Tree *menus = NULL;
+
+ /* convert the xml into menus */
+ menus = fdo_menus_get(path, menu_xml);
+ }
+ free(path);
+
+ /* During the processing of the menu file, you will need to search for
+ * .directory files, .desktop files, and icons.
+ */
+ path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DIRECTORY, directory, 1, NULL, NULL);
+ if (path)
+ {
+ printf("Path to %s is %s\n", directory, path);
+ free(path);
+ }
+
+ path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DESKTOP, desktop, 1, NULL, NULL);
+ if (path)
+ {
+ Ecore_Hash *desktop_hash;
+
+ printf("Path to %s is %s\n", desktop, path);
+ desktop_hash = parse_ini_file(path);
+ if (desktop_hash)
+ {
+ }
+ free(path);
+ }
+
+ path = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, icon, 1, NULL, NULL);
+ if (path)
+ {
+ printf("Path to %s is %s\n", icon, path);
+ free(path);
+ }
+ }
path = find_icon("tux");
if (path)
- {
- printf("Path to tux is %s\n", path);
- free(path);
- }
+ {
+ printf("Path to tux is %s\n", path);
+ free(path);
+ }
path = find_icon("blah");
if (path)
- {
- printf("Path to blah is %s\n", path);
- free(path);
- }
+ {
+ printf("Path to blah is %s\n", path);
+ free(path);
+ }
parse_ini_shutdown();
fdo_paths_shutdown();
@@ -132,8 +132,7 @@
printf(" -s=<size> | --icon-size=<size>\tUse <size> icons. (48x48)\n");
printf(" -t=<theme> | --icon-theme=<theme>\tUse <theme> for icons\n");
printf(" -l | --lossy\tUse Lossy Compression For Eaps\n");
- printf
- (" -d=<dir> | --desktop-dir=<dir>\tCreate eaps for .desktop files in <dir>\n");
+ printf(" -d=<dir> | --desktop-dir=<dir>\tCreate eaps for .desktop files in <dir>\n");
printf(" -o | --overwrite\tOverwrite Eaps\n");
printf(" -m | --mapping\tGenerate Mapping File\n");
printf(" -f | --fdo\tGenerate menus from fdo files\n");
@@ -197,8 +196,7 @@
snprintf(path, sizeof(path), "%s" EAPPDIR, get_home());
if (!ecore_file_exists(path))
{
- fprintf(stderr, "ERROR: %s doesn't exist. Where are the eapps?\n",
- path);
+ fprintf(stderr, "ERROR: %s doesn't exist. Where are the eapps?\n", path);
eet_shutdown();
ecore_file_shutdown();
ecore_shutdown();
@@ -259,16 +257,15 @@
#ifdef DEBUG
fprintf(stderr, "Regenerating Eapp Caches...\n");
#endif
- snprintf(path, sizeof(path), "enlightenment_eapp_cache_gen %s" EAPPDIR " -r",
- get_home());
+ snprintf(path, sizeof(path), "enlightenment_eapp_cache_gen %s" EAPPDIR " -r", get_home());
system(path);
- snprintf(path, sizeof(path), "enlightenment_eapp_cache_gen %s/.e/e/applications/favorite -r",
- get_home());
+ snprintf(path, sizeof(path), "enlightenment_eapp_cache_gen %s/.e/e/applications/favorite -r", get_home());
system(path);
cache_time += ecore_time_get() - begin;
- printf("\nTotal time %3.3f seconds, finding fdo paths %3.3f, converting fdo menus %3.3f, generating %d (rejected %d) eaps in %d menus %3.3f, finding icons %3.3f, generating eap caches %3.3f.\n",
- ecore_time_get() - start, paths, convert, item_count, reject_count, menu_count, gen - icon_time, icon_time, cache_time);
+ printf
+ ("\nTotal time %3.3f seconds, finding fdo paths %3.3f, converting fdo menus %3.3f, generating %d (rejected %d) eaps in %d menus %3.3f, finding icons %3.3f, generating eap caches %3.3f.\n",
+ ecore_time_get() - start, paths, convert, item_count, reject_count, menu_count, gen - icon_time, icon_time, cache_time);
parse_ini_shutdown();
fdo_paths_shutdown();
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/menus.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- menus.c 22 Feb 2006 04:15:44 -0000 1.12
+++ menus.c 22 Feb 2006 04:30:53 -0000 1.13
@@ -9,62 +9,60 @@
extern double convert;
extern int menu_count, item_count;
-
-static int _menu_make_apps(const void *data, Dumb_Tree *tree, int element, int level);
+static int _menu_make_apps(const void *data, Dumb_Tree * tree, int element, int level);
static void _menu_dump_each_hash_node(void *value, void *user_data);
-
void
make_menus()
{
char *d;
if (get_fdo())
- {
- char *menu = "applications.menu";
- char *menu_file;
-
- /* First, find the main menu file. */
- menu_file = fdo_paths_search_for_file(FDO_PATHS_TYPE_MENU, menu, 1, NULL, NULL);
- if (menu_file)
- {
- char *path;
- Dumb_Tree *menu_xml = NULL;
-
- path = ecore_file_get_dir(menu_file);
- menu_xml = xmlame_get(menu_file);;
- if ((menu_xml) && (path))
- {
- Dumb_Tree *menus = NULL;
-
- /* convert the xml into menus */
- menus = fdo_menus_get(menu_file, menu_xml);
- convert = ecore_time_get();
- if (menus)
- {
- /* create the .eap and order files from the menu */
- dumb_tree_foreach(menu_xml, 0, _menu_make_apps, path);
- }
- }
- E_FREE(path);
- }
- }
+ {
+ char *menu = "applications.menu";
+ char *menu_file;
+
+ /* First, find the main menu file. */
+ menu_file = fdo_paths_search_for_file(FDO_PATHS_TYPE_MENU, menu, 1, NULL, NULL);
+ if (menu_file)
+ {
+ char *path;
+ Dumb_Tree *menu_xml = NULL;
+
+ path = ecore_file_get_dir(menu_file);
+ menu_xml = xmlame_get(menu_file);;
+ if ((menu_xml) && (path))
+ {
+ Dumb_Tree *menus = NULL;
+
+ /* convert the xml into menus */
+ menus = fdo_menus_get(menu_file, menu_xml);
+ convert = ecore_time_get();
+ if (menus)
+ {
+ /* create the .eap and order files from the menu */
+ dumb_tree_foreach(menu_xml, 0, _menu_make_apps, path);
+ }
+ }
+ E_FREE(path);
+ }
+ }
else
- {
- d = get_desktop_dir();
- if (d)
- check_for_dirs(strdup(d));
-
- if (!d)
- {
- /* Check desktop files in these directories */
- check_for_dirs(GNOME_DIRS);
- check_for_dirs(KDE_DIRS);
- check_for_dirs(DEBIAN_DIRS);
- }
- if (d)
- free(d);
- }
+ {
+ d = get_desktop_dir();
+ if (d)
+ check_for_dirs(strdup(d));
+
+ if (!d)
+ {
+ /* Check desktop files in these directories */
+ check_for_dirs(GNOME_DIRS);
+ check_for_dirs(KDE_DIRS);
+ check_for_dirs(DEBIAN_DIRS);
+ }
+ if (d)
+ free(d);
+ }
}
void
@@ -74,7 +72,7 @@
char dirs[MAX_PATH];
snprintf(dirs, sizeof(dirs), path);
- dir = path; //strdup(path);
+ dir = path; //strdup(path);
if (dirs)
{
if (strstr(dirs, ":"))
@@ -142,24 +140,24 @@
}
static int
-_menu_make_apps(const void *data, Dumb_Tree *tree, int element, int level)
+_menu_make_apps(const void *data, Dumb_Tree * tree, int element, int level)
{
if (tree->elements[element].type == DUMB_TREE_ELEMENT_TYPE_STRING)
- {
- if (strncmp((char *) tree->elements[element].element, "<MENU ", 6) == 0)
- {
- char *name, *path;
- Ecore_Hash *pool, *apps;
-
- name = (char *) tree->elements[element].element;
- path = (char *) tree->elements[element + 1].element;
- pool = (Ecore_Hash *) tree->elements[element + 2].element;
- apps = (Ecore_Hash *) tree->elements[element + 4].element;
- printf("MAKING MENU - %s \t\t%s\n", path, name);
- menu_count++;
- ecore_hash_for_each_node(apps, _menu_dump_each_hash_node, &path[11]);
- }
- }
+ {
+ if (strncmp((char *)tree->elements[element].element, "<MENU ", 6) == 0)
+ {
+ char *name, *path;
+ Ecore_Hash *pool, *apps;
+
+ name = (char *)tree->elements[element].element;
+ path = (char *)tree->elements[element + 1].element;
+ pool = (Ecore_Hash *) tree->elements[element + 2].element;
+ apps = (Ecore_Hash *) tree->elements[element + 4].element;
+ printf("MAKING MENU - %s \t\t%s\n", path, name);
+ menu_count++;
+ ecore_hash_for_each_node(apps, _menu_dump_each_hash_node, &path[11]);
+ }
+ }
return 0;
}
@@ -169,9 +167,9 @@
Ecore_Hash_Node *node;
char *file, *path;
- path = (char *) user_data;
+ path = (char *)user_data;
node = (Ecore_Hash_Node *) value;
- file = (char *) node->value;
+ file = (char *)node->value;
printf("MAKING EAP %s -> %s\n", path, file);
item_count++;
parse_desktop_file(strdup(file), path);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/order.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- order.h 31 Jan 2006 22:04:17 -0000 1.2
+++ order.h 22 Feb 2006 04:30:53 -0000 1.3
@@ -7,6 +7,6 @@
int search_list(Ecore_List *list, char *search);
void create_order(char *path);
-void modify_order (char *path, char *entry);
+void modify_order(char *path, char *entry);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/parse.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- parse.c 22 Feb 2006 04:15:44 -0000 1.19
+++ parse.c 22 Feb 2006 04:30:53 -0000 1.20
@@ -8,8 +8,7 @@
extern int reject_count;
-static void _parse_desktop_del(Desktop *desktop);
-
+static void _parse_desktop_del(Desktop * desktop);
char *
get_t(char *icon)
@@ -144,28 +143,37 @@
desktop = parse_desktop_ini_file(app);
if ((desktop) && (desktop->group))
- {
- char *value;
+ {
+ char *value;
- value = (char *) ecore_hash_get(desktop->group, "Name");
- if (value) eap->name = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "GenericName");
- if (value) eap->generic = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "Comment");
- if (value) eap->comment = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "Type");
- if (value) eap->type = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "Categories");
- if (value) eap->categories = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "Exec");
- if (value) eap->exec = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "Icon");
- if (value) eap->icon = strdup(value);
- value = (char *) ecore_hash_get(desktop->group, "X-KDE-StartupNotify");
- if (value) eap->startup = (!strcmp(value, "true")) ? "1" : "0";
- value = (char *) ecore_hash_get(desktop->group, "StartupNotify");
- if (value) eap->startup = (!strcmp(value, "true")) ? "1" : "0";
- }
+ value = (char *)ecore_hash_get(desktop->group, "Name");
+ if (value)
+ eap->name = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "GenericName");
+ if (value)
+ eap->generic = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "Comment");
+ if (value)
+ eap->comment = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "Type");
+ if (value)
+ eap->type = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "Categories");
+ if (value)
+ eap->categories = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "Exec");
+ if (value)
+ eap->exec = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "Icon");
+ if (value)
+ eap->icon = strdup(value);
+ value = (char *)ecore_hash_get(desktop->group, "X-KDE-StartupNotify");
+ if (value)
+ eap->startup = (!strcmp(value, "true")) ? "1" : "0";
+ value = (char *)ecore_hash_get(desktop->group, "StartupNotify");
+ if (value)
+ eap->startup = (!strcmp(value, "true")) ? "1" : "0";
+ }
/* Check If We Process */
if (!eap->type)
@@ -179,12 +187,11 @@
/* Write Out Mapping File ? */
if (get_mapping())
{
- if ((!eap->icon) || (!eap->name) ||
- (!eap->exec) || (!eap->window_class))
- {
- reject_count++;
- return;
- }
+ if ((!eap->icon) || (!eap->name) || (!eap->exec) || (!eap->window_class))
+ {
+ reject_count++;
+ return;
+ }
FILE *f;
char buff[MAX_PATH];
@@ -195,11 +202,10 @@
if (!f)
{
fprintf(stderr, "ERROR: Cannot Open Mapping File\n");
- reject_count++;
+ reject_count++;
return;
}
- snprintf(buff, sizeof(buff), "%s|!%s|!%s|!%s\n",
- eap->icon, eap->name, eap->window_class, eap->exec);
+ snprintf(buff, sizeof(buff), "%s|!%s|!%s|!%s\n", eap->icon, eap->name, eap->window_class, eap->exec);
fwrite(buff, sizeof(char), strlen(buff), f);
fclose(f);
}
@@ -229,26 +235,24 @@
if ((ecore_file_exists(path)) && (!overwrite))
{
if (menu_path != NULL)
- {
- snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s",
- home, menu_path);
- modify_order(order_path, eap->eap_name);
- }
- else
- {
- category = NULL;
- if (eap->categories != NULL)
- {
- category = find_category(eap->categories);
- if (category != NULL)
- {
- snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s",
- home, category);
- modify_order(order_path, eap->eap_name);
- }
- }
- return;
- }
+ {
+ snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s", home, menu_path);
+ modify_order(order_path, eap->eap_name);
+ }
+ else
+ {
+ category = NULL;
+ if (eap->categories != NULL)
+ {
+ category = find_category(eap->categories);
+ if (category != NULL)
+ {
+ snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s", home, category);
+ modify_order(order_path, eap->eap_name);
+ }
+ }
+ return;
+ }
}
if (eap->icon != NULL)
@@ -289,18 +293,16 @@
category = NULL;
if (menu_path != NULL)
- {
- snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s", home,
- menu_path);
- modify_order(order_path, eap->eap_name);
- }
+ {
+ snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s", home, menu_path);
+ modify_order(order_path, eap->eap_name);
+ }
else if (eap->categories != NULL)
{
category = find_category(eap->categories);
if (category != NULL)
{
- snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s", home,
- category);
+ snprintf(order_path, sizeof(order_path), "%s" EFAVDIR "/%s", home, category);
modify_order(order_path, eap->eap_name);
}
}
@@ -387,23 +389,23 @@
parse_ini_init()
{
if (!ini_file_cache)
- {
- ini_file_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
- if (ini_file_cache)
- {
- ecore_hash_set_free_key(ini_file_cache, free);
- ecore_hash_set_free_value(ini_file_cache, (Ecore_Free_Cb) ecore_hash_destroy);
- }
- }
+ {
+ ini_file_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ if (ini_file_cache)
+ {
+ ecore_hash_set_free_key(ini_file_cache, free);
+ ecore_hash_set_free_value(ini_file_cache, (Ecore_Free_Cb) ecore_hash_destroy);
+ }
+ }
if (!desktop_cache)
- {
- desktop_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
- if (desktop_cache)
- {
- ecore_hash_set_free_key(desktop_cache, free);
- ecore_hash_set_free_value(desktop_cache, (Ecore_Free_Cb) _parse_desktop_del);
- }
- }
+ {
+ desktop_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ if (desktop_cache)
+ {
+ ecore_hash_set_free_key(desktop_cache, free);
+ ecore_hash_set_free_value(desktop_cache, (Ecore_Free_Cb) _parse_desktop_del);
+ }
+ }
}
Ecore_Hash *
@@ -439,8 +441,7 @@
c = buffer;
/* Strip preceeding blanks. */
- while (((*c == ' ') || (*c == '\t')) && (*c != '\n')
- && (*c != '\0'))
+ while (((*c == ' ') || (*c == '\t')) && (*c != '\n') && (*c != '\0'))
c++;
/* Skip blank lines and comments */
if ((*c == '\0') || (*c == '\n') || (*c == '#'))
@@ -466,8 +467,7 @@
{
key = c;
/* Find trailing blanks or =. */
- while ((*c != '=') && (*c != ' ') && (*c != '\t')
- && (*c != '\n') && (*c != '\0'))
+ while ((*c != '=') && (*c != ' ') && (*c != '\t') && (*c != '\n') && (*c != '\0'))
c++;
if (*c != '=') /* Find equals. */
{
@@ -479,8 +479,7 @@
{
*c++ = '\0';
/* Strip preceeding blanks. */
- while (((*c == ' ') || (*c == '\t')) && (*c != '\n')
- && (*c != '\0'))
+ while (((*c == ' ') || (*c == '\t')) && (*c != '\n') && (*c != '\0'))
c++;
value = c;
/* Find end. */
@@ -504,67 +503,72 @@
return result;
}
-Desktop *parse_desktop_ini_file(char *file)
+Desktop *
+parse_desktop_ini_file(char *file)
{
Desktop *result;
result = (Desktop *) ecore_hash_get(desktop_cache, file);
if (!result)
- {
- result = calloc(1, sizeof(Desktop));
- if (result)
- {
- result->data = parse_ini_file(file);
- if (result->data)
- {
- result->group = (Ecore_Hash *) ecore_hash_get(result->data, "Desktop Entry");
- if (!result->group)
- result->group = (Ecore_Hash *) ecore_hash_get(result->data, "KDE Desktop Entry");
- if (result->group)
- {
- char *temp;
-
- temp = (char *) ecore_hash_get(result->group, "Categories");
- if (temp)
- result->Categories = dumb_tree_from_paths(temp);
- temp = (char *) ecore_hash_get(result->group, "OnlyShowIn");
- if (temp)
- result->OnlyShowIn = dumb_tree_from_paths(temp);
- temp = (char *) ecore_hash_get(result->group, "NotShowIn");
- if (temp)
- result->NotShowIn = dumb_tree_from_paths(temp);
- }
- ecore_hash_set(desktop_cache, strdup(file), result);
- }
- else
- {
- free(result);
- result = NULL;
- }
- }
- }
+ {
+ result = calloc(1, sizeof(Desktop));
+ if (result)
+ {
+ result->data = parse_ini_file(file);
+ if (result->data)
+ {
+ result->group = (Ecore_Hash *) ecore_hash_get(result->data, "Desktop Entry");
+ if (!result->group)
+ result->group = (Ecore_Hash *) ecore_hash_get(result->data, "KDE Desktop Entry");
+ if (result->group)
+ {
+ char *temp;
+
+ temp = (char *)ecore_hash_get(result->group, "Categories");
+ if (temp)
+ result->Categories = dumb_tree_from_paths(temp);
+ temp = (char *)ecore_hash_get(result->group, "OnlyShowIn");
+ if (temp)
+ result->OnlyShowIn = dumb_tree_from_paths(temp);
+ temp = (char *)ecore_hash_get(result->group, "NotShowIn");
+ if (temp)
+ result->NotShowIn = dumb_tree_from_paths(temp);
+ }
+ ecore_hash_set(desktop_cache, strdup(file), result);
+ }
+ else
+ {
+ free(result);
+ result = NULL;
+ }
+ }
+ }
return result;
}
-static void _parse_desktop_del(Desktop *desktop)
+static void
+_parse_desktop_del(Desktop * desktop)
{
- if (desktop->NotShowIn) dumb_tree_del(desktop->NotShowIn);
- if (desktop->OnlyShowIn) dumb_tree_del(desktop->OnlyShowIn);
- if (desktop->Categories) dumb_tree_del(desktop->Categories);
+ if (desktop->NotShowIn)
+ dumb_tree_del(desktop->NotShowIn);
+ if (desktop->OnlyShowIn)
+ dumb_tree_del(desktop->OnlyShowIn);
+ if (desktop->Categories)
+ dumb_tree_del(desktop->Categories);
free(desktop);
}
void
parse_ini_shutdown()
{
- if(ini_file_cache)
- {
- ecore_hash_destroy(ini_file_cache);
- ini_file_cache = NULL;
- }
- if(desktop_cache)
- {
- ecore_hash_destroy(desktop_cache);
- desktop_cache = NULL;
- }
+ if (ini_file_cache)
+ {
+ ecore_hash_destroy(ini_file_cache);
+ ini_file_cache = NULL;
+ }
+ if (desktop_cache)
+ {
+ ecore_hash_destroy(desktop_cache);
+ desktop_cache = NULL;
+ }
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/parse.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- parse.h 22 Feb 2006 04:15:44 -0000 1.7
+++ parse.h 22 Feb 2006 04:30:53 -0000 1.8
@@ -7,12 +7,11 @@
#include <Ecore_Data.h>
#include "dumb_tree.h"
-
typedef struct _Desktop Desktop;
struct _Desktop
{
Ecore_Hash *data, *group;
- Dumb_Tree *Categories, *OnlyShowIn, *NotShowIn; /* FIXME: Better to have these as hashes. */
+ Dumb_Tree *Categories, *OnlyShowIn, *NotShowIn; /* FIXME: Better to have these as hashes. */
int NoDisplay, Hidden, allocated;
};
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/sort.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- sort.c 1 Feb 2006 09:41:25 -0000 1.4
+++ sort.c 22 Feb 2006 04:30:53 -0000 1.5
@@ -88,8 +88,7 @@
name = get_name(strdup(path2));
if (name != NULL)
{
- snprintf(path2, sizeof(path2), "%s:%s", strdup(name),
- strdup(buffer));
+ snprintf(path2, sizeof(path2), "%s:%s", strdup(name), strdup(buffer));
if (!search_list(eaps, strdup(path2)))
eaps = add_list(eaps, strdup(path2));
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/xmlame.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- xmlame.c 22 Feb 2006 04:15:44 -0000 1.6
+++ xmlame.c 22 Feb 2006 04:30:53 -0000 1.7
@@ -27,8 +27,7 @@
* The final '>' of a tag is replaced with a '\0', but it's existance can be implied.
*/
-static char *_xmlame_parse(Dumb_Tree *tree, char *buffer);
-
+static char *_xmlame_parse(Dumb_Tree * tree, char *buffer);
Dumb_Tree *
xmlame_new(char *buffer)
@@ -47,89 +46,90 @@
Dumb_Tree *tree = NULL;
size = ecore_file_size(file);
- buffer = (char *) malloc(size + 1);
+ buffer = (char *)malloc(size + 1);
if (buffer)
- {
- int fd;
+ {
+ int fd;
- buffer[0] = '\0';
- fd = open(file, O_RDONLY);
- if (fd != -1)
- {
- if (read(fd, buffer, size) == size)
- buffer[size] = '\0';
- }
- tree = xmlame_new(buffer);
- if (tree)
- {
- /* Have the file name as the first item on the tree, for later reference. */
- dumb_tree_extend(tree, file);
- _xmlame_parse(tree, buffer);
- }
- }
+ buffer[0] = '\0';
+ fd = open(file, O_RDONLY);
+ if (fd != -1)
+ {
+ if (read(fd, buffer, size) == size)
+ buffer[size] = '\0';
+ }
+ tree = xmlame_new(buffer);
+ if (tree)
+ {
+ /* Have the file name as the first item on the tree, for later reference. */
+ dumb_tree_extend(tree, file);
+ _xmlame_parse(tree, buffer);
+ }
+ }
return tree;
}
static char *
-_xmlame_parse(Dumb_Tree *tree, char *buffer)
+_xmlame_parse(Dumb_Tree * tree, char *buffer)
{
do
- {
- char *text;
+ {
+ char *text;
- /* Skip any white space at the beginning. */
- while ((*buffer != '\0') && (isspace(*buffer)))
- buffer++;
- text = buffer;
- /* Find the beginning of a tag. */
- while ((*buffer != '<') && (*buffer != '\0'))
- buffer++;
- /* Check for data between tags. */
- if (buffer != text)
- {
- char t;
-
- t = *buffer;
- *buffer = '\0';
- dumb_tree_extend(tree, strdup(text));
- *buffer = t;
- }
- if (*buffer != '\0')
- {
- char *begin;
-
- begin = buffer++;
- /* Find the end of the tag. */
- while ((*buffer != '>') && (*buffer != '\0'))
- buffer++;
- /* We have our tag, do something with it. */
- if (*buffer != '\0')
- {
- *buffer++ = '\0';
- if (begin[1] == '/')
- { /* The end of an element. */
- dumb_tree_add(tree, begin);
- break;
- }
- else if ((begin[1] == '!') || (begin[1] == '-') || (*(buffer - 2) == '/'))
- { /* This is a script, a comment, or a stand alone tag. */
- dumb_tree_add(tree, begin);
- }
- else
- { /* The beginning of an element. */
- Dumb_Tree *new_tree;
-
- new_tree = xmlame_new(NULL);
- if (new_tree)
- {
- dumb_tree_add_child(tree, new_tree);
- dumb_tree_add(new_tree, begin);
- buffer = _xmlame_parse(new_tree, buffer);
- }
- }
- }
- }
- } while (*buffer != '\0');
+ /* Skip any white space at the beginning. */
+ while ((*buffer != '\0') && (isspace(*buffer)))
+ buffer++;
+ text = buffer;
+ /* Find the beginning of a tag. */
+ while ((*buffer != '<') && (*buffer != '\0'))
+ buffer++;
+ /* Check for data between tags. */
+ if (buffer != text)
+ {
+ char t;
+
+ t = *buffer;
+ *buffer = '\0';
+ dumb_tree_extend(tree, strdup(text));
+ *buffer = t;
+ }
+ if (*buffer != '\0')
+ {
+ char *begin;
+
+ begin = buffer++;
+ /* Find the end of the tag. */
+ while ((*buffer != '>') && (*buffer != '\0'))
+ buffer++;
+ /* We have our tag, do something with it. */
+ if (*buffer != '\0')
+ {
+ *buffer++ = '\0';
+ if (begin[1] == '/')
+ { /* The end of an element. */
+ dumb_tree_add(tree, begin);
+ break;
+ }
+ else if ((begin[1] == '!') || (begin[1] == '-') || (*(buffer - 2) == '/'))
+ { /* This is a script, a comment, or a stand alone tag. */
+ dumb_tree_add(tree, begin);
+ }
+ else
+ { /* The beginning of an element. */
+ Dumb_Tree *new_tree;
+
+ new_tree = xmlame_new(NULL);
+ if (new_tree)
+ {
+ dumb_tree_add_child(tree, new_tree);
+ dumb_tree_add(new_tree, begin);
+ buffer = _xmlame_parse(new_tree, buffer);
+ }
+ }
+ }
+ }
+ }
+ while (*buffer != '\0');
return buffer;
}
|