diff options
author | xengineering <me@xengineering.eu> | 2022-08-17 12:53:29 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2022-08-19 12:13:49 +0200 |
commit | e6667aed7aaa5e60b3ded91aa5a6c28bf6da3314 (patch) | |
tree | 8e61c3ad3aa701cc13fca1f6f33e8eb95d932f63 | |
parent | c584fa579ab1ce12e162580a6e443b9035dd3f88 (diff) | |
download | limox-e6667aed7aaa5e60b3ded91aa5a6c28bf6da3314.tar limox-e6667aed7aaa5e60b3ded91aa5a6c28bf6da3314.tar.zst limox-e6667aed7aaa5e60b3ded91aa5a6c28bf6da3314.zip |
Implement roster to chat view transition
-rw-r--r-- | data.c | 21 | ||||
-rw-r--r-- | data.h | 1 | ||||
-rw-r--r-- | gtk.c | 12 |
3 files changed, 32 insertions, 2 deletions
@@ -64,3 +64,24 @@ void add_roster_item(const char* jid, const char* subscription, const char* name item->page_widget = gui_add_chat(); } + +void* data_get_chat_page(void* roster_item_widget) { + + if (roster == NULL) { + printf("Empty roster!\n"); + exit(1); + } else { + roster_item_t* current = roster; + while (1) { + if (current->widget == roster_item_widget) { + return current->page_widget; + } + if (current->next == NULL) { + printf("Could not find matching roster item!\n"); + exit(1); + } + current = current->next; + } + } + +} @@ -1 +1,2 @@ void add_roster_item(const char* jid, const char* subscription, const char* name); +void* data_get_chat_page(void* roster_item_widget); @@ -4,6 +4,7 @@ #include <stdio.h> #include "limox.h" +#include "data.h" // the GTK application is available as global variable @@ -219,6 +220,13 @@ void gui_add_message(const char* sender_jid, const char* content) { printf("Received from %s:\n%s\n", sender_jid, content); } +static void to_chat(GtkWidget* roster_item_widget) { + + GtkWidget* chat_page = data_get_chat_page((void*)roster_item_widget); + gtk_stack_set_visible_child(GTK_STACK(stack), chat_page); + +} + void* gui_add_roster_item(const char* jid, const char* sub, const char* name) { // print debug message @@ -238,8 +246,8 @@ void* gui_add_roster_item(const char* jid, const char* sub, const char* name) { // add roster item widget to roster page gtk_box_append(GTK_BOX(roster_content_box), roster_item_widget); - //g_signal_connect_swapped(roster_item_widget, "clicked", G_CALLBACK(to_chat), - // chat->chat_layout_box); TODO this should be realized again + g_signal_connect_swapped(roster_item_widget, "clicked", G_CALLBACK(to_chat), + roster_item_widget); return (void*)roster_item_widget; } |