messenger-gtk

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

commit 21eff6c7c215672d9d0fedd68bc1ca3c3eb4762f
parent 9d5b6a94224d6fcf6820bbc4230ef7cf1c2f9714
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Mon,  1 Nov 2021 21:27:54 +0100

Added ui files for messages and automated some debug entries

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

Diffstat:
MMakefile | 1+
Mresources/css/style.css | 8++++++--
Mresources/ui/chat_entry.ui | 45+++++++++++++++++++++++++++++++++++----------
Aresources/ui/message-sent.ui | 137+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aresources/ui/message.ui | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mresources/ui/messenger.ui | 543+------------------------------------------------------------------------------
Msrc/event.c | 11+++++++++++
Msrc/ui/chat_entry.c | 20++++++++++++--------
Msrc/ui/chat_entry.h | 9+++++----
Asrc/ui/message.c | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/ui/message.h | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/ui/messenger.c | 4++++
Msrc/ui/messenger.h | 2++
13 files changed, 473 insertions(+), 566 deletions(-)

diff --git a/Makefile b/Makefile @@ -8,6 +8,7 @@ SOURCES = messenger_gtk.c\ event.c\ chat/messenger.c\ ui/chat_entry.c\ + ui/message.c\ ui/messenger.c HEADERS = diff --git a/resources/css/style.css b/resources/css/style.css @@ -11,6 +11,10 @@ padding: 4px; } +.message-avatar { + margin: 4px; +} + .message-box { border-radius: 12px; padding: 8px 12px; @@ -18,13 +22,13 @@ font-size: small; } -.message-box:not(.own) { +.message-box:not(.sent) { background-color: mix(@theme_bg_color, @theme_fg_color, 0.1); color: @theme_fg_color; margin-right: 20px; } -.message-box.own { +.message-box.sent { background-color: @theme_selected_bg_color; color: @theme_selected_fg_color; margin-left: 20px; diff --git a/resources/ui/chat_entry.ui b/resources/ui/chat_entry.ui @@ -28,7 +28,7 @@ Author: Tobias Frisch <property name="can-focus">False</property> <property name="spacing">8</property> <child> - <object class="HdyAvatar"> + <object class="HdyAvatar" id="entry_avatar"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="size">48</property> @@ -51,7 +51,7 @@ Author: Tobias Frisch <property name="can-focus">False</property> <property name="spacing">8</property> <child> - <object class="GtkLabel"> + <object class="GtkLabel" id="title_label"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="label" translatable="yes">Chat title</property> @@ -67,7 +67,7 @@ Author: Tobias Frisch </packing> </child> <child> - <object class="GtkLabel"> + <object class="GtkLabel" id="timestamp_label"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="label" translatable="yes">11.12.13</property> @@ -88,15 +88,40 @@ Author: Tobias Frisch </packing> </child> <child> - <object class="GtkLabel"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> - <property name="wrap">True</property> - <property name="wrap-mode">word-char</property> - <property name="ellipsize">end</property> - <property name="max-width-chars">48</property> - <property name="xalign">0</property> + <property name="spacing">4</property> + <child> + <object class="GtkLabel" id="text_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> + <property name="wrap">True</property> + <property name="wrap-mode">word-char</property> + <property name="ellipsize">end</property> + <property name="max-width-chars">48</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkImage" id="read_receipt_image"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">emblem-default-symbolic</property> + </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> </object> <packing> <property name="expand">True</property> diff --git a/resources/ui/message-sent.ui b/resources/ui/message-sent.ui @@ -0,0 +1,137 @@ +<?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"/> + <requires lib="libhandy" version="1.2"/> + <object class="GtkBox" id="message_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="HdyAvatar" id="sender_avatar"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">end</property> + <property name="size">36</property> + <style> + <class name="message-avatar"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label-xalign">0</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="text_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> + <property name="wrap">True</property> + <property name="max-width-chars">64</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="spacing">4</property> + <child> + <object class="GtkImage" id="read_receipt_image"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">emblem-default-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="timestamp_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">0min</property> + <attributes> + <attribute name="weight" value="light"/> + </attributes> + </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> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </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="sent"/> + </style> + </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> + </object> +</interface> diff --git a/resources/ui/message.ui b/resources/ui/message.ui @@ -0,0 +1,133 @@ +<?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"/> + <requires lib="libhandy" version="1.2"/> + <object class="GtkBox" id="message_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="HdyAvatar" id="sender_avatar"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="valign">end</property> + <property name="size">36</property> + <style> + <class name="message-avatar"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label-xalign">0</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="text_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> + <property name="wrap">True</property> + <property name="max-width-chars">64</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="spacing">4</property> + <child> + <object class="GtkImage" id="read_receipt_image"> + <property name="can-focus">False</property> + <property name="icon-name">emblem-default-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="timestamp_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">0min</property> + <attributes> + <attribute name="weight" value="light"/> + </attributes> + </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> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </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"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> +</interface> diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui @@ -114,107 +114,6 @@ Author: Tobias Frisch <property name="visible">True</property> <property name="can-focus">False</property> <property name="selection-mode">none</property> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="spacing">8</property> - <child> - <object class="HdyAvatar"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="text">Tobias Frisch</property> - <property name="size">48</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">2</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="spacing">8</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">Chat title</property> - <property name="wrap">True</property> - <property name="wrap-mode">word-char</property> - <property name="ellipsize">end</property> - <property name="xalign">2.2351741291171123e-10</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">11.12.13</property> - <property name="justify">right</property> - </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> - </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">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> - <property name="wrap">True</property> - <property name="wrap-mode">word-char</property> - <property name="ellipsize">end</property> - <property name="max-width-chars">48</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> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <style> - <class name="chat-entry"/> - </style> - </object> - </child> - </object> - </child> </object> </child> </object> @@ -940,451 +839,11 @@ Author: Tobias Frisch <property name="visible">True</property> <property name="can-focus">False</property> <child> - <object class="GtkListBox"> + <object class="GtkListBox" id="messages_listbox"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="selection-mode">none</property> <property name="activate-on-single-click">False</property> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <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="label-xalign">0</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"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> - <property name="wrap">True</property> - <property name="max-width-chars">64</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">5h</property> - <property name="justify">right</property> - <property name="xalign">1</property> - <attributes> - <attribute name="weight" value="light"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">User</property> - </object> - </child> - <style> - <class name="message-box"/> - <class name="own"/> - </style> - </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> - </child> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <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="label-xalign">0</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"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">Great stuff to write</property> - <property name="max-width-chars">64</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">4h</property> - <property name="xalign">0</property> - <attributes> - <attribute name="weight" value="light"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">OtherGuy69</property> - </object> - </child> - <style> - <class name="message-box"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> - </child> - </object> - </child> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <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="label-xalign">0</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"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> - <property name="wrap">True</property> - <property name="max-width-chars">64</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">2h</property> - <property name="justify">right</property> - <property name="xalign">1</property> - <attributes> - <attribute name="weight" value="light"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">User</property> - </object> - </child> - <style> - <class name="message-box"/> - <class name="own"/> - </style> - </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> - </child> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <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="label-xalign">0</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"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">If people would know that you spam here like this...</property> - <property name="wrap">True</property> - <property name="max-width-chars">64</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">1h</property> - <property name="xalign">0</property> - <attributes> - <attribute name="weight" value="light"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">CookieHunter</property> - </object> - </child> - <style> - <class name="message-box"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - </object> - </child> - </object> - </child> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <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="label-xalign">0</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"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">Existence is a crisis my friends. You will only get releaf by open-sourcing your hard work because profit is temporary. Forks remain forever!</property> - <property name="wrap">True</property> - <property name="max-width-chars">64</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">30min</property> - <property name="xalign">0</property> - <attributes> - <attribute name="weight" value="light"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">SomePhilosoph28</property> - </object> - </child> - <style> - <class name="message-box"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - </object> - </child> - </object> - </child> - <child> - <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <child> - <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="label-xalign">0</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"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">My evil comment text is awesome! This is coming to the Pinephone which will be extremely awesome and this text may only cut some borders in certain areas!!!</property> - <property name="wrap">True</property> - <property name="max-width-chars">64</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">12min</property> - <property name="justify">right</property> - <property name="xalign">1</property> - <attributes> - <attribute name="weight" value="light"/> - </attributes> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">User</property> - </object> - </child> - <style> - <class name="message-box"/> - <class name="own"/> - </style> - </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> - </child> </object> <packing> <property name="name">page0</property> diff --git a/src/event.c b/src/event.c @@ -25,6 +25,7 @@ #include "event.h" #include "ui/chat_entry.h" +#include "ui/message.h" static int _iterate_profile_contacts(void *cls, @@ -93,4 +94,14 @@ event_update_profile(MESSENGER_Application *app) GNUNET_CHAT_iterate_contacts(chat->handle, _iterate_profile_contacts, app); GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app); + + UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(); + gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box); + g_free(entry); + + for (int i = 0; i < 8; i++) { + UI_MESSAGE_Handle *message = ui_message_new(app, i % 2 == 0); + gtk_container_add(GTK_CONTAINER(ui->messages_listbox), message->message_box); + g_free(message); + } } diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c @@ -35,20 +35,24 @@ ui_chat_entry_new(void) gtk_builder_get_object(builder, "entry_box") ); - handle->avatar = HDY_AVATAR( - gtk_builder_get_object(builder, "avatar") + handle->entry_avatar = HDY_AVATAR( + gtk_builder_get_object(builder, "entry_avatar") ); - handle->title = GTK_LABEL( - gtk_builder_get_object(builder, "title") + handle->title_label = GTK_LABEL( + gtk_builder_get_object(builder, "title_label") ); - handle->timestamp = GTK_LABEL( - gtk_builder_get_object(builder, "timestamp") + handle->timestamp_label = GTK_LABEL( + gtk_builder_get_object(builder, "timestamp_label") ); - handle->text = GTK_LABEL( - gtk_builder_get_object(builder, "text") + handle->text_label = GTK_LABEL( + gtk_builder_get_object(builder, "text_label") + ); + + handle->read_receipt_image = GTK_IMAGE( + gtk_builder_get_object(builder, "read_receipt_image") ); return handle; diff --git a/src/ui/chat_entry.h b/src/ui/chat_entry.h @@ -34,12 +34,13 @@ typedef struct UI_CHAT_ENTRY_Handle { GtkWidget* entry_box; - HdyAvatar* avatar; + HdyAvatar* entry_avatar; - GtkLabel* title; - GtkLabel* timestamp; + GtkLabel* title_label; + GtkLabel* timestamp_label; - GtkLabel* text; + GtkLabel* text_label; + GtkImage* read_receipt_image; } UI_CHAT_ENTRY_Handle; UI_CHAT_ENTRY_Handle* diff --git a/src/ui/message.c b/src/ui/message.c @@ -0,0 +1,74 @@ +/* + This file is part of GNUnet. + 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 + * @file ui/message.c + */ + +#include "message.h" + +#include "../application.h" + +UI_MESSAGE_Handle* +ui_message_new(MESSENGER_Application *app, + bool sent) +{ + UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); + GtkBuilder* builder; + + if (sent) + builder = gtk_builder_new_from_file("resources/ui/message-sent.ui"); + else + builder = gtk_builder_new_from_file("resources/ui/message.ui"); + + handle->message_box = GTK_WIDGET( + gtk_builder_get_object(builder, "message_box") + ); + + handle->sender_avatar = HDY_AVATAR( + gtk_builder_get_object(builder, "sender_avatar") + ); + + handle->sender_label = GTK_LABEL( + gtk_builder_get_object(builder, "sender_label") + ); + + if (sent) + { + const char *sender = GNUNET_CHAT_get_name(app->chat.messenger.handle); + + hdy_avatar_set_text(handle->sender_avatar, sender); + gtk_label_set_text(handle->sender_label, sender); + } + + handle->text_label = GTK_LABEL( + gtk_builder_get_object(builder, "text_label") + ); + + handle->timestamp_label = GTK_LABEL( + gtk_builder_get_object(builder, "timestamp_label") + ); + + handle->read_receipt_image = GTK_IMAGE( + gtk_builder_get_object(builder, "read_receipt_image") + ); + + return handle; +} diff --git a/src/ui/message.h b/src/ui/message.h @@ -0,0 +1,52 @@ +/* + This file is part of GNUnet. + 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 + * @file ui/message.h + */ + +#ifndef UI_MESSAGE_H_ +#define UI_MESSAGE_H_ + +#include <stdbool.h> + +#include <gtk-3.0/gtk/gtk.h> +#include <libhandy-1/handy.h> + +typedef struct MESSENGER_Application MESSENGER_Application; + +typedef struct UI_MESSAGE_Handle +{ + GtkWidget* message_box; + + HdyAvatar* sender_avatar; + GtkLabel* sender_label; + + GtkLabel* text_label; + + GtkLabel* timestamp_label; + GtkImage* read_receipt_image; +} UI_MESSAGE_Handle; + +UI_MESSAGE_Handle* +ui_message_new(MESSENGER_Application *app, + bool sent); + +#endif /* UI_MESSAGE_H_ */ diff --git a/src/ui/messenger.c b/src/ui/messenger.c @@ -279,6 +279,10 @@ ui_messenger_init(MESSENGER_Application *app, handle->flap_chat_details ); + handle->messages_listbox = GTK_LIST_BOX( + gtk_builder_get_object(builder, "messages_listbox") + ); + gtk_widget_show(GTK_WIDGET(handle->main_window)); g_signal_connect( diff --git a/src/ui/messenger.h b/src/ui/messenger.h @@ -67,6 +67,8 @@ typedef struct UI_MESSENGER_Handle GtkButton *chat_details_button; GtkButton *hide_chat_details_button; + + GtkListBox *messages_listbox; } UI_MESSENGER_Handle; void