messenger.h (3587B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2021--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/messenger.h 23 */ 24 25 #ifndef UI_MESSENGER_H_ 26 #define UI_MESSENGER_H_ 27 28 #include <gtk-3.0/gtk/gtk.h> 29 #include <libhandy-1/handy.h> 30 #include <libnotify/notify.h> 31 32 #include <gnunet/gnunet_chat_lib.h> 33 34 typedef struct MESSENGER_Application MESSENGER_Application; 35 36 typedef struct UI_MESSENGER_Handle 37 { 38 MESSENGER_Application *app; 39 40 GList *chat_entries; 41 guint chat_selection; 42 guint account_refresh; 43 44 GtkBuilder *builder; 45 GtkApplicationWindow *main_window; 46 47 HdyLeaflet *leaflet_title; 48 HdyLeaflet *leaflet_chat; 49 HdyFlap *flap_user_details; 50 51 GtkWidget *nav_box; 52 GtkWidget *main_box; 53 54 HdyHeaderBar *nav_bar; 55 HdyHeaderBar *main_bar; 56 57 GtkButton *profile_button; 58 HdyAvatar *profile_avatar; 59 GtkLabel *profile_label; 60 GtkLabel *profile_key_label; 61 62 GtkButton *hide_user_details_button; 63 GtkButton *lobby_button; 64 GtkButton *account_details_button; 65 GtkImage *account_details_symbol; 66 67 GtkRevealer *account_details_revealer; 68 GtkListBox *accounts_listbox; 69 GtkListBoxRow *add_account_listbox_row; 70 71 GtkButton *new_contact_button; 72 GtkButton *new_group_button; 73 GtkButton *new_platform_button; 74 GtkButton *contacts_button; 75 GtkButton *settings_button; 76 GtkButton *about_button; 77 78 GtkStack *chats_title_stack; 79 GtkWidget *title_box; 80 GtkWidget *search_box; 81 82 GtkButton *user_details_button; 83 GtkButton *chats_search_button; 84 85 GtkSearchEntry *chats_search_entry; 86 GtkStack *search_icon_stack; 87 88 GtkListBox *chats_listbox; 89 90 GtkStack *chats_stack; 91 GtkWidget *no_chat_box; 92 93 GtkStack *chat_title_stack; 94 } UI_MESSENGER_Handle; 95 96 /** 97 * Initializes a handle for the messenger main 98 * window of a given messenger application. 99 * 100 * @param app Messenger application 101 * @param handle Messenger window handle 102 */ 103 void 104 ui_messenger_init(MESSENGER_Application *app, 105 UI_MESSENGER_Handle *handle); 106 107 /** 108 * Refreshes a given messenger window handle with 109 * the data of the current state from a given 110 * messenger application. 111 * 112 * @param app Messenger application 113 * @param handle Messenger window handle 114 */ 115 void 116 ui_messenger_refresh(MESSENGER_Application *app, 117 UI_MESSENGER_Handle *handle); 118 119 /** 120 * Returns whether a certain chat context is currently 121 * visually represented via a chat UI handle. 122 * 123 * @param handle Messenger window handle 124 * @param context Chat context 125 * @return true if the context is viewed, otherwise false 126 */ 127 gboolean 128 ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, 129 struct GNUNET_CHAT_Context *context); 130 131 /** 132 * Cleans up the allocated resources and resets the 133 * state of a given messenger window handle. 134 * 135 * @param handle Messenger window handle 136 */ 137 void 138 ui_messenger_cleanup(UI_MESSENGER_Handle *handle); 139 140 #endif /* UI_MESSENGER_H_ */