messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit 619371fa3bd73a0996c5336228450d54ed9f5bbb
parent 1b0b1f7ed77e7a6cec8874692437befcf663b883
Author: Jacki <jacki@thejackimonster.de>
Date:   Wed,  3 Jan 2024 14:48:34 +0100

Show status of invitation visually

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Mresources/ui/message-status.ui | 6+++---
Msrc/event.c | 66+++++++++++++++++++++++++++++++-----------------------------------
Msrc/ui/chat.c | 18+++++++++---------
Msrc/ui/chat_entry.c | 12++++++------
Msrc/ui/message.c | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
5 files changed, 117 insertions(+), 70 deletions(-)

diff --git a/resources/ui/message-status.ui b/resources/ui/message-status.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 +<!-- Generated with glade 3.40.0 Copyright (C) 2021 GNUnet e.V. @@ -43,9 +43,9 @@ Author: Tobias Frisch <property name="visible">True</property> <property name="can-focus">False</property> <property name="transition-type">slide-left</property> - <property name="reveal-child">True</property> <child> <object class="GtkButton" id="deny_button"> + <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">True</property> <property name="relief">none</property> @@ -85,9 +85,9 @@ Author: Tobias Frisch <property name="visible">True</property> <property name="can-focus">False</property> <property name="transition-type">slide-right</property> - <property name="reveal-child">True</property> <child> <object class="GtkButton" id="accept_button"> + <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">True</property> <property name="relief">none</property> diff --git a/src/event.c b/src/event.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -32,6 +32,8 @@ #include "ui/chat_entry.h" #include "ui/contact_entry.h" #include "ui/message.h" +#include <gnunet/gnunet_chat_lib.h> +#include <gnunet/gnunet_common.h> static void _close_notification(NotifyNotification* notification, @@ -179,8 +181,8 @@ _idle_chat_entry_update(gpointer user_data) struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( g_object_get_qdata( - G_OBJECT(entry->chat->send_text_view), - entry->chat->app->quarks.data + G_OBJECT(entry->chat->send_text_view), + entry->chat->app->quarks.data ) ); @@ -362,9 +364,9 @@ event_update_chats(MESSENGER_Application *app, if (app->settings.leave_chats_delay > 0) g_timeout_add_seconds( - app->settings.leave_chats_delay, - _delayed_context_drop, - context + app->settings.leave_chats_delay, + _delayed_context_drop, + context ); } else if ((handle) && (handle->entry_box)) @@ -442,12 +444,12 @@ event_presence_contact(MESSENGER_Application *app, if (!ui_messenger_is_context_active(&(app->ui.messenger), context)) _show_notification( - app, - context, - contact, - text, - "avatar-default-symbolic", - "presence.online" + app, + context, + contact, + text, + "avatar-default-symbolic", + "presence.online" ); struct GNUNET_TIME_Absolute timestamp = GNUNET_CHAT_message_get_timestamp( @@ -494,7 +496,7 @@ event_update_contacts(UNUSED MESSENGER_Application *app, static void _event_invitation_accept_click(UNUSED GtkButton *button, - gpointer user_data) + gpointer user_data) { struct GNUNET_CHAT_Invitation *invitation = ( (struct GNUNET_CHAT_Invitation*) user_data @@ -521,8 +523,8 @@ event_invitation(MESSENGER_Application *app, if (app->settings.delete_invitations_delay > 0) GNUNET_CHAT_message_delete(msg, GNUNET_TIME_relative_multiply( - GNUNET_TIME_relative_get_second_(), - app->settings.delete_invitations_delay + GNUNET_TIME_relative_get_second_(), + app->settings.delete_invitations_delay )); const int sent = GNUNET_CHAT_message_is_sent(msg); @@ -544,12 +546,12 @@ event_invitation(MESSENGER_Application *app, if (!ui_messenger_is_context_active(&(app->ui.messenger), context)) _show_notification( - app, - context, - contact, - invite_message, - "mail-message-new-symbolic", - "im.received" + app, + context, + contact, + invite_message, + "mail-message-new-symbolic", + "im.received" ); ui_label_set_text(message->text_label, invite_message); @@ -561,14 +563,8 @@ event_invitation(MESSENGER_Application *app, invitation ); - gtk_widget_show(GTK_WIDGET(message->deny_button)); - gtk_widget_show(GTK_WIDGET(message->accept_button)); - ui_chat_add_message(handle->chat, app, message); - if (app->settings.accept_all_invitations) - gtk_button_clicked(message->accept_button); - enqueue_chat_entry_update(handle); } @@ -623,8 +619,8 @@ event_receive_message(MESSENGER_Application *app, if (app->settings.delete_files_delay > 0) GNUNET_CHAT_message_delete(msg, GNUNET_TIME_relative_multiply( - GNUNET_TIME_relative_get_second_(), - app->settings.delete_files_delay + GNUNET_TIME_relative_get_second_(), + app->settings.delete_files_delay )); } @@ -646,12 +642,12 @@ event_receive_message(MESSENGER_Application *app, if ((!ui_messenger_is_context_active(&(app->ui.messenger), context)) && (GNUNET_YES != sent)) _show_notification( - app, - context, - contact, - text, - "mail-unread-symbolic", - "im.received" + app, + context, + contact, + text, + "mail-unread-symbolic", + "im.received" ); ui_label_set_text(message->text_label, text); diff --git a/src/ui/chat.c b/src/ui/chat.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -1392,9 +1392,9 @@ ui_chat_update(UI_CHAT_Handle *handle, icon = "system-users-symbolic"; g_string_append_printf( - subtitle, - _("%d members"), - GNUNET_CHAT_group_iterate_contacts(group, NULL, NULL) + subtitle, + _("%d members"), + GNUNET_CHAT_group_iterate_contacts(group, NULL, NULL) ); } @@ -1421,8 +1421,8 @@ ui_chat_update(UI_CHAT_Handle *handle, children = children->next; gtk_container_remove( - GTK_CONTAINER(handle->chat_contacts_listbox), - widget + GTK_CONTAINER(handle->chat_contacts_listbox), + widget ); } @@ -1433,9 +1433,9 @@ ui_chat_update(UI_CHAT_Handle *handle, closure.listbox = handle->chat_contacts_listbox; GNUNET_CHAT_group_iterate_contacts( - group, - iterate_ui_chat_update_group_contacts, - &closure + group, + iterate_ui_chat_update_group_contacts, + &closure ); } diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -124,13 +124,13 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, if (group) { GString *message_text = g_string_new( - gtk_label_get_text(message->sender_label) + gtk_label_get_text(message->sender_label) ); g_string_append_printf( - message_text, - _(": %s"), - text + message_text, + _(": %s"), + text ); gtk_label_set_text(handle->text_label, message_text->str); @@ -144,7 +144,7 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, gtk_widget_set_visible( GTK_WIDGET(handle->read_receipt_image), message->read_receipt_image? gtk_widget_is_visible( - GTK_WIDGET(message->read_receipt_image) + GTK_WIDGET(message->read_receipt_image) ) : FALSE ); diff --git a/src/ui/message.c b/src/ui/message.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -25,6 +25,7 @@ #include "message.h" #include <gnunet/gnunet_chat_lib.h> +#include <gnunet/gnunet_common.h> #include "../application.h" #include "../file.h" @@ -283,7 +284,7 @@ _clear_message_preview_data(UI_MESSAGE_Handle *handle) UI_MESSAGE_Handle* ui_message_new(MESSENGER_Application *app, - UI_MESSAGE_Type type) + UI_MESSAGE_Type type) { UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); @@ -326,7 +327,7 @@ ui_message_new(MESSENGER_Application *app, if (UI_MESSAGE_STATUS == handle->type) { handle->deny_revealer = GTK_REVEALER( - gtk_builder_get_object(handle->builder[0], "deny_revealer") + gtk_builder_get_object(handle->builder[0], "deny_revealer") ); handle->accept_revealer = GTK_REVEALER( @@ -334,11 +335,11 @@ ui_message_new(MESSENGER_Application *app, ); handle->deny_button = GTK_BUTTON( - gtk_builder_get_object(handle->builder[0], "deny_button") + gtk_builder_get_object(handle->builder[0], "deny_button") ); handle->accept_button = GTK_BUTTON( - gtk_builder_get_object(handle->builder[0], "accept_button") + gtk_builder_get_object(handle->builder[0], "accept_button") ); } else @@ -517,9 +518,46 @@ _message_media_supports_file_extension(const gchar *filename) } static void +_update_invitation_message(UI_MESSAGE_Handle *handle, + MESSENGER_Application *app, + struct GNUNET_CHAT_Invitation *invitation) +{ + enum GNUNET_GenericReturnValue accepted; + accepted = GNUNET_CHAT_invitation_is_accepted(invitation); + + if (handle->deny_button) + gtk_widget_set_sensitive( + GTK_WIDGET(handle->deny_button), + GNUNET_YES == accepted? FALSE : TRUE + ); + + if (handle->accept_button) + gtk_widget_set_sensitive( + GTK_WIDGET(handle->accept_button), + GNUNET_YES == accepted? FALSE : TRUE + ); + + if (handle->deny_revealer) + gtk_revealer_set_reveal_child( + GTK_REVEALER(handle->deny_revealer), + GNUNET_YES == accepted? FALSE : TRUE + ); + + if (handle->accept_revealer) + gtk_revealer_set_reveal_child( + GTK_REVEALER(handle->accept_revealer), + GNUNET_YES == accepted? FALSE : TRUE + ); + + if ((app->settings.accept_all_invitations) && + (GNUNET_NO == accepted) && (handle->accept_button)) + gtk_button_clicked(handle->accept_button); +} + +static void _update_file_message(UI_MESSAGE_Handle *handle, - MESSENGER_Application *app, - struct GNUNET_CHAT_File *file) + MESSENGER_Application *app, + struct GNUNET_CHAT_File *file) { const char *filename = GNUNET_CHAT_file_get_name(file); @@ -580,9 +618,9 @@ _update_file_message(UI_MESSAGE_Handle *handle, if (_message_media_supports_file_extension(filename)) { gtk_image_set_from_icon_name( - handle->media_type_image, - "audio-x-generic-symbolic", - GTK_ICON_SIZE_DND + handle->media_type_image, + "audio-x-generic-symbolic", + GTK_ICON_SIZE_DND ); goto media_content; @@ -644,6 +682,7 @@ ui_message_update(UI_MESSAGE_Handle *handle, const struct GNUNET_CHAT_Message *msg) { struct GNUNET_CHAT_File *file = NULL; + struct GNUNET_CHAT_Invitation *invitation = NULL; handle->msg = msg; @@ -653,25 +692,37 @@ ui_message_update(UI_MESSAGE_Handle *handle, { if (GNUNET_CHAT_KIND_WHISPER == GNUNET_CHAT_message_get_kind(msg)) gtk_stack_set_visible_child( - handle->content_stack, - GTK_WIDGET(handle->whisper_box) + handle->content_stack, + GTK_WIDGET(handle->whisper_box) ); - + + invitation = GNUNET_CHAT_message_get_invitation(msg); file = GNUNET_CHAT_message_get_file(msg); handle->timestamp = GNUNET_CHAT_message_get_timestamp(msg); + if (handle->accept_button) + g_object_set_qdata(G_OBJECT(handle->accept_button), app->quarks.data, invitation); + g_object_set_qdata(G_OBJECT(handle->message_box), app->quarks.data, file); } else + { + if (handle->accept_button) + invitation = (struct GNUNET_CHAT_Invitation*) ( + g_object_get_qdata(G_OBJECT(handle->accept_button), app->quarks.data) + ); + file = (struct GNUNET_CHAT_File*) ( - g_object_get_qdata(G_OBJECT(handle->message_box), app->quarks.data) + g_object_get_qdata(G_OBJECT(handle->message_box), app->quarks.data) ); + } - if (!file) - return; + if (invitation) + _update_invitation_message(handle, app, invitation); - _update_file_message(handle, app, file); + if (file) + _update_file_message(handle, app, file); } void