Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_callback.c ewl_widget.c ewl_widget.h 


Log Message:
Use a smaller limit on the number of callbacks of one type on a widget.
Move from a hash table to an array for the theme text.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_callback.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ewl_callback.c      13 Nov 2005 06:01:51 -0000      1.10
+++ ewl_callback.c      29 Nov 2005 17:00:58 -0000      1.11
@@ -182,6 +182,11 @@
        DCHECK_PARAM_PTR_RET("cb", cb, 0);
        DCHECK_TYPE_RET("w", w, "widget", 0);
 
+       if (EWL_CALLBACK_LEN(w, t) == 255) {
+               DERROR("Maximum number of callbacks of one type exceeded on a 
widget\n");
+               DRETURN_INT(0, DLEVEL_STABLE);
+       }
+
        /* set direct if possible */
        if (!EWL_CALLBACK_LEN(w, t))
        {
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- ewl_widget.c        27 Nov 2005 08:02:06 -0000      1.43
+++ ewl_widget.c        29 Nov 2005 17:00:58 -0000      1.44
@@ -775,36 +775,76 @@
 void
 ewl_widget_appearance_part_text_set(Ewl_Widget * w, char *part, char *text)
 {
-       char *key, *value, *old_value;
+       int i;
+       Ewl_Pair *match = NULL;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
        DCHECK_PARAM_PTR("part", part);
        DCHECK_TYPE("w", w, "widget");
 
-       if (!(w->theme_text)) {
-               w->theme_text = ecore_hash_new(ecore_str_hash, 
ecore_str_compare);
-               ecore_hash_set_free_key(w->theme_text, free);
-               ecore_hash_set_free_value(w->theme_text, free);
+       /*
+        * Check for an existing instance of the part key.
+        */
+       if (w->theme_text.list) {
+               if (w->theme_text.direct) {
+                       match = EWL_PAIR(w->theme_text.list);
+                       if (strcmp(part, match->key))
+                               match = NULL;
+               }
+               else {
+                       for (i = 0; i < w->theme_text.len; i++) {
+                               Ewl_Pair *current = w->theme_text.list[i];
+                               if (!strcmp(current->key, part)) {
+                                       match = current;
+                                       break;
+                               }
+                       }
+               }
        }
 
-       old_value = ecore_hash_get(w->theme_text, part);
+       /*
+        * Part key exists and the value is the same as the current value.
+        */
+       if (match) {
+               if (!strcmp(text, match->value))
+                       DRETURN(DLEVEL_STABLE);
 
-       if (old_value && text && !strcmp(old_value, text))
-               DLEAVE_FUNCTION(DLEVEL_STABLE);
+               IF_FREE(match->value);
+       }
+       else {
+               match = NEW(Ewl_Pair, 1);
+               if (!match)
+                       DRETURN(DLEVEL_STABLE);
+               match->key = ecore_string_instance(part);
+               w->theme_text.len++;
+
+               if (!w->theme_text.list) {
+                       w->theme_text.direct = 1;
+                       w->theme_text.list = (Ewl_Pair **)match;
+               }
+               else {
+                       if (w->theme_text.direct) {
+                               Ewl_Pair *old = EWL_PAIR(w->theme_text.list);
+                               w->theme_text.list = NEW(Ewl_Pair *, 2);
+                               w->theme_text.list[0] = old;
+                       }
+                       else {
+                               w->theme_text.list = realloc(w->theme_text.list,
+                                               sizeof(Ewl_Pair) *
+                                               w->theme_text.len);
+                       }
+                       w->theme_text.list[w->theme_text.len - 1] = match;
+               }
+       }
 
        /*
         * What should be the default if you enter NULL? A blank string?
         * Revert to the text specified in the Edje? Use blank for now.
         */
-       value = strdup( text ? text : "" );
-
-       if (old_value) key = part;
-       else key = strdup(part);
-
-       ecore_hash_set(w->theme_text, key, value);
+       match->value = strdup( text ? text : "" );
 
-       ewl_widget_appearance_part_text_apply(w, key, value);
+       ewl_widget_appearance_part_text_apply(w, match->key, match->value);
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -1594,9 +1634,22 @@
                w->theme = NULL;
        }
 
-       if (w->theme_text) {
-               ecore_hash_destroy(w->theme_text);
-               w->theme_text = NULL;
+       if (w->theme_text.list) {
+               if (w->theme_text.direct) {
+                       ecore_string_release(EWL_PAIR(w->theme_text.list)->key);
+                       FREE(EWL_PAIR(w->theme_text.list)->value);
+               }
+               else {
+                       int i;
+                       for (i = 0; i < w->theme_text.len; i++) {
+                               
ecore_string_release(w->theme_text.list[i]->key);
+                               FREE(w->theme_text.list[i]->value);
+                               FREE(w->theme_text.list[i]);
+                       }
+               }
+
+               FREE(w->theme_text.list);
+               w->theme_text.len = 0;
        }
 
        if (w->data) {
@@ -1730,18 +1783,26 @@
                 * FIXME: These should probably be ported to an array rather
                 * than a full hash.
                 */
-               if (w->theme_object && w->theme_text) {
-                      char *key;
-                      Ecore_List *keys = ecore_hash_keys(w->theme_text);
-
-                      ecore_list_goto_first(keys);
-                      while ((key = (char *)ecore_list_next(keys))) {
-                              char *value = ecore_hash_get(w->theme_text, key);
-                              /* printf("Setting text %s: %s\n", key, value); 
*/
-                              ewl_widget_appearance_part_text_apply(w, key, 
value);
-                      }
-                      ecore_list_destroy(keys);
-              }
+               if (w->theme_object && w->theme_text.list) {
+                       char *key, *value;
+
+                       if (w->theme_text.direct) {
+                               key = EWL_PAIR(w->theme_text.list)->key;
+                               value = EWL_PAIR(w->theme_text.list)->value;
+                               ewl_widget_appearance_part_text_apply(w,
+                                               key, value);
+                                       
+                       }
+                       else {
+                               int i;
+                               for (i = 0; i < w->theme_text.len; i++) {
+                                       key = w->theme_text.list[i]->key;
+                                       value = w->theme_text.list[i]->value;
+                                       ewl_widget_appearance_part_text_apply(w,
+                                                       key, value);
+                               }
+                       }
+               }
        }
 
        /*
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- ewl_widget.h        13 Nov 2005 06:48:55 -0000      1.20
+++ ewl_widget.h        29 Nov 2005 17:00:58 -0000      1.21
@@ -22,6 +22,22 @@
        unsigned int len:31;
 };
 
+typedef struct Ewl_Pair Ewl_Pair;
+#define EWL_PAIR(p) ((Ewl_Pair *)p)
+struct Ewl_Pair
+{
+       char *key;
+       char *value;
+};
+
+typedef struct Ewl_Pair_List Ewl_Pair_List;
+struct Ewl_Pair_List
+{
+       Ewl_Pair **list;
+       unsigned int direct:1;
+       unsigned int len:31;
+};
+
 /**
  * Callback chain container a list and bitmask of chain properties.
  */
@@ -30,9 +46,9 @@
 struct Ewl_Callback_Chain
 {
        void **list;
-       unsigned short mask;
-       unsigned short len;
-       unsigned short index;
+       unsigned char mask;
+       unsigned char len;
+       unsigned char index;
 };
 
 typedef struct Ewl_Color_Set Ewl_Color_Set;
@@ -77,9 +93,9 @@
        char            *inheritance;  /**< Inheritance of path widget */
        int              layer;        /**< Current layer of widget on canvas */
 
-       Ecore_Hash       *theme; /**< Overriding theme settings of this widget 
*/
-       Ecore_Hash       *theme_text; /**< Overriding text in widgets theme */
-       Ecore_Hash       *data; /**< Arbitrary data attached to this widget */
+       Ecore_Hash      *theme;        /**< Overriding theme settings */
+       Ewl_Pair_List    theme_text;   /**< Overriding text in theme */
+       Ecore_Hash      *data;         /**< Arbitrary data attached to widget */
 };
 
 /*




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to