aboutsummaryrefslogtreecommitdiff
path: root/src/ui/file_load_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/file_load_entry.c')
-rw-r--r--src/ui/file_load_entry.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/ui/file_load_entry.c b/src/ui/file_load_entry.c
new file mode 100644
index 0000000..a722787
--- /dev/null
+++ b/src/ui/file_load_entry.c
@@ -0,0 +1,90 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/*
21 * @author Tobias Frisch
22 * @file ui/file_load_entry.c
23 */
24
25#include "file_load_entry.h"
26
27#include "../application.h"
28
29#include "chat.h"
30
31static void
32handle_cancel_button_click(GNUNET_UNUSED GtkButton *button,
33 gpointer user_data)
34{
35 UI_FILE_LOAD_ENTRY_Handle* handle = (UI_FILE_LOAD_ENTRY_Handle*) user_data;
36
37 if (handle->chat)
38 ui_chat_remove_file_load(handle->chat, handle);
39
40 // TODO: cancel upload?
41}
42
43UI_FILE_LOAD_ENTRY_Handle*
44ui_file_load_entry_new(MESSENGER_Application *app)
45{
46 UI_FILE_LOAD_ENTRY_Handle* handle = g_malloc(sizeof(UI_FILE_LOAD_ENTRY_Handle));
47
48 handle->chat = NULL;
49
50 handle->builder = gtk_builder_new_from_resource(
51 application_get_resource_path(app, "ui/file_load_entry.ui")
52 );
53
54 handle->entry_box = GTK_WIDGET(
55 gtk_builder_get_object(handle->builder, "entry_box")
56 );
57
58 handle->file_image = GTK_IMAGE(
59 gtk_builder_get_object(handle->builder, "file_image")
60 );
61
62 handle->file_label = GTK_LABEL(
63 gtk_builder_get_object(handle->builder, "file_label")
64 );
65
66 handle->load_progress_bar = GTK_PROGRESS_BAR(
67 gtk_builder_get_object(handle->builder, "load_progress_bar")
68 );
69
70 handle->cancel_button = GTK_BUTTON(
71 gtk_builder_get_object(handle->builder, "cancel_button")
72 );
73
74 g_signal_connect(
75 handle->cancel_button,
76 "clicked",
77 G_CALLBACK(handle_cancel_button_click),
78 handle
79 );
80
81 return handle;
82}
83
84void
85ui_file_load_entry_delete(UI_FILE_LOAD_ENTRY_Handle *handle)
86{
87 g_object_unref(handle->builder);
88
89 g_free(handle);
90}