diff options
Diffstat (limited to 'src/ui/contacts.c')
-rw-r--r-- | src/ui/contacts.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/ui/contacts.c b/src/ui/contacts.c new file mode 100644 index 0000000..3750f8f --- /dev/null +++ b/src/ui/contacts.c | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2021 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/contacts.c | ||
23 | */ | ||
24 | |||
25 | #include "contacts.h" | ||
26 | |||
27 | #include "../application.h" | ||
28 | |||
29 | static void | ||
30 | handle_close_button_click(UNUSED GtkButton *button, | ||
31 | gpointer user_data) | ||
32 | { | ||
33 | GtkDialog *dialog = GTK_DIALOG(user_data); | ||
34 | gtk_window_close(GTK_WINDOW(dialog)); | ||
35 | } | ||
36 | |||
37 | static void | ||
38 | handle_dialog_destroy(UNUSED GtkWidget *window, | ||
39 | gpointer user_data) | ||
40 | { | ||
41 | ui_contacts_dialog_cleanup((UI_CONTACTS_Handle*) user_data); | ||
42 | } | ||
43 | |||
44 | void | ||
45 | ui_contacts_dialog_init(MESSENGER_Application *app, | ||
46 | UI_CONTACTS_Handle *handle) | ||
47 | { | ||
48 | handle->builder = gtk_builder_new_from_file("resources/ui/contacts.ui"); | ||
49 | |||
50 | handle->dialog = GTK_DIALOG( | ||
51 | gtk_builder_get_object(handle->builder, "contacts_dialog") | ||
52 | ); | ||
53 | |||
54 | gtk_window_set_title( | ||
55 | GTK_WINDOW(handle->dialog), | ||
56 | "Contacts" | ||
57 | ); | ||
58 | |||
59 | gtk_window_set_transient_for( | ||
60 | GTK_WINDOW(handle->dialog), | ||
61 | GTK_WINDOW(app->ui.messenger.main_window) | ||
62 | ); | ||
63 | |||
64 | handle->contact_search_entry = GTK_SEARCH_ENTRY( | ||
65 | gtk_builder_get_object(handle->builder, "contact_search_entry") | ||
66 | ); | ||
67 | |||
68 | handle->close_button = GTK_BUTTON( | ||
69 | gtk_builder_get_object(handle->builder, "close_button") | ||
70 | ); | ||
71 | |||
72 | g_signal_connect( | ||
73 | handle->close_button, | ||
74 | "clicked", | ||
75 | G_CALLBACK(handle_close_button_click), | ||
76 | handle->dialog | ||
77 | ); | ||
78 | |||
79 | g_signal_connect( | ||
80 | handle->dialog, | ||
81 | "destroy", | ||
82 | G_CALLBACK(handle_dialog_destroy), | ||
83 | handle | ||
84 | ); | ||
85 | } | ||
86 | |||
87 | void | ||
88 | ui_contacts_dialog_cleanup(UI_CONTACTS_Handle *handle) | ||
89 | { | ||
90 | g_object_unref(handle->builder); | ||
91 | } | ||