commit 43e1bdf4a87b0e6979aa75f36a920e21028c4f74
parent 6b71ae4702f4ee9bea58bb12b1d41d76974a078b
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Sat, 19 Feb 2022 15:11:05 +0100
Added avatar to chat page title
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
5 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui
@@ -143,6 +143,18 @@ Author: Tobias Frisch
</packing>
</child>
<child>
+ <object class="HdyAvatar" id="chat_avatar">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="size">32</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="chat_load_button">
<property name="can-focus">True</property>
<property name="receives-default">True</property>
diff --git a/src/event.c b/src/event.c
@@ -53,6 +53,9 @@ _show_notification(MESSENGER_Application *app,
const gchar *text,
const gchar *icon)
{
+ if (app->settings.disable_notifications)
+ return;
+
const char *sender = GNUNET_CHAT_contact_get_name(contact);
NotifyNotification *notification = notify_notification_new(
diff --git a/src/ui/chat.c b/src/ui/chat.c
@@ -471,6 +471,10 @@ ui_chat_new(MESSENGER_Application *app)
gtk_builder_get_object(handle->builder, "selection_box")
);
+ handle->chat_avatar = HDY_AVATAR(
+ gtk_builder_get_object(handle->builder, "chat_avatar")
+ );
+
handle->chat_title = GTK_LABEL(
gtk_builder_get_object(handle->builder, "chat_title")
);
@@ -741,9 +745,7 @@ ui_chat_update(UI_CHAT_Handle *handle,
GString *subtitle = g_string_new("");
if (contact)
- {
title = GNUNET_CHAT_contact_get_name(contact);
- }
else if (group)
{
title = GNUNET_CHAT_group_get_name(group);
diff --git a/src/ui/chat.h b/src/ui/chat.h
@@ -56,6 +56,7 @@ typedef struct UI_CHAT_Handle
GtkWidget *title_box;
GtkWidget *selection_box;
+ HdyAvatar *chat_avatar;
GtkLabel *chat_title;
GtkLabel *chat_subtitle;
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c
@@ -66,16 +66,6 @@ ui_chat_entry_new(MESSENGER_Application *app)
return handle;
}
-/*static int
-_iterate_message_read_receipt(UNUSED void *cls,
- UNUSED const struct GNUNET_CHAT_Message *message,
- const struct GNUNET_CHAT_Contact *contact,
- int read_receipt)
-{
- printf("read_receipt: %s %d\n", GNUNET_CHAT_contact_get_name(contact), read_receipt);
- return GNUNET_YES;
-}*/
-
void
ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle,
MESSENGER_Application *app,
@@ -88,23 +78,36 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle,
group = GNUNET_CHAT_context_get_group(context);
const char *title = NULL;
+ const char *icon = "action-unavailable-symbolic";
if (contact)
+ {
title = GNUNET_CHAT_contact_get_name(contact);
+ icon = "avatar-default-symbolic";
+ }
else if (group)
+ {
title = GNUNET_CHAT_group_get_name(group);
- if (title)
- {
- gtk_label_set_text(handle->title_label, title);
- hdy_avatar_set_text(handle->entry_avatar, title);
+ if ((title) && ('#' == *title))
+ icon = "network-wired-symbolic";
+ else
+ icon = "system-users-symbolic";
}
+ gtk_label_set_text(handle->title_label, title? title : "");
+
+ hdy_avatar_set_text(handle->entry_avatar, title? title : "");
+ hdy_avatar_set_icon_name(handle->entry_avatar, icon);
+
if (!(handle->chat))
return;
ui_chat_update(handle->chat, app, context);
+ hdy_avatar_set_text(handle->chat->chat_avatar, title? title : "");
+ hdy_avatar_set_icon_name(handle->chat->chat_avatar, icon);
+
if (!(handle->chat->messages))
return;