Enlightenment CVS committal

Author  : davemds
Project : e17
Module  : libs/etk

Dir     : e17/libs/etk/src/bin


Modified Files:
        etk_combobox_test.c 


Log Message:
* moved the search code from etk_test to inside etk_combobox_entry, so that 
everyone can use it.

* add 2 new field to the Etk_Combobox_Entry struct:
   int autosearch_enable;
   int autosearch_column;

* add 2 new API functions to etk_combobox_entry:
   void etk_combobox_entry_autosearch_enable_set(Etk_Combobox_Entry 
*combobox_entry, int enable);
   void etk_combobox_entry_autosearch_column_set(Etk_Combobox_Entry 
*combobox_entry, int col_num);
   The first will enable/disable autosearch and the second tell witch is the 
combo-column to use for searching.

4. Changed the way the focus is handled between the 2 windows (the 
combo-entry-win and the combo-popup-win) so that you don't need an etk_window 
as the base window.

4. The searching code is different from the actual code, the new one don't 
split up words but simply search the typed string in the entries.

5. Fixed a small bug in the current code that couse the "up" key to not work 
well

===================================================================
RCS file: /cvs/e/e17/libs/etk/src/bin/etk_combobox_test.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- etk_combobox_test.c 2 Oct 2007 15:29:56 -0000       1.22
+++ etk_combobox_test.c 15 Jul 2008 00:08:15 -0000      1.23
@@ -13,6 +13,7 @@
 static Etk_Bool _active_item_changed_cb(Etk_Object *object, void *data);
 static void _etk_combobox_entry_populate(Etk_Combobox_Entry *combobox_entry, 
char *dir);
 static Etk_Bool _etk_combobox_entry_active_item_changed_cb(Etk_Object *object, 
void *data);
+static Etk_Bool 
_etk_combobox_entry_autosearch_active_item_changed_cb(Etk_Object *object, void 
*data);
 static Etk_Bool _etk_combobox_entry_text_changed_cb(Etk_Object *object, void 
*data);
 static char **str_split(char **str, char *delim);
 
@@ -101,11 +102,12 @@
    etk_box_append(ETK_BOX(vbox), frame, ETK_BOX_START, ETK_BOX_NONE, 0);
 
    combobox = etk_combobox_entry_new_default();
+   etk_combobox_entry_autosearch_enable_set(ETK_COMBOBOX_ENTRY(combobox), 
ETK_TRUE);
 
    for (i = 0; _keywords[i]; i++)
      etk_combobox_entry_item_append(ETK_COMBOBOX_ENTRY(combobox), 
_keywords[i], NULL);
 
-   etk_signal_connect_by_code(ETK_ENTRY_TEXT_CHANGED_SIGNAL, 
ETK_OBJECT(etk_combobox_entry_entry_get(ETK_COMBOBOX_ENTRY(combobox))), 
ETK_CALLBACK(_etk_combobox_entry_text_changed_cb), combobox);
+   etk_signal_connect_by_code(ETK_COMBOBOX_ENTRY_ACTIVE_ITEM_CHANGED_SIGNAL, 
ETK_OBJECT(combobox), 
ETK_CALLBACK(_etk_combobox_entry_autosearch_active_item_changed_cb), NULL);
    etk_container_add(ETK_CONTAINER(frame), combobox);
 
    /*******************
@@ -277,68 +279,19 @@
    return ETK_TRUE;
 }
 
-static Etk_Bool _etk_combobox_entry_text_changed_cb(Etk_Object *object, void 
*data)
+static Etk_Bool 
_etk_combobox_entry_autosearch_active_item_changed_cb(Etk_Object *object, void 
*data)
 {
-   Etk_Combobox_Entry *combobox;
-   Etk_Entry *entry;
-   char *search_str = NULL;
-   const char *entry_text = NULL;
-   char **words = NULL;
-   int i;
+   Etk_Combobox_Entry *combobox_entry;
+   Etk_Combobox_Entry_Item *active_item = NULL;
+   const char *field;
 
-   if (!(combobox = ETK_COMBOBOX_ENTRY(data)) || !(entry = ETK_ENTRY(object)))
+   if (!(combobox_entry = ETK_COMBOBOX_ENTRY(object)) || !(active_item = 
etk_combobox_entry_active_item_get(combobox_entry)))
       return ETK_TRUE;
 
-   if (!etk_combobox_entry_is_popped_up(combobox))
-     {
-       etk_combobox_entry_pop_up(combobox);
-       etk_popup_window_focused_window_set(ETK_POPUP_WINDOW(win));
-     }
+   field = etk_combobox_entry_item_field_get(active_item, 0);
+   etk_entry_text_set(ETK_ENTRY(combobox_entry->entry), field);
 
-   entry_text = etk_entry_text_get(entry);
-   if (!entry_text)
-     return ETK_TRUE;
-
-   search_str = strdup(entry_text);
-   words = str_split(&search_str, " ");
-
-   etk_combobox_entry_clear(combobox);
-   etk_combobox_entry_pop_down(combobox);
-   for (i = 0; _keywords[i]; i++)
-     {
-       int j;
-
-       for (j = 0; words[j]; j++)
-         {
-            if (!strcasestr(_keywords[i], words[j]))
-              goto brk;
-         }
-       etk_combobox_entry_item_append(combobox, _keywords[i], NULL);
-brk:
-       continue;
-     }
-   etk_combobox_entry_pop_up(combobox);
-   etk_popup_window_focused_window_set(ETK_POPUP_WINDOW(win));
-   if (words)
-      free(words);
    return ETK_TRUE;
 }
 
-static char **str_split(char **str, char *delim)
-{
-   char **tok;
-   int  i = 0;
-   char *t;
-
-   tok = calloc(2048, sizeof(char*));
-   tok[i] = strtok(*str, delim);
-   i++;
-   while((t = strtok(NULL, delim)))
-     {
-       tok[i] = t;
-       i++;
-     }
-   tok[i] = NULL;
 
-   return tok;
-}



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to