Add overlay_list_get and extension_list_get, and use them in elm_web to correctly...
authorsachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 5 Mar 2012 21:48:32 +0000 (21:48 +0000)
committersachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 5 Mar 2012 21:48:32 +0000 (21:48 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68746 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_theme.c
src/lib/elm_theme.h
src/lib/elm_web.c

index 3323a1e..98819e0 100644 (file)
@@ -435,6 +435,13 @@ elm_theme_overlay_del(Elm_Theme *th, const char *item)
    elm_theme_flush(th);
 }
 
+EAPI const Eina_List *
+elm_theme_overlay_list_get(Elm_Theme *th)
+{
+   if (!th) th = &(theme_default);
+   return th->overlay;
+}
+
 EAPI void
 elm_theme_extension_add(Elm_Theme *th, const char *item)
 {
@@ -464,6 +471,13 @@ elm_theme_extension_del(Elm_Theme *th, const char *item)
    elm_theme_flush(th);
 }
 
+EAPI const Eina_List *
+elm_theme_extension_list_get(Elm_Theme *th)
+{
+   if (!th) th = &(theme_default);
+   return th->extension;
+}
+
 EAPI void
 elm_theme_set(Elm_Theme *th, const char *theme)
 {
index 7c543a5..0fdb8fa 100644 (file)
@@ -180,6 +180,16 @@ EAPI void             elm_theme_overlay_add(Elm_Theme *th, const char *item);
 EAPI void             elm_theme_overlay_del(Elm_Theme *th, const char *item);
 
 /**
+ * Get the list of registered overlays for the given theme
+ *
+ * @param th The theme from which to get the overlays
+ * @return List of theme overlays. Do not free it.
+ *
+ * @see elm_theme_overlay_add()
+ */
+EAPI const Eina_List *elm_theme_overlay_list_get(Elm_Theme *th);
+
+/**
  * Appends a theme extension to the list of extensions.
  *
  * @param th The theme to add to, or if NULL, the default theme
@@ -211,6 +221,16 @@ EAPI void             elm_theme_extension_add(Elm_Theme *th, const char *item);
 EAPI void             elm_theme_extension_del(Elm_Theme *th, const char *item);
 
 /**
+ * Get the list of registered extensions for the given theme
+ *
+ * @param th The theme from which to get the extensions
+ * @return List of theme extensions. Do not free it.
+ *
+ * @see elm_theme_extension_add()
+ */
+EAPI const Eina_List *elm_theme_extension_list_get(Elm_Theme *th);
+
+/**
  * Set the theme search order for the given theme
  *
  * @param th The theme to set the search order, or if NULL, the default theme
index 0ab49b6..c372ff6 100644 (file)
@@ -138,29 +138,45 @@ static const Evas_Smart_Cb_Description _elm_web_callback_names[] = {
    { NULL, NULL }
 };
 
-static void
-_theme_hook(Evas_Object *obj)
+static char *
+_webkit_theme_find(const Eina_List *list)
 {
-#ifdef HAVE_ELEMENTARY_WEB
-   Elm_Theme *theme = elm_object_theme_get(obj);
-   Widget_Data *wd = elm_widget_data_get(obj);
-   const Eina_List *themes, *l;
+   const Eina_List *l;
    const char *th;
-   char *view_theme = NULL;
 
-   themes = elm_theme_list_get(theme);
-   EINA_LIST_FOREACH(themes, l, th)
+   EINA_LIST_FOREACH(list, l, th)
      {
         char *path = elm_theme_list_item_path_get(th, NULL);
         if (!path) continue;
         if (edje_file_group_exists(path, "webkit/base"))
-          {
-             view_theme = path;
-             break;
-          }
+          return path;
         free(path);
      }
 
+   return NULL;
+}
+
+static void
+_theme_hook(Evas_Object *obj)
+{
+#ifdef HAVE_ELEMENTARY_WEB
+   Elm_Theme *theme = elm_object_theme_get(obj);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   const Eina_List *themes;
+   char *view_theme = NULL;
+
+   themes = elm_theme_overlay_list_get(theme);
+   view_theme = _webkit_theme_find(themes);
+   if (view_theme) goto set;
+
+   themes = elm_theme_list_get(theme);
+   view_theme = _webkit_theme_find(themes);
+   if (view_theme) goto set;
+
+   themes = elm_theme_extension_list_get(theme);
+   view_theme = _webkit_theme_find(themes);
+
+set:
    if (view_theme)
      {
         ewk_view_theme_set(wd->ewk_view, view_theme);