diff options
Diffstat (limited to 'src/ui/chat.c')
-rw-r--r-- | src/ui/chat.c | 82 |
1 files changed, 73 insertions, 9 deletions
diff --git a/src/ui/chat.c b/src/ui/chat.c index f19ee1e..c45b7b5 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -34,10 +34,10 @@ | |||
34 | #include "../contact.h" | 34 | #include "../contact.h" |
35 | 35 | ||
36 | static void | 36 | static void |
37 | handle_flap_via_button_click(UNUSED GtkButton* button, | 37 | handle_flap_via_button_click(UNUSED GtkButton *button, |
38 | gpointer user_data) | 38 | gpointer user_data) |
39 | { | 39 | { |
40 | HdyFlap* flap = HDY_FLAP(user_data); | 40 | HdyFlap *flap = HDY_FLAP(user_data); |
41 | 41 | ||
42 | if (TRUE == hdy_flap_get_reveal_flap(flap)) { | 42 | if (TRUE == hdy_flap_get_reveal_flap(flap)) { |
43 | hdy_flap_set_reveal_flap(flap, FALSE); | 43 | hdy_flap_set_reveal_flap(flap, FALSE); |
@@ -47,8 +47,8 @@ handle_flap_via_button_click(UNUSED GtkButton* button, | |||
47 | } | 47 | } |
48 | 48 | ||
49 | static void | 49 | static void |
50 | handle_chat_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, | 50 | handle_chat_contacts_listbox_row_activated(UNUSED GtkListBox *listbox, |
51 | GtkListBoxRow* row, | 51 | GtkListBoxRow *row, |
52 | gpointer user_data) | 52 | gpointer user_data) |
53 | { | 53 | { |
54 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 54 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
@@ -79,12 +79,12 @@ handle_chat_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
79 | } | 79 | } |
80 | 80 | ||
81 | static void | 81 | static void |
82 | handle_back_button_click(UNUSED GtkButton* button, | 82 | handle_back_button_click(UNUSED GtkButton *button, |
83 | gpointer user_data) | 83 | gpointer user_data) |
84 | { | 84 | { |
85 | HdyLeaflet* leaflet = HDY_LEAFLET(user_data); | 85 | HdyLeaflet *leaflet = HDY_LEAFLET(user_data); |
86 | 86 | ||
87 | GList* children = gtk_container_get_children(GTK_CONTAINER(leaflet)); | 87 | GList *children = gtk_container_get_children(GTK_CONTAINER(leaflet)); |
88 | 88 | ||
89 | if (children) { | 89 | if (children) { |
90 | hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->data)); | 90 | hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->data)); |
@@ -92,6 +92,57 @@ handle_back_button_click(UNUSED GtkButton* button, | |||
92 | } | 92 | } |
93 | 93 | ||
94 | static void | 94 | static void |
95 | handle_attach_file_button_click(GtkButton *button, | ||
96 | gpointer user_data) | ||
97 | { | ||
98 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
99 | |||
100 | GtkTextView *text_view = GTK_TEXT_VIEW( | ||
101 | g_hash_table_lookup(app->ui.bindings, button) | ||
102 | ); | ||
103 | |||
104 | if (!text_view) | ||
105 | return; | ||
106 | |||
107 | GtkWidget *dialog = gtk_file_chooser_dialog_new( | ||
108 | _("Select file"), | ||
109 | GTK_WINDOW(app->ui.messenger.main_window), | ||
110 | GTK_FILE_CHOOSER_ACTION_OPEN, | ||
111 | _("Cancel"), | ||
112 | GTK_RESPONSE_CANCEL, | ||
113 | _("Confirm"), | ||
114 | GTK_RESPONSE_ACCEPT, | ||
115 | NULL | ||
116 | ); | ||
117 | |||
118 | if (GTK_RESPONSE_ACCEPT != gtk_dialog_run(GTK_DIALOG(dialog))) | ||
119 | goto close_dialog; | ||
120 | |||
121 | gchar *filename = gtk_file_chooser_get_filename( | ||
122 | GTK_FILE_CHOOSER(dialog) | ||
123 | ); | ||
124 | |||
125 | if (!filename) | ||
126 | return; | ||
127 | |||
128 | ui_send_file_dialog_init(app, &(app->ui.send_file)); | ||
129 | ui_send_file_dialog_update(&(app->ui.send_file), filename); | ||
130 | |||
131 | g_free(filename); | ||
132 | |||
133 | g_hash_table_insert( | ||
134 | app->ui.bindings, | ||
135 | app->ui.send_file.send_button, | ||
136 | text_view | ||
137 | ); | ||
138 | |||
139 | gtk_widget_show(GTK_WIDGET(app->ui.send_file.dialog)); | ||
140 | |||
141 | close_dialog: | ||
142 | gtk_widget_destroy(dialog); | ||
143 | } | ||
144 | |||
145 | static void | ||
95 | handle_send_text_buffer_changed(GtkTextBuffer *buffer, | 146 | handle_send_text_buffer_changed(GtkTextBuffer *buffer, |
96 | gpointer user_data) | 147 | gpointer user_data) |
97 | { | 148 | { |
@@ -128,7 +179,7 @@ _send_text_from_view(MESSENGER_Application *app, | |||
128 | return FALSE; | 179 | return FALSE; |
129 | 180 | ||
130 | struct GNUNET_CHAT_Context *context = g_hash_table_lookup( | 181 | struct GNUNET_CHAT_Context *context = g_hash_table_lookup( |
131 | app->ui.bindings, text_view | 182 | app->ui.bindings, text_view |
132 | ); | 183 | ); |
133 | 184 | ||
134 | if (context) | 185 | if (context) |
@@ -274,6 +325,13 @@ ui_chat_new(MESSENGER_Application *app) | |||
274 | gtk_builder_get_object(handle->builder, "attach_file_button") | 325 | gtk_builder_get_object(handle->builder, "attach_file_button") |
275 | ); | 326 | ); |
276 | 327 | ||
328 | g_signal_connect( | ||
329 | handle->attach_file_button, | ||
330 | "clicked", | ||
331 | G_CALLBACK(handle_attach_file_button_click), | ||
332 | app | ||
333 | ); | ||
334 | |||
277 | handle->send_text_view = GTK_TEXT_VIEW( | 335 | handle->send_text_view = GTK_TEXT_VIEW( |
278 | gtk_builder_get_object(handle->builder, "send_text_view") | 336 | gtk_builder_get_object(handle->builder, "send_text_view") |
279 | ); | 337 | ); |
@@ -317,6 +375,12 @@ ui_chat_new(MESSENGER_Application *app) | |||
317 | 375 | ||
318 | g_hash_table_insert( | 376 | g_hash_table_insert( |
319 | app->ui.bindings, | 377 | app->ui.bindings, |
378 | handle->attach_file_button, | ||
379 | handle->send_text_view | ||
380 | ); | ||
381 | |||
382 | g_hash_table_insert( | ||
383 | app->ui.bindings, | ||
320 | handle->send_record_button, | 384 | handle->send_record_button, |
321 | handle->send_text_view | 385 | handle->send_text_view |
322 | ); | 386 | ); |
@@ -398,7 +462,7 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
398 | 462 | ||
399 | g_string_append_printf( | 463 | g_string_append_printf( |
400 | subtitle, | 464 | subtitle, |
401 | "%d members", | 465 | _("%d members"), |
402 | GNUNET_CHAT_group_iterate_contacts(group, NULL, NULL) | 466 | GNUNET_CHAT_group_iterate_contacts(group, NULL, NULL) |
403 | ); | 467 | ); |
404 | } | 468 | } |