Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src Modified Files: ewl_theme.c ewl_widget.c Log Message: - build the widget appearance on the fly. - if you want the full appearance string you *must* call ewl_widget_appearance_get now. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_theme.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -3 -r1.71 -r1.72 --- ewl_theme.c 13 Sep 2004 13:56:17 -0000 1.71 +++ ewl_theme.c 9 Dec 2004 03:04:21 -0000 1.72 @@ -339,9 +339,17 @@ /* * Use the widget's appearance string to build a relative theme key. */ - if (w) - snprintf(key, PATH_MAX, "%s/%s", w->appearance, k); - else + if (w) { + char *tmp; + + tmp = ewl_widget_appearance_get(w); + if (tmp) { + snprintf(key, PATH_MAX, "%s/%s", tmp, k); + FREE(tmp); + } else + snprintf(key, PATH_MAX, "%s", k); + + } else snprintf(key, PATH_MAX, "%s", k); if (ewl_config.theme.print_keys) @@ -399,9 +407,16 @@ /* * Use the widget's appearance string to build a relative theme key. */ - if (w) - snprintf(key, PATH_MAX, "%s/%s", w->appearance, k); - else + if (w) { + char *tmp; + + tmp = ewl_widget_appearance_get(w); + if (tmp) { + snprintf(key, PATH_MAX, "%s/%s", tmp, k); + FREE(tmp); + } else + snprintf(key, PATH_MAX, "%s", k); + } else snprintf(key, PATH_MAX, "%s", k); for (temp = key; temp && !ret; temp = strchr(temp, '/')) { =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v retrieving revision 1.125 retrieving revision 1.126 diff -u -3 -r1.125 -r1.126 --- ewl_widget.c 21 Sep 2004 22:37:45 -0000 1.125 +++ ewl_widget.c 9 Dec 2004 03:04:21 -0000 1.126 @@ -6,7 +6,6 @@ Ewl_Widget *last_focused = NULL; Ewl_Widget *dnd_widget = NULL; -static void ewl_widget_appearance_rebuild(Ewl_Widget *w); static void ewl_widget_theme_padding_get(Ewl_Widget *w, int *l, int *r, int *t, int *b); static void ewl_widget_theme_insets_get(Ewl_Widget *w, int *l, int *r, @@ -396,20 +395,11 @@ DCHECK_PARAM_PTR("w", w); DCHECK_PARAM_PTR("appearance", appearance); - /* - * Only continue if the appearance has changed. - */ - if (w->appearance) { - current = strrchr(w->appearance, '/'); - if (current) { - current++; - if (!strcmp(current, appearance)) - DRETURN(DLEVEL_STABLE); - } - - FREE(w->appearance); - } + /* make sure we have something to do */ + if (!strcmp(appearance, w->appearance)) + DLEAVE_FUNCTION(DLEVEL_STABLE); + IF_FREE(w->appearance); al = strlen(appearance) + 1; /* @@ -438,10 +428,8 @@ } /* - * Regenerate the entire path of widgets in the heirarchy, and - * recreate the visible components of the widget if necessary. + * Recreate the visible components of the widget if necessary. */ - ewl_widget_appearance_rebuild(w); if (REALIZED(w)) { ewl_widget_unrealize(w); ewl_widget_realize(w); @@ -456,14 +444,28 @@ * failure. * @brief Retrieve the appearance key of the widget */ -char *ewl_widget_appearance_get(Ewl_Widget * w) +char *ewl_widget_appearance_get(Ewl_Widget * w) { - DENTER_FUNCTION(DLEVEL_STABLE); + char *ret = NULL, *tmp; + int len; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("w", w, NULL); - DRETURN_PTR(w->appearance ? strdup(w->appearance) : NULL, - DLEVEL_STABLE); + if (w->parent) + tmp = ewl_widget_appearance_get(w->parent); + else + tmp = strdup(""); + + len = strlen(tmp) + 2; /* one for the / one for the \0 */ + len += (w->appearance ? strlen(w->appearance) : 0); + + ret = malloc(sizeof(char) * len); + snprintf(ret, len, "%s/%s", tmp, + (w->appearance ? w->appearance : "")); + FREE(tmp); + + DRETURN_PTR(ret, DLEVEL_STABLE); } /** @@ -887,32 +889,6 @@ DRETURN_PTR(last_key, DLEVEL_STABLE); } -static void ewl_widget_appearance_rebuild(Ewl_Widget *w) -{ - char *base; - char path[PATH_MAX]; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("w", w); - DCHECK_PARAM_PTR("w->appearance", w->appearance); - - base = strrchr(w->appearance, '/'); - if (base) { - *base = '\0'; - base++; - } - else - base = w->appearance; - - snprintf(path, PATH_MAX, "%s/%s", - (w->parent ? w->parent->appearance : ""), base); - - FREE(w->appearance); - w->appearance = strdup(path); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - /* * Perform the series of operations common to every widget when * they are destroyed. This should ALWAYS be the the last callback @@ -1235,8 +1211,6 @@ pc = EWL_CONTAINER(w->parent); - ewl_widget_appearance_rebuild(w); - /* * If the new parent is on a different evas, we must re-realize it. */ ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs