From 5481b37fcf1a820e55719da9593216e58774da18 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Wed, 16 Mar 2022 19:10:30 +0100 Subject: Added about dialog and ui files of contact information dialog Signed-off-by: TheJackiMonster --- Makefile | 3 + resources/ui.gresource.xml | 2 + resources/ui/about.ui | 105 +++++++++++++++++++++++ resources/ui/contact_info.ui | 180 ++++++++++++++++++++++++++++++++++++++++ resources/ui/delete_messages.ui | 3 +- resources/ui/messenger.ui | 59 +++++++++++-- resources/ui/new_account.ui | 3 +- resources/ui/new_contact.ui | 1 + resources/ui/new_group.ui | 1 + resources/ui/new_platform.ui | 1 + src/application.c | 8 +- src/application.h | 12 +++ src/ui/about.c | 101 ++++++++++++++++++++++ src/ui/about.h | 45 ++++++++++ src/ui/contact_info.c | 125 ++++++++++++++++++++++++++++ src/ui/contact_info.h | 61 ++++++++++++++ src/ui/messenger.c | 52 +++++++++--- src/ui/messenger.h | 1 + 18 files changed, 741 insertions(+), 22 deletions(-) create mode 100644 resources/ui/about.ui create mode 100644 resources/ui/contact_info.ui create mode 100644 src/ui/about.c create mode 100644 src/ui/about.h create mode 100644 src/ui/contact_info.c create mode 100644 src/ui/contact_info.h diff --git a/Makefile b/Makefile index 845f5d4..4adb048 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,13 @@ SOURCES = messenger_gtk.c\ file.c\ resources.c\ chat/messenger.c\ + ui/about.c\ ui/account_entry.c\ ui/accounts.c\ ui/chat_entry.c\ ui/chat.c\ ui/contact_entry.c\ + ui/contact_info.c\ ui/contacts.c\ ui/delete_messages.c\ ui/file_load_entry.c\ @@ -118,6 +120,7 @@ install: $(foreach SIZE,$(ICON_SIZES),$(call install-icon,$(SIZE));) install -Dm644 $(addprefix $(APPICON_DIR), full_color.svg) $(addprefix $(INSTALL_DIR), share/icons/hicolor/scalable/apps/$(APP_ID).svg) desktop-file-install --dir=$(addprefix $(INSTALL_DIR), share/applications/) $(addprefix $(RESOURCES_DIR), $(APP_ID).desktop) + gtk-update-icon-cache -f -t $(addprefix $(INSTALL_DIR), share/icons/hicolor) .PHONY: uninstall diff --git a/resources/ui.gresource.xml b/resources/ui.gresource.xml index cbdcf3d..eb0072e 100644 --- a/resources/ui.gresource.xml +++ b/resources/ui.gresource.xml @@ -1,10 +1,12 @@ + ui/about.ui ui/accounts.ui ui/chat_entry.ui ui/chat.ui ui/contact_entry.ui + ui/contact_info.ui ui/contacts.ui ui/delete_messages.ui ui/file_load_entry.ui diff --git a/resources/ui/about.ui b/resources/ui/about.ui new file mode 100644 index 0000000..40c8ecf --- /dev/null +++ b/resources/ui/about.ui @@ -0,0 +1,105 @@ + + + + + + False + True + center-on-parent + dialog + GNUnet Messenger + 0.0.1 + This application is part of GNUnet. +Copyright (C) 2021--2022 GNUnet e.V. + https://www.gnunet.org + Tobias Frisch + Tobias Frisch +Marcos Marado + Tobias Frisch + Tobias Frisch + org.gnunet.Messenger + agpl-3-0 + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + True + False + end + + + Close + True + True + True + + + True + True + 0 + + + + + False + True + end + 1 + + + + + True + False + + + False + True + end + 2 + + + + + + diff --git a/resources/ui/contact_info.ui b/resources/ui/contact_info.ui new file mode 100644 index 0000000..8ac2e04 --- /dev/null +++ b/resources/ui/contact_info.ui @@ -0,0 +1,180 @@ + + + + + + + False + True + center-on-parent + dialog + + + False + vertical + 2 + + + False + end + + + Back + True + True + True + + + True + True + 0 + + + + + Close + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + 8 + + + True + False + center + center + 8 + vertical + 4 + + + True + False + center + 8 + 8 + avatar-default-symbolic + 128 + + + False + True + 0 + + + + + True + False + Name: + 0 + + + False + True + 1 + + + + + 250 + True + True + + + False + True + 2 + + + + + Reveal Identity + True + True + True + + + False + True + 3 + + + + + Open Private Chat + True + True + True + + + False + True + 4 + + + + + details_page + + + + + 250 + True + False + + + drawing_page + 1 + + + + + True + True + 1 + + + + + + diff --git a/resources/ui/delete_messages.ui b/resources/ui/delete_messages.ui index 860f6ea..7078f6c 100644 --- a/resources/ui/delete_messages.ui +++ b/resources/ui/delete_messages.ui @@ -97,6 +97,7 @@ True False center + center 8 vertical 8 @@ -157,7 +158,7 @@ - False + True True 1 diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui index 28dd808..bc8d302 100644 --- a/resources/ui/messenger.ui +++ b/resources/ui/messenger.ui @@ -442,7 +442,7 @@ Author: Tobias Frisch False True - 1 + 0 @@ -490,7 +490,7 @@ Author: Tobias Frisch False True - 2 + 1 @@ -538,7 +538,7 @@ Author: Tobias Frisch False True - 3 + 2 @@ -586,7 +586,7 @@ Author: Tobias Frisch False True - 4 + 3 @@ -631,6 +631,53 @@ Author: Tobias Frisch + + False + True + 4 + + + + + True + True + True + none + + + True + False + 4 + 16 + + + True + False + help-about-symbolic + 3 + + + False + True + 0 + + + + + True + False + About + 0 + + + False + True + 1 + + + + + False True @@ -651,7 +698,7 @@ Author: Tobias Frisch 16 vertical - + True False start @@ -667,7 +714,7 @@ Author: Tobias Frisch - + True False start diff --git a/resources/ui/new_account.ui b/resources/ui/new_account.ui index daa7f11..0e0a33d 100644 --- a/resources/ui/new_account.ui +++ b/resources/ui/new_account.ui @@ -76,6 +76,7 @@ Author: Tobias Frisch True False center + center 8 vertical 4 @@ -134,7 +135,7 @@ Author: Tobias Frisch - False + True True 1 diff --git a/resources/ui/new_contact.ui b/resources/ui/new_contact.ui index a4dc25d..6a09ea4 100644 --- a/resources/ui/new_contact.ui +++ b/resources/ui/new_contact.ui @@ -87,6 +87,7 @@ Author: Tobias Frisch True False + center center vertical 8 diff --git a/resources/ui/new_group.ui b/resources/ui/new_group.ui index 009c218..dc498b7 100644 --- a/resources/ui/new_group.ui +++ b/resources/ui/new_group.ui @@ -104,6 +104,7 @@ Author: Tobias Frisch True False center + center 8 vertical 4 diff --git a/resources/ui/new_platform.ui b/resources/ui/new_platform.ui index 19aa01f..e55f879 100644 --- a/resources/ui/new_platform.ui +++ b/resources/ui/new_platform.ui @@ -76,6 +76,7 @@ Author: Tobias Frisch True False center + center 8 vertical 4 diff --git a/src/application.c b/src/application.c index 335db11..d960ed9 100644 --- a/src/application.c +++ b/src/application.c @@ -89,13 +89,13 @@ application_init(MESSENGER_Application *app, hdy_init(); app->application = gtk_application_new( - "org.gnunet.Messenger", + MESSENGER_APPLICATION_ID, G_APPLICATION_NON_UNIQUE ); resources_register(); - notify_init("Messenger-GTK"); + notify_init(MESSENGER_APPLICATION_NAME); app->notifications = NULL; _load_ui_stylesheets(app); @@ -177,8 +177,8 @@ _application_chat_thread(void *args) app->chat.status = (GNUNET_PROGRAM_run( app->argc, app->argv, - "messenger-gtk", - gettext_noop("A GTK based GUI for the Messenger service of GNUnet."), + MESSENGER_APPLICATION_BINARY, + gettext_noop(MESSENGER_APPLICATION_DESCRIPTION), options, &chat_messenger_run, app diff --git a/src/application.h b/src/application.h index d678e1b..8e0149b 100644 --- a/src/application.h +++ b/src/application.h @@ -30,6 +30,7 @@ #include "chat/messenger.h" +#include "ui/about.h" #include "ui/accounts.h" #include "ui/contacts.h" #include "ui/delete_messages.h" @@ -45,6 +46,16 @@ #include "util.h" +#define MESSENGER_APPLICATION_APPNAME "GNUnet Messenger" +#define MESSENGER_APPLICATION_BINARY "messenger-gtk" +#define MESSENGER_APPLICATION_ID "org.gnunet.Messenger" +#define MESSENGER_APPLICATION_NAME "Messenger-GTK" +#define MESSENGER_APPLICATION_DESCRIPTION \ + "A GTK based GUI for the Messenger service of GNUnet." +#define MESSENGER_APPLICATION_TITLE "Messenger" +#define MESSENGER_APPLICATION_SUBTITLE "GNUnet" +#define MESSENGER_APPLICATION_VERSION "0.0.1" + typedef enum MESSENGER_ApplicationSignal { MESSENGER_NONE = 0, @@ -81,6 +92,7 @@ typedef struct MESSENGER_Application int status; UI_MESSENGER_Handle messenger; + UI_ABOUT_Handle about; UI_INVITE_CONTACT_Handle invite_contact; UI_SEND_FILE_Handle send_file; diff --git a/src/ui/about.c b/src/ui/about.c new file mode 100644 index 0000000..70b2cd0 --- /dev/null +++ b/src/ui/about.c @@ -0,0 +1,101 @@ +/* + This file is part of GNUnet. + Copyright (C) 2022 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author Tobias Frisch + * @file about.c + */ + +#include "about.h" + +#include "../application.h" + +static void +handle_close_button_click(UNUSED GtkButton *button, + gpointer user_data) +{ + GtkAboutDialog *dialog = GTK_ABOUT_DIALOG(user_data); + gtk_window_close(GTK_WINDOW(dialog)); +} + +static void +handle_dialog_destroy(UNUSED GtkWidget *window, + gpointer user_data) +{ + ui_about_dialog_cleanup((UI_ABOUT_Handle*) user_data); +} + +void +ui_about_dialog_init(MESSENGER_Application *app, + UI_ABOUT_Handle *handle) +{ + handle->builder = gtk_builder_new_from_resource( + application_get_resource_path(app, "ui/about.ui") + ); + + handle->dialog = GTK_ABOUT_DIALOG( + gtk_builder_get_object(handle->builder, "about_dialog") + ); + + gtk_window_set_transient_for( + GTK_WINDOW(handle->dialog), + GTK_WINDOW(app->ui.messenger.main_window) + ); + + gtk_about_dialog_set_program_name( + handle->dialog, + MESSENGER_APPLICATION_APPNAME + ); + + gtk_about_dialog_set_version( + handle->dialog, + MESSENGER_APPLICATION_VERSION + ); + + gtk_about_dialog_set_logo_icon_name( + handle->dialog, + MESSENGER_APPLICATION_ID + ); + + handle->close_button = GTK_BUTTON( + gtk_builder_get_object(handle->builder, "close_button") + ); + + g_signal_connect( + handle->close_button, + "clicked", + G_CALLBACK(handle_close_button_click), + handle->dialog + ); + + g_signal_connect( + handle->dialog, + "destroy", + G_CALLBACK(handle_dialog_destroy), + handle + ); +} + +void +ui_about_dialog_cleanup(UI_ABOUT_Handle *handle) +{ + g_object_unref(handle->builder); + + memset(handle, 0, sizeof(*handle)); +} diff --git a/src/ui/about.h b/src/ui/about.h new file mode 100644 index 0000000..86e7fe0 --- /dev/null +++ b/src/ui/about.h @@ -0,0 +1,45 @@ +/* + This file is part of GNUnet. + Copyright (C) 2022 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author Tobias Frisch + * @file about.h + */ + +#ifndef UI_ABOUT_H_ +#define UI_ABOUT_H_ + +#include "messenger.h" + +typedef struct UI_ABOUT_Handle +{ + GtkBuilder *builder; + GtkAboutDialog *dialog; + + GtkButton *close_button; +} UI_ABOUT_Handle; + +void +ui_about_dialog_init(MESSENGER_Application *app, + UI_ABOUT_Handle *handle); + +void +ui_about_dialog_cleanup(UI_ABOUT_Handle *handle); + +#endif /* UI_ABOUT_H_ */ diff --git a/src/ui/contact_info.c b/src/ui/contact_info.c new file mode 100644 index 0000000..b8e504b --- /dev/null +++ b/src/ui/contact_info.c @@ -0,0 +1,125 @@ +/* + This file is part of GNUnet. + Copyright (C) 2022 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author Tobias Frisch + * @file ui/contact_info.c + */ + +#include "contact_info.h" + +#include "../application.h" + +static void +handle_close_button_click(UNUSED GtkButton *button, + gpointer user_data) +{ + GtkDialog *dialog = GTK_DIALOG(user_data); + gtk_window_close(GTK_WINDOW(dialog)); +} + +static void +handle_dialog_destroy(UNUSED GtkWidget *window, + gpointer user_data) +{ + ui_contact_info_dialog_cleanup((UI_CONTACT_INFO_Handle*) user_data); +} + +void +ui_contact_info_dialog_init(MESSENGER_Application *app, + UI_CONTACT_INFO_Handle *handle) +{ + handle->builder = gtk_builder_new_from_resource( + application_get_resource_path(app, "ui/contact_info.ui") + ); + + handle->dialog = GTK_DIALOG( + gtk_builder_get_object(handle->builder, "contact_info_dialog") + ); + + gtk_window_set_transient_for( + GTK_WINDOW(handle->dialog), + GTK_WINDOW(app->ui.messenger.main_window) + ); + + handle->contact_info_stack = GTK_STACK( + gtk_builder_get_object(handle->builder, "contact_info_stack") + ); + + handle->details_box = GTK_WIDGET( + gtk_builder_get_object(handle->builder, "details_box") + ); + + handle->contact_avatar = HDY_AVATAR( + gtk_builder_get_object(handle->builder, "contact_avatar") + ); + + handle->contact_name = GTK_ENTRY( + gtk_builder_get_object(handle->builder, "contact_name") + ); + + handle->reveal_identity_button = GTK_BUTTON( + gtk_builder_get_object(handle->builder, "reveal_identity_button") + ); + + handle->open_chat_button = GTK_BUTTON( + gtk_builder_get_object(handle->builder, "open_chat_button") + ); + + handle->id_drawing_area = GTK_DRAWING_AREA( + gtk_builder_get_object(handle->builder, "id_drawing_area") + ); + + handle->back_button = GTK_BUTTON( + gtk_builder_get_object(handle->builder, "back_button") + ); + + handle->close_button = GTK_BUTTON( + gtk_builder_get_object(handle->builder, "close_button") + ); + + g_signal_connect( + handle->close_button, + "clicked", + G_CALLBACK(handle_close_button_click), + handle->dialog + ); + + g_signal_connect( + handle->dialog, + "destroy", + G_CALLBACK(handle_dialog_destroy), + handle + ); +} + +void +ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle, + struct GNUNET_CHAT_Contact *contact) +{ + // TODO +} + +void +ui_contact_info_dialog_cleanup(UI_CONTACT_INFO_Handle *handle) +{ + g_object_unref(handle->builder); + + memset(handle, 0, sizeof(*handle)); +} diff --git a/src/ui/contact_info.h b/src/ui/contact_info.h new file mode 100644 index 0000000..ef44c0c --- /dev/null +++ b/src/ui/contact_info.h @@ -0,0 +1,61 @@ +/* + This file is part of GNUnet. + Copyright (C) 2022 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author Tobias Frisch + * @file ui/contact_info.h + */ + +#ifndef UI_CONTACT_INFO_H_ +#define UI_CONTACT_INFO_H_ + +#include "messenger.h" + +typedef struct UI_CONTACT_INFO_Handle +{ + GtkBuilder *builder; + GtkDialog *dialog; + + GtkStack *contact_info_stack; + + GtkWidget *details_box; + HdyAvatar *contact_avatar; + GtkEntry *contact_name; + + GtkButton *reveal_identity_button; + GtkButton *open_chat_button; + + GtkDrawingArea *id_drawing_area; + + GtkButton *back_button; + GtkButton *close_button; +} UI_CONTACT_INFO_Handle; + +void +ui_contact_info_dialog_init(MESSENGER_Application *app, + UI_CONTACT_INFO_Handle *handle); + +void +ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle, + struct GNUNET_CHAT_Contact *contact); + +void +ui_contact_info_dialog_cleanup(UI_CONTACT_INFO_Handle *handle); + +#endif /* UI_CONTACT_INFO_H_ */ diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 45da0cd..b4d12af 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c @@ -140,9 +140,7 @@ handle_new_contact_button_click(UNUSED GtkButton* button, MESSENGER_Application *app = (MESSENGER_Application*) user_data; hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); - ui_new_contact_dialog_init(app, &(app->ui.new_contact)); - gtk_widget_show(GTK_WIDGET(app->ui.new_contact.dialog)); } @@ -153,9 +151,7 @@ handle_new_group_button_click(UNUSED GtkButton* button, MESSENGER_Application *app = (MESSENGER_Application*) user_data; hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); - ui_new_group_dialog_init(app, &(app->ui.new_group)); - gtk_widget_show(GTK_WIDGET(app->ui.new_group.dialog)); } @@ -166,9 +162,7 @@ handle_new_platform_button_click(UNUSED GtkButton* button, MESSENGER_Application *app = (MESSENGER_Application*) user_data; hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); - ui_new_platform_dialog_init(app, &(app->ui.new_platform)); - gtk_widget_show(GTK_WIDGET(app->ui.new_platform.dialog)); } @@ -179,9 +173,7 @@ handle_contacts_button_click(UNUSED GtkButton* button, MESSENGER_Application *app = (MESSENGER_Application*) user_data; hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); - ui_contacts_dialog_init(app, &(app->ui.contacts)); - gtk_widget_show(GTK_WIDGET(app->ui.contacts.dialog)); } @@ -192,12 +184,21 @@ handle_settings_button_click(UNUSED GtkButton* button, MESSENGER_Application *app = (MESSENGER_Application*) user_data; hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); - ui_settings_dialog_init(app, &(app->ui.settings)); - gtk_widget_show(GTK_WIDGET(app->ui.settings.dialog)); } +static void +handle_about_button_click(UNUSED GtkButton* button, + gpointer user_data) +{ + MESSENGER_Application *app = (MESSENGER_Application*) user_data; + + hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); + ui_about_dialog_init(app, &(app->ui.about)); + gtk_widget_show(GTK_WIDGET(app->ui.about.dialog)); +} + static void handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, GtkListBoxRow* row, @@ -295,6 +296,16 @@ ui_messenger_init(MESSENGER_Application *app, gtk_builder_get_object(handle->builder, "main_window") ); + gtk_window_set_startup_id( + GTK_WINDOW(handle->main_window), + MESSENGER_APPLICATION_ID + ); + + gtk_window_set_icon_name( + GTK_WINDOW(handle->main_window), + MESSENGER_APPLICATION_ID + ); + gtk_application_add_window( app->application, GTK_WINDOW(handle->main_window) @@ -317,6 +328,16 @@ ui_messenger_init(MESSENGER_Application *app, gtk_builder_get_object(handle->builder, "title_bar") ); + hdy_header_bar_set_title( + handle->title_bar, + MESSENGER_APPLICATION_TITLE + ); + + hdy_header_bar_set_subtitle( + handle->title_bar, + MESSENGER_APPLICATION_SUBTITLE + ); + g_object_bind_property( handle->leaflet_chat, "folded", @@ -458,6 +479,17 @@ ui_messenger_init(MESSENGER_Application *app, app ); + handle->about_button = GTK_BUTTON( + gtk_builder_get_object(handle->builder, "about_button") + ); + + g_signal_connect( + handle->about_button, + "clicked", + G_CALLBACK(handle_about_button_click), + app + ); + handle->user_details_button = GTK_BUTTON( gtk_builder_get_object(handle->builder, "user_details_button") ); diff --git a/src/ui/messenger.h b/src/ui/messenger.h index 54f8dfa..6c36ed9 100644 --- a/src/ui/messenger.h +++ b/src/ui/messenger.h @@ -67,6 +67,7 @@ typedef struct UI_MESSENGER_Handle GtkButton *new_platform_button; GtkButton *contacts_button; GtkButton *settings_button; + GtkButton *about_button; GtkButton *user_details_button; GtkSearchEntry *chats_search; -- cgit v1.2.3