start work on 'Tab' nick completion in entry widget

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-02-12 14:02:24 -05:00
parent 39b74a1c00
commit 3d3820a912
1 changed files with 44 additions and 14 deletions

View File

@ -4,6 +4,7 @@
#include "theme.h"
#include "window.h"
#include "grid.h"
#include "utils.h"
struct _Channel
{
@ -222,14 +223,6 @@ _cb_options(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
_window_options_toggle(chl->o_grid, _cb_options_done, chl);
}
static void
_cb_entry_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
Channel *chl;
chl = data;
}
static void
_cb_entry_go(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
@ -257,6 +250,34 @@ _cb_entry_go(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
}
}
static void
_cb_entry_key_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
{
Evas_Event_Key_Down *ev;
ev = event;
if (!strcmp(ev->key, "Tab"))
{
Channel *chl;
const char *usr, *str;
Eina_List *l;
chl = data;
str = elm_entry_entry_get(chl->o_entry);
if ((!str) || (strlen(str) < 1)) return;
EINA_LIST_FOREACH(chl->userlist.users, l, usr)
{
if (_util_str_has_prefix(usr, str))
{
DBG("\tMatched User: %s", usr);
}
}
}
}
static void
_cb_tabregion_change(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event EINA_UNUSED)
{
@ -420,6 +441,8 @@ _channel_create(Evas *evas, Evas_Object *win, const char *name, const char *serv
void
_channel_destroy(Channel *chl)
{
const char *usr;
/* delete tabregion stuff */
_channel_tabbar_clear(chl);
if (chl->o_tabregion_bg) evas_object_del(chl->o_tabregion_bg);
@ -427,6 +450,9 @@ _channel_destroy(Channel *chl)
if (chl->o_tab_spacer) evas_object_del(chl->o_tab_spacer);
/* delete channel userlist objects */
EINA_LIST_FREE(chl->userlist.users, usr)
eina_stringshare_del(usr);
if (chl->userlist.o_dismiss) evas_object_del(chl->userlist.o_dismiss);
if (chl->userlist.o_list) evas_object_del(chl->userlist.o_list);
if (chl->userlist.o_spacer) evas_object_del(chl->userlist.o_spacer);
@ -724,9 +750,6 @@ _channel_text_append(Channel *chl, const char *user, const char *txt)
/* write buff to grid */
if (user)
{
/* FIXME: If the user has a short nickname, and another user has a
* longer nickname, then things don't line up on the grid. We need to
* deal with this somehow */
_grid_text_append(chl->o_grid, user, strlen(user));
_grid_text_append(chl->o_grid, "\t", strlen("\t"));
}
@ -766,12 +789,16 @@ _channel_window_set(Channel *chl, Evas_Object *win)
elm_entry_input_panel_return_key_type_set(chl->o_entry,
ELM_INPUT_PANEL_RETURN_KEY_TYPE_GO);
elm_entry_prediction_allow_set(chl->o_entry, EINA_TRUE);
elm_entry_cnp_mode_set(chl->o_entry, ELM_CNP_MODE_PLAINTEXT);
evas_object_smart_callback_add(chl->o_entry, "changed,user",
_cb_entry_changed, chl);
evas_object_smart_callback_add(chl->o_entry, "activated",
_cb_entry_go, chl);
/* NB: This is messed up. Elm_Entry in single-line mode does not
* generate a changed event when pressing the Tab key */
evas_object_event_callback_add(chl->o_entry, EVAS_CALLBACK_KEY_DOWN,
_cb_entry_key_down, chl);
edje_object_part_swallow(chl->o_base, "channel.entry", chl->o_entry);
elm_entry_entry_set(chl->o_entry, "");
elm_object_focus_allow_set(chl->o_entry, EINA_FALSE);
@ -786,8 +813,11 @@ _channel_network_set(Channel *chl, Express_Network *net)
void
_channel_userlist_user_append(Channel *chl, const char *user, Eina_Bool op)
{
if ((!user) || (strlen(user) < 1)) return;
/* append to list of users for autocomplete */
chl->userlist.users = eina_list_append(chl->userlist.users, user);
chl->userlist.users =
eina_list_append(chl->userlist.users, eina_stringshare_add(user));
if (!op)
elm_list_item_sorted_insert(chl->userlist.o_list, user, NULL, NULL,