diff options
Diffstat (limited to 'src/ui/chat.c')
-rw-r--r-- | src/ui/chat.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/ui/chat.c b/src/ui/chat.c index b4dcca9..42943c3 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "chat.h" | 25 | #include "chat.h" |
26 | 26 | ||
27 | #include "messenger.h" | 27 | #include "messenger.h" |
28 | #include "picker.h" | ||
28 | #include "../application.h" | 29 | #include "../application.h" |
29 | 30 | ||
30 | static void | 31 | static void |
@@ -67,7 +68,7 @@ handle_send_text_buffer_changed(GtkTextBuffer *buffer, | |||
67 | 68 | ||
68 | gtk_image_set_from_icon_name( | 69 | gtk_image_set_from_icon_name( |
69 | symbol, | 70 | symbol, |
70 | 0 < g_utf8_strlen(text, 1)? | 71 | 0 < strlen(text)? |
71 | "mail-send-symbolic" : | 72 | "mail-send-symbolic" : |
72 | "audio-input-microphone-symbolic", | 73 | "audio-input-microphone-symbolic", |
73 | GTK_ICON_SIZE_BUTTON | 74 | GTK_ICON_SIZE_BUTTON |
@@ -86,7 +87,7 @@ _send_text_from_view(MESSENGER_Application *app, | |||
86 | 87 | ||
87 | const gchar *text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE); | 88 | const gchar *text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE); |
88 | 89 | ||
89 | if (0 == g_utf8_strlen(text, 1)) | 90 | if (0 == strlen(text)) |
90 | return FALSE; | 91 | return FALSE; |
91 | 92 | ||
92 | struct GNUNET_CHAT_Context *context = g_hash_table_lookup( | 93 | struct GNUNET_CHAT_Context *context = g_hash_table_lookup( |
@@ -132,6 +133,16 @@ handle_send_text_key_press (GtkWidget *widget, | |||
132 | return _send_text_from_view(app, GTK_TEXT_VIEW(widget)); | 133 | return _send_text_from_view(app, GTK_TEXT_VIEW(widget)); |
133 | } | 134 | } |
134 | 135 | ||
136 | static void | ||
137 | handle_picker_button_click(UNUSED GtkButton *button, | ||
138 | gpointer user_data) | ||
139 | { | ||
140 | GtkRevealer *revealer = GTK_REVEALER(user_data); | ||
141 | gboolean reveal = !gtk_revealer_get_child_revealed(revealer); | ||
142 | |||
143 | gtk_revealer_set_reveal_child(revealer, reveal); | ||
144 | } | ||
145 | |||
135 | UI_CHAT_Handle* | 146 | UI_CHAT_Handle* |
136 | ui_chat_new(MESSENGER_Application *app) | 147 | ui_chat_new(MESSENGER_Application *app) |
137 | { | 148 | { |
@@ -239,12 +250,32 @@ ui_chat_new(MESSENGER_Application *app) | |||
239 | handle->send_text_view | 250 | handle->send_text_view |
240 | ); | 251 | ); |
241 | 252 | ||
253 | handle->picker_revealer = GTK_REVEALER( | ||
254 | gtk_builder_get_object(handle->builder, "picker_revealer") | ||
255 | ); | ||
256 | |||
257 | handle->picker = ui_picker_new(app, handle); | ||
258 | |||
259 | gtk_container_add( | ||
260 | GTK_CONTAINER(handle->picker_revealer), | ||
261 | handle->picker->picker_box | ||
262 | ); | ||
263 | |||
264 | g_signal_connect( | ||
265 | handle->emoji_button, | ||
266 | "clicked", | ||
267 | G_CALLBACK(handle_picker_button_click), | ||
268 | handle->picker_revealer | ||
269 | ); | ||
270 | |||
242 | return handle; | 271 | return handle; |
243 | } | 272 | } |
244 | 273 | ||
245 | void | 274 | void |
246 | ui_chat_delete(UI_CHAT_Handle *handle) | 275 | ui_chat_delete(UI_CHAT_Handle *handle) |
247 | { | 276 | { |
277 | ui_picker_delete(handle->picker); | ||
278 | |||
248 | g_object_unref(handle->builder); | 279 | g_object_unref(handle->builder); |
249 | 280 | ||
250 | g_free(handle); | 281 | g_free(handle); |