theme: add fallback matching when referenced theme is not found
authorMike Blumenkrantz <zmike@osg.samsung.com>
Wed, 28 Feb 2018 16:01:26 +0000 (11:01 -0500)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 10 Apr 2018 11:10:44 +0000 (20:10 +0900)
if done properly, this should never occur, but at least find some
layout to use if one is available

src/lib/elementary/elm_theme.c

index a20196b..72be510 100644 (file)
@@ -16,11 +16,11 @@ static Elm_Theme theme_default =
 static Eina_List *themes = NULL;
 
 static Eina_File *
-_elm_theme_find_try(Elm_Theme *th, Elm_Theme_File *etf, const char *group)
+_elm_theme_find_try(Elm_Theme *th, Elm_Theme_File *etf, const char *group, Eina_Bool force)
 {
    if (edje_mmap_group_exists(etf->handle, group))
      {
-        if (etf->match_theme) // overlay or extension
+        if (etf->match_theme && (!force)) // overlay or extension
           {
              Elm_Theme_File *base_etf;
              Eina_Bool found = EINA_FALSE;
@@ -218,8 +218,8 @@ _elm_theme_clear(Elm_Theme *th)
      }
 }
 
-Eina_File *
-_elm_theme_group_file_find(Elm_Theme *th, const char *group)
+static Eina_File *
+_elm_theme_group_file_find_internal(Elm_Theme *th, const char *group, Eina_Bool force)
 {
    Elm_Theme_File *etf;
    Eina_File *file = eina_hash_find(th->cache, group);
@@ -228,23 +228,32 @@ _elm_theme_group_file_find(Elm_Theme *th, const char *group)
 
    EINA_INLIST_FOREACH(th->overlay, etf)
      {
-        file = _elm_theme_find_try(th, etf, group);
+        file = _elm_theme_find_try(th, etf, group, force);
         if (file) return file;
      }
    EINA_INLIST_FOREACH(th->themes, etf)
      {
-        file = _elm_theme_find_try(th, etf, group);
+        file = _elm_theme_find_try(th, etf, group, force);
         if (file) return file;
      }
    EINA_INLIST_FOREACH(th->extension, etf)
      {
-        file = _elm_theme_find_try(th, etf, group);
+        file = _elm_theme_find_try(th, etf, group, force);
         if (file) return file;
      }
-   if (th->ref_theme) return _elm_theme_group_file_find(th->ref_theme, group);
+   if (th->ref_theme) return _elm_theme_group_file_find_internal(th->ref_theme, group, force);
    return NULL;
 }
 
+Eina_File *
+_elm_theme_group_file_find(Elm_Theme *th, const char *group)
+{
+   Eina_File *file = _elm_theme_group_file_find_internal(th, group, EINA_FALSE);
+   if (file) return file;
+   file = _elm_theme_group_file_find_internal(th, group, EINA_TRUE);
+   return file;
+}
+
 static const char *
 _elm_theme_find_data_try(Elm_Theme *th, const Eina_File *f, const char *key)
 {