summaryrefslogtreecommitdiff
path: root/gtk.c
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-08-21 10:04:40 +0200
committerxengineering <me@xengineering.eu>2022-08-21 10:04:40 +0200
commit3a20726b2679f9d5966156d83aac782de8234732 (patch)
tree2b062335bbc7efbb1f7b4cd4469feb21ff115792 /gtk.c
parent1f494e68fd0ce306079731bbf91667e6718e47ee (diff)
downloadlimox-3a20726b2679f9d5966156d83aac782de8234732.tar
limox-3a20726b2679f9d5966156d83aac782de8234732.tar.zst
limox-3a20726b2679f9d5966156d83aac782de8234732.zip
Reimplement dummy text sending
Diffstat (limited to 'gtk.c')
-rw-r--r--gtk.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gtk.c b/gtk.c
index da5b509..42bdb16 100644
--- a/gtk.c
+++ b/gtk.c
@@ -10,6 +10,7 @@
typedef struct _chat_widget_t {
GtkWidget* page;
GtkWidget* content;
+ GtkWidget* entry;
} chat_widget_t;
@@ -65,22 +66,25 @@ static void disconnect_cb(void) {
net_disconnect();
}
-void send_message() {
+void send_message(chat_t* chat) {
- //// get recipient and message text
- //const char* recipient = "dummy@example.com"; // TODO reimplement this
- //const char* text = gtk_editable_get_text(GTK_EDITABLE(chat->text_entry));
+ chat_widget_t* chat_widget = (chat_widget_t*)chat->widget;
+
+ // get recipient and message text
+ const char* recipient = "unknown@example.com"; // TODO implement this
+ const char* text = gtk_editable_get_text(GTK_EDITABLE(chat_widget->entry));
- //// execute dummy XMPP send TODO
- //printf("Sending to %s:\n> %s\n", recipient, text);
+ // execute dummy XMPP send TODO
+ printf("Sending to %s:\n> %s\n", recipient, text);
//// add message content to the chat
//GtkWidget* message = gtk_label_new(text);
//gtk_box_append(GTK_BOX(chat->chat_content_box), message);
- //// clear text input
- //GtkEntryBuffer* empty_buffer = gtk_entry_buffer_new("", 0);
- //gtk_entry_set_buffer(GTK_ENTRY(chat->text_entry), empty_buffer);
+ // clear text input
+ GtkEntryBuffer* buffer;
+ buffer = gtk_entry_get_buffer(GTK_ENTRY(chat_widget->entry));
+ gtk_entry_buffer_delete_text(buffer, 0, -1);
}
static void build_static_widgets(void) {
@@ -192,12 +196,13 @@ void gui_add_chat_widget(chat_t* chat) {
// create and add text input field
GtkWidget* text_entry = gtk_entry_new();
gtk_box_append(GTK_BOX(chat_layout_box), text_entry);
+ chat_widget->entry = text_entry;
// create and add send button
GtkWidget* send_button = gtk_button_new_with_label("send");
gtk_box_append(GTK_BOX(chat_layout_box), send_button);
- // g_signal_connect_swapped(send_button, "clicked", G_CALLBACK(send_message),
- // chat); // TODO
+ g_signal_connect_swapped(send_button, "clicked", G_CALLBACK(send_message),
+ chat);
}