file_load_entry.c (2440B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2022--2024 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 #include "../ui.h" 29 30 #include "chat_title.h" 31 32 static void 33 handle_cancel_button_click(GNUNET_UNUSED GtkButton *button, 34 gpointer user_data) 35 { 36 g_assert(user_data); 37 38 UI_FILE_LOAD_ENTRY_Handle* handle = (UI_FILE_LOAD_ENTRY_Handle*) user_data; 39 40 if (handle->chat_title) 41 ui_chat_title_remove_file_load(handle->chat_title, handle); 42 43 // TODO: cancel upload? 44 } 45 46 UI_FILE_LOAD_ENTRY_Handle* 47 ui_file_load_entry_new(MESSENGER_Application *app) 48 { 49 g_assert(app); 50 51 UI_FILE_LOAD_ENTRY_Handle* handle = g_malloc(sizeof(UI_FILE_LOAD_ENTRY_Handle)); 52 53 handle->chat_title = NULL; 54 55 handle->builder = ui_builder_from_resource( 56 application_get_resource_path(app, "ui/file_load_entry.ui") 57 ); 58 59 handle->entry_box = GTK_WIDGET( 60 gtk_builder_get_object(handle->builder, "entry_box") 61 ); 62 63 handle->file_image = GTK_IMAGE( 64 gtk_builder_get_object(handle->builder, "file_image") 65 ); 66 67 handle->file_label = GTK_LABEL( 68 gtk_builder_get_object(handle->builder, "file_label") 69 ); 70 71 handle->load_progress_bar = GTK_PROGRESS_BAR( 72 gtk_builder_get_object(handle->builder, "load_progress_bar") 73 ); 74 75 handle->cancel_button = GTK_BUTTON( 76 gtk_builder_get_object(handle->builder, "cancel_button") 77 ); 78 79 g_signal_connect( 80 handle->cancel_button, 81 "clicked", 82 G_CALLBACK(handle_cancel_button_click), 83 handle 84 ); 85 86 return handle; 87 } 88 89 void 90 ui_file_load_entry_delete(UI_FILE_LOAD_ENTRY_Handle *handle) 91 { 92 g_assert(handle); 93 94 g_object_unref(handle->builder); 95 96 g_free(handle); 97 }