summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-02-03 23:31:26 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-02-03 23:31:26 +0100
commit8be839f18683638189879428d4e6600818c51f85 (patch)
tree7807ee35c8af94857c53dbc43f557ec32136074d
parent775ccf17a6af5a0a48cf6280a22caca8a5023da7 (diff)
insert the names sorted
-rw-r--r--src/main.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index db918e1..800dbb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -68,6 +68,41 @@ create_canvas(int width, int height)
68 return canvas; 68 return canvas;
69} 69}
70 70
71int
72aplhabetic_search(const char *n1, const char *n2)
73{
74 int c = 0;
75 while(n1[c] != '\0' && n2[c] != '\0')
76 {
77 char c1, c2;
78
79 c1 = n1[c];
80 c2 = n2[c];
81
82 if (c1 < c2)
83 return -1;
84 else if (c1 > c2)
85 return 1;
86 c ++;
87 }
88 return 0;
89}
90
91int
92sort(const void *a, const void *b)
93{
94 return aplhabetic_search(a, b);
95}
96
97int
98sort_group(const void *a, const void *b)
99{
100 const Theme_Group *ga = a;
101 const Theme_Group *gb = b;
102
103 return aplhabetic_search(ga->name, gb->name);
104}
105
71void 106void
72add_parts(Theme *theme, Theme_Group *group) 107add_parts(Theme *theme, Theme_Group *group)
73{ 108{
@@ -86,7 +121,9 @@ add_parts(Theme *theme, Theme_Group *group)
86 121
87 type = edje_edit_part_type_get(o, part); 122 type = edje_edit_part_type_get(o, part);
88 123
89 group->parts[type] = eina_list_append(group->parts[type], part); 124 if (eina_list_data_find(group->parts[type], part)) continue;
125
126 group->parts[type] = eina_list_sorted_insert(group->parts[type], sort, part);
90 } 127 }
91 128
92 programs = edje_edit_programs_list_get(o); 129 programs = edje_edit_programs_list_get(o);
@@ -98,7 +135,9 @@ add_parts(Theme *theme, Theme_Group *group)
98 _signal = edje_edit_program_signal_get(o, program); 135 _signal = edje_edit_program_signal_get(o, program);
99 if (!_signal) continue; 136 if (!_signal) continue;
100 137
101 group->signals = eina_list_append(group->signals, _signal); 138 if (eina_list_data_find(group->signals, _signal)) continue;
139
140 group->signals = eina_list_sorted_insert(group->signals, sort, _signal);
102 } 141 }
103} 142}
104 143
@@ -122,7 +161,7 @@ parse_theme(const char *file)
122 161
123 add_parts(theme, theme_group); 162 add_parts(theme, theme_group);
124 163
125 theme->groups = eina_list_append(theme->groups, theme_group); 164 theme->groups = eina_list_sorted_insert(theme->groups, sort_group, theme_group);
126 } 165 }
127 166
128 edje_file_collection_list_free(groups); 167 edje_file_collection_list_free(groups);