aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-01-15 21:40:55 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-01-15 21:40:55 +0100
commite4f21c04bc978487afcabb595703e50759a92a10 (patch)
tree99c1fe316f098014e70e7ef0152060c9ecd91f18
parent1c66a5e7ba39f6dde7afad4bdc4be067bc6a7da3 (diff)
downloadmessenger-gtk-e4f21c04bc978487afcabb595703e50759a92a10.tar.gz
messenger-gtk-e4f21c04bc978487afcabb595703e50759a92a10.zip
Added visual changes to select messages for deletion
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--resources/css/style.css2
-rw-r--r--resources/ui.gresource.xml1
-rw-r--r--resources/ui/chat.ui234
-rw-r--r--src/event.c6
-rw-r--r--src/file.c14
-rw-r--r--src/ui/chat.c75
-rw-r--r--src/ui/chat.h10
7 files changed, 261 insertions, 81 deletions
diff --git a/resources/css/style.css b/resources/css/style.css
index 084a639..f513280 100644
--- a/resources/css/style.css
+++ b/resources/css/style.css
@@ -45,7 +45,7 @@
45} 45}
46 46
47.message-box.sent { 47.message-box.sent {
48 background-color: @theme_selected_bg_color; 48 background-color: mix(@theme_bg_color, @theme_selected_bg_color, 0.8);
49 color: @theme_selected_fg_color; 49 color: @theme_selected_fg_color;
50} 50}
51 51
diff --git a/resources/ui.gresource.xml b/resources/ui.gresource.xml
index 122697e..96b1f1a 100644
--- a/resources/ui.gresource.xml
+++ b/resources/ui.gresource.xml
@@ -3,6 +3,7 @@
3 <gresource prefix="/org/gnunet/Messenger"> 3 <gresource prefix="/org/gnunet/Messenger">
4 <file compressed="true">ui/chat_entry.ui</file> 4 <file compressed="true">ui/chat_entry.ui</file>
5 <file compressed="true">ui/chat.ui</file> 5 <file compressed="true">ui/chat.ui</file>
6 <file compressed="true">ui/contact_entry.ui</file>
6 <file compressed="true">ui/contacts.ui</file> 7 <file compressed="true">ui/contacts.ui</file>
7 <file compressed="true">ui/file_load_entry.ui</file> 8 <file compressed="true">ui/file_load_entry.ui</file>
8 <file compressed="true">ui/invite_contact.ui</file> 9 <file compressed="true">ui/invite_contact.ui</file>
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui
index d928dff..b99c28e 100644
--- a/resources/ui/chat.ui
+++ b/resources/ui/chat.ui
@@ -1,7 +1,7 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!-- Generated with glade 3.38.2 2<!-- Generated with glade 3.38.2
3 3
4Copyright (C) 2021 GNUnet e.V. 4Copyright (C) 2021‑‑2022 GNUnet e.V.
5 5
6GNUnet is free software: you can redistribute it and/or modify it 6GNUnet is free software: you can redistribute it and/or modify it
7under the terms of the GNU Affero General Public License as published 7under the terms of the GNU Affero General Public License as published
@@ -40,48 +40,156 @@ Author: Tobias Frisch
40 <property name="can-focus">False</property> 40 <property name="can-focus">False</property>
41 <property name="orientation">vertical</property> 41 <property name="orientation">vertical</property>
42 <child> 42 <child>
43 <object class="GtkBox"> 43 <object class="GtkStack" id="chat_title_stack">
44 <property name="visible">True</property> 44 <property name="visible">True</property>
45 <property name="can-focus">False</property> 45 <property name="can-focus">False</property>
46 <property name="border-width">8</property> 46 <property name="transition-type">slide-down</property>
47 <property name="spacing">8</property>
48 <child> 47 <child>
49 <object class="GtkButton" id="back_button"> 48 <object class="GtkBox" id="title_box">
50 <property name="visible">True</property> 49 <property name="visible">True</property>
51 <property name="can-focus">True</property> 50 <property name="can-focus">False</property>
52 <property name="receives-default">True</property> 51 <property name="border-width">8</property>
53 <property name="relief">none</property> 52 <property name="spacing">8</property>
54 <child> 53 <child>
55 <object class="GtkImage"> 54 <object class="GtkButton" id="back_button">
55 <property name="visible">True</property>
56 <property name="can-focus">True</property>
57 <property name="receives-default">True</property>
58 <property name="relief">none</property>
59 <child>
60 <object class="GtkImage">
61 <property name="visible">True</property>
62 <property name="can-focus">False</property>
63 <property name="icon-name">go-previous-symbolic</property>
64 </object>
65 </child>
66 </object>
67 <packing>
68 <property name="expand">False</property>
69 <property name="fill">True</property>
70 <property name="position">0</property>
71 </packing>
72 </child>
73 <child>
74 <object class="GtkBox">
56 <property name="visible">True</property> 75 <property name="visible">True</property>
57 <property name="can-focus">False</property> 76 <property name="can-focus">False</property>
58 <property name="icon-name">go-previous-symbolic</property> 77 <property name="margin-start">4</property>
78 <property name="margin-end">4</property>
79 <property name="orientation">vertical</property>
80 <child>
81 <object class="GtkLabel" id="chat_title">
82 <property name="visible">True</property>
83 <property name="can-focus">False</property>
84 <property name="ellipsize">end</property>
85 <property name="single-line-mode">True</property>
86 <property name="xalign">0</property>
87 <attributes>
88 <attribute name="weight" value="bold"/>
89 </attributes>
90 </object>
91 <packing>
92 <property name="expand">False</property>
93 <property name="fill">True</property>
94 <property name="position">0</property>
95 </packing>
96 </child>
97 <child>
98 <object class="GtkLabel" id="chat_subtitle">
99 <property name="visible">True</property>
100 <property name="can-focus">False</property>
101 <property name="ellipsize">end</property>
102 <property name="single-line-mode">True</property>
103 <property name="xalign">0</property>
104 <attributes>
105 <attribute name="weight" value="light"/>
106 </attributes>
107 <style>
108 <class name="header-subtitle"/>
109 </style>
110 </object>
111 <packing>
112 <property name="expand">False</property>
113 <property name="fill">True</property>
114 <property name="position">1</property>
115 </packing>
116 </child>
59 </object> 117 </object>
118 <packing>
119 <property name="expand">True</property>
120 <property name="fill">True</property>
121 <property name="position">1</property>
122 </packing>
60 </child> 123 </child>
124 <child>
125 <object class="GtkButton" id="chat_details_button">
126 <property name="visible">True</property>
127 <property name="can-focus">True</property>
128 <property name="receives-default">True</property>
129 <property name="relief">none</property>
130 <child>
131 <object class="GtkImage">
132 <property name="visible">True</property>
133 <property name="can-focus">False</property>
134 <property name="icon-name">view-more-symbolic</property>
135 </object>
136 </child>
137 </object>
138 <packing>
139 <property name="expand">False</property>
140 <property name="fill">True</property>
141 <property name="pack-type">end</property>
142 <property name="position">1</property>
143 </packing>
144 </child>
145 <child>
146 <object class="GtkButton" id="chat_load_button">
147 <property name="can-focus">True</property>
148 <property name="receives-default">True</property>
149 <property name="relief">none</property>
150 <child>
151 <object class="GtkSpinner">
152 <property name="visible">True</property>
153 <property name="can-focus">False</property>
154 <property name="active">True</property>
155 </object>
156 </child>
157 </object>
158 <packing>
159 <property name="expand">False</property>
160 <property name="fill">True</property>
161 <property name="pack-type">end</property>
162 <property name="position">3</property>
163 </packing>
164 </child>
165 <style>
166 <class name="header-box"/>
167 </style>
61 </object> 168 </object>
62 <packing> 169 <packing>
63 <property name="expand">False</property> 170 <property name="name">page0</property>
64 <property name="fill">True</property> 171 <property name="title" translatable="yes">page0</property>
65 <property name="position">0</property>
66 </packing> 172 </packing>
67 </child> 173 </child>
68 <child> 174 <child>
69 <object class="GtkBox"> 175 <object class="GtkBox" id="selection_box">
70 <property name="visible">True</property> 176 <property name="visible">True</property>
71 <property name="can-focus">False</property> 177 <property name="can-focus">False</property>
72 <property name="margin-start">4</property> 178 <property name="border-width">8</property>
73 <property name="margin-end">4</property> 179 <property name="spacing">8</property>
74 <property name="orientation">vertical</property>
75 <child> 180 <child>
76 <object class="GtkLabel" id="chat_title"> 181 <object class="GtkButton" id="selection_close_button">
77 <property name="visible">True</property> 182 <property name="visible">True</property>
78 <property name="can-focus">False</property> 183 <property name="can-focus">True</property>
79 <property name="ellipsize">end</property> 184 <property name="receives-default">True</property>
80 <property name="single-line-mode">True</property> 185 <property name="relief">none</property>
81 <property name="xalign">0</property> 186 <child>
82 <attributes> 187 <object class="GtkImage">
83 <attribute name="weight" value="bold"/> 188 <property name="visible">True</property>
84 </attributes> 189 <property name="can-focus">False</property>
190 <property name="icon-name">window-close-symbolic</property>
191 </object>
192 </child>
85 </object> 193 </object>
86 <packing> 194 <packing>
87 <property name="expand">False</property> 195 <property name="expand">False</property>
@@ -90,18 +198,12 @@ Author: Tobias Frisch
90 </packing> 198 </packing>
91 </child> 199 </child>
92 <child> 200 <child>
93 <object class="GtkLabel" id="chat_subtitle"> 201 <object class="GtkLabel" id="selection_count_label">
94 <property name="visible">True</property> 202 <property name="visible">True</property>
95 <property name="can-focus">False</property> 203 <property name="can-focus">False</property>
96 <property name="ellipsize">end</property>
97 <property name="single-line-mode">True</property>
98 <property name="xalign">0</property>
99 <attributes> 204 <attributes>
100 <attribute name="weight" value="light"/> 205 <attribute name="weight" value="semibold"/>
101 </attributes> 206 </attributes>
102 <style>
103 <class name="header-subtitle"/>
104 </style>
105 </object> 207 </object>
106 <packing> 208 <packing>
107 <property name="expand">False</property> 209 <property name="expand">False</property>
@@ -109,57 +211,37 @@ Author: Tobias Frisch
109 <property name="position">1</property> 211 <property name="position">1</property>
110 </packing> 212 </packing>
111 </child> 213 </child>
112 </object>
113 <packing>
114 <property name="expand">True</property>
115 <property name="fill">True</property>
116 <property name="position">1</property>
117 </packing>
118 </child>
119 <child>
120 <object class="GtkButton" id="chat_details_button">
121 <property name="visible">True</property>
122 <property name="can-focus">True</property>
123 <property name="receives-default">True</property>
124 <property name="relief">none</property>
125 <child> 214 <child>
126 <object class="GtkImage"> 215 <object class="GtkButton" id="selection_delete_button">
127 <property name="visible">True</property> 216 <property name="visible">True</property>
128 <property name="can-focus">False</property> 217 <property name="can-focus">True</property>
129 <property name="icon-name">view-more-symbolic</property> 218 <property name="receives-default">True</property>
219 <property name="relief">none</property>
220 <child>
221 <object class="GtkImage">
222 <property name="visible">True</property>
223 <property name="can-focus">False</property>
224 <property name="icon-name">user-trash-symbolic</property>
225 </object>
226 </child>
130 </object> 227 </object>
228 <packing>
229 <property name="expand">False</property>
230 <property name="fill">True</property>
231 <property name="pack-type">end</property>
232 <property name="position">2</property>
233 </packing>
131 </child> 234 </child>
235 <style>
236 <class name="header-box"/>
237 </style>
132 </object> 238 </object>
133 <packing> 239 <packing>
134 <property name="expand">False</property> 240 <property name="name">page1</property>
135 <property name="fill">True</property> 241 <property name="title" translatable="yes">page1</property>
136 <property name="pack-type">end</property>
137 <property name="position">1</property> 242 <property name="position">1</property>
138 </packing> 243 </packing>
139 </child> 244 </child>
140 <child>
141 <object class="GtkButton" id="chat_load_button">
142 <property name="can-focus">True</property>
143 <property name="receives-default">True</property>
144 <property name="relief">none</property>
145 <child>
146 <object class="GtkSpinner">
147 <property name="visible">True</property>
148 <property name="can-focus">False</property>
149 <property name="active">True</property>
150 </object>
151 </child>
152 </object>
153 <packing>
154 <property name="expand">False</property>
155 <property name="fill">True</property>
156 <property name="pack-type">end</property>
157 <property name="position">3</property>
158 </packing>
159 </child>
160 <style>
161 <class name=".header-box"/>
162 </style>
163 </object> 245 </object>
164 <packing> 246 <packing>
165 <property name="expand">False</property> 247 <property name="expand">False</property>
@@ -179,7 +261,7 @@ Author: Tobias Frisch
179 <object class="GtkListBox" id="messages_listbox"> 261 <object class="GtkListBox" id="messages_listbox">
180 <property name="visible">True</property> 262 <property name="visible">True</property>
181 <property name="can-focus">False</property> 263 <property name="can-focus">False</property>
182 <property name="selection-mode">none</property> 264 <property name="selection-mode">multiple</property>
183 <property name="activate-on-single-click">False</property> 265 <property name="activate-on-single-click">False</property>
184 </object> 266 </object>
185 </child> 267 </child>
diff --git a/src/event.c b/src/event.c
index d80e563..a12bfef 100644
--- a/src/event.c
+++ b/src/event.c
@@ -269,7 +269,7 @@ event_joining_contact(MESSENGER_Application *app,
269 gtk_label_set_text(message->text_label, join_message); 269 gtk_label_set_text(message->text_label, join_message);
270 gtk_label_set_text(message->timestamp_label, time? time : ""); 270 gtk_label_set_text(message->timestamp_label, time? time : "");
271 271
272 ui_chat_add_message(handle->chat, message); 272 ui_chat_add_message(handle->chat, app, message);
273 ui_chat_entry_update(handle, app, context); 273 ui_chat_entry_update(handle, app, context);
274} 274}
275 275
@@ -353,7 +353,7 @@ event_invitation(MESSENGER_Application *app,
353 gtk_widget_show(GTK_WIDGET(message->deny_button)); 353 gtk_widget_show(GTK_WIDGET(message->deny_button));
354 gtk_widget_show(GTK_WIDGET(message->accept_button)); 354 gtk_widget_show(GTK_WIDGET(message->accept_button));
355 355
356 ui_chat_add_message(handle->chat, message); 356 ui_chat_add_message(handle->chat, app, message);
357 ui_chat_entry_update(handle, app, context); 357 ui_chat_entry_update(handle, app, context);
358} 358}
359 359
@@ -412,6 +412,6 @@ event_receive_message(MESSENGER_Application *app,
412 gtk_label_set_text(message->text_label, text? text : ""); 412 gtk_label_set_text(message->text_label, text? text : "");
413 gtk_label_set_text(message->timestamp_label, time? time : ""); 413 gtk_label_set_text(message->timestamp_label, time? time : "");
414 414
415 ui_chat_add_message(handle->chat, message); 415 ui_chat_add_message(handle->chat, app, message);
416 ui_chat_entry_update(handle, app, context); 416 ui_chat_entry_update(handle, app, context);
417} 417}
diff --git a/src/file.c b/src/file.c
index a9c64d7..7cb5fd9 100644
--- a/src/file.c
+++ b/src/file.c
@@ -75,7 +75,19 @@ file_update_upload_info(const struct GNUNET_CHAT_File *file,
75 if (!info) 75 if (!info)
76 return; 76 return;
77 77
78 // TODO 78 GList *list = info->file_messages;
79
80 while (list)
81 {
82 UI_MESSAGE_Handle *message = (UI_MESSAGE_Handle*) list->data;
83
84 gtk_progress_bar_set_fraction(
85 message->file_progress_bar,
86 1.0 * completed / size
87 );
88
89 list = list->next;
90 }
79} 91}
80 92
81void 93void
diff --git a/src/ui/chat.c b/src/ui/chat.c
index 0039a5d..eefb7cf 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -143,6 +143,41 @@ handle_back_button_click(UNUSED GtkButton *button,
143} 143}
144 144
145static void 145static void
146handle_chat_messages_selected_rows_changed(GtkListBox *listbox,
147 gpointer user_data)
148{
149 UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
150
151 GList *selected = gtk_list_box_get_selected_rows(listbox);
152 uint32_t count = 0;
153
154 while (selected)
155 {
156 count++;
157 selected = selected->next;
158 }
159
160 GString *counter = g_string_new("");
161 g_string_append_printf(counter, "%u", count);
162 gtk_label_set_text(handle->selection_count_label, counter->str);
163 g_string_free(counter, TRUE);
164
165 if (count > 0)
166 gtk_stack_set_visible_child(handle->chat_title_stack, handle->selection_box);
167 else
168 gtk_stack_set_visible_child(handle->chat_title_stack, handle->title_box);
169}
170
171static void
172handle_chat_selection_close_button_click(UNUSED GtkButton *button,
173 gpointer user_data)
174{
175 GtkListBox *listbox = GTK_LIST_BOX(user_data);
176
177 gtk_list_box_unselect_all(listbox);
178}
179
180static void
146handle_attach_file_button_click(GtkButton *button, 181handle_attach_file_button_click(GtkButton *button,
147 gpointer user_data) 182 gpointer user_data)
148{ 183{
@@ -326,6 +361,18 @@ ui_chat_new(MESSENGER_Application *app)
326 gtk_builder_get_object(handle->builder, "flap_chat_details") 361 gtk_builder_get_object(handle->builder, "flap_chat_details")
327 ); 362 );
328 363
364 handle->chat_title_stack = GTK_STACK(
365 gtk_builder_get_object(handle->builder, "chat_title_stack")
366 );
367
368 handle->title_box = GTK_WIDGET(
369 gtk_builder_get_object(handle->builder, "title_box")
370 );
371
372 handle->selection_box = GTK_WIDGET(
373 gtk_builder_get_object(handle->builder, "selection_box")
374 );
375
329 handle->chat_title = GTK_LABEL( 376 handle->chat_title = GTK_LABEL(
330 gtk_builder_get_object(handle->builder, "chat_title") 377 gtk_builder_get_object(handle->builder, "chat_title")
331 ); 378 );
@@ -383,6 +430,18 @@ ui_chat_new(MESSENGER_Application *app)
383 gtk_builder_get_object(handle->builder, "chat_details_contacts_box") 430 gtk_builder_get_object(handle->builder, "chat_details_contacts_box")
384 ); 431 );
385 432
433 handle->selection_close_button = GTK_BUTTON(
434 gtk_builder_get_object(handle->builder, "selection_close_button")
435 );
436
437 handle->selection_count_label = GTK_LABEL(
438 gtk_builder_get_object(handle->builder, "selection_count_label")
439 );
440
441 handle->selection_delete_button = GTK_BUTTON(
442 gtk_builder_get_object(handle->builder, "selection_delete_button")
443 );
444
386 handle->chat_scrolled_window = GTK_SCROLLED_WINDOW( 445 handle->chat_scrolled_window = GTK_SCROLLED_WINDOW(
387 gtk_builder_get_object(handle->builder, "chat_scrolled_window") 446 gtk_builder_get_object(handle->builder, "chat_scrolled_window")
388 ); 447 );
@@ -404,6 +463,20 @@ ui_chat_new(MESSENGER_Application *app)
404 463
405 g_signal_connect( 464 g_signal_connect(
406 handle->messages_listbox, 465 handle->messages_listbox,
466 "selected-rows-changed",
467 G_CALLBACK(handle_chat_messages_selected_rows_changed),
468 handle
469 );
470
471 g_signal_connect(
472 handle->selection_close_button,
473 "clicked",
474 G_CALLBACK(handle_chat_selection_close_button_click),
475 handle->messages_listbox
476 );
477
478 g_signal_connect(
479 handle->messages_listbox,
407 "size-allocate", 480 "size-allocate",
408 G_CALLBACK(handle_chat_messages_listbox_size_allocate), 481 G_CALLBACK(handle_chat_messages_listbox_size_allocate),
409 handle 482 handle
@@ -674,6 +747,7 @@ ui_chat_delete(UI_CHAT_Handle *handle)
674 747
675void 748void
676ui_chat_add_message(UI_CHAT_Handle *handle, 749ui_chat_add_message(UI_CHAT_Handle *handle,
750 GNUNET_UNUSED MESSENGER_Application *app,
677 UI_MESSAGE_Handle *message) 751 UI_MESSAGE_Handle *message)
678{ 752{
679 GNUNET_assert((handle) && (message)); 753 GNUNET_assert((handle) && (message));
@@ -688,6 +762,7 @@ ui_chat_add_message(UI_CHAT_Handle *handle,
688 762
689void 763void
690ui_chat_remove_message(UI_CHAT_Handle *handle, 764ui_chat_remove_message(UI_CHAT_Handle *handle,
765 GNUNET_UNUSED MESSENGER_Application *app,
691 UI_MESSAGE_Handle *message) 766 UI_MESSAGE_Handle *message)
692{ 767{
693 GNUNET_assert((handle) && (message)); 768 GNUNET_assert((handle) && (message));
diff --git a/src/ui/chat.h b/src/ui/chat.h
index 6ce6064..8b38db8 100644
--- a/src/ui/chat.h
+++ b/src/ui/chat.h
@@ -50,6 +50,10 @@ typedef struct UI_CHAT_Handle
50 50
51 HdyFlap *flap_chat_details; 51 HdyFlap *flap_chat_details;
52 52
53 GtkStack *chat_title_stack;
54 GtkWidget *title_box;
55 GtkWidget *selection_box;
56
53 GtkLabel *chat_title; 57 GtkLabel *chat_title;
54 GtkLabel *chat_subtitle; 58 GtkLabel *chat_subtitle;
55 59
@@ -62,6 +66,10 @@ typedef struct UI_CHAT_Handle
62 GtkButton *hide_chat_details_button; 66 GtkButton *hide_chat_details_button;
63 GtkBox *chat_details_contacts_box; 67 GtkBox *chat_details_contacts_box;
64 68
69 GtkButton *selection_close_button;
70 GtkLabel *selection_count_label;
71 GtkButton *selection_delete_button;
72
65 GtkScrolledWindow *chat_scrolled_window; 73 GtkScrolledWindow *chat_scrolled_window;
66 74
67 GtkListBox *chat_contacts_listbox; 75 GtkListBox *chat_contacts_listbox;
@@ -91,10 +99,12 @@ ui_chat_delete(UI_CHAT_Handle *handle);
91 99
92void 100void
93ui_chat_add_message(UI_CHAT_Handle *handle, 101ui_chat_add_message(UI_CHAT_Handle *handle,
102 MESSENGER_Application *app,
94 UI_MESSAGE_Handle *message); 103 UI_MESSAGE_Handle *message);
95 104
96void 105void
97ui_chat_remove_message(UI_CHAT_Handle *handle, 106ui_chat_remove_message(UI_CHAT_Handle *handle,
107 MESSENGER_Application *app,
98 UI_MESSAGE_Handle *message); 108 UI_MESSAGE_Handle *message);
99 109
100void 110void