From b05756d46692433b0522f106f367b9389905095b Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Fri, 19 Dec 2014 15:08:09 -0500 Subject: [PATCH] send text to the channel when Enter is pressed Signed-off-by: Chris Michael --- src/bin/channel.c | 21 +++++++++++++++++++-- src/bin/channel.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bin/channel.c b/src/bin/channel.c index 8485934..211c622 100644 --- a/src/bin/channel.c +++ b/src/bin/channel.c @@ -27,6 +27,8 @@ struct _Channel Eina_Bool focused : 1; Eina_Bool unswallowed : 1; Eina_Bool missed : 1; + + Express_Network *net; }; static void @@ -144,12 +146,21 @@ _cb_entry_go(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) char *txt; chl = data; + if (!chl->net) return; + if ((txt = (char *)elm_entry_entry_get(chl->o_entry))) { if ((txt = elm_entry_markup_to_utf8(txt))) { - DBG("Send Text To Channel %s", chl->name); - DBG("\t%s", txt); + char buff[PATH_MAX]; + + snprintf(buff, sizeof(buff), "%s\r\n", txt); + express_network_channel_priv_send(chl->net, chl->name, buff); + + elm_entry_entry_set(chl->o_entry, ""); + + /* TODO */ + /* _channel_text_append(chl, buff, txt); */ } } } @@ -535,3 +546,9 @@ _channel_window_set(Channel *chl, Evas_Object *win) edje_object_part_swallow(chl->o_base, "channel.entry", chl->o_entry); elm_entry_entry_set(chl->o_entry, ""); } + +void +_channel_network_set(Channel *chl, Express_Network *net) +{ + chl->net = net; +} diff --git a/src/bin/channel.h b/src/bin/channel.h index b30f9c6..74b5c63 100644 --- a/src/bin/channel.h +++ b/src/bin/channel.h @@ -43,5 +43,6 @@ void _channel_spacer_create(Channel *chl); void _channel_text_append(Channel *chl, const char *user, const char *txt); void _channel_window_set(Channel *chl, Evas_Object *win); +void _channel_network_set(Channel *chl, Express_Network *net); #endif