diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-19 15:11:05 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-02-19 15:11:05 +0100 |
commit | 43e1bdf4a87b0e6979aa75f36a920e21028c4f74 (patch) | |
tree | 8a49ab1be631531099c5c6273be69dfacf773101 | |
parent | 6b71ae4702f4ee9bea58bb12b1d41d76974a078b (diff) | |
download | messenger-gtk-43e1bdf4a87b0e6979aa75f36a920e21028c4f74.tar.gz messenger-gtk-43e1bdf4a87b0e6979aa75f36a920e21028c4f74.zip |
Added avatar to chat page title
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | resources/ui/chat.ui | 12 | ||||
-rw-r--r-- | src/event.c | 3 | ||||
-rw-r--r-- | src/ui/chat.c | 6 | ||||
-rw-r--r-- | src/ui/chat.h | 1 | ||||
-rw-r--r-- | src/ui/chat_entry.c | 31 |
5 files changed, 37 insertions, 16 deletions
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui index 383645d..5f50cbd 100644 --- a/resources/ui/chat.ui +++ b/resources/ui/chat.ui | |||
@@ -143,6 +143,18 @@ Author: Tobias Frisch | |||
143 | </packing> | 143 | </packing> |
144 | </child> | 144 | </child> |
145 | <child> | 145 | <child> |
146 | <object class="HdyAvatar" id="chat_avatar"> | ||
147 | <property name="visible">True</property> | ||
148 | <property name="can-focus">False</property> | ||
149 | <property name="size">32</property> | ||
150 | </object> | ||
151 | <packing> | ||
152 | <property name="expand">False</property> | ||
153 | <property name="fill">True</property> | ||
154 | <property name="position">2</property> | ||
155 | </packing> | ||
156 | </child> | ||
157 | <child> | ||
146 | <object class="GtkButton" id="chat_load_button"> | 158 | <object class="GtkButton" id="chat_load_button"> |
147 | <property name="can-focus">True</property> | 159 | <property name="can-focus">True</property> |
148 | <property name="receives-default">True</property> | 160 | <property name="receives-default">True</property> |
diff --git a/src/event.c b/src/event.c index 9269b9b..c1f7502 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -53,6 +53,9 @@ _show_notification(MESSENGER_Application *app, | |||
53 | const gchar *text, | 53 | const gchar *text, |
54 | const gchar *icon) | 54 | const gchar *icon) |
55 | { | 55 | { |
56 | if (app->settings.disable_notifications) | ||
57 | return; | ||
58 | |||
56 | const char *sender = GNUNET_CHAT_contact_get_name(contact); | 59 | const char *sender = GNUNET_CHAT_contact_get_name(contact); |
57 | 60 | ||
58 | NotifyNotification *notification = notify_notification_new( | 61 | NotifyNotification *notification = notify_notification_new( |
diff --git a/src/ui/chat.c b/src/ui/chat.c index 60a4697..7919989 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -471,6 +471,10 @@ ui_chat_new(MESSENGER_Application *app) | |||
471 | gtk_builder_get_object(handle->builder, "selection_box") | 471 | gtk_builder_get_object(handle->builder, "selection_box") |
472 | ); | 472 | ); |
473 | 473 | ||
474 | handle->chat_avatar = HDY_AVATAR( | ||
475 | gtk_builder_get_object(handle->builder, "chat_avatar") | ||
476 | ); | ||
477 | |||
474 | handle->chat_title = GTK_LABEL( | 478 | handle->chat_title = GTK_LABEL( |
475 | gtk_builder_get_object(handle->builder, "chat_title") | 479 | gtk_builder_get_object(handle->builder, "chat_title") |
476 | ); | 480 | ); |
@@ -741,9 +745,7 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
741 | GString *subtitle = g_string_new(""); | 745 | GString *subtitle = g_string_new(""); |
742 | 746 | ||
743 | if (contact) | 747 | if (contact) |
744 | { | ||
745 | title = GNUNET_CHAT_contact_get_name(contact); | 748 | title = GNUNET_CHAT_contact_get_name(contact); |
746 | } | ||
747 | else if (group) | 749 | else if (group) |
748 | { | 750 | { |
749 | title = GNUNET_CHAT_group_get_name(group); | 751 | title = GNUNET_CHAT_group_get_name(group); |
diff --git a/src/ui/chat.h b/src/ui/chat.h index 2c33789..119071d 100644 --- a/src/ui/chat.h +++ b/src/ui/chat.h | |||
@@ -56,6 +56,7 @@ typedef struct UI_CHAT_Handle | |||
56 | GtkWidget *title_box; | 56 | GtkWidget *title_box; |
57 | GtkWidget *selection_box; | 57 | GtkWidget *selection_box; |
58 | 58 | ||
59 | HdyAvatar *chat_avatar; | ||
59 | GtkLabel *chat_title; | 60 | GtkLabel *chat_title; |
60 | GtkLabel *chat_subtitle; | 61 | GtkLabel *chat_subtitle; |
61 | 62 | ||
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c index c065fc7..3c9461e 100644 --- a/src/ui/chat_entry.c +++ b/src/ui/chat_entry.c | |||
@@ -66,16 +66,6 @@ ui_chat_entry_new(MESSENGER_Application *app) | |||
66 | return handle; | 66 | return handle; |
67 | } | 67 | } |
68 | 68 | ||
69 | /*static int | ||
70 | _iterate_message_read_receipt(UNUSED void *cls, | ||
71 | UNUSED const struct GNUNET_CHAT_Message *message, | ||
72 | const struct GNUNET_CHAT_Contact *contact, | ||
73 | int read_receipt) | ||
74 | { | ||
75 | printf("read_receipt: %s %d\n", GNUNET_CHAT_contact_get_name(contact), read_receipt); | ||
76 | return GNUNET_YES; | ||
77 | }*/ | ||
78 | |||
79 | void | 69 | void |
80 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | 70 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, |
81 | MESSENGER_Application *app, | 71 | MESSENGER_Application *app, |
@@ -88,23 +78,36 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | |||
88 | group = GNUNET_CHAT_context_get_group(context); | 78 | group = GNUNET_CHAT_context_get_group(context); |
89 | 79 | ||
90 | const char *title = NULL; | 80 | const char *title = NULL; |
81 | const char *icon = "action-unavailable-symbolic"; | ||
91 | 82 | ||
92 | if (contact) | 83 | if (contact) |
84 | { | ||
93 | title = GNUNET_CHAT_contact_get_name(contact); | 85 | title = GNUNET_CHAT_contact_get_name(contact); |
86 | icon = "avatar-default-symbolic"; | ||
87 | } | ||
94 | else if (group) | 88 | else if (group) |
89 | { | ||
95 | title = GNUNET_CHAT_group_get_name(group); | 90 | title = GNUNET_CHAT_group_get_name(group); |
96 | 91 | ||
97 | if (title) | 92 | if ((title) && ('#' == *title)) |
98 | { | 93 | icon = "network-wired-symbolic"; |
99 | gtk_label_set_text(handle->title_label, title); | 94 | else |
100 | hdy_avatar_set_text(handle->entry_avatar, title); | 95 | icon = "system-users-symbolic"; |
101 | } | 96 | } |
102 | 97 | ||
98 | gtk_label_set_text(handle->title_label, title? title : ""); | ||
99 | |||
100 | hdy_avatar_set_text(handle->entry_avatar, title? title : ""); | ||
101 | hdy_avatar_set_icon_name(handle->entry_avatar, icon); | ||
102 | |||
103 | if (!(handle->chat)) | 103 | if (!(handle->chat)) |
104 | return; | 104 | return; |
105 | 105 | ||
106 | ui_chat_update(handle->chat, app, context); | 106 | ui_chat_update(handle->chat, app, context); |
107 | 107 | ||
108 | hdy_avatar_set_text(handle->chat->chat_avatar, title? title : ""); | ||
109 | hdy_avatar_set_icon_name(handle->chat->chat_avatar, icon); | ||
110 | |||
108 | if (!(handle->chat->messages)) | 111 | if (!(handle->chat->messages)) |
109 | return; | 112 | return; |
110 | 113 | ||