aboutsummaryrefslogtreecommitdiff
path: root/src/ui/send_file.c
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-01-10 17:21:28 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-01-10 17:21:28 +0100
commit69e3d367f8e0d1168d5c6d6daebed1d2722b265c (patch)
tree369ff4e9421743fe513d0159d878736fdbf3c2c0 /src/ui/send_file.c
parent031a28213115d042de65ce344a8f4a23a8ba056a (diff)
downloadmessenger-gtk-69e3d367f8e0d1168d5c6d6daebed1d2722b265c.tar.gz
messenger-gtk-69e3d367f8e0d1168d5c6d6daebed1d2722b265c.zip
Adding visual list of current uploading files to be sent
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/ui/send_file.c')
-rw-r--r--src/ui/send_file.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/ui/send_file.c b/src/ui/send_file.c
index 7e1e270..d998e24 100644
--- a/src/ui/send_file.c
+++ b/src/ui/send_file.c
@@ -24,7 +24,12 @@
24 24
25#include "send_file.h" 25#include "send_file.h"
26 26
27#include "chat.h"
28#include "chat_entry.h"
29#include "file_load_entry.h"
30
27#include "../application.h" 31#include "../application.h"
32#include "../file.h"
28 33
29static void 34static void
30handle_cancel_button_click(UNUSED GtkButton *button, 35handle_cancel_button_click(UNUSED GtkButton *button,
@@ -36,11 +41,21 @@ handle_cancel_button_click(UNUSED GtkButton *button,
36 41
37static void 42static void
38handle_sending_upload_file(UNUSED void *cls, 43handle_sending_upload_file(UNUSED void *cls,
39 UNUSED const struct GNUNET_CHAT_File *file, 44 const struct GNUNET_CHAT_File *file,
40 uint64_t completed, 45 uint64_t completed,
41 uint64_t size) 46 uint64_t size)
42{ 47{
43 printf("UPLOAD: %lu / %lu\n", completed, size); 48 UI_FILE_LOAD_ENTRY_Handle *file_load = cls;
49
50 gtk_progress_bar_set_fraction(
51 file_load->load_progress_bar,
52 1.0 * completed / size
53 );
54
55 file_update_upload_info(file, completed, size);
56
57 if ((completed >= size) && (file_load->chat))
58 ui_chat_remove_file_load(file_load->chat, file_load);
44} 59}
45 60
46static void 61static void
@@ -67,17 +82,38 @@ handle_send_button_click(GtkButton *button,
67 app->ui.bindings, text_view 82 app->ui.bindings, text_view
68 ); 83 );
69 84
70 if (context) 85 UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context);
71 GNUNET_CHAT_context_send_file( 86 UI_CHAT_Handle *handle = entry? entry->chat : NULL;
87
88 struct GNUNET_CHAT_File *file = NULL;
89
90 if ((context) && (handle))
91 {
92 UI_FILE_LOAD_ENTRY_Handle *file_load = ui_file_load_entry_new(app);
93
94 gtk_label_set_text(file_load->file_label, filename);
95 gtk_progress_bar_set_fraction(file_load->load_progress_bar, 0.0);
96
97 ui_chat_add_file_load(handle, file_load);
98
99 file = GNUNET_CHAT_context_send_file(
72 context, 100 context,
73 filename, 101 filename,
74 handle_sending_upload_file, 102 handle_sending_upload_file,
75 NULL 103 file_load
76 ); 104 );
105 }
77 106
78 g_free(filename); 107 g_free(filename);
79 108
80 gtk_window_close(GTK_WINDOW(app->ui.send_file.dialog)); 109 gtk_window_close(GTK_WINDOW(app->ui.send_file.dialog));
110
111 if (!file)
112 return;
113
114 file_create_info(file);
115
116 // TODO: create UI component?
81} 117}
82 118
83static void 119static void
@@ -117,7 +153,7 @@ handle_file_drawing_area_draw(GtkWidget* drawing_area,
117 153
118 GdkPixbuf *image = handle->image; 154 GdkPixbuf *image = handle->image;
119 155
120 if (!handle->animation) 156 if (!(handle->animation))
121 goto render_image; 157 goto render_image;
122 158
123 if (handle->animation_iter) 159 if (handle->animation_iter)
@@ -219,7 +255,7 @@ handle_file_chooser_button_file_set(GtkFileChooserButton *file_chooser_button,
219 { 255 {
220 handle->animation = gdk_pixbuf_animation_new_from_file(filename, NULL); 256 handle->animation = gdk_pixbuf_animation_new_from_file(filename, NULL);
221 257
222 if (!handle->animation) 258 if (!(handle->animation))
223 handle->image = gdk_pixbuf_new_from_file(filename, NULL); 259 handle->image = gdk_pixbuf_new_from_file(filename, NULL);
224 260
225 g_free(filename); 261 g_free(filename);
@@ -313,7 +349,7 @@ void
313ui_send_file_dialog_update(UI_SEND_FILE_Handle *handle, 349ui_send_file_dialog_update(UI_SEND_FILE_Handle *handle,
314 const gchar *filename) 350 const gchar *filename)
315{ 351{
316 if (!handle->file_chooser_button) 352 if (!(handle->file_chooser_button))
317 return; 353 return;
318 354
319 gtk_file_chooser_set_filename( 355 gtk_file_chooser_set_filename(