davemds pushed a commit to branch master. http://git.enlightenment.org/enlightenment/modules/edgar.git/commit/?id=0b7cf71b057b09203c0c000d6fe1843bc6f609dc
commit 0b7cf71b057b09203c0c000d6fe1843bc6f609dc Author: davemds <[email protected]> Date: Thu Aug 28 20:49:45 2014 +0200 Move the gadget infos to the module level I got some trouble withe them stored inside the class on py3.4, edgar was getting the info from the base class instead of the gadget. --- GADGETS/audio/__init__.py | 16 ++++++---------- GADGETS/calculator/__init__.py | 15 +++++++++------ GADGETS/led_clock/__init__.py | 14 +++++++------- GADGETS/ruler/__init__.py | 14 +++++++------- python/e.py | 8 -------- src/e_mod_edgar.c | 28 +++++++++------------------- 6 files changed, 38 insertions(+), 57 deletions(-) diff --git a/GADGETS/audio/__init__.py b/GADGETS/audio/__init__.py index 8b1c031..e53aed3 100644 --- a/GADGETS/audio/__init__.py +++ b/GADGETS/audio/__init__.py @@ -16,9 +16,12 @@ from efl.elementary.label import Label from efl.elementary.slider import Slider -def DBG(*args): - print(*args) - sys.stdout.flush() +__gadget_name__ = 'Audio' +__gadget_vers__ = '0.1' +__gadget_auth__ = 'DaveMDS' +__gadget_mail__ = '[email protected]' +__gadget_desc__ = 'The complete audio gadget.' +__gadget_vapi__ = 1 _instance = None @@ -26,13 +29,6 @@ _instance = None class Gadget(e.Gadget): - __gadget_name__ = 'Audio' - __gadget_vers__ = '0.1' - __gadget_auth__ = 'DaveMDS' - __gadget_mail__ = '[email protected]' - __gadget_desc__ = 'The complete audio gadget.' - __gadget_vapi__ = 1 - def __init__(self): global _instance _instance = self diff --git a/GADGETS/calculator/__init__.py b/GADGETS/calculator/__init__.py index 90bd90c..cc4e99a 100644 --- a/GADGETS/calculator/__init__.py +++ b/GADGETS/calculator/__init__.py @@ -3,11 +3,14 @@ import e +__gadget_name__ = 'Calculator' +__gadget_vers__ = '0.1' +__gadget_auth__ = 'DaveMDS' +__gadget_mail__ = '[email protected]' +__gadget_desc__ = 'A pure edje calculator.' +__gadget_vapi__ = 1 + class Gadget(e.Gadget): - __gadget_name__ = 'Calculator' - __gadget_vers__ = '0.1' - __gadget_auth__ = 'DaveMDS' - __gadget_mail__ = '[email protected]' - __gadget_desc__ = 'A pure edje calculator.' - __gadget_vapi__ = 1 + pass + diff --git a/GADGETS/led_clock/__init__.py b/GADGETS/led_clock/__init__.py index 5a5bd5c..98bb75f 100644 --- a/GADGETS/led_clock/__init__.py +++ b/GADGETS/led_clock/__init__.py @@ -9,18 +9,18 @@ import e from efl import edje from efl import ecore +__gadget_name__ = 'Led Clock' +__gadget_vers__ = '0.1' +__gadget_auth__ = 'DaveMDS' +__gadget_mail__ = '[email protected]' +__gadget_desc__ = 'The usual led clock.' +__gadget_vapi__ = 1 + COLORS = ('off', 'red', 'green', 'blu') class Gadget(e.Gadget): - __gadget_name__ = 'Led Clock' - __gadget_vers__ = '0.1' - __gadget_auth__ = 'DaveMDS' - __gadget_mail__ = '[email protected]' - __gadget_desc__ = 'The usual led clock.' - __gadget_vapi__ = 1 - def instance_created(self, obj, site): super().instance_created(obj, site) diff --git a/GADGETS/ruler/__init__.py b/GADGETS/ruler/__init__.py index 5b7b667..4a4fb4d 100644 --- a/GADGETS/ruler/__init__.py +++ b/GADGETS/ruler/__init__.py @@ -6,15 +6,15 @@ import e from efl import evas +__gadget_name__ = 'Ruler (HalloWorld)' +__gadget_vers__ = '0.1' +__gadget_auth__ = 'DaveMDS' +__gadget_mail__ = '[email protected]' +__gadget_desc__ = 'All gadgets sets have a ruler...' +__gadget_vapi__ = 1 -class Gadget(e.Gadget): - __gadget_name__ = 'Ruler (HalloWorld)' - __gadget_vers__ = '0.1' - __gadget_auth__ = 'DaveMDS' - __gadget_mail__ = '[email protected]' - __gadget_desc__ = 'All gadgets sets have a ruler...' - __gadget_vapi__ = 1 +class Gadget(e.Gadget): def __init__(self): super().__init__() diff --git a/python/e.py b/python/e.py index fc361b5..dffb710 100644 --- a/python/e.py +++ b/python/e.py @@ -8,14 +8,6 @@ from eapi import ( class Gadget(object): """ Class doc """ - __gadget_name__ = 'Unnamed' - __gadget_vers__ = '0.0' - __gadget_auth__ = 'Your name' - __gadget_mail__ = '[email protected]' - __gadget_desc__ = 'Long gadget description.' - __gadget_vapi__ = 0 - - def __init__(self): """ Class initialiser """ self._instances = list() diff --git a/src/e_mod_edgar.c b/src/e_mod_edgar.c index e5a59d7..bbbe5ef 100644 --- a/src/e_mod_edgar.c +++ b/src/e_mod_edgar.c @@ -197,7 +197,7 @@ edgar_gadget_load(const char *name, const char *path) E_Gadcon_Client_Class *cclass; char fname[PATH_MAX]; const char *label; - PyObject *mod, *cls, *attr; + PyObject *mod, *attr; long vapi = 0; // check the given path @@ -214,12 +214,8 @@ edgar_gadget_load(const char *name, const char *path) mod = PyImport_ImportModule(name); PY_ON_ERROR_RETURN(mod == NULL, NULL, "Gadget import failed!"); - // check the existance of the Gadget class - cls = PyObject_GetAttrString(mod, "Gadget"); - PY_ON_ERROR_RETURN(cls == NULL, NULL, "Gadget class not found"); - // check the api version - attr = PyObject_GetAttrString(cls, "__gadget_vapi__"); + attr = PyObject_GetAttrString(mod, "__gadget_vapi__"); if ((attr == NULL) || (!PyLong_Check(attr)) || ((vapi = PyLong_AsLong(attr)) != CURRENT_VAPI)) { @@ -234,12 +230,10 @@ edgar_gadget_load(const char *name, const char *path) Py_DECREF(attr); // cache the label - attr = PyObject_GetAttrString(cls, "__gadget_name__"); + attr = PyObject_GetAttrString(mod, "__gadget_name__"); PY_ON_ERROR_RETURN(attr == NULL, NULL, "Gadget name not found"); - label = eina_stringshare_add(PyString_AsString(attr)); Py_DECREF(attr); - Py_DECREF(cls); //Alloc & populate the gc_class cclass = E_NEW(E_Gadcon_Client_Class, 1); @@ -401,42 +395,38 @@ edgar_menu_info_cb(void *data, E_Menu *m, E_Menu_Item *mi) Evas_Object *hbox, *tb, *icon, *img; Eina_Strbuf *strbuf; Evas_Coord w, h; - PyObject *cls, *attr; + PyObject *attr; E_Dialog *dia; // build the text strbuf = eina_strbuf_new(); - if (!(cls = PyObject_GetAttrString(gadget->mod, "Gadget"))) - return; - - if ((attr = PyObject_GetAttrString(cls, "__gadget_name__"))) + if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_name__"))) { eina_strbuf_append_printf(strbuf, "<title>%s</title>", PyString_AsString(attr)); Py_DECREF(attr); } - if ((attr = PyObject_GetAttrString(cls, "__gadget_vers__"))) + if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_vers__"))) { eina_strbuf_append_printf(strbuf, " v%s", PyString_AsString(attr)); Py_DECREF(attr); } - if ((attr = PyObject_GetAttrString(cls, "__gadget_auth__"))) + if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_auth__"))) { eina_strbuf_append_printf(strbuf, "<br>Author: %s", PyString_AsString(attr)); Py_DECREF(attr); } - if ((attr = PyObject_GetAttrString(cls, "__gadget_mail__"))) + if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_mail__"))) { eina_strbuf_append_printf(strbuf, "<br>Contact: %s", PyString_AsString(attr)); Py_DECREF(attr); } - if ((attr = PyObject_GetAttrString(cls, "__gadget_desc__"))) + if ((attr = PyObject_GetAttrString(gadget->mod, "__gadget_desc__"))) { eina_strbuf_append_printf(strbuf, "<br><br>%s", PyString_AsString(attr)); Py_DECREF(attr); } - Py_DECREF(cls); // dialog #ifdef HAVE_E19 --
