davemds pushed a commit to branch master.

http://git.enlightenment.org/enlightenment/modules/edgar.git/commit/?id=421ee244a7e218f3d27b474b6bcb0d2f7d806ce7

commit 421ee244a7e218f3d27b474b6bcb0d2f7d806ce7
Author: davemds <[email protected]>
Date:   Sun Sep 7 13:03:58 2014 +0200

    theme_edje_object_set() now also support ElmLayout
    
    thus renamed to theme_object_set()
---
 GADGETS/audio/__init__.py |  2 +-
 python/e.py               |  6 +++---
 src/e_mod_edgar.c         | 28 +++++++++++++++++-----------
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/GADGETS/audio/__init__.py b/GADGETS/audio/__init__.py
index 67f5715..21a33d0 100644
--- a/GADGETS/audio/__init__.py
+++ b/GADGETS/audio/__init__.py
@@ -114,7 +114,7 @@ class Gadget(e.Gadget):
     def popup_player_add(self, popup, player):
         # create the edje obj for this player from 'e/gadgets/audio/player'
         o = edje.Edje(popup.evas, update_hints=True)
-        e.theme_edje_object_set(o, 'audio', 'player')
+        e.theme_object_set(o, 'audio', 'player')
 
         o.signal_callback_add('act,play', '', lambda o,sig,src: player.play())
         o.signal_callback_add('act,prev', '', lambda o,sig,src: player.prev())
diff --git a/python/e.py b/python/e.py
index 43adeac..1867d5e 100644
--- a/python/e.py
+++ b/python/e.py
@@ -1,17 +1,17 @@
 # This python file use the following encoding: utf-8
 
 from eapi import (
-    theme_edje_object_set
+    theme_object_set
 )
 
-""" theme_edje_object_set(edje_obj, gadget_name, group_name)
+""" theme_object_set(obj, gadget_name, group_name)
 
 You must use this function to load additional groups from your
 edje file. This function will search the group first in the E theme
 and then in your local edje file.
 
 Args:
-    obj: the edje object where the group will be loaded
+    obj: the object where the group will be loaded (Edje or ElmLayout)
     gadget_name: the name of your gadget
     group_name: the name of the edje group to load
 
diff --git a/src/e_mod_edgar.c b/src/e_mod_edgar.c
index db79c9a..d6234a0 100644
--- a/src/e_mod_edgar.c
+++ b/src/e_mod_edgar.c
@@ -42,7 +42,7 @@ static Edgar_Py_Gadget *edgar_gadget_load(const char *name, 
const char *path);
 static void             edgar_gadget_unload(Edgar_Py_Gadget *gadget);
 static void             edgar_gadgets_load_all(const char *path);
 static void             edgar_gadgets_hash_free_func(void *data);
-static Eina_Bool        edgar_theme_edje_object_set(Edgar_Py_Gadget *gadget, 
Evas_Object *obj, const char *group);
+static Eina_Bool        edgar_theme_object_set(Edgar_Py_Gadget *gadget, 
Evas_Object *obj, const char *group);
 
 /* Local Gadcon Prototypes */
 static E_Gadcon_Client *_edgar_gc_init(E_Gadcon *gc, const char *name, const 
char *id, const char *style);
@@ -324,7 +324,7 @@ edgar_gadgets_hash_free_func(void *data)
 /*****************************************************************************/
  
 static Eina_Bool
-edgar_theme_edje_object_set(Edgar_Py_Gadget *gadget, Evas_Object *obj, const 
char *group)
+edgar_theme_object_set(Edgar_Py_Gadget *gadget, Evas_Object *obj, const char 
*group)
 {
    char buf[PATH_MAX];
 
@@ -339,7 +339,13 @@ edgar_theme_edje_object_set(Edgar_Py_Gadget *gadget, 
Evas_Object *obj, const cha
    if (!gadget->edjefile)
       return EINA_FALSE;
 
-   return edje_object_file_set(obj, gadget->edjefile, buf);
+   if (eo_isa(obj, EDJE_OBJECT_CLASS))
+      return edje_object_file_set(obj, gadget->edjefile, buf);
+
+   if (eo_isa(obj, ELM_LAYOUT_CLASS))
+      return elm_layout_file_set(obj, gadget->edjefile, buf);
+
+   return EINA_FALSE;
 }
 
 static Eina_Bool
@@ -368,7 +374,7 @@ edgar_popup_new(Edgar_Py_Gadget *gadget, E_Gadcon_Client 
*gcc)
 
    // create the popup content from the e/gadgets/name/popup group
    content = edje_object_add(gcc->gadcon->evas);
-   if (!edgar_theme_edje_object_set(gadget, content, "popup"))
+   if (!edgar_theme_object_set(gadget, content, "popup"))
    {
       evas_object_del(content);
       return NULL;
@@ -458,7 +464,7 @@ edgar_menu_info_cb(void *data, E_Menu *m, E_Menu_Item *mi)
 
    // icon
    icon = edje_object_add(dia->win->evas);
-   edgar_theme_edje_object_set(gadget, icon, "icon");
+   edgar_theme_object_set(gadget, icon, "icon");
    img = e_widget_image_add_from_object(dia->win->evas, icon,
                                         70 * e_scale, 70 * e_scale);
    e_widget_list_object_append(hbox, img, 1, 0, 0.0);
@@ -565,7 +571,7 @@ _edgar_gc_init(E_Gadcon *gc, const char *name, const char 
*id, const char *style
    // create the edje object (popup or main)
    obj = edje_object_add(gc->evas);
    group = pop_on_desk ? "popup" : "main";
-   if (!edgar_theme_edje_object_set(gadget, obj, group))
+   if (!edgar_theme_object_set(gadget, obj, group))
    {
       DBG("EDGAR:   ERROR, cannot find a theme for the gadget: '%s'", name);
       evas_object_del(obj);
@@ -743,7 +749,7 @@ _edgar_gc_icon(const E_Gadcon_Client_Class *client_class, 
Evas *evas)
    if (!gadget) return NULL;
 
    icon = edje_object_add(evas);
-   if (edgar_theme_edje_object_set(gadget, icon, "icon"))
+   if (edgar_theme_object_set(gadget, icon, "icon"))
       return icon;
 
    evas_object_del(icon);
@@ -763,21 +769,21 @@ _edgar_gc_icon(const E_Gadcon_Client_Class *client_class, 
Evas *evas)
 
 
 static PyObject*
-_eapi_theme_edje_object_set(PyObject *self, PyObject *args)
+_eapi_theme_object_set(PyObject *self, PyObject *args)
 {
    Edgar_Py_Gadget *gadget;
    const char *name, *group;
    Evas_Object *obj;
    PyObject *pyobj;
 
-   if (!PyArg_ParseTuple(args, "O!ss", edjeEdjeType, &pyobj, &name, &group))
+   if (!PyArg_ParseTuple(args, "Oss", &pyobj, &name, &group))
       return NULL;
 
    if (!(gadget = eina_hash_find(edgar_gadgets, name)))
       EXCEPTION(PyExc_ValueError, "name is not a valid gadget name");
 
    obj = instance_from_object(pyobj);
-   if (!edgar_theme_edje_object_set(gadget, obj, group))
+   if (!edgar_theme_object_set(gadget, obj, group))
       EXCEPTION(PyExc_RuntimeError, "cannot find group in theme");
 
    Py_RETURN_NONE;
@@ -785,7 +791,7 @@ _eapi_theme_edje_object_set(PyObject *self, PyObject *args)
 
 
 static PyMethodDef EApiMethods[] = {
-   {"theme_edje_object_set", _eapi_theme_edje_object_set, METH_VARARGS,
+   {"theme_object_set", _eapi_theme_object_set, METH_VARARGS,
     "Load the given group from the theme file."},
    {NULL, NULL, 0, NULL}
 };

-- 


Reply via email to