commit 5481b37fcf1a820e55719da9593216e58774da18
parent 4d8a11bc5778037f0eeb5d94d9b3de2f04b6fee6
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Wed, 16 Mar 2022 19:10:30 +0100
Added about dialog and ui files of contact information dialog
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
18 files changed, 741 insertions(+), 22 deletions(-)
diff --git 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
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnunet/Messenger">
+ <file compressed="true">ui/about.ui</file>
<file compressed="true">ui/accounts.ui</file>
<file compressed="true">ui/chat_entry.ui</file>
<file compressed="true">ui/chat.ui</file>
<file compressed="true">ui/contact_entry.ui</file>
+ <file compressed="true">ui/contact_info.ui</file>
<file compressed="true">ui/contacts.ui</file>
<file compressed="true">ui/delete_messages.ui</file>
<file compressed="true">ui/file_load_entry.ui</file>
diff --git a/resources/ui/about.ui b/resources/ui/about.ui
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+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 <http://www.gnu.org/licenses/>.
+
+SPDX-License-Identifier: AGPL3.0-or-later
+Author: Tobias Frisch
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <object class="GtkAboutDialog" id="about_dialog">
+ <property name="can-focus">False</property>
+ <property name="modal">True</property>
+ <property name="window-position">center-on-parent</property>
+ <property name="type-hint">dialog</property>
+ <property name="program-name">GNUnet Messenger</property>
+ <property name="version">0.0.1</property>
+ <property name="copyright" translatable="yes">This application is part of GNUnet.
+Copyright (C) 2021--2022 GNUnet e.V.</property>
+ <property name="website">https://www.gnunet.org</property>
+ <property name="authors">Tobias Frisch</property>
+ <property name="documenters">Tobias Frisch
+Marcos Marado</property>
+ <property name="translator-credits" translatable="yes">Tobias Frisch</property>
+ <property name="artists">Tobias Frisch</property>
+ <property name="logo-icon-name">org.gnunet.Messenger</property>
+ <property name="license-type">agpl-3-0</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label" translatable="yes">Close</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/resources/ui/contact_info.ui b/resources/ui/contact_info.ui
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Copyright (C) 2021‑‑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 <http://www.gnu.org/licenses/>.
+
+SPDX-License-Identifier: AGPL3.0-or-later
+Author: Tobias Frisch
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <requires lib="libhandy" version="1.2"/>
+ <object class="GtkDialog" id="contact_info_dialog">
+ <property name="can-focus">False</property>
+ <property name="modal">True</property>
+ <property name="window-position">center-on-parent</property>
+ <property name="type-hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="label" translatable="yes">Back</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label" translatable="yes">Close</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStack" id="contact_info_stack">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="border-width">8</property>
+ <child>
+ <object class="GtkBox" id="details_box">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="border-width">8</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="HdyAvatar" id="contact_avatar">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">center</property>
+ <property name="margin-top">8</property>
+ <property name="margin-bottom">8</property>
+ <property name="icon-name">avatar-default-symbolic</property>
+ <property name="size">128</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Name:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="contact_name">
+ <property name="width-request">250</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="reveal_identity_button">
+ <property name="label" translatable="yes">Reveal Identity</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="open_chat_button">
+ <property name="label" translatable="yes">Open Private Chat</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="name">details_page</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkDrawingArea" id="id_drawing_area">
+ <property name="height-request">250</property>
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="name">drawing_page</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/resources/ui/delete_messages.ui b/resources/ui/delete_messages.ui
@@ -97,6 +97,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
+ <property name="valign">center</property>
<property name="border-width">8</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
@@ -157,7 +158,7 @@
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui
@@ -442,7 +442,7 @@ Author: Tobias Frisch
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -490,7 +490,7 @@ Author: Tobias Frisch
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -538,7 +538,7 @@ Author: Tobias Frisch
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -586,7 +586,7 @@ Author: Tobias Frisch
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -634,6 +634,53 @@ Author: Tobias Frisch
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="about_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="border-width">4</property>
+ <property name="spacing">16</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">help-about-symbolic</property>
+ <property name="icon_size">3</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="about-label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">About</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
@@ -651,7 +698,7 @@ Author: Tobias Frisch
<property name="border-width">16</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="application-name-label">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
@@ -667,7 +714,7 @@ Author: Tobias Frisch
</packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="application-version-label">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
diff --git a/resources/ui/new_account.ui b/resources/ui/new_account.ui
@@ -76,6 +76,7 @@ Author: Tobias Frisch
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
+ <property name="valign">center</property>
<property name="border-width">8</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
@@ -134,7 +135,7 @@ Author: Tobias Frisch
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
diff --git a/resources/ui/new_contact.ui b/resources/ui/new_contact.ui
@@ -87,6 +87,7 @@ Author: Tobias Frisch
<object class="GtkBox" id="fail_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
diff --git a/resources/ui/new_group.ui b/resources/ui/new_group.ui
@@ -104,6 +104,7 @@ Author: Tobias Frisch
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
+ <property name="valign">center</property>
<property name="border-width">8</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
diff --git a/resources/ui/new_platform.ui b/resources/ui/new_platform.ui
@@ -76,6 +76,7 @@ Author: Tobias Frisch
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
+ <property name="valign">center</property>
<property name="border-width">8</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
diff --git 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
@@ -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
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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
@@ -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,13 +184,22 @@ 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,
gpointer user_data)
@@ -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
@@ -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;