summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen 'Okra' Houston <smhouston88@gmail.com>2017-02-22 11:05:27 -0600
committerStephen 'Okra' Houston <smhouston88@gmail.com>2017-02-22 11:05:55 -0600
commit3ce76c66d22be70c9d009b3cb5ec4c783d403e2c (patch)
tree000e455b94424c7107119677b9dcf474f4e7d9bb
parenta534433a914c333b1a036217685af709e9fc994f (diff)
Luncher: Unify icon image file setting code.
-rw-r--r--src/modules/luncher/bar.c253
-rw-r--r--src/modules/luncher/grid.c189
2 files changed, 184 insertions, 258 deletions
diff --git a/src/modules/luncher/bar.c b/src/modules/luncher/bar.c
index d5d9fa18e..1ae1e48bf 100644
--- a/src/modules/luncher/bar.c
+++ b/src/modules/luncher/bar.c
@@ -954,6 +954,110 @@ _bar_exec_new_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *even
954} 954}
955 955
956static void 956static void
957_bar_icon_file_set(Icon *ic, Efreet_Desktop *desktop, E_Client *non_desktop_client)
958{
959 const char *path = NULL, *k = NULL;
960 char buf[4096];
961 int len = 0;
962 if (desktop)
963 {
964 if (!desktop->icon)
965 path = NULL;
966 else if (strncmp(desktop->icon, "/", 1) && !ecore_file_exists(desktop->icon))
967 {
968 path = efreet_icon_path_find(e_config->icon_theme, desktop->icon, ic->inst->size);
969 if (!path)
970 {
971 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
972 path = efreet_icon_path_find("hicolor", desktop->icon, ic->inst->size);
973 }
974 }
975 else if (ecore_file_exists(desktop->icon))
976 {
977 path = desktop->icon;
978 }
979 if (!path && desktop->icon)
980 {
981 snprintf(buf, sizeof(buf), "e/icons/%s", desktop->icon);
982 if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
983 {
984 path = e_theme_edje_file_get("base/theme/icons", buf);
985 k = buf;
986 }
987 else
988 {
989 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
990 k = "e/icons/unknown";
991 }
992 }
993 else if (!path && !desktop->icon)
994 {
995 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
996 k = "e/icons/unknown";
997 }
998 if (path && desktop->icon && !k)
999 {
1000 len = strlen(desktop->icon);
1001 if ((len > 4) && (!strcasecmp(desktop->icon + len - 4, ".edj")))
1002 k = "icon";
1003 }
1004 }
1005 else if (non_desktop_client)
1006 {
1007 Evas_Object *tmp;
1008 const char *file, *group;
1009 Eina_Bool ret = EINA_FALSE;
1010
1011 tmp = e_client_icon_add(non_desktop_client, evas_object_evas_get(ic->o_layout));
1012 if (isedje(tmp))
1013 {
1014 edje_object_file_get(tmp, &file, &group);
1015 if (file && group)
1016 ret = EINA_TRUE;
1017 }
1018 else
1019 ret = e_icon_file_get(tmp, &file, &group);
1020 if (ret)
1021 {
1022 eina_stringshare_replace(&ic->icon, file);
1023 eina_stringshare_replace(&ic->key, group);
1024 path = ic->icon;
1025 k = ic->key;
1026 }
1027 evas_object_del(tmp);
1028 }
1029 else if (ic->icon)
1030 {
1031 if (strncmp(ic->icon, "/", 1) && !ecore_file_exists(ic->icon))
1032 {
1033 path = efreet_icon_path_find(e_config->icon_theme, ic->icon, ic->inst->size);
1034 if (!path)
1035 {
1036 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
1037 path = efreet_icon_path_find("hicolor", ic->icon, ic->inst->size);
1038 }
1039 }
1040 else if (ecore_file_exists(ic->icon))
1041 {
1042 path = ic->icon;
1043 k = ic->key;
1044 }
1045 if (!path)
1046 {
1047 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
1048 k = "e/icons/unknown";
1049 }
1050 }
1051 else
1052 {
1053 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
1054 k = "e/icons/unknown";
1055 }
1056 elm_image_file_set(ic->o_icon, path, k);
1057 elm_image_file_set(ic->o_overlay, path, k);
1058}
1059
1060static void
957_bar_icon_resized(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED) 1061_bar_icon_resized(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
958{ 1062{
959 //This code is supposed to adjust aspect correctly when there is an effect happening. Uncomment to test. 1063 //This code is supposed to adjust aspect correctly when there is an effect happening. Uncomment to test.
@@ -990,9 +1094,7 @@ _bar_icon_resized(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const ch
990static Icon * 1094static Icon *
991_bar_icon_add(Instance *inst, Efreet_Desktop *desktop, E_Client *non_desktop_client) 1095_bar_icon_add(Instance *inst, Efreet_Desktop *desktop, E_Client *non_desktop_client)
992{ 1096{
993 const char *path = NULL, *k = NULL; 1097 char ori[32];
994 char buf[4096], ori[32];
995 int len = 0;
996 Icon *ic; 1098 Icon *ic;
997 const Eina_List *l; 1099 const Eina_List *l;
998 Edje_Message_String *msg; 1100 Edje_Message_String *msg;
@@ -1035,74 +1137,7 @@ _bar_icon_add(Instance *inst, Efreet_Desktop *desktop, E_Client *non_desktop_cli
1035 ic->o_overlay = elm_icon_add(ic->o_layout); 1137 ic->o_overlay = elm_icon_add(ic->o_layout);
1036 E_EXPAND(ic->o_overlay); 1138 E_EXPAND(ic->o_overlay);
1037 1139
1038 if (desktop) 1140 _bar_icon_file_set(ic, desktop, non_desktop_client);
1039 {
1040 if (!desktop->icon)
1041 path = NULL;
1042 else if (strncmp(desktop->icon, "/", 1) && !ecore_file_exists(desktop->icon))
1043 {
1044 path = efreet_icon_path_find(e_config->icon_theme, desktop->icon, inst->size);
1045 if (!path)
1046 {
1047 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
1048 path = efreet_icon_path_find("hicolor", desktop->icon, inst->size);
1049 }
1050 }
1051 else if (ecore_file_exists(desktop->icon))
1052 {
1053 path = desktop->icon;
1054 }
1055 if (!path && desktop->icon)
1056 {
1057 snprintf(buf, sizeof(buf), "e/icons/%s", desktop->icon);
1058 if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
1059 {
1060 path = e_theme_edje_file_get("base/theme/icons", buf);
1061 k = buf;
1062 }
1063 else
1064 {
1065 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
1066 k = "e/icons/unknown";
1067 }
1068 }
1069 else if (!path && !desktop->icon)
1070 {
1071 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
1072 k = "e/icons/unknown";
1073 }
1074 if (path && desktop->icon && !k)
1075 {
1076 len = strlen(desktop->icon);
1077 if ((len > 4) && (!strcasecmp(desktop->icon + len - 4, ".edj")))
1078 k = "icon";
1079 }
1080 }
1081 else
1082 {
1083 Evas_Object *tmp;
1084 const char *file, *group;
1085 Eina_Bool ret = EINA_FALSE;
1086
1087 tmp = e_client_icon_add(non_desktop_client, evas_object_evas_get(ic->o_layout));
1088 if (isedje(tmp))
1089 {
1090 edje_object_file_get(tmp, &file, &group);
1091 if (file && group)
1092 ret = EINA_TRUE;
1093 }
1094 else
1095 ret = e_icon_file_get(tmp, &file, &group);
1096 if (ret)
1097 {
1098 eina_stringshare_replace(&ic->icon, file);
1099 eina_stringshare_replace(&ic->key, group);
1100 path = ic->icon;
1101 k = ic->key;
1102 }
1103 evas_object_del(tmp);
1104 }
1105 elm_image_file_set(ic->o_icon, path, k);
1106 1141
1107 if (desktop) 1142 if (desktop)
1108 elm_object_tooltip_text_set(ic->o_icon, desktop->name); 1143 elm_object_tooltip_text_set(ic->o_icon, desktop->name);
@@ -1133,7 +1168,6 @@ _bar_icon_add(Instance *inst, Efreet_Desktop *desktop, E_Client *non_desktop_cli
1133 _bar_icon_mouse_out, ic); 1168 _bar_icon_mouse_out, ic);
1134 evas_object_show(ic->o_icon); 1169 evas_object_show(ic->o_icon);
1135 1170
1136 elm_image_file_set(ic->o_overlay, path, k);
1137 evas_object_size_hint_aspect_set(ic->o_overlay, EVAS_ASPECT_CONTROL_BOTH, 1, 1); 1171 evas_object_size_hint_aspect_set(ic->o_overlay, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
1138 elm_layout_content_set(ic->o_layout, "e.swallow.overlay", ic->o_overlay); 1172 elm_layout_content_set(ic->o_layout, "e.swallow.overlay", ic->o_overlay);
1139 evas_object_show(ic->o_overlay); 1173 evas_object_show(ic->o_overlay);
@@ -1556,80 +1590,7 @@ _bar_resize_job(void *data)
1556 } 1590 }
1557 inst->size = size; 1591 inst->size = size;
1558 EINA_LIST_FOREACH(inst->icons, l, ic) 1592 EINA_LIST_FOREACH(inst->icons, l, ic)
1559 { 1593 _bar_icon_file_set(ic, ic->desktop, NULL);
1560 const char *path = NULL, *key = NULL;
1561 int len = 0;
1562
1563 if (ic->desktop)
1564 {
1565 if (!ic->desktop->icon)
1566 path = NULL;
1567 else if (strncmp(ic->desktop->icon, "/", 1) && !ecore_file_exists(ic->desktop->icon))
1568 {
1569 path = efreet_icon_path_find(e_config->icon_theme, ic->desktop->icon, inst->size);
1570 if (!path)
1571 {
1572 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
1573 path = efreet_icon_path_find("hicolor", ic->desktop->icon, inst->size);
1574 }
1575 }
1576 else if (ecore_file_exists(ic->desktop->icon))
1577 {
1578 path = ic->desktop->icon;
1579 }
1580 if (!path)
1581 {
1582 elm_image_file_set(ic->o_icon, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
1583 "e/icons/unknown");
1584 elm_image_file_set(ic->o_overlay, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
1585 "e/icons/unknown");
1586 }
1587 if (path && ic->desktop->icon)
1588 {
1589 len = strlen(ic->desktop->icon);
1590 if ((len > 4) && (!strcasecmp(ic->desktop->icon + len - 4, ".edj")))
1591 key = "icon";
1592
1593 elm_image_file_set(ic->o_icon, path, key);
1594 elm_image_file_set(ic->o_overlay, path, key);
1595 }
1596 }
1597 else if (ic->icon)
1598 {
1599 if (strncmp(ic->icon, "/", 1) && !ecore_file_exists(ic->icon))
1600 {
1601 path = efreet_icon_path_find(e_config->icon_theme, ic->icon, inst->size);
1602 if (!path)
1603 {
1604 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
1605 path = efreet_icon_path_find("hicolor", ic->icon, inst->size);
1606 }
1607 }
1608 else if (ecore_file_exists(ic->icon))
1609 {
1610 path = ic->icon;
1611 }
1612 if (!path)
1613 {
1614 elm_image_file_set(ic->o_icon, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
1615 "e/icons/unknown");
1616 elm_image_file_set(ic->o_overlay, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
1617 "e/icons/unknown");
1618 }
1619 else
1620 {
1621 elm_image_file_set(ic->o_icon, path, ic->key);
1622 elm_image_file_set(ic->o_overlay, path, ic->key);
1623 }
1624 }
1625 else
1626 {
1627 elm_image_file_set(ic->o_icon, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
1628 "e/icons/unknown");
1629 elm_image_file_set(ic->o_overlay, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
1630 "e/icons/unknown");
1631 }
1632 }
1633 inst->resize_job = NULL; 1594 inst->resize_job = NULL;
1634 } 1595 }
1635} 1596}
diff --git a/src/modules/luncher/grid.c b/src/modules/luncher/grid.c
index 2a22a870d..81a29c811 100644
--- a/src/modules/luncher/grid.c
+++ b/src/modules/luncher/grid.c
@@ -240,11 +240,83 @@ _gengrid_icon_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
240 return ic->o_layout; 240 return ic->o_layout;
241} 241}
242 242
243static Icon * 243static void
244_grid_icon_add(Instance *inst, Efreet_Desktop *desktop) 244_grid_icon_file_set(Icon *ic, Efreet_Desktop *desktop)
245{ 245{
246 const char *path = NULL, *k = NULL; 246 const char *path = NULL, *k = NULL;
247 char buf[4096]; 247 char buf[4096];
248
249 if (desktop)
250 {
251 if (!desktop->icon)
252 path = NULL;
253 else if (strncmp(desktop->icon, "/", 1) && !ecore_file_exists(desktop->icon))
254 {
255 path = efreet_icon_path_find(e_config->icon_theme, desktop->icon, ic->inst->size);
256 if (!path)
257 {
258 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
259 path = efreet_icon_path_find("hicolor", desktop->icon, ic->inst->size);
260 }
261 }
262 else if (ecore_file_exists(desktop->icon))
263 {
264 path = desktop->icon;
265 }
266 if (!path && desktop->icon)
267 {
268 snprintf(buf, sizeof(buf), "e/icons/%s", desktop->icon);
269 if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
270 {
271 path = e_theme_edje_file_get("base/theme/icons", buf);
272 k = buf;
273 }
274 else
275 {
276 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
277 k = "e/icons/unknown";
278 }
279 }
280 else if (!path && !desktop->icon)
281 {
282 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
283 k = "e/icons/unknown";
284 }
285 }
286 else if (ic->icon)
287 {
288 if (strncmp(ic->icon, "/", 1) && !ecore_file_exists(ic->icon))
289 {
290 path = efreet_icon_path_find(e_config->icon_theme, ic->icon, ic->inst->size);
291 if (!path)
292 {
293 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
294 path = efreet_icon_path_find("hicolor", ic->icon, ic->inst->size);
295 }
296 }
297 else if (ecore_file_exists(ic->icon))
298 {
299 path = ic->icon;
300 k = ic->key;
301 }
302 if (!path)
303 {
304 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
305 k = "e/icons/unknown";
306 }
307 }
308 else
309 {
310 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
311 k = "e/icons/unknown";
312 }
313 elm_image_file_set(ic->o_icon, path, k);
314 elm_image_file_set(ic->o_overlay, path, k);
315}
316
317static Icon *
318_grid_icon_add(Instance *inst, Efreet_Desktop *desktop)
319{
248 Icon *ic; 320 Icon *ic;
249 321
250 ic = E_NEW(Icon, 1); 322 ic = E_NEW(Icon, 1);
@@ -271,41 +343,8 @@ _grid_icon_add(Instance *inst, Efreet_Desktop *desktop)
271 ic->o_overlay = elm_icon_add(ic->o_layout); 343 ic->o_overlay = elm_icon_add(ic->o_layout);
272 E_EXPAND(ic->o_overlay); 344 E_EXPAND(ic->o_overlay);
273 345
274 if (!desktop->icon) 346 _grid_icon_file_set(ic, desktop);
275 path = NULL; 347
276 else if (strncmp(desktop->icon, "/", 1) && !ecore_file_exists(desktop->icon))
277 {
278 path = efreet_icon_path_find(e_config->icon_theme, desktop->icon, inst->size);
279 if (!path)
280 {
281 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
282 path = efreet_icon_path_find("hicolor", desktop->icon, inst->size);
283 }
284 }
285 else if (ecore_file_exists(desktop->icon))
286 {
287 path = desktop->icon;
288 }
289 if (!path && desktop->icon)
290 {
291 snprintf(buf, sizeof(buf), "e/icons/%s", desktop->icon);
292 if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
293 {
294 path = e_theme_edje_file_get("base/theme/icons", buf);
295 k = buf;
296 }
297 else
298 {
299 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
300 k = "e/icons/unknown";
301 }
302 }
303 else if (!path && !desktop->icon)
304 {
305 path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
306 k = "e/icons/unknown";
307 }
308 elm_image_file_set(ic->o_icon, path, k);
309 elm_object_tooltip_text_set(ic->o_icon, desktop->name); 348 elm_object_tooltip_text_set(ic->o_icon, desktop->name);
310 elm_object_tooltip_orient_set(ic->o_icon, ELM_TOOLTIP_ORIENT_CENTER); 349 elm_object_tooltip_orient_set(ic->o_icon, ELM_TOOLTIP_ORIENT_CENTER);
311 elm_object_tooltip_style_set(ic->o_icon, "luncher"); 350 elm_object_tooltip_style_set(ic->o_icon, "luncher");
@@ -323,7 +362,6 @@ _grid_icon_add(Instance *inst, Efreet_Desktop *desktop)
323 _grid_icon_mouse_out, ic); 362 _grid_icon_mouse_out, ic);
324 evas_object_show(ic->o_icon); 363 evas_object_show(ic->o_icon);
325 364
326 elm_image_file_set(ic->o_overlay, path, k);
327 evas_object_size_hint_aspect_set(ic->o_overlay, EVAS_ASPECT_CONTROL_BOTH, 1, 1); 365 evas_object_size_hint_aspect_set(ic->o_overlay, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
328 elm_layout_content_set(ic->o_layout, "e.swallow.overlay", ic->o_overlay); 366 elm_layout_content_set(ic->o_layout, "e.swallow.overlay", ic->o_overlay);
329 evas_object_show(ic->o_overlay); 367 evas_object_show(ic->o_overlay);
@@ -379,80 +417,7 @@ _grid_resize_job(void *data)
379 elm_layout_sizing_eval(inst->o_main); 417 elm_layout_sizing_eval(inst->o_main);
380 _grid_aspect(inst); 418 _grid_aspect(inst);
381 EINA_LIST_FOREACH(inst->icons, l, ic) 419 EINA_LIST_FOREACH(inst->icons, l, ic)
382 { 420 _grid_icon_file_set(ic, ic->desktop);
383 const char *path = NULL, *key = NULL;
384 int len = 0;
385
386 if (ic->desktop)
387 {
388 if (!ic->desktop->icon)
389 path = NULL;
390 else if (strncmp(ic->desktop->icon, "/", 1) && !ecore_file_exists(ic->desktop->icon))
391 {
392 path = efreet_icon_path_find(e_config->icon_theme, ic->desktop->icon, inst->size);
393 if (!path)
394 {
395 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
396 path = efreet_icon_path_find("hicolor", ic->desktop->icon, inst->size);
397 }
398 }
399 else if (ecore_file_exists(ic->desktop->icon))
400 {
401 path = ic->desktop->icon;
402 }
403 if (!path)
404 {
405 elm_image_file_set(ic->o_icon, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
406 "e/icons/unknown");
407 elm_image_file_set(ic->o_overlay, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
408 "e/icons/unknown");
409 }
410 if (path && ic->desktop->icon)
411 {
412 len = strlen(ic->desktop->icon);
413 if ((len > 4) && (!strcasecmp(ic->desktop->icon + len - 4, ".edj")))
414 key = "icon";
415
416 elm_image_file_set(ic->o_icon, path, key);
417 elm_image_file_set(ic->o_overlay, path, key);
418 }
419 }
420 else if (ic->icon)
421 {
422 if (strncmp(ic->icon, "/", 1) && !ecore_file_exists(ic->icon))
423 {
424 path = efreet_icon_path_find(e_config->icon_theme, ic->icon, inst->size);
425 if (!path)
426 {
427 if (e_util_strcmp(e_config->icon_theme, "hicolor"))
428 path = efreet_icon_path_find("hicolor", ic->icon, inst->size);
429 }
430 }
431 else if (ecore_file_exists(ic->icon))
432 {
433 path = ic->icon;
434 }
435 if (!path)
436 {
437 elm_image_file_set(ic->o_icon, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
438 "e/icons/unknown");
439 elm_image_file_set(ic->o_overlay, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
440 "e/icons/unknown");
441 }
442 else
443 {
444 elm_image_file_set(ic->o_icon, path, ic->key);
445 elm_image_file_set(ic->o_overlay, path, ic->key);
446 }
447 }
448 else
449 {
450 elm_image_file_set(ic->o_icon, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
451 "e/icons/unknown");
452 elm_image_file_set(ic->o_overlay, e_theme_edje_file_get("base/theme/icons", "e/icons/unknown"),
453 "e/icons/unknown");
454 }
455 }
456 inst->resize_job = NULL; 421 inst->resize_job = NULL;
457 } 422 }
458} 423}