commit 7b869a2a7479c5e48e1944678fb343dc66bb7233
parent 908132faab9643b24955e506b9793f232644b550
Author: Jacki <jacki@thejackimonster.de>
Date: Mon, 15 Apr 2024 00:53:22 +0200
Implement view to display and edit attributes
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
5 files changed, 569 insertions(+), 251 deletions(-)
diff --git a/resources/ui/contact_info.ui b/resources/ui/contact_info.ui
@@ -23,6 +23,14 @@ Author: Tobias Frisch
<interface>
<requires lib="gtk+" version="3.24"/>
<requires lib="libhandy" version="1.2"/>
+ <object class="GtkListStore" id="attributes_list">
+ <columns>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name value -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="contact_info_dialog">
<property name="can-focus">False</property>
<property name="title" translatable="yes">Contact Information</property>
@@ -71,111 +79,44 @@ Author: Tobias Frisch
</packing>
</child>
<child>
- <object class="GtkStack" id="contact_info_stack">
+ <object class="GtkScrolledWindow">
+ <property name="width-request">284</property>
+ <property name="height-request">384</property>
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="border-width">8</property>
+ <property name="can-focus">True</property>
<child>
- <object class="GtkBox" id="details_box">
+ <object class="GtkViewport">
<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>
+ <property name="shadow-type">none</property>
<child>
- <object class="GtkLabel">
+ <object class="GtkStack" id="contact_info_stack">
<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="GtkBox">
- <property name="width-request">250</property>
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="spacing">4</property>
- <child>
- <object class="GtkEntry" id="contact_name">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can-focus">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="contact_edit_button">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <child>
- <object class="GtkImage" id="contact_edit_symbol">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">document-edit-symbolic</property>
- </object>
- </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>
- </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="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
+ <property name="border-width">8</property>
<child>
- <object class="GtkBox">
+ <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="GtkImage">
+ <object class="HdyAvatar" id="contact_avatar">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="icon-name">user-info-symbolic</property>
+ <property name="halign">center</property>
+ <property name="margin-left">32</property>
+ <property name="margin-start">32</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="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@@ -184,140 +125,312 @@ Author: Tobias Frisch
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="margin-end">16</property>
- <property name="label" translatable="yes">Reveal Identity</property>
+ <property name="label" translatable="yes">Name:</property>
+ <property name="xalign">0</property>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="pack-type">end</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">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkStack" id="block_stack">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <child>
- <object class="GtkButton" id="block_button">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
<child>
<object class="GtkBox">
+ <property name="width-request">250</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">4</property>
<child>
- <object class="GtkImage">
+ <object class="GtkEntry" id="contact_name">
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">mail-mark-junk-symbolic</property>
+ <property name="sensitive">False</property>
+ <property name="can-focus">True</property>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="GtkButton" id="contact_edit_button">
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="margin-end">16</property>
- <property name="label" translatable="yes">Block Contact</property>
- <property name="xalign">0.5</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <child>
+ <object class="GtkImage" id="contact_edit_symbol">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">document-edit-symbolic</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="expand">True</property>
+ <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">2</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="name">page_block</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="unblock_button">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
<child>
- <object class="GtkBox">
+ <object class="GtkButton" id="reveal_identity_button">
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="spacing">4</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
<child>
- <object class="GtkImage">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="icon-name">mail-mark-notjunk-symbolic</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">user-info-symbolic</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="margin-end">16</property>
+ <property name="label" translatable="yes">Reveal Identity</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</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">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="list_attributes_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">emblem-documents-symbolic</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="margin-end">16</property>
+ <property name="label" translatable="yes">List Attributes</property>
+ </object>
+ <packing>
+ <property name="expand">True</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">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStack" id="block_stack">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkButton" id="block_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">mail-mark-junk-symbolic</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="margin-end">16</property>
+ <property name="label" translatable="yes">Block Contact</property>
+ <property name="xalign">0.5</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</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">0</property>
+ <property name="name">page_block</property>
</packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="GtkButton" id="unblock_button">
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="margin-end">16</property>
- <property name="label" translatable="yes">Unblock Contact</property>
- <property name="xalign">0.5</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">mail-mark-notjunk-symbolic</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="margin-end">16</property>
+ <property name="label" translatable="yes">Unblock Contact</property>
+ <property name="xalign">0.5</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="pack-type">end</property>
+ <property name="name">page_unblock</property>
<property name="position">1</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="open_chat_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">user-available-symbolic</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="margin-end">16</property>
+ <property name="label" translatable="yes">Open Private Chat</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</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>
</object>
<packing>
- <property name="name">page_unblock</property>
- <property name="position">1</property>
+ <property name="name">details_page</property>
</packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="open_chat_button">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="identity_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="GtkImage">
+ <object class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="icon-name">user-available-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
@@ -326,109 +439,141 @@ 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="margin-end">16</property>
- <property name="label" translatable="yes">Open Private Chat</property>
+ <property name="border-width">8</property>
+ <property name="orientation">vertical</property>
+ <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="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="expand">True</property>
+ <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="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">ID:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="id_entry">
+ <property name="width-request">250</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="name">identity_page</property>
+ <property name="position">1</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="name">details_page</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="identity_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="GtkLabel" id="name_label">
- <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="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="border-width">8</property>
- <property name="orientation">vertical</property>
<child>
- <object class="GtkDrawingArea" id="id_drawing_area">
- <property name="height-request">250</property>
+ <object class="GtkBox" id="attributes_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="border-width">8</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Attributes:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTreeView" id="attributes_tree">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="model">attributes_list</property>
+ <property name="reorderable">True</property>
+ <property name="search-column">0</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="resizable">True</property>
+ <property name="spacing">4</property>
+ <property name="min-width">120</property>
+ <property name="title" translatable="yes">Name:</property>
+ <property name="clickable">True</property>
+ <property name="sort-indicator">True</property>
+ <property name="sort-column-id">0</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="resizable">True</property>
+ <property name="spacing">4</property>
+ <property name="min-width">120</property>
+ <property name="title" translatable="yes">Value:</property>
+ <child>
+ <object class="GtkCellRendererText" id="value_renderer">
+ <property name="editable">True</property>
+ </object>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </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">True</property>
- <property name="position">0</property>
+ <property name="name">attributes_page</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">ID:</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="id_entry">
- <property name="width-request">250</property>
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="editable">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
</child>
</object>
- <packing>
- <property name="name">identity_page</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui
@@ -154,7 +154,7 @@ Author: Tobias Frisch
<child>
<object class="GtkButton" id="profile_button">
<property name="visible">True</property>
- <property name="can-focus">True</property>
+ <property name="can-focus">False</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="relief">none</property>
diff --git a/src/event.c b/src/event.c
@@ -59,8 +59,10 @@ _show_notification(MESSENGER_Application *app,
const char *category)
{
g_assert(
- (app) && (context) && (contact) &&
- (text) && (icon) && (category)
+ (app) &&
+ (text) &&
+ (icon) &&
+ (category)
);
if (app->settings.disable_notifications)
@@ -94,7 +96,7 @@ event_handle_warning(MESSENGER_Application *app,
struct GNUNET_CHAT_Context *context,
const struct GNUNET_CHAT_Message *msg)
{
- g_assert((app) && (context) && (msg));
+ g_assert((app) && (msg));
const char *text = GNUNET_CHAT_message_get_text(msg);
diff --git a/src/ui/contact_info.c b/src/ui/contact_info.c
@@ -29,6 +29,8 @@
#include "../application.h"
#include "../ui.h"
#include <gnunet/gnunet_chat_lib.h>
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_time_lib.h>
static void
handle_contact_edit_button_click(UNUSED GtkButton *button,
@@ -108,6 +110,19 @@ _contact_info_reveal_identity(UI_CONTACT_INFO_Handle *handle)
}
static void
+_contact_info_list_attributes(UI_CONTACT_INFO_Handle *handle)
+{
+ g_assert(handle);
+
+ gtk_widget_set_visible(GTK_WIDGET(handle->back_button), TRUE);
+
+ gtk_stack_set_visible_child(
+ handle->contact_info_stack,
+ handle->attributes_box
+ );
+}
+
+static void
handle_reveal_identity_button_click(UNUSED GtkButton *button,
gpointer user_data)
{
@@ -117,6 +132,15 @@ handle_reveal_identity_button_click(UNUSED GtkButton *button,
}
static void
+handle_list_attributes_button_click(UNUSED GtkButton *button,
+ gpointer user_data)
+{
+ g_assert(user_data);
+
+ _contact_info_list_attributes((UI_CONTACT_INFO_Handle*) user_data);
+}
+
+static void
handle_block_button_click(UNUSED GtkButton *button,
gpointer user_data)
{
@@ -351,6 +375,92 @@ handle_id_drawing_area_draw(GtkWidget* drawing_area,
return FALSE;
}
+static enum GNUNET_GenericReturnValue
+cb_contact_info_attributes(void *cls,
+ struct GNUNET_CHAT_Handle *chat,
+ const char *name,
+ const char *value)
+{
+ g_assert((cls) && (chat) && (name) && (value));
+
+ UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) cls;
+
+ gtk_list_store_insert_with_values(
+ handle->attributes_list,
+ NULL,
+ -1,
+ 0,
+ name,
+ 1,
+ value,
+ -1
+ );
+
+ return GNUNET_YES;
+}
+
+static enum GNUNET_GenericReturnValue
+cb_contact_info_contact_attributes(void *cls,
+ struct GNUNET_CHAT_Contact *contact,
+ const char *name,
+ const char *value)
+{
+ g_assert((cls) && (contact) && (name) && (value));
+
+ UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) cls;
+
+ gtk_list_store_insert_with_values(
+ handle->attributes_list,
+ NULL,
+ -1,
+ 0,
+ name,
+ 1,
+ value,
+ -1
+ );
+
+ return GNUNET_YES;
+}
+
+static void
+handle_value_renderer_edit(GtkCellRendererText *renderer,
+ char *path,
+ char *new_text,
+ gpointer user_data)
+{
+ g_assert((renderer) && (path) && (new_text) && (user_data));
+
+ UI_CONTACT_INFO_Handle *handle = (UI_CONTACT_INFO_Handle*) user_data;
+ GtkTreeIter iter;
+
+ if (!gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(handle->attributes_list), &iter, path))
+ return;
+
+ struct GNUNET_CHAT_Handle *chat = handle->app->chat.messenger.handle;
+
+ if (!chat)
+ return;
+
+ struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) g_object_get_qdata(
+ G_OBJECT(handle->attributes_tree),
+ handle->app->quarks.data
+ );
+
+ if ((contact) && (GNUNET_YES != GNUNET_CHAT_contact_is_owned(contact)))
+ return;
+
+ GValue value = G_VALUE_INIT;
+ gtk_tree_model_get_value(GTK_TREE_MODEL(handle->attributes_list), &iter, 0, &value);
+
+ const gchar *name = g_value_get_string(&value);
+
+ GNUNET_CHAT_set_attribute(chat, name, new_text, GNUNET_TIME_relative_get_forever_());
+ gtk_list_store_set(handle->attributes_list, &iter, 1, new_text, -1);
+
+ g_value_unset(&value);
+}
+
void
ui_contact_info_dialog_init(MESSENGER_Application *app,
UI_CONTACT_INFO_Handle *handle)
@@ -421,6 +531,17 @@ ui_contact_info_dialog_init(MESSENGER_Application *app,
handle
);
+ handle->list_attributes_button = GTK_BUTTON(
+ gtk_builder_get_object(handle->builder, "list_attributes_button")
+ );
+
+ g_signal_connect(
+ handle->list_attributes_button,
+ "clicked",
+ G_CALLBACK(handle_list_attributes_button_click),
+ handle
+ );
+
handle->block_stack = GTK_STACK(
gtk_builder_get_object(handle->builder, "block_stack")
);
@@ -481,6 +602,29 @@ ui_contact_info_dialog_init(MESSENGER_Application *app,
gtk_builder_get_object(handle->builder, "id_entry")
);
+ handle->attributes_box = GTK_WIDGET(
+ gtk_builder_get_object(handle->builder, "attributes_box")
+ );
+
+ handle->attributes_tree = GTK_TREE_VIEW(
+ gtk_builder_get_object(handle->builder, "attributes_tree")
+ );
+
+ handle->attributes_list = GTK_LIST_STORE(
+ gtk_builder_get_object(handle->builder, "attributes_list")
+ );
+
+ handle->value_renderer = GTK_CELL_RENDERER_TEXT(
+ gtk_builder_get_object(handle->builder, "value_renderer")
+ );
+
+ g_signal_connect(
+ handle->value_renderer,
+ "edited",
+ G_CALLBACK(handle_value_renderer_edit),
+ handle
+ );
+
handle->back_button = GTK_BUTTON(
gtk_builder_get_object(handle->builder, "back_button")
);
@@ -529,6 +673,12 @@ ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle,
contact
);
+ g_object_set_qdata(
+ G_OBJECT(handle->attributes_tree),
+ handle->app->quarks.data,
+ contact
+ );
+
const char *key = GNUNET_CHAT_contact_get_key(contact);
if (handle->qr)
@@ -585,6 +735,21 @@ ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle,
contact
);
+ gtk_list_store_clear(handle->attributes_list);
+
+ if ((!contact) || (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact)))
+ GNUNET_CHAT_get_attributes(
+ handle->app->chat.messenger.handle,
+ cb_contact_info_attributes,
+ handle
+ );
+ else
+ GNUNET_CHAT_contact_get_attributes(
+ contact,
+ cb_contact_info_contact_attributes,
+ handle
+ );
+
struct GNUNET_CHAT_Context *context = GNUNET_CHAT_contact_get_context(
contact
);
diff --git a/src/ui/contact_info.h b/src/ui/contact_info.h
@@ -48,6 +48,7 @@ typedef struct UI_CONTACT_INFO_Handle
GtkImage *contact_edit_symbol;
GtkButton *reveal_identity_button;
+ GtkButton *list_attributes_button;
GtkStack *block_stack;
GtkButton *block_button;
GtkButton *unblock_button;
@@ -60,6 +61,11 @@ typedef struct UI_CONTACT_INFO_Handle
gulong id_draw_signal;
GtkEntry *id_entry;
+ GtkWidget *attributes_box;
+ GtkTreeView *attributes_tree;
+ GtkListStore *attributes_list;
+ GtkCellRendererText *value_renderer;
+
GtkButton *back_button;
GtkButton *close_button;