aboutsummaryrefslogtreecommitdiff
path: root/src/ui/chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/chat.c')
-rw-r--r--src/ui/chat.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/ui/chat.c b/src/ui/chat.c
index 42ccb9e..5dd11f6 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -95,6 +95,29 @@ handle_chat_contacts_listbox_row_activated(GtkListBox *listbox,
95} 95}
96 96
97static void 97static void
98handle_chat_messages_listbox_size_allocate(UNUSED GtkWidget *widget,
99 UNUSED GdkRectangle *allocation,
100 gpointer user_data)
101{
102 UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
103
104 GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(
105 handle->chat_scrolled_window
106 );
107
108 const gdouble value = gtk_adjustment_get_value(adjustment);
109 const gdouble upper = gtk_adjustment_get_upper(adjustment);
110 const gdouble page_size = gtk_adjustment_get_page_size(adjustment);
111
112 const gdouble edge_value = upper - page_size;
113
114 if (value >= handle->edge_value)
115 gtk_adjustment_set_value(adjustment, edge_value);
116
117 handle->edge_value = upper - page_size;
118}
119
120static void
98handle_back_button_click(UNUSED GtkButton *button, 121handle_back_button_click(UNUSED GtkButton *button,
99 gpointer user_data) 122 gpointer user_data)
100{ 123{
@@ -254,6 +277,7 @@ ui_chat_new(MESSENGER_Application *app)
254 UI_MESSENGER_Handle *messenger = &(app->ui.messenger); 277 UI_MESSENGER_Handle *messenger = &(app->ui.messenger);
255 278
256 handle->messages = NULL; 279 handle->messages = NULL;
280 handle->edge_value = 0;
257 281
258 handle->builder = gtk_builder_new_from_file( 282 handle->builder = gtk_builder_new_from_file(
259 "resources/ui/chat.ui" 283 "resources/ui/chat.ui"
@@ -324,6 +348,10 @@ ui_chat_new(MESSENGER_Application *app)
324 gtk_builder_get_object(handle->builder, "chat_details_contacts_box") 348 gtk_builder_get_object(handle->builder, "chat_details_contacts_box")
325 ); 349 );
326 350
351 handle->chat_scrolled_window = GTK_SCROLLED_WINDOW(
352 gtk_builder_get_object(handle->builder, "chat_scrolled_window")
353 );
354
327 handle->chat_contacts_listbox = GTK_LIST_BOX( 355 handle->chat_contacts_listbox = GTK_LIST_BOX(
328 gtk_builder_get_object(handle->builder, "chat_contacts_listbox") 356 gtk_builder_get_object(handle->builder, "chat_contacts_listbox")
329 ); 357 );
@@ -339,6 +367,13 @@ ui_chat_new(MESSENGER_Application *app)
339 gtk_builder_get_object(handle->builder, "messages_listbox") 367 gtk_builder_get_object(handle->builder, "messages_listbox")
340 ); 368 );
341 369
370 g_signal_connect(
371 handle->messages_listbox,
372 "size-allocate",
373 G_CALLBACK(handle_chat_messages_listbox_size_allocate),
374 handle
375 );
376
342 handle->attach_file_button = GTK_BUTTON( 377 handle->attach_file_button = GTK_BUTTON(
343 gtk_builder_get_object(handle->builder, "attach_file_button") 378 gtk_builder_get_object(handle->builder, "attach_file_button")
344 ); 379 );