about.c (2558B)
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 about.c 23 */ 24 25 #include "about.h" 26 27 #include "../application.h" 28 #include "../ui.h" 29 30 static void 31 handle_close_button_click(UNUSED GtkButton *button, 32 gpointer user_data) 33 { 34 g_assert(user_data); 35 36 GtkAboutDialog *dialog = GTK_ABOUT_DIALOG(user_data); 37 gtk_window_close(GTK_WINDOW(dialog)); 38 } 39 40 static void 41 handle_dialog_destroy(UNUSED GtkWidget *window, 42 gpointer user_data) 43 { 44 g_assert(user_data); 45 46 ui_about_dialog_cleanup((UI_ABOUT_Handle*) user_data); 47 } 48 49 void 50 ui_about_dialog_init(MESSENGER_Application *app, 51 UI_ABOUT_Handle *handle) 52 { 53 g_assert((app) && (handle)); 54 55 handle->builder = ui_builder_from_resource( 56 application_get_resource_path(app, "ui/about.ui") 57 ); 58 59 handle->dialog = GTK_ABOUT_DIALOG( 60 gtk_builder_get_object(handle->builder, "about_dialog") 61 ); 62 63 gtk_window_set_transient_for( 64 GTK_WINDOW(handle->dialog), 65 GTK_WINDOW(app->ui.messenger.main_window) 66 ); 67 68 gtk_about_dialog_set_program_name( 69 handle->dialog, 70 MESSENGER_APPLICATION_APPNAME 71 ); 72 73 gtk_about_dialog_set_version( 74 handle->dialog, 75 MESSENGER_APPLICATION_VERSION 76 ); 77 78 gtk_about_dialog_set_logo_icon_name( 79 handle->dialog, 80 MESSENGER_APPLICATION_ID 81 ); 82 83 handle->close_button = GTK_BUTTON( 84 gtk_builder_get_object(handle->builder, "close_button") 85 ); 86 87 g_signal_connect( 88 handle->close_button, 89 "clicked", 90 G_CALLBACK(handle_close_button_click), 91 handle->dialog 92 ); 93 94 g_signal_connect( 95 handle->dialog, 96 "destroy", 97 G_CALLBACK(handle_dialog_destroy), 98 handle 99 ); 100 } 101 102 void 103 ui_about_dialog_cleanup(UI_ABOUT_Handle *handle) 104 { 105 g_assert(handle); 106 107 g_object_unref(handle->builder); 108 109 memset(handle, 0, sizeof(*handle)); 110 }