messenger-gtk

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

commit fc7f147d38bd144d3868861e97923c87d9d1a283
parent 3db72a57b0973b24a69c1322345b7ddbbcdc5116
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Sat, 20 Nov 2021 04:21:17 +0100

Added first ui files for status messages and integrated public key api changes

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
MMakefile | 4++--
Mresources/css/style.css | 9++++++++-
Aresources/ui/message-status.ui | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/chat/messenger.c | 10++++++++++
Msrc/event.c | 21+++++++++++++++++++++
Msrc/event.h | 5+++++
Msrc/ui/contacts.c | 11++---------
7 files changed, 127 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile @@ -18,8 +18,8 @@ SOURCES = messenger_gtk.c\ HEADERS = -LIBRARIES = gnunetchat zbargtk -PACKAGES = gnunetutil libhandy-1 gtk+-3.0 libnotify zbar libqrencode gnunetidentity +LIBRARIES = gnunetchat +PACKAGES = gnunetutil libhandy-1 gtk+-3.0 libnotify zbar libqrencode GNU_CC ?= gcc GNU_LD ?= gcc diff --git a/resources/css/style.css b/resources/css/style.css @@ -31,10 +31,17 @@ .message-box.sent { background-color: @theme_selected_bg_color; color: @theme_selected_fg_color; +} + +.message-box.sent, .message-box.status { margin-left: 20px; } -.message-content { +.message-content:not(.status) { padding-top: 4px; } +.message-box.status > .message-content { + padding: 2px 12px; +} + diff --git a/resources/ui/message-status.ui b/resources/ui/message-status.ui @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 + +Copyright (C) 2021 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="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="GtkFrame"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">center</property> + <property name="label-xalign">0.5</property> + <property name="shadow-type">none</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="status_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">status information</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <style> + <class name="message-content"/> + </style> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="sender_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">User</property> + <attributes> + <attribute name="weight" value="semibold"/> + </attributes> + </object> + </child> + <style> + <class name="message-box"/> + <class name="status"/> + </style> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> diff --git a/src/chat/messenger.c b/src/chat/messenger.c @@ -82,6 +82,16 @@ _chat_messenger_message(void *cls, { if (GNUNET_YES == GNUNET_CHAT_message_is_sent(message)) application_call_event(app, event_update_chats, 1, (void**) &context); + else + { + void* event_data [2] = { context, &message }; + application_call_event(app, event_joining_contact, 2, event_data); + } + + break; + } + case GNUNET_CHAT_KIND_CONTACT: + { break; } diff --git a/src/event.c b/src/event.c @@ -158,6 +158,27 @@ event_update_chats(MESSENGER_Application *app, } void +event_joining_contact(MESSENGER_Application *app, + int argc, + void **argv) +{ + if (argc < 2) + return; + + struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) argv[0]; + + UI_CHAT_ENTRY_Handle *handle = GNUNET_CHAT_context_get_user_pointer(context); + + if (!handle) + return; + + const struct GNUNET_CHAT_Message *msg; + msg = *((const struct GNUNET_CHAT_Message**) argv[1]); + + // +} + +void event_receive_message(MESSENGER_Application *app, int argc, void **argv) diff --git a/src/event.h b/src/event.h @@ -38,6 +38,11 @@ event_update_chats(MESSENGER_Application *app, void **argv); void +event_joining_contact(MESSENGER_Application *app, + int argc, + void **argv); + +void event_receive_message(MESSENGER_Application *app, int argc, void **argv); diff --git a/src/ui/contacts.c b/src/ui/contacts.c @@ -28,8 +28,6 @@ #include "contact_entry.h" #include "../application.h" -#include <gnunet/gnunet_identity_service.h> - static void handle_close_button_click(UNUSED GtkButton *button, gpointer user_data) @@ -134,8 +132,7 @@ _iterate_contacts(void *cls, const char *title; title = GNUNET_CHAT_contact_get_name(contact); - const struct GNUNET_IDENTITY_PublicKey *key; - key = GNUNET_CHAT_contact_get_key(contact); + const char *key = GNUNET_CHAT_contact_get_key(contact); UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(); gtk_container_add( @@ -152,11 +149,7 @@ _iterate_contacts(void *cls, } if (key) - { - char *key_string = GNUNET_IDENTITY_public_key_to_string(key); - gtk_label_set_text(entry->subtitle_label, key_string); - GNUNET_free(key_string); - } + gtk_label_set_text(entry->subtitle_label, key); GtkListBoxRow *row = GTK_LIST_BOX_ROW( gtk_widget_get_parent(entry->entry_box)