aboutsummaryrefslogtreecommitdiff
path: root/src/ui/messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/messenger.c')
-rw-r--r--src/ui/messenger.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index e6ea657..69200f9 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -50,6 +50,7 @@ _flap_user_details_reveal_switch(gpointer user_data)
50 hdy_flap_set_reveal_flap(flap, TRUE); 50 hdy_flap_set_reveal_flap(flap, TRUE);
51 } 51 }
52 52
53 gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), TRUE);
53 gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), TRUE); 54 gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), TRUE);
54 return FALSE; 55 return FALSE;
55} 56}
@@ -60,6 +61,7 @@ handle_user_details_via_button_click(UNUSED GtkButton* button,
60{ 61{
61 UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; 62 UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data;
62 63
64 gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE);
63 gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), FALSE); 65 gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), FALSE);
64 g_idle_add( 66 g_idle_add(
65 G_SOURCE_FUNC(_flap_user_details_reveal_switch), 67 G_SOURCE_FUNC(_flap_user_details_reveal_switch),
@@ -236,6 +238,40 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox,
236 gtk_stack_set_visible_child(stack, entry->chat->chat_box); 238 gtk_stack_set_visible_child(stack, entry->chat->chat_box);
237} 239}
238 240
241static gint
242handle_chats_listbox_sort_func(GtkListBoxRow* row0,
243 GtkListBoxRow* row1,
244 gpointer user_data)
245{
246 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
247
248 if ((!row0) || (!row1) ||
249 (!gtk_list_box_row_get_selectable(row0)) ||
250 (!gtk_list_box_row_get_selectable(row1)))
251 return 0;
252
253 UI_CHAT_ENTRY_Handle *entry0 = (UI_CHAT_ENTRY_Handle*) (
254 g_object_get_qdata(G_OBJECT(row0), app->quarks.ui)
255 );
256
257 UI_CHAT_ENTRY_Handle *entry1 = (UI_CHAT_ENTRY_Handle*) (
258 g_object_get_qdata(G_OBJECT(row1), app->quarks.ui)
259 );
260
261 if ((!entry0) || (!entry1))
262 return 0;
263
264 struct GNUNET_TIME_Absolute timestamp0 = entry0->timestamp;
265 struct GNUNET_TIME_Absolute timestamp1 = entry1->timestamp;
266
267 if (GNUNET_TIME_absolute_cmp(timestamp0, >, timestamp1))
268 return -1;
269 else if (GNUNET_TIME_absolute_cmp(timestamp0, <, timestamp1))
270 return +1;
271 else
272 return 0;
273}
274
239static gboolean 275static gboolean
240handle_chats_listbox_filter_func(GtkListBoxRow *row, 276handle_chats_listbox_filter_func(GtkListBoxRow *row,
241 gpointer user_data) 277 gpointer user_data)
@@ -517,6 +553,13 @@ ui_messenger_init(MESSENGER_Application *app,
517 gtk_builder_get_object(handle->builder, "chats_listbox") 553 gtk_builder_get_object(handle->builder, "chats_listbox")
518 ); 554 );
519 555
556 gtk_list_box_set_sort_func(
557 handle->chats_listbox,
558 handle_chats_listbox_sort_func,
559 app,
560 NULL
561 );
562
520 gtk_list_box_set_filter_func( 563 gtk_list_box_set_filter_func(
521 handle->chats_listbox, 564 handle->chats_listbox,
522 handle_chats_listbox_filter_func, 565 handle_chats_listbox_filter_func,