1 #include "e.h"
2
3
4 typedef struct _Match_Config
5 {
6 E_Comp_Match match;
7 E_Config_Dialog *cfd;
8 char *title, *name, *clas, *role;
9 int borderless, dialog, accepts_focus;
10 int argb, fullscreen, modal, primary_type;
11 int effect_type;
12 } Match_Config;
13
14 struct _E_Config_Dialog_Data
15 {
16 Eina_List *popups; // used for e popups
17 Eina_List *borders; // used for borders
18 Eina_List *overrides; // used for client menus, tooltips etc.
19 Eina_List *menus; // used for e menus
20 Eina_List *objects; // used for e objects
21 Eina_List *comp_effects; // list of visibility effects
22 int changed;
23
24 Evas_Object *edit_il;
25
26 Evas_Object *popups_il;
27 Evas_Object *borders_il;
28 Evas_Object *overrides_il;
29 Evas_Object *menus_il;
30 Evas_Object *objects_il;
31 };
32
33 static void
_match_dup(E_Comp_Match * m,Match_Config * m2)34 _match_dup(E_Comp_Match *m, Match_Config *m2)
35 {
36 m2->match = *m;
37 m2->match.title = eina_stringshare_ref(m2->match.title);
38 m2->match.name = eina_stringshare_ref(m2->match.name);
39 m2->match.clas = eina_stringshare_ref(m2->match.clas);
40 m2->match.role = eina_stringshare_ref(m2->match.role);
41 m2->primary_type = m2->match.primary_type;
42
43 m2->match.shadow_style = eina_stringshare_ref(m2->match.shadow_style);
44 m2->match.visibility_effect = eina_stringshare_ref(m2->match.visibility_effect);
45 }
46
47 static void
_match_free(Match_Config * m)48 _match_free(Match_Config *m)
49 {
50 eina_stringshare_del(m->match.title);
51 eina_stringshare_del(m->match.name);
52 eina_stringshare_del(m->match.clas);
53 eina_stringshare_del(m->match.role);
54 eina_stringshare_del(m->match.shadow_style);
55 eina_stringshare_del(m->match.visibility_effect);
56 free(m->title);
57 free(m->name);
58 free(m->clas);
59 free(m->role);
60 free(m);
61 }
62
63 static void
_match_dup2(Match_Config * m2,E_Comp_Match * m)64 _match_dup2(Match_Config *m2, E_Comp_Match *m)
65 {
66 *m = m2->match;
67 m->title = eina_stringshare_add(m->title);
68 m->name = eina_stringshare_add(m->name);
69 m->clas = eina_stringshare_add(m->clas);
70 m->role = eina_stringshare_add(m->role);
71 m->shadow_style = eina_stringshare_add(m->shadow_style);
72 m->visibility_effect = eina_stringshare_add(m->visibility_effect);
73 }
74
75 static const char *
_match_type_label_get(int type)76 _match_type_label_get(int type)
77 {
78 if (E_WINDOW_TYPE_UNKNOWN == type)
79 return _("Unused");
80 if (E_WINDOW_TYPE_COMBO == type)
81 return _("Combo");
82 if (E_WINDOW_TYPE_DESKTOP == type)
83 return _("Desktop");
84 if (E_WINDOW_TYPE_DIALOG == type)
85 return _("Dialog");
86 if (E_WINDOW_TYPE_DOCK == type)
87 return _("Dock");
88 if (E_WINDOW_TYPE_DND == type)
89 return _("Drag and Drop");
90 if (E_WINDOW_TYPE_MENU == type)
91 return _("Menu");
92 if (E_WINDOW_TYPE_DROPDOWN_MENU == type)
93 return _("Menu (Dropdown)");
94 if (E_WINDOW_TYPE_POPUP_MENU == type)
95 return _("Menu (Popup)");
96 if (E_WINDOW_TYPE_NORMAL == type)
97 return _("Normal");
98 if (E_WINDOW_TYPE_NOTIFICATION == type)
99 return _("Notification");
100 if (E_WINDOW_TYPE_SPLASH == type)
101 return _("Splash");
102 if (E_WINDOW_TYPE_TOOLBAR == type)
103 return _("Toolbar");
104 if (E_WINDOW_TYPE_TOOLTIP == type)
105 return _("Tooltip");
106 if (E_WINDOW_TYPE_UTILITY == type)
107 return _("Utility");
108 if (E_WINDOW_TYPE_REAL_UNKNOWN == type)
109 return _("Unknown");
110
111 return _("Unused");
112 }
113
114 static char *
_match_label_get(Match_Config * m)115 _match_label_get(Match_Config *m)
116 {
117 char *label;
118 Eina_Strbuf *buf = eina_strbuf_new();
119
120 if (m->match.title)
121 {
122 eina_strbuf_append(buf, _("Title:"));
123 eina_strbuf_append(buf, m->match.title);
124 eina_strbuf_append(buf, _(" / "));
125 }
126 if (m->match.primary_type)
127 {
128 eina_strbuf_append(buf, _("Type:"));
129 eina_strbuf_append(buf, _match_type_label_get(m->match.primary_type));
130 eina_strbuf_append(buf, _(" / "));
131 }
132 if (m->match.name)
133 {
134 eina_strbuf_append(buf, _("Name:"));
135 eina_strbuf_append(buf, m->match.name);
136 eina_strbuf_append(buf, _(" / "));
137 }
138 if (m->match.clas)
139 {
140 eina_strbuf_append(buf, _("Class:"));
141 eina_strbuf_append(buf, m->match.clas);
142 eina_strbuf_append(buf, _(" / "));
143 }
144 if (m->match.role)
145 {
146 eina_strbuf_append(buf, _("Role:"));
147 eina_strbuf_append(buf, m->match.role);
148 eina_strbuf_append(buf, _(" / "));
149 }
150 if (m->match.shadow_style)
151 {
152 eina_strbuf_append(buf, _("Style:"));
153 eina_strbuf_append(buf, m->match.shadow_style);
154 }
155 if (m->match.visibility_effect)
156 {
157 eina_strbuf_append(buf, _(" / "));
158 eina_strbuf_append(buf, _("Effect:"));
159 eina_strbuf_append(buf, m->match.visibility_effect);
160 }
161
162 if (!eina_strbuf_length_get(buf))
163 return _("Unknown");
164
165 label = eina_strbuf_string_steal(buf);
166 eina_strbuf_free(buf);
167
168 return label;
169 }
170
171 static void
_match_ilist_append(Evas_Object * il,Match_Config * m,int pos,int pre)172 _match_ilist_append(Evas_Object *il, Match_Config *m, int pos, int pre)
173 {
174 char *name = _match_label_get(m);
175
176 if (pos == -1)
177 e_widget_ilist_append(il, NULL, name, NULL, m, NULL);
178 else
179 {
180 if (pre)
181 e_widget_ilist_prepend_relative(il, NULL, name, NULL, m, NULL, pos);
182 else
183 e_widget_ilist_append_relative(il, NULL, name, NULL, m, NULL, pos);
184 }
185 free(name);
186 }
187
188 static void
_match_list_up(Eina_List ** list,Match_Config * m)189 _match_list_up(Eina_List **list, Match_Config *m)
190 {
191 Eina_List *l, *lp;
192
193 l = eina_list_data_find_list(*list, m);
194 if (!l) return;
195 lp = l->prev;
196 *list = eina_list_remove_list(*list, l);
197 if (lp) *list = eina_list_prepend_relative_list(*list, m, lp);
198 else *list = eina_list_prepend(*list, m);
199 }
200
201 static void
_match_list_down(Eina_List ** list,Match_Config * m)202 _match_list_down(Eina_List **list, Match_Config *m)
203 {
204 Eina_List *l, *lp;
205
206 l = eina_list_data_find_list(*list, m);
207 if (!l) return;
208 lp = l->next;
209 *list = eina_list_remove_list(*list, l);
210 if (lp) *list = eina_list_append_relative_list(*list, m, lp);
211 else *list = eina_list_append(*list, m);
212 }
213
214 static Eina_Bool
_match_list_del(Eina_List ** list,Match_Config * m)215 _match_list_del(Eina_List **list, Match_Config *m)
216 {
217 Eina_List *l;
218
219 l = eina_list_data_find_list(*list, m);
220 if (!l) return EINA_FALSE;
221 *list = eina_list_remove_list(*list, l);
222 _match_free(m);
223 return EINA_TRUE;
224 }
225
226
227 static void
_cb_dialog_resize(void * data,Evas * e EINA_UNUSED,Evas_Object * obj,void * event_info EINA_UNUSED)228 _cb_dialog_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
229 {
230 Evas_Object *bg, *of;
231 int x, y, w, h;
232
233 of = data;
234 bg = evas_object_data_get(of, "bg");
235 evas_object_geometry_get(obj, &x, &y, &w, &h);
236
237 evas_object_move(bg, x, y);
238 evas_object_resize(bg, w, h);
239 evas_object_move(of, x, y);
240 evas_object_resize(of, w, h);
241 }
242
243 static void
_edit_ok(void * d1,void * d2)244 _edit_ok(void *d1, void *d2)
245 {
246 Match_Config *m = d1;
247 Evas_Object *dia, *bg, *of = d2;
248 Evas_Object *il;
249
250 if (m->title || m->name || m->clas || m->role || (m->primary_type != m->match.primary_type) ||
251 (eina_list_nth(m->cfd->cfdata->comp_effects, m->effect_type) != m->match.visibility_effect))
252 {
253 m->cfd->cfdata->changed = 1;
254 e_config_dialog_changed_set(m->cfd, 1);
255 eina_stringshare_replace(&m->match.title, NULL);
256 if (m->title)
257 {
258 if (m->title[0]) m->match.title = eina_stringshare_add(m->title);
259 E_FREE(m->title);
260 }
261 eina_stringshare_replace(&m->match.name, NULL);
262 if (m->name)
263 {
264 if (m->name[0]) m->match.name = eina_stringshare_add(m->name);
265 E_FREE(m->name);
266 }
267 eina_stringshare_replace(&m->match.clas, NULL);
268 if (m->clas)
269 {
270 if (m->clas[0]) m->match.clas = eina_stringshare_add(m->clas);
271 E_FREE(m->clas);
272 }
273 eina_stringshare_replace(&m->match.role, NULL);
274 if (m->role)
275 {
276 if (m->role[0]) m->match.role = eina_stringshare_add(m->role);
277 E_FREE(m->role);
278 }
279 m->match.borderless = m->borderless;
280 m->match.dialog = m->dialog;
281 m->match.accepts_focus = m->accepts_focus;
282 m->match.argb = m->argb;
283 m->match.fullscreen = m->fullscreen;
284 m->match.modal = m->modal;
285 m->match.primary_type = m->primary_type;
286 eina_stringshare_refplace(&m->match.visibility_effect, eina_list_nth(m->cfd->cfdata->comp_effects, m->effect_type));
287 if (eina_streq(m->match.visibility_effect, "none"))
288 eina_stringshare_replace(&m->match.visibility_effect, NULL);
289 il = m->cfd->cfdata->edit_il;
290 {
291 const Eina_List *l;
292 E_Ilist_Item *ili;
293 Eina_Bool found = EINA_FALSE;
294
295 EINA_LIST_FOREACH(e_widget_ilist_items_get(il), l, ili)
296 {
297 char *txt;
298
299 if (e_widget_ilist_item_data_get(ili) != m) continue;
300 txt = _match_label_get(m);
301 e_ilist_item_label_set(ili, txt);
302 free(txt);
303 found = EINA_TRUE;
304 break;
305 }
306 if (!found)
307 {
308 unsigned int n;
309
310 if (il == m->cfd->cfdata->popups_il)
311 m->cfd->cfdata->popups = eina_list_append(m->cfd->cfdata->popups, m);
312 else if (il == m->cfd->cfdata->borders_il)
313 m->cfd->cfdata->borders = eina_list_append(m->cfd->cfdata->borders, m);
314 else if (il == m->cfd->cfdata->overrides_il)
315 m->cfd->cfdata->overrides = eina_list_append(m->cfd->cfdata->overrides, m);
316 else if (il == m->cfd->cfdata->menus_il)
317 m->cfd->cfdata->menus = eina_list_append(m->cfd->cfdata->menus, m);
318 else if (il == m->cfd->cfdata->objects_il)
319 m->cfd->cfdata->objects = eina_list_append(m->cfd->cfdata->objects, m);
320 _match_ilist_append(il, m, -1, 0);
321 n = e_widget_ilist_count(il);
322 e_widget_ilist_nth_show(il, n - 1, 0);
323 e_widget_ilist_selected_set(il, n - 1);
324 }
325 }
326 }
327 bg = evas_object_data_get(of, "bg");
328 dia = evas_object_data_get(of, "dia");
329
330 evas_object_event_callback_del(dia, EVAS_CALLBACK_RESIZE, _cb_dialog_resize);
331 evas_object_del(bg);
332 evas_object_del(of);
333 }
334
335 static void
_create_edit_frame(E_Config_Dialog * cfd,Evas * evas,E_Config_Dialog_Data * cfdata,Match_Config * m)336 _create_edit_frame(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata, Match_Config *m)
337 {
338 Evas_Object *of, *oi, *lb, *en, *bt, *tb, *tab2, *o, *sf, *li;
339 E_Radio_Group *rg;
340 Eina_List *l;
341 Eina_Stringshare *s;
342 int row, mode = 0;
343 int x, y, w, h, mw, mh;
344
345 o = edje_object_add(evas);
346 e_theme_edje_object_set(o, "base/theme/dialog", "e/widgets/dialog/main");
347 evas_object_geometry_get(cfd->dia->bg_object, &x, &y, &w, &h);
348 evas_object_move(o, x, y);
349 evas_object_resize(o, w, h);
350 evas_object_show(o);
351
352 of = e_widget_frametable_add(evas, _("Edit E_Comp_Match"), 0);
353 evas_object_data_set(of, "bg", o);
354 evas_object_data_set(of, "dia", cfd->dia->bg_object);
355 evas_object_move(of, x, y);
356 evas_object_resize(of, w, h);
357 evas_object_show(of);
358
359 evas_object_event_callback_add(cfd->dia->bg_object, EVAS_CALLBACK_RESIZE,
360 _cb_dialog_resize, of);
361
362 tb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
363
364 tab2 = e_widget_table_add(e_win_evas_win_get(evas), 0);
365 if (cfdata->edit_il == cfdata->borders_il)
366 {
367 if (m->match.title) m->title = strdup(m->match.title);
368 else m->title = NULL;
369 lb = e_widget_label_add(evas, _("Title"));
370 e_widget_table_object_append(tab2, lb, 0, 0, 1, 1, 1, 0, 0, 0);
371 en = e_widget_entry_add(cfd->dia->win, &(m->title), NULL, NULL, NULL);
372 e_widget_table_object_append(tab2, en, 1, 0, 1, 1, 1, 0, 1, 0);
373 }
374 if ((cfdata->edit_il == cfdata->borders_il) ||
375 (cfdata->edit_il == cfdata->overrides_il) ||
376 (cfdata->edit_il == cfdata->popups_il))
377 {
378 if (m->match.name) m->name = strdup(m->match.name);
379 else m->name = NULL;
380 lb = e_widget_label_add(evas, _("Name"));
381 e_widget_table_object_append(tab2, lb, 0, 1, 1, 1, 1, 0, 0, 0);
382 en = e_widget_entry_add(cfd->dia->win, &(m->name), NULL, NULL, NULL);
383 e_widget_table_object_append(tab2, en, 1, 1, 1, 1, 1, 0, 1, 0);
384 }
385 if ((cfdata->edit_il == cfdata->borders_il) ||
386 (cfdata->edit_il == cfdata->overrides_il))
387 {
388 if (m->match.clas) m->clas = strdup(m->match.clas);
389 else m->clas = NULL;
390 lb = e_widget_label_add(evas, _("Class"));
391 e_widget_table_object_append(tab2, lb, 0, 2, 1, 1, 1, 0, 0, 0);
392 en = e_widget_entry_add(cfd->dia->win, &(m->clas), NULL, NULL, NULL);
393 e_widget_table_object_append(tab2, en, 1, 2, 1, 1, 1, 0, 1, 0);
394 }
395 if (cfdata->edit_il == cfdata->borders_il)
396 {
397 if (m->match.role) m->role = strdup(m->match.role);
398 else m->role = NULL;
399 lb = e_widget_label_add(evas, _("Role"));
400 e_widget_table_object_append(tab2, lb, 0, 3, 1, 1, 1, 0, 0, 0);
401 en = e_widget_entry_add(cfd->dia->win, &(m->role), NULL, NULL, NULL);
402 e_widget_table_object_append(tab2, en, 1, 3, 1, 1, 1, 0, 1, 0);
403 }
404 e_widget_toolbook_page_append(tb, NULL, _("Names"), tab2, 1, 1, 1, 1, 0.5, 0.0);
405
406 if ((cfdata->edit_il == cfdata->borders_il) ||
407 (cfdata->edit_il == cfdata->overrides_il))
408 {
409 rg = e_widget_radio_group_new(&m->primary_type);
410
411 li = e_widget_list_add(evas, 1, 0);
412
413 o = e_widget_radio_add(evas, _("Unused"), E_WINDOW_TYPE_UNKNOWN, rg);
414 e_widget_list_object_append(li, o, 1, 0, 0.0);
415
416 o = e_widget_radio_add(evas, _("Combo"), E_WINDOW_TYPE_COMBO, rg);
417 e_widget_list_object_append(li, o, 1, 0, 0.0);
418 o = e_widget_radio_add(evas, _("Desktop"), E_WINDOW_TYPE_DESKTOP, rg);
419 e_widget_list_object_append(li, o, 1, 0, 0.0);
420 o = e_widget_radio_add(evas, _("Dialog"), E_WINDOW_TYPE_DIALOG, rg);
421 e_widget_list_object_append(li, o, 1, 0, 0.0);
422 o = e_widget_radio_add(evas, _("Dock"), E_WINDOW_TYPE_DOCK, rg);
423 e_widget_list_object_append(li, o, 1, 0, 0.0);
424 o = e_widget_radio_add(evas, _("Drag and Drop"), E_WINDOW_TYPE_DND, rg);
425 e_widget_list_object_append(li, o, 1, 0, 0.0);
426 o = e_widget_radio_add(evas, _("Menu"), E_WINDOW_TYPE_MENU, rg);
427 e_widget_list_object_append(li, o, 1, 0, 0.0);
428 o = e_widget_radio_add(evas, _("Menu (Dropdown)"), E_WINDOW_TYPE_DROPDOWN_MENU, rg);
429 e_widget_list_object_append(li, o, 1, 0, 0.0);
430 o = e_widget_radio_add(evas, _("Menu (Popup)"), E_WINDOW_TYPE_POPUP_MENU, rg);
431 e_widget_list_object_append(li, o, 1, 0, 0.0);
432 o = e_widget_radio_add(evas, _("Normal"), E_WINDOW_TYPE_NORMAL, rg);
433 e_widget_list_object_append(li, o, 1, 0, 0.0);
434 o = e_widget_radio_add(evas, _("Notification"), E_WINDOW_TYPE_NOTIFICATION, rg);
435 e_widget_list_object_append(li, o, 1, 0, 0.0);
436 o = e_widget_radio_add(evas, _("Splash"), E_WINDOW_TYPE_SPLASH, rg);
437 e_widget_list_object_append(li, o, 1, 0, 0.0);
438 o = e_widget_radio_add(evas, _("Toolbar"), E_WINDOW_TYPE_TOOLBAR, rg);
439 e_widget_list_object_append(li, o, 1, 0, 0.0);
440 o = e_widget_radio_add(evas, _("Tooltip"), E_WINDOW_TYPE_TOOLTIP, rg);
441 e_widget_list_object_append(li, o, 1, 0, 0.0);
442 o = e_widget_radio_add(evas, _("Utility"), E_WINDOW_TYPE_UTILITY, rg);
443 e_widget_list_object_append(li, o, 1, 0, 0.0);
444 o = e_widget_radio_add(evas, _("Unknown"), E_WINDOW_TYPE_REAL_UNKNOWN, rg);
445 e_widget_list_object_append(li, o, 1, 0, 0.0);
446
447 e_widget_size_min_get(li, &mw, &mh);
448 evas_object_resize(li, mw, mh);
449
450 sf = e_widget_scrollframe_simple_add(evas, li);
451 e_widget_toolbook_page_append(tb, NULL, _("Types"), sf,
452 1, 1, 1, 1, 0.5, 0.0);
453 }
454
455 m->borderless = m->match.borderless;
456 m->dialog = m->match.dialog;
457 m->accepts_focus = m->match.accepts_focus;
458 m->argb = m->match.argb;
459 m->fullscreen = m->match.fullscreen;
460 m->modal = m->match.modal;
461
462 row = 0;
463 tab2 = e_widget_table_add(e_win_evas_win_get(evas), 0);
464 lb = e_widget_label_add(evas, _("Unused"));
465 e_widget_table_object_append(tab2, lb, 1, row, 1, 1, 0, 0, 0, 0);
466 lb = e_widget_label_add(evas, _("On"));
467 e_widget_table_object_append(tab2, lb, 2, row, 1, 1, 0, 0, 0, 0);
468 lb = e_widget_label_add(evas, _("Off"));
469 e_widget_table_object_append(tab2, lb, 3, row, 1, 1, 0, 0, 0, 0);
470 row++;
471
472 if (cfdata->edit_il == cfdata->borders_il)
473 {
474 lb = e_widget_label_add(evas, _("Borderless"));
475 e_widget_table_object_append(tab2, lb, 0, row, 1, 1, 1, 0, 1, 0);
476 rg = e_widget_radio_group_new(&m->borderless);
477 o = e_widget_radio_add(evas, NULL, 0, rg);
478 e_widget_table_object_append(tab2, o, 1, row, 1, 1, 0, 0, 0, 0);
479 o = e_widget_radio_add(evas, NULL, 1, rg);
480 e_widget_table_object_append(tab2, o, 2, row, 1, 1, 0, 0, 0, 0);
481 o = e_widget_radio_add(evas, NULL, -1, rg);
482 e_widget_table_object_append(tab2, o, 3, row, 1, 1, 0, 0, 0, 0);
483 row++;
484 }
485 if (cfdata->edit_il == cfdata->borders_il)
486 {
487 lb = e_widget_label_add(evas, _("Dialog"));
488 e_widget_table_object_append(tab2, lb, 0, row, 1, 1, 1, 0, 1, 0);
489 rg = e_widget_radio_group_new(&m->dialog);
490 o = e_widget_radio_add(evas, NULL, 0, rg);
491 e_widget_table_object_append(tab2, o, 1, row, 1, 1, 0, 0, 0, 0);
492 o = e_widget_radio_add(evas, NULL, 1, rg);
493 e_widget_table_object_append(tab2, o, 2, row, 1, 1, 0, 0, 0, 0);
494 o = e_widget_radio_add(evas, NULL, -1, rg);
495 e_widget_table_object_append(tab2, o, 3, row, 1, 1, 0, 0, 0, 0);
496 row++;
497 }
498 if (cfdata->edit_il == cfdata->borders_il)
499 {
500 lb = e_widget_label_add(evas, _("Accepts Focus"));
501 e_widget_table_object_append(tab2, lb, 0, row, 1, 1, 1, 0, 1, 0);
502 rg = e_widget_radio_group_new(&m->accepts_focus);
503 o = e_widget_radio_add(evas, NULL, 0, rg);
504 e_widget_table_object_append(tab2, o, 1, row, 1, 1, 0, 0, 0, 0);
505 o = e_widget_radio_add(evas, NULL, 1, rg);
506 e_widget_table_object_append(tab2, o, 2, row, 1, 1, 0, 0, 0, 0);
507 o = e_widget_radio_add(evas, NULL, -1, rg);
508 e_widget_table_object_append(tab2, o, 3, row, 1, 1, 0, 0, 0, 0);
509 row++;
510 }
511 lb = e_widget_label_add(evas, _("ARGB"));
512 e_widget_table_object_append(tab2, lb, 0, row, 1, 1, 1, 0, 1, 0);
513 rg = e_widget_radio_group_new(&m->argb);
514 o = e_widget_radio_add(evas, NULL, 0, rg);
515 e_widget_table_object_append(tab2, o, 1, row, 1, 1, 0, 0, 0, 0);
516 o = e_widget_radio_add(evas, NULL, 1, rg);
517 e_widget_table_object_append(tab2, o, 2, row, 1, 1, 0, 0, 0, 0);
518 o = e_widget_radio_add(evas, NULL, -1, rg);
519 e_widget_table_object_append(tab2, o, 3, row, 1, 1, 0, 0, 0, 0);
520 row++;
521 if (cfdata->edit_il == cfdata->borders_il)
522 {
523 lb = e_widget_label_add(evas, _("Fullscreen"));
524 e_widget_table_object_append(tab2, lb, 0, row, 1, 1, 1, 0, 1, 0);
525 rg = e_widget_radio_group_new(&m->fullscreen);
526 o = e_widget_radio_add(evas, NULL, 0, rg);
527 e_widget_table_object_append(tab2, o, 1, row, 1, 1, 0, 0, 0, 0);
528 o = e_widget_radio_add(evas, NULL, 1, rg);
529 e_widget_table_object_append(tab2, o, 2, row, 1, 1, 0, 0, 0, 0);
530 o = e_widget_radio_add(evas, NULL, -1, rg);
531 e_widget_table_object_append(tab2, o, 3, row, 1, 1, 0, 0, 0, 0);
532 row++;
533 }
534 if (cfdata->edit_il == cfdata->borders_il)
535 {
536 lb = e_widget_label_add(evas, _("Modal"));
537 e_widget_table_object_append(tab2, lb, 0, row, 1, 1, 1, 0, 1, 0);
538 rg = e_widget_radio_group_new(&m->modal);
539 o = e_widget_radio_add(evas, NULL, 0, rg);
540 e_widget_table_object_append(tab2, o, 1, row, 1, 1, 0, 0, 0, 0);
541 o = e_widget_radio_add(evas, NULL, 1, rg);
542 e_widget_table_object_append(tab2, o, 2, row, 1, 1, 0, 0, 0, 0);
543 o = e_widget_radio_add(evas, NULL, -1, rg);
544 e_widget_table_object_append(tab2, o, 3, row, 1, 1, 0, 0, 0, 0);
545 row++;
546 }
547 e_widget_toolbook_page_append(tb, NULL, _("Flags"), tab2,
548 1, 1, 1, 1, 0.5, 0.0);
549
550 oi = e_comp_style_selector_create(evas, &(m->match.shadow_style));
551 e_widget_toolbook_page_append(tb, NULL, _("Style"), oi,
552 1, 1, 1, 1, 0.5, 0.0);
553
554 oi = e_widget_list_add(evas, 1, 0);
555 EINA_LIST_FOREACH(cfdata->comp_effects->next, l, s)
556 {
557 m->effect_type++;
558 if (s == m->match.visibility_effect)
559 break;
560 }
561 if (!s) m->effect_type = 0;
562 rg = e_widget_radio_group_new(&(m->effect_type));
563 EINA_LIST_FOREACH(cfdata->comp_effects, l, s)
564 {
565 char *p;
566 const char *pp;
567 char buf[PATH_MAX];
568
569 pp = strchr(s, '/');
570 pp = pp ? pp + 1 : s;
571 p = memcpy(buf, pp, strlen(pp) + 1);
572 p[0] = toupper(p[0]);
573 o = e_widget_radio_add(evas, _(p), mode, rg);
574 e_widget_list_object_append(oi, o, 1, 0, 0.5);
575 mode++;
576 }
577 e_widget_toolbook_page_append(tb, NULL, _("Effect"), oi,
578 1, 1, 1, 1, 0.5, 0.0);
579
580 e_widget_frametable_object_append(of, tb, 0, 0, 1, 1, 1, 1, 1, 1);
581 e_widget_toolbook_page_show(tb, 0);
582
583 bt = e_widget_button_add(evas, _("OK"), NULL, _edit_ok, m, of);
584 e_widget_frametable_object_append(of, bt, 0, 1, 1, 1, 0, 0, 0, 0);
585
586 e_widget_size_min_get(of, &mw, &mh);
587 {
588 int ww, wh;
589
590 evas_object_geometry_get(cfd->dia->win, NULL, NULL, &ww, &wh);
591 evas_object_resize(cfd->dia->win, MAX(mw, ww), MAX(mh, wh));
592 }
593 }
594
595 static void
_but_up(void * d1,void * d2)596 _but_up(void *d1, void *d2)
597 {
598 E_Config_Dialog *cfd = d1;
599 Evas_Object *il = d2;
600 Match_Config *m;
601 int n;
602
603 e_widget_ilist_freeze(il);
604 n = e_widget_ilist_selected_get(il);
605 if (n < 1) return;
606 m = e_widget_ilist_nth_data_get(il, n);
607 if (!m)
608 {
609 e_widget_ilist_thaw(il);
610 return;
611 }
612 e_widget_ilist_remove_num(il, n);
613 n--;
614 _match_ilist_append(il, m, n, 1);
615 e_widget_ilist_nth_show(il, n, 0);
616 e_widget_ilist_selected_set(il, n);
617 e_widget_ilist_thaw(il);
618 e_widget_ilist_go(il);
619 _match_list_up(&(cfd->cfdata->popups), m);
620 _match_list_up(&(cfd->cfdata->borders), m);
621 _match_list_up(&(cfd->cfdata->overrides), m);
622 _match_list_up(&(cfd->cfdata->menus), m);
623 _match_list_up(&(cfd->cfdata->objects), m);
624 cfd->cfdata->changed = 1;
625 e_config_dialog_changed_set(cfd, 1);
626 }
627
628 static void
_but_down(void * d1,void * d2)629 _but_down(void *d1, void *d2)
630 {
631 E_Config_Dialog *cfd = d1;
632 Evas_Object *il = d2;
633 Match_Config *m;
634 int n;
635
636 e_widget_ilist_freeze(il);
637 n = e_widget_ilist_selected_get(il);
638 if (n >= (e_widget_ilist_count(il) - 1)) return;
639 m = e_widget_ilist_nth_data_get(il, n);
640 if (!m)
641 {
642 e_widget_ilist_thaw(il);
643 return;
644 }
645 e_widget_ilist_remove_num(il, n);
646 _match_ilist_append(il, m, n, 0);
647 e_widget_ilist_nth_show(il, n + 1, 0);
648 e_widget_ilist_selected_set(il, n + 1);
649 e_widget_ilist_thaw(il);
650 e_widget_ilist_go(il);
651 _match_list_down(&(cfd->cfdata->popups), m);
652 _match_list_down(&(cfd->cfdata->borders), m);
653 _match_list_down(&(cfd->cfdata->overrides), m);
654 _match_list_down(&(cfd->cfdata->menus), m);
655 _match_list_down(&(cfd->cfdata->objects), m);
656 cfd->cfdata->changed = 1;
657 e_config_dialog_changed_set(cfd, 1);
658 }
659
660 static void
_but_add(void * d1,void * d2)661 _but_add(void *d1, void *d2)
662 {
663 E_Config_Dialog *cfd = d1;
664 Evas_Object *il = d2;
665 Match_Config *m;
666
667 m = E_NEW(Match_Config, 1);
668 m->cfd = cfd;
669 m->match.shadow_style = eina_stringshare_add("default");
670
671 cfd->cfdata->edit_il = il;
672 _create_edit_frame(cfd, evas_object_evas_get(il), cfd->cfdata, m);
673 }
674
675 static void
_but_del(void * d1,void * d2)676 _but_del(void *d1, void *d2)
677 {
678 E_Config_Dialog *cfd = d1;
679 Evas_Object *il = d2;
680 Match_Config *m;
681 int n;
682
683 e_widget_ilist_freeze(il);
684 n = e_widget_ilist_selected_get(il);
685 m = e_widget_ilist_nth_data_get(il, n);
686 if (!m)
687 {
688 e_widget_ilist_thaw(il);
689 return;
690 }
691 e_widget_ilist_remove_num(il, n);
692 e_widget_ilist_thaw(il);
693 e_widget_ilist_go(il);
694 if (!_match_list_del(&(cfd->cfdata->popups), m))
695 if (!_match_list_del(&(cfd->cfdata->borders), m))
696 if (!_match_list_del(&(cfd->cfdata->overrides), m))
697 if (!_match_list_del(&(cfd->cfdata->menus), m))
698 _match_list_del(&(cfd->cfdata->objects), m);
699 cfd->cfdata->changed = 1;
700 e_config_dialog_changed_set(cfd, 1);
701 }
702
703 static void
_but_edit(void * d1,void * d2)704 _but_edit(void *d1, void *d2)
705 {
706 E_Config_Dialog *cfd = d1;
707 Evas_Object *il = d2;
708 int n;
709 Match_Config *m;
710
711 n = e_widget_ilist_selected_get(il);
712 m = e_widget_ilist_nth_data_get(il, n);
713 if (!m) return;
714
715 cfd->cfdata->edit_il = il;
716 _create_edit_frame(cfd, evas_object_evas_get(il), cfd->cfdata, m);
717 cfd->cfdata->changed = 1;
718 e_config_dialog_changed_set(cfd, 1);
719 }
720
721 static Evas_Object *
_create_match_editor(E_Config_Dialog * cfd,Evas * evas,E_Config_Dialog_Data * cfdata EINA_UNUSED,Eina_List ** matches,Evas_Object ** il_ret)722 _create_match_editor(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata EINA_UNUSED, Eina_List **matches, Evas_Object **il_ret)
723 {
724 Evas_Object *tab, *il, *bt;
725 Match_Config *m;
726 Eina_List *l;
727
728 tab = e_widget_table_add(e_win_evas_win_get(evas), 0);
729
730 il = e_widget_ilist_add(evas, 16, 16, NULL);
731 e_widget_size_min_set(il, 160, 100);
732
733 EINA_LIST_FOREACH(*matches, l, m)
734 {
735 _match_ilist_append(il, m, -1, 0);
736 }
737
738 e_widget_ilist_go(il);
739 e_widget_table_object_append(tab, il, 0, 0, 1, 5, 1, 1, 1, 1);
740
741 bt = e_widget_button_add(evas, _("Up"), NULL, _but_up, cfd, il);
742 e_widget_table_object_append(tab, bt, 1, 0, 1, 1, 1, 1, 0, 0);
743 bt = e_widget_button_add(evas, _("Down"), NULL, _but_down, cfd, il);
744 e_widget_table_object_append(tab, bt, 1, 1, 1, 1, 1, 1, 0, 0);
745 bt = e_widget_button_add(evas, _("Add"), NULL, _but_add, cfd, il);
746 e_widget_table_object_append(tab, bt, 1, 2, 1, 1, 1, 1, 0, 0);
747 bt = e_widget_button_add(evas, _("Del"), NULL, _but_del, cfd, il);
748 e_widget_table_object_append(tab, bt, 1, 3, 1, 1, 1, 1, 0, 0);
749 bt = e_widget_button_add(evas, _("Edit"), NULL, _but_edit, cfd, il);
750 e_widget_table_object_append(tab, bt, 1, 4, 1, 1, 1, 1, 0, 0);
751
752 *il_ret = il;
753
754 return tab;
755 }
756
757 static Evas_Object *
_create_styles_toolbook(E_Config_Dialog * cfd,Evas * evas,E_Config_Dialog_Data * cfdata)758 _create_styles_toolbook(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
759 {
760 Evas_Object *tb, *oi, *il;
761
762 tb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
763
764 oi = _create_match_editor(cfd, evas, cfdata, &(cfdata->borders), &il);
765 cfdata->borders_il = il;
766 e_widget_toolbook_page_append(tb, NULL, _("Apps"), oi, 1, 1, 1, 1, 0.5, 0.0);
767
768 oi = _create_match_editor(cfd, evas, cfdata, &(cfdata->popups), &il);
769 cfdata->popups_il = il;
770 e_widget_toolbook_page_append(tb, NULL, _("Popups"), oi, 1, 1, 1, 1, 0.5, 0.0);
771
772 oi = _create_match_editor(cfd, evas, cfdata, &(cfdata->overrides), &il);
773 cfdata->overrides_il = il;
774 e_widget_toolbook_page_append(tb, NULL, _("Overrides"), oi, 1, 1, 1, 1, 0.5, 0.0);
775
776 oi = _create_match_editor(cfd, evas, cfdata, &(cfdata->menus), &il);
777 cfdata->menus_il = il;
778 e_widget_toolbook_page_append(tb, NULL, _("Menus"), oi, 1, 1, 1, 1, 0.5, 0.0);
779
780 oi = _create_match_editor(cfd, evas, cfdata, &(cfdata->objects), &il);
781 cfdata->objects_il = il;
782 e_widget_toolbook_page_append(tb, NULL, _("Objects"), oi, 1, 1, 1, 1, 0.5, 0.0);
783
784 e_widget_toolbook_page_show(tb, 0);
785
786 return tb;
787 }
788
789 static int
_basic_apply_data(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)790 _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
791 {
792 Eina_List *l;
793 E_Comp_Match *m;
794 Match_Config *m2;
795 E_Comp_Config *conf = e_comp_config_get();
796
797 if (!cfdata->changed) return 0;
798
799 E_FREE_LIST(conf->match.popups, e_comp_cfdata_match_free);
800 E_FREE_LIST(conf->match.borders, e_comp_cfdata_match_free);
801 E_FREE_LIST(conf->match.overrides, e_comp_cfdata_match_free);
802 E_FREE_LIST(conf->match.menus, e_comp_cfdata_match_free);
803 E_FREE_LIST(conf->match.objects, e_comp_cfdata_match_free);
804
805 EINA_LIST_FOREACH(cfdata->popups, l, m2)
806 {
807 m = E_NEW(E_Comp_Match, 1);
808 _match_dup2(m2, m);
809 conf->match.popups = eina_list_append(conf->match.popups, m);
810 }
811 EINA_LIST_FOREACH(cfdata->borders, l, m2)
812 {
813 m = E_NEW(E_Comp_Match, 1);
814 _match_dup2(m2, m);
815 conf->match.borders = eina_list_append(conf->match.borders, m);
816 }
817 EINA_LIST_FOREACH(cfdata->overrides, l, m2)
818 {
819 m = E_NEW(E_Comp_Match, 1);
820 _match_dup2(m2, m);
821 conf->match.overrides = eina_list_append(conf->match.overrides, m);
822 }
823 EINA_LIST_FOREACH(cfdata->menus, l, m2)
824 {
825 m = E_NEW(E_Comp_Match, 1);
826 _match_dup2(m2, m);
827 conf->match.menus = eina_list_append(conf->match.menus, m);
828 }
829 EINA_LIST_FOREACH(cfdata->objects, l, m2)
830 {
831 m = E_NEW(E_Comp_Match, 1);
832 _match_dup2(m2, m);
833 conf->match.objects = eina_list_append(conf->match.objects, m);
834 }
835 cfdata->changed = 0;
836 e_comp_shadows_reset();
837 e_config_save_queue();
838 return 1;
839 }
840
841 static Evas_Object *
_basic_create_widgets(E_Config_Dialog * cfd,Evas * evas,E_Config_Dialog_Data * cfdata)842 _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
843 {
844 Evas_Object *orec0;
845
846 orec0 = evas_object_rectangle_add(evas);
847 evas_object_name_set(orec0, "style_shadows");
848 elm_win_center(cfd->dia->win, 1, 1);
849
850 return _create_styles_toolbook(cfd, evas, cfdata);
851 }
852
853 static void
_free_data(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)854 _free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
855 {
856 E_FREE_LIST(cfdata->popups, _match_free);
857 E_FREE_LIST(cfdata->borders, _match_free);
858 E_FREE_LIST(cfdata->menus, _match_free);
859 E_FREE_LIST(cfdata->objects, _match_free);
860 E_FREE_LIST(cfdata->overrides, _match_free);
861 free(cfdata);
862 }
863
864 static void *
_create_data(E_Config_Dialog * cfd)865 _create_data(E_Config_Dialog *cfd)
866 {
867 E_Config_Dialog_Data *cfdata;
868 Eina_List *l;
869 Eina_Stringshare *grp;
870 E_Comp_Match *m;
871 Match_Config *m2;
872 E_Comp_Config *conf = e_comp_config_get();
873
874 cfdata = E_NEW(E_Config_Dialog_Data, 1);
875
876 EINA_LIST_FOREACH(conf->match.popups, l, m)
877 {
878 m2 = E_NEW(Match_Config, 1);
879 _match_dup(m, m2);
880 m2->cfd = cfd;
881 cfdata->popups = eina_list_append(cfdata->popups, m2);
882 }
883
884 EINA_LIST_FOREACH(conf->match.borders, l, m)
885 {
886 m2 = E_NEW(Match_Config, 1);
887 _match_dup(m, m2);
888 m2->cfd = cfd;
889 cfdata->borders = eina_list_append(cfdata->borders, m2);
890 }
891
892 EINA_LIST_FOREACH(conf->match.overrides, l, m)
893 {
894 m2 = E_NEW(Match_Config, 1);
895 _match_dup(m, m2);
896 m2->cfd = cfd;
897 cfdata->overrides = eina_list_append(cfdata->overrides, m2);
898 }
899
900 EINA_LIST_FOREACH(conf->match.menus, l, m)
901 {
902 m2 = E_NEW(Match_Config, 1);
903 _match_dup(m, m2);
904 m2->cfd = cfd;
905 cfdata->menus = eina_list_append(cfdata->menus, m2);
906 }
907
908 EINA_LIST_FOREACH(conf->match.objects, l, m)
909 {
910 m2 = E_NEW(Match_Config, 1);
911 _match_dup(m, m2);
912 m2->cfd = cfd;
913 cfdata->objects = eina_list_append(cfdata->objects, m2);
914 }
915 cfdata->comp_effects = e_theme_collection_items_find("base/theme/borders", "e/comp/effects/visibility");
916 /* comp effects must be prefixed with "visibility" or they won't work and things will break! */
917 EINA_LIST_FOREACH(cfdata->comp_effects, l, grp)
918 {
919 Eina_Stringshare *g;
920 char buf[1024];
921
922 snprintf(buf, sizeof(buf), "visibility/%s", grp);
923 g = eina_stringshare_add(buf);
924 eina_stringshare_del(grp);
925 eina_list_data_set(l, g);
926 }
927 cfdata->comp_effects = eina_list_prepend(cfdata->comp_effects, eina_stringshare_add("none"));
928 return cfdata;
929 }
930
931 E_API E_Config_Dialog *
e_int_config_comp_match(Evas_Object * parent,const char * params EINA_UNUSED)932 e_int_config_comp_match(Evas_Object *parent, const char *params EINA_UNUSED)
933 {
934 E_Config_Dialog *cfd;
935 E_Config_Dialog_View *v;
936
937 if (e_config_dialog_find("E", "internal/comp_matches")) return NULL;
938 v = E_NEW(E_Config_Dialog_View, 1);
939
940 v->create_cfdata = _create_data;
941 v->free_cfdata = _free_data;
942 v->basic.apply_cfdata = _basic_apply_data;
943 v->basic.create_widgets = _basic_create_widgets;
944
945 cfd = e_config_dialog_new(parent, _("Composite Match Settings"),
946 "E", "_comp_matches", "preferences-composite", 0, v, NULL);
947 e_dialog_resizable_set(cfd->dia, 1);
948 return cfd;
949 }
950