aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-02-18 15:26:52 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-02-18 15:26:52 +0100
commit1bdb0791ee56fa081f8af1c18b457a1cf1c471fd (patch)
tree465b77924e9cfca7fe59a49437c9e784f515638e
parent394afaba0b6410c163b459404d36a805c3166d51 (diff)
downloadmessenger-gtk-1bdb0791ee56fa081f8af1c18b457a1cf1c471fd.tar.gz
messenger-gtk-1bdb0791ee56fa081f8af1c18b457a1cf1c471fd.zip
Added dialog to delete with custom delay
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--Makefile1
-rw-r--r--resources/ui.gresource.xml3
-rw-r--r--resources/ui/accounts.ui1
-rw-r--r--resources/ui/contacts.ui3
-rw-r--r--resources/ui/delete_messages.ui168
-rw-r--r--resources/ui/invite_contact.ui3
-rw-r--r--resources/ui/messenger.ui2
-rw-r--r--resources/ui/new_account.ui3
-rw-r--r--resources/ui/new_contact.ui3
-rw-r--r--resources/ui/new_group.ui3
-rw-r--r--resources/ui/new_platform.ui3
-rw-r--r--src/application.c4
-rw-r--r--src/application.h11
-rw-r--r--src/ui/accounts.c5
-rw-r--r--src/ui/chat.c50
-rw-r--r--src/ui/chat.h2
-rw-r--r--src/ui/contacts.c7
-rw-r--r--src/ui/delete_messages.c152
-rw-r--r--src/ui/delete_messages.h65
-rw-r--r--src/ui/invite_contact.c7
-rw-r--r--src/ui/messenger.c2
-rw-r--r--src/ui/new_account.c5
-rw-r--r--src/ui/new_contact.c5
-rw-r--r--src/ui/new_group.c7
-rw-r--r--src/ui/new_platform.c7
25 files changed, 458 insertions, 64 deletions
diff --git a/Makefile b/Makefile
index ff655d1..0ccef0c 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ SOURCES = messenger_gtk.c\
19 ui/chat.c\ 19 ui/chat.c\
20 ui/contact_entry.c\ 20 ui/contact_entry.c\
21 ui/contacts.c\ 21 ui/contacts.c\
22 ui/delete_messages.c\
22 ui/file_load_entry.c\ 23 ui/file_load_entry.c\
23 ui/invite_contact.c\ 24 ui/invite_contact.c\
24 ui/message.c\ 25 ui/message.c\
diff --git a/resources/ui.gresource.xml b/resources/ui.gresource.xml
index e0942e5..3a5e629 100644
--- a/resources/ui.gresource.xml
+++ b/resources/ui.gresource.xml
@@ -1,10 +1,12 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<gresources> 2<gresources>
3 <gresource prefix="/org/gnunet/Messenger"> 3 <gresource prefix="/org/gnunet/Messenger">
4 <file compressed="true">ui/accounts.ui</file>
4 <file compressed="true">ui/chat_entry.ui</file> 5 <file compressed="true">ui/chat_entry.ui</file>
5 <file compressed="true">ui/chat.ui</file> 6 <file compressed="true">ui/chat.ui</file>
6 <file compressed="true">ui/contact_entry.ui</file> 7 <file compressed="true">ui/contact_entry.ui</file>
7 <file compressed="true">ui/contacts.ui</file> 8 <file compressed="true">ui/contacts.ui</file>
9 <file compressed="true">ui/delete_messages.ui</file>
8 <file compressed="true">ui/file_load_entry.ui</file> 10 <file compressed="true">ui/file_load_entry.ui</file>
9 <file compressed="true">ui/invite_contact.ui</file> 11 <file compressed="true">ui/invite_contact.ui</file>
10 <file compressed="true">ui/message_content.ui</file> 12 <file compressed="true">ui/message_content.ui</file>
@@ -20,6 +22,5 @@
20 <file compressed="true">ui/account_entry.ui</file> 22 <file compressed="true">ui/account_entry.ui</file>
21 <file compressed="true">ui/send_file.ui</file> 23 <file compressed="true">ui/send_file.ui</file>
22 <file compressed="true">ui/settings.ui</file> 24 <file compressed="true">ui/settings.ui</file>
23 <file compressed="true">ui/accounts.ui</file>
24 </gresource> 25 </gresource>
25</gresources> 26</gresources>
diff --git a/resources/ui/accounts.ui b/resources/ui/accounts.ui
index bca34b6..5fe3390 100644
--- a/resources/ui/accounts.ui
+++ b/resources/ui/accounts.ui
@@ -24,6 +24,7 @@ Author: Tobias Frisch
24 <requires lib="gtk+" version="3.24"/> 24 <requires lib="gtk+" version="3.24"/>
25 <object class="GtkDialog" id="accounts_dialog"> 25 <object class="GtkDialog" id="accounts_dialog">
26 <property name="can-focus">False</property> 26 <property name="can-focus">False</property>
27 <property name="title" translatable="yes">Accounts</property>
27 <property name="modal">True</property> 28 <property name="modal">True</property>
28 <property name="window-position">center-on-parent</property> 29 <property name="window-position">center-on-parent</property>
29 <property name="type-hint">dialog</property> 30 <property name="type-hint">dialog</property>
diff --git a/resources/ui/contacts.ui b/resources/ui/contacts.ui
index 85da426..5fbdf5a 100644
--- a/resources/ui/contacts.ui
+++ b/resources/ui/contacts.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
@@ -24,6 +24,7 @@ Author: Tobias Frisch
24 <requires lib="gtk+" version="3.24"/> 24 <requires lib="gtk+" version="3.24"/>
25 <object class="GtkDialog" id="contacts_dialog"> 25 <object class="GtkDialog" id="contacts_dialog">
26 <property name="can-focus">False</property> 26 <property name="can-focus">False</property>
27 <property name="title" translatable="yes">Contacts</property>
27 <property name="modal">True</property> 28 <property name="modal">True</property>
28 <property name="window-position">center-on-parent</property> 29 <property name="window-position">center-on-parent</property>
29 <property name="type-hint">dialog</property> 30 <property name="type-hint">dialog</property>
diff --git a/resources/ui/delete_messages.ui b/resources/ui/delete_messages.ui
new file mode 100644
index 0000000..860f6ea
--- /dev/null
+++ b/resources/ui/delete_messages.ui
@@ -0,0 +1,168 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!-- Generated with glade 3.38.2 -->
3<interface>
4 <requires lib="gtk+" version="3.24"/>
5 <object class="GtkListStore" id="delay_store">
6 <columns>
7 <!-- column-name name -->
8 <column type="gchararray"/>
9 <!-- column-name value -->
10 <column type="gulong"/>
11 </columns>
12 <data>
13 <row>
14 <col id="0" translatable="yes">Off</col>
15 <col id="1">0</col>
16 </row>
17 <row>
18 <col id="0" translatable="yes">4 weeks</col>
19 <col id="1">2419200</col>
20 </row>
21 <row>
22 <col id="0" translatable="yes">1 week</col>
23 <col id="1">604800</col>
24 </row>
25 <row>
26 <col id="0" translatable="yes">1 day</col>
27 <col id="1">86400</col>
28 </row>
29 <row>
30 <col id="0" translatable="yes">8 hours</col>
31 <col id="1">28800</col>
32 </row>
33 <row>
34 <col id="0" translatable="yes">1 hour</col>
35 <col id="1">3600</col>
36 </row>
37 <row>
38 <col id="0" translatable="yes">5 minutes</col>
39 <col id="1">300</col>
40 </row>
41 <row>
42 <col id="0" translatable="yes">30 seconds</col>
43 <col id="1">30</col>
44 </row>
45 </data>
46 </object>
47 <object class="GtkDialog" id="delete_messages_dialog">
48 <property name="can-focus">False</property>
49 <property name="title" translatable="yes">Delete Messages</property>
50 <property name="modal">True</property>
51 <property name="window-position">center-on-parent</property>
52 <property name="type-hint">dialog</property>
53 <child internal-child="vbox">
54 <object class="GtkBox">
55 <property name="can-focus">False</property>
56 <property name="orientation">vertical</property>
57 <property name="spacing">2</property>
58 <child internal-child="action_area">
59 <object class="GtkButtonBox">
60 <property name="can-focus">False</property>
61 <property name="layout-style">end</property>
62 <child>
63 <object class="GtkButton" id="cancel_button">
64 <property name="label" translatable="yes">Cancel</property>
65 <property name="visible">True</property>
66 <property name="can-focus">True</property>
67 <property name="receives-default">True</property>
68 </object>
69 <packing>
70 <property name="expand">True</property>
71 <property name="fill">True</property>
72 <property name="position">0</property>
73 </packing>
74 </child>
75 <child>
76 <object class="GtkButton" id="confirm_button">
77 <property name="label" translatable="yes">Confirm</property>
78 <property name="visible">True</property>
79 <property name="can-focus">True</property>
80 <property name="receives-default">True</property>
81 </object>
82 <packing>
83 <property name="expand">True</property>
84 <property name="fill">True</property>
85 <property name="position">1</property>
86 </packing>
87 </child>
88 </object>
89 <packing>
90 <property name="expand">False</property>
91 <property name="fill">False</property>
92 <property name="position">0</property>
93 </packing>
94 </child>
95 <child>
96 <object class="GtkBox">
97 <property name="visible">True</property>
98 <property name="can-focus">False</property>
99 <property name="halign">center</property>
100 <property name="border-width">8</property>
101 <property name="orientation">vertical</property>
102 <property name="spacing">8</property>
103 <child>
104 <object class="GtkLabel">
105 <property name="visible">True</property>
106 <property name="can-focus">False</property>
107 <property name="label" translatable="yes">When do you want those messages to be deleted?</property>
108 <property name="wrap">True</property>
109 <property name="wrap-mode">word-char</property>
110 <property name="xalign">0</property>
111 </object>
112 <packing>
113 <property name="expand">False</property>
114 <property name="fill">True</property>
115 <property name="position">-1</property>
116 </packing>
117 </child>
118 <child>
119 <object class="GtkComboBox" id="delay_combobox">
120 <property name="visible">True</property>
121 <property name="can-focus">False</property>
122 <property name="model">delay_store</property>
123 <property name="active">0</property>
124 <child>
125 <object class="GtkCellRendererText"/>
126 <attributes>
127 <attribute name="text">0</attribute>
128 </attributes>
129 </child>
130 </object>
131 <packing>
132 <property name="expand">False</property>
133 <property name="fill">True</property>
134 <property name="position">1</property>
135 </packing>
136 </child>
137 <child>
138 <object class="GtkCheckButton" id="hide_checkbox">
139 <property name="visible">True</property>
140 <property name="can-focus">True</property>
141 <property name="receives-default">False</property>
142 <property name="draw-indicator">True</property>
143 <child>
144 <object class="GtkLabel">
145 <property name="visible">True</property>
146 <property name="can-focus">False</property>
147 <property name="label" translatable="yes">Hide this dialog in the future</property>
148 <property name="ellipsize">end</property>
149 </object>
150 </child>
151 </object>
152 <packing>
153 <property name="expand">False</property>
154 <property name="fill">True</property>
155 <property name="position">2</property>
156 </packing>
157 </child>
158 </object>
159 <packing>
160 <property name="expand">False</property>
161 <property name="fill">True</property>
162 <property name="position">1</property>
163 </packing>
164 </child>
165 </object>
166 </child>
167 </object>
168</interface>
diff --git a/resources/ui/invite_contact.ui b/resources/ui/invite_contact.ui
index 03c3dca..1575f70 100644
--- a/resources/ui/invite_contact.ui
+++ b/resources/ui/invite_contact.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
@@ -24,6 +24,7 @@ Author: Tobias Frisch
24 <requires lib="gtk+" version="3.24"/> 24 <requires lib="gtk+" version="3.24"/>
25 <object class="GtkDialog" id="invite_contact_dialog"> 25 <object class="GtkDialog" id="invite_contact_dialog">
26 <property name="can-focus">False</property> 26 <property name="can-focus">False</property>
27 <property name="title" translatable="yes">Invite Contact</property>
27 <property name="modal">True</property> 28 <property name="modal">True</property>
28 <property name="window-position">center-on-parent</property> 29 <property name="window-position">center-on-parent</property>
29 <property name="type-hint">dialog</property> 30 <property name="type-hint">dialog</property>
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui
index fdc8146..2f3cd8f 100644
--- a/resources/ui/messenger.ui
+++ b/resources/ui/messenger.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
diff --git a/resources/ui/new_account.ui b/resources/ui/new_account.ui
index 46d46f7..daa7f11 100644
--- a/resources/ui/new_account.ui
+++ b/resources/ui/new_account.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
@@ -25,6 +25,7 @@ Author: Tobias Frisch
25 <requires lib="libhandy" version="1.2"/> 25 <requires lib="libhandy" version="1.2"/>
26 <object class="GtkDialog" id="new_account_dialog"> 26 <object class="GtkDialog" id="new_account_dialog">
27 <property name="can-focus">False</property> 27 <property name="can-focus">False</property>
28 <property name="title" translatable="yes">New Account</property>
28 <property name="modal">True</property> 29 <property name="modal">True</property>
29 <property name="window-position">center-on-parent</property> 30 <property name="window-position">center-on-parent</property>
30 <property name="type-hint">dialog</property> 31 <property name="type-hint">dialog</property>
diff --git a/resources/ui/new_contact.ui b/resources/ui/new_contact.ui
index 25a90a9..8db0635 100644
--- a/resources/ui/new_contact.ui
+++ b/resources/ui/new_contact.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
@@ -24,6 +24,7 @@ Author: Tobias Frisch
24 <requires lib="gtk+" version="3.24"/> 24 <requires lib="gtk+" version="3.24"/>
25 <object class="GtkDialog" id="new_contact_dialog"> 25 <object class="GtkDialog" id="new_contact_dialog">
26 <property name="can-focus">False</property> 26 <property name="can-focus">False</property>
27 <property name="title" translatable="yes">New Contact</property>
27 <property name="modal">True</property> 28 <property name="modal">True</property>
28 <property name="window-position">center-on-parent</property> 29 <property name="window-position">center-on-parent</property>
29 <property name="type-hint">dialog</property> 30 <property name="type-hint">dialog</property>
diff --git a/resources/ui/new_group.ui b/resources/ui/new_group.ui
index c6439ae..009c218 100644
--- a/resources/ui/new_group.ui
+++ b/resources/ui/new_group.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
@@ -25,6 +25,7 @@ Author: Tobias Frisch
25 <requires lib="libhandy" version="1.2"/> 25 <requires lib="libhandy" version="1.2"/>
26 <object class="GtkDialog" id="new_group_dialog"> 26 <object class="GtkDialog" id="new_group_dialog">
27 <property name="can-focus">False</property> 27 <property name="can-focus">False</property>
28 <property name="title" translatable="yes">New Group</property>
28 <property name="modal">True</property> 29 <property name="modal">True</property>
29 <property name="window-position">center-on-parent</property> 30 <property name="window-position">center-on-parent</property>
30 <property name="type-hint">dialog</property> 31 <property name="type-hint">dialog</property>
diff --git a/resources/ui/new_platform.ui b/resources/ui/new_platform.ui
index 0f4e057..19aa01f 100644
--- a/resources/ui/new_platform.ui
+++ b/resources/ui/new_platform.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
@@ -25,6 +25,7 @@ Author: Tobias Frisch
25 <requires lib="libhandy" version="1.2"/> 25 <requires lib="libhandy" version="1.2"/>
26 <object class="GtkDialog" id="new_platform_dialog"> 26 <object class="GtkDialog" id="new_platform_dialog">
27 <property name="can-focus">False</property> 27 <property name="can-focus">False</property>
28 <property name="title" translatable="yes">New Platform</property>
28 <property name="modal">True</property> 29 <property name="modal">True</property>
29 <property name="window-position">center-on-parent</property> 30 <property name="window-position">center-on-parent</property>
30 <property name="type-hint">dialog</property> 31 <property name="type-hint">dialog</property>
diff --git a/src/application.c b/src/application.c
index 74e8bd4..f8a1274 100644
--- a/src/application.c
+++ b/src/application.c
@@ -99,8 +99,6 @@ application_init(MESSENGER_Application *app,
99 99
100 pthread_mutex_init(&(app->chat.mutex), NULL); 100 pthread_mutex_init(&(app->chat.mutex), NULL);
101 101
102 app->ui.mobile = FALSE;
103
104 app->ui.bindings = g_hash_table_new(g_direct_hash, g_direct_equal); 102 app->ui.bindings = g_hash_table_new(g_direct_hash, g_direct_equal);
105 103
106 g_application_add_main_option( 104 g_application_add_main_option(
@@ -155,7 +153,7 @@ _application_chat_thread(void *args)
155 'm', 153 'm',
156 "mobile", 154 "mobile",
157 "Optimize UI spacing for mobile devices", 155 "Optimize UI spacing for mobile devices",
158 &(app->ui.mobile) 156 &(app->settings.mobile_design)
159 ), 157 ),
160 GNUNET_GETOPT_option_string ( 158 GNUNET_GETOPT_option_string (
161 'e', 159 'e',
diff --git a/src/application.h b/src/application.h
index d7be05a..8e3e51a 100644
--- a/src/application.h
+++ b/src/application.h
@@ -32,6 +32,7 @@
32 32
33#include "ui/accounts.h" 33#include "ui/accounts.h"
34#include "ui/contacts.h" 34#include "ui/contacts.h"
35#include "ui/delete_messages.h"
35#include "ui/invite_contact.h" 36#include "ui/invite_contact.h"
36#include "ui/messenger.h" 37#include "ui/messenger.h"
37#include "ui/new_account.h" 38#include "ui/new_account.h"
@@ -71,7 +72,6 @@ typedef struct MESSENGER_Application
71 72
72 struct { 73 struct {
73 int status; 74 int status;
74 gboolean mobile;
75 75
76 GHashTable *bindings; 76 GHashTable *bindings;
77 77
@@ -79,6 +79,7 @@ typedef struct MESSENGER_Application
79 79
80 UI_INVITE_CONTACT_Handle invite_contact; 80 UI_INVITE_CONTACT_Handle invite_contact;
81 UI_SEND_FILE_Handle send_file; 81 UI_SEND_FILE_Handle send_file;
82 UI_DELETE_MESSAGES_Handle delete_messages;
82 83
83 UI_NEW_CONTACT_Handle new_contact; 84 UI_NEW_CONTACT_Handle new_contact;
84 UI_NEW_GROUP_Handle new_group; 85 UI_NEW_GROUP_Handle new_group;
@@ -89,6 +90,14 @@ typedef struct MESSENGER_Application
89 UI_CONTACTS_Handle contacts; 90 UI_CONTACTS_Handle contacts;
90 UI_SETTINGS_Handle settings; 91 UI_SETTINGS_Handle settings;
91 } ui; 92 } ui;
93
94 struct {
95 gboolean mobile_design;
96 gboolean hide_delete_dialog;
97 gboolean disable_notifications;
98 gboolean accept_all_files;
99 gboolean accept_all_invites;
100 } settings;
92} MESSENGER_Application; 101} MESSENGER_Application;
93 102
94void 103void
diff --git a/src/ui/accounts.c b/src/ui/accounts.c
index f89244f..1817180 100644
--- a/src/ui/accounts.c
+++ b/src/ui/accounts.c
@@ -148,11 +148,6 @@ ui_accounts_dialog_init(MESSENGER_Application *app,
148 gtk_builder_get_object(handle->builder, "accounts_dialog") 148 gtk_builder_get_object(handle->builder, "accounts_dialog")
149 ); 149 );
150 150
151 gtk_window_set_title(
152 GTK_WINDOW(handle->dialog),
153 _("Accounts")
154 );
155
156 gtk_window_set_transient_for( 151 gtk_window_set_transient_for(
157 GTK_WINDOW(handle->dialog), 152 GTK_WINDOW(handle->dialog),
158 GTK_WINDOW(app->ui.messenger.main_window) 153 GTK_WINDOW(app->ui.messenger.main_window)
diff --git a/src/ui/chat.c b/src/ui/chat.c
index 72d75b0..4fe4735 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -33,6 +33,7 @@
33#include "../application.h" 33#include "../application.h"
34#include "../contact.h" 34#include "../contact.h"
35#include "account_entry.h" 35#include "account_entry.h"
36#include "delete_messages.h"
36 37
37static gboolean 38static gboolean
38_flap_reveal_switch(gpointer user_data) 39_flap_reveal_switch(gpointer user_data)
@@ -214,13 +215,11 @@ handle_chat_selection_close_button_click(UNUSED GtkButton *button,
214 gtk_list_box_unselect_all(listbox); 215 gtk_list_box_unselect_all(listbox);
215} 216}
216 217
217static void 218void
218handle_chat_selection_delete_button_click(UNUSED GtkButton *button, 219_delete_messages_callback(GHashTable *bindings,
219 gpointer user_data) 220 GList *selected,
221 gulong delay)
220{ 222{
221 UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
222
223 GList *selected = gtk_list_box_get_selected_rows(handle->messages_listbox);
224 UI_MESSAGE_Handle *message; 223 UI_MESSAGE_Handle *message;
225 224
226 while (selected) 225 while (selected)
@@ -230,14 +229,17 @@ handle_chat_selection_delete_button_click(UNUSED GtkButton *button,
230 if (!row) 229 if (!row)
231 goto skip_row; 230 goto skip_row;
232 231
233 message = g_hash_table_lookup(handle->bindings, row); 232 message = g_hash_table_lookup(bindings, row);
234 233
235 if ((!message) || (!(message->msg))) 234 if ((!message) || (!(message->msg)))
236 goto skip_row; 235 goto skip_row;
237 236
238 GNUNET_CHAT_message_delete( 237 GNUNET_CHAT_message_delete(
239 message->msg, 238 message->msg,
240 GNUNET_TIME_relative_get_zero_() 239 GNUNET_TIME_relative_multiply(
240 GNUNET_TIME_relative_get_second_(),
241 delay
242 )
241 ); 243 );
242 244
243 skip_row: 245 skip_row:
@@ -246,6 +248,32 @@ handle_chat_selection_delete_button_click(UNUSED GtkButton *button,
246} 248}
247 249
248static void 250static void
251handle_chat_selection_delete_button_click(UNUSED GtkButton *button,
252 gpointer user_data)
253{
254 UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
255
256 MESSENGER_Application *app = handle->app;
257
258 GList *selected = gtk_list_box_get_selected_rows(handle->messages_listbox);
259
260 if (app->settings.hide_delete_dialog)
261 _delete_messages_callback(app->ui.bindings, selected, 0);
262 else
263 {
264 ui_delete_messages_dialog_init(app, &(app->ui.delete_messages));
265
266 ui_delete_messages_dialog_link(
267 &(app->ui.delete_messages),
268 _delete_messages_callback,
269 selected
270 );
271
272 gtk_widget_show(GTK_WIDGET(app->ui.delete_messages.dialog));
273 }
274}
275
276static void
249handle_attach_file_button_click(GtkButton *button, 277handle_attach_file_button_click(GtkButton *button,
250 gpointer user_data) 278 gpointer user_data)
251{ 279{
@@ -366,7 +394,7 @@ handle_send_text_key_press (GtkWidget *widget,
366{ 394{
367 MESSENGER_Application *app = (MESSENGER_Application*) user_data; 395 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
368 396
369 if ((app->ui.mobile) || 397 if ((app->settings.mobile_design) ||
370 (event->state & GDK_SHIFT_MASK) || 398 (event->state & GDK_SHIFT_MASK) ||
371 ((event->keyval != GDK_KEY_Return) && 399 ((event->keyval != GDK_KEY_Return) &&
372 (event->keyval != GDK_KEY_KP_Enter))) 400 (event->keyval != GDK_KEY_KP_Enter)))
@@ -393,7 +421,7 @@ ui_chat_new(MESSENGER_Application *app)
393 UI_CHAT_Handle *handle = g_malloc(sizeof(UI_CHAT_Handle)); 421 UI_CHAT_Handle *handle = g_malloc(sizeof(UI_CHAT_Handle));
394 UI_MESSENGER_Handle *messenger = &(app->ui.messenger); 422 UI_MESSENGER_Handle *messenger = &(app->ui.messenger);
395 423
396 handle->bindings = app->ui.bindings; 424 handle->app = app;
397 425
398 handle->messages = NULL; 426 handle->messages = NULL;
399 handle->edge_value = 0; 427 handle->edge_value = 0;
diff --git a/src/ui/chat.h b/src/ui/chat.h
index b27f829..2c33789 100644
--- a/src/ui/chat.h
+++ b/src/ui/chat.h
@@ -38,7 +38,7 @@ typedef struct UI_FILE_LOAD_ENTRY_Handle UI_FILE_LOAD_ENTRY_Handle;
38 38
39typedef struct UI_CHAT_Handle 39typedef struct UI_CHAT_Handle
40{ 40{
41 GHashTable *bindings; 41 MESSENGER_Application *app;
42 42
43 GList *messages; 43 GList *messages;
44 gdouble edge_value; 44 gdouble edge_value;
diff --git a/src/ui/contacts.c b/src/ui/contacts.c
index ad46773..2e3b0ec 100644
--- a/src/ui/contacts.c
+++ b/src/ui/contacts.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021--2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -188,11 +188,6 @@ ui_contacts_dialog_init(MESSENGER_Application *app,
188 gtk_builder_get_object(handle->builder, "contacts_dialog") 188 gtk_builder_get_object(handle->builder, "contacts_dialog")
189 ); 189 );
190 190
191 gtk_window_set_title(
192 GTK_WINDOW(handle->dialog),
193 _("Contacts")
194 );
195
196 gtk_window_set_transient_for( 191 gtk_window_set_transient_for(
197 GTK_WINDOW(handle->dialog), 192 GTK_WINDOW(handle->dialog),
198 GTK_WINDOW(app->ui.messenger.main_window) 193 GTK_WINDOW(app->ui.messenger.main_window)
diff --git a/src/ui/delete_messages.c b/src/ui/delete_messages.c
new file mode 100644
index 0000000..df75484
--- /dev/null
+++ b/src/ui/delete_messages.c
@@ -0,0 +1,152 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/*
21 * @author Tobias Frisch
22 * @file ui/delete_messages.c
23 */
24
25#include "delete_messages.h"
26
27#include "../application.h"
28
29static void
30handle_cancel_button_click(UNUSED GtkButton *button,
31 gpointer user_data)
32{
33 GtkDialog *dialog = GTK_DIALOG(user_data);
34 gtk_window_close(GTK_WINDOW(dialog));
35}
36
37static void
38handle_confirm_button_click(UNUSED GtkButton *button,
39 gpointer user_data)
40{
41 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
42
43 app->settings.hide_delete_dialog = gtk_toggle_button_get_active(
44 GTK_TOGGLE_BUTTON(app->ui.delete_messages.hide_checkbox)
45 );
46
47 GtkTreeModel *model = gtk_combo_box_get_model(
48 app->ui.delete_messages.delay_combobox
49 );
50
51 gulong delay = 0;
52
53 GtkTreeIter iter;
54 if (gtk_combo_box_get_active_iter(app->ui.delete_messages.delay_combobox,
55 &iter))
56 gtk_tree_model_get(model, &iter, 1, &delay, -1);
57
58 if (app->ui.delete_messages.callback)
59 app->ui.delete_messages.callback(
60 app->ui.bindings,
61 app->ui.delete_messages.selected,
62 delay
63 );
64
65 gtk_window_close(GTK_WINDOW(app->ui.delete_messages.dialog));
66}
67
68static void
69handle_dialog_destroy(UNUSED GtkWidget *window,
70 gpointer user_data)
71{
72 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
73
74 ui_delete_messages_dialog_cleanup(&(app->ui.delete_messages));
75}
76
77void
78ui_delete_messages_dialog_init(MESSENGER_Application *app,
79 UI_DELETE_MESSAGES_Handle *handle)
80{
81 handle->selected = NULL;
82 handle->callback = NULL;
83
84 handle->builder = gtk_builder_new_from_resource(
85 application_get_resource_path(app, "ui/delete_messages.ui")
86 );
87
88 handle->dialog = GTK_DIALOG(
89 gtk_builder_get_object(handle->builder, "delete_messages_dialog")
90 );
91
92 gtk_window_set_transient_for(
93 GTK_WINDOW(handle->dialog),
94 GTK_WINDOW(app->ui.messenger.main_window)
95 );
96
97 handle->delay_store = GTK_LIST_STORE(
98 gtk_builder_get_object(handle->builder, "delay_store")
99 );
100
101 handle->delay_combobox = GTK_COMBO_BOX(
102 gtk_builder_get_object(handle->builder, "delay_combobox")
103 );
104
105 handle->hide_checkbox = GTK_CHECK_BUTTON(
106 gtk_builder_get_object(handle->builder, "hide_checkbox")
107 );
108
109 handle->cancel_button = GTK_BUTTON(
110 gtk_builder_get_object(handle->builder, "cancel_button")
111 );
112
113 g_signal_connect(
114 handle->cancel_button,
115 "clicked",
116 G_CALLBACK(handle_cancel_button_click),
117 handle->dialog
118 );
119
120 handle->confirm_button = GTK_BUTTON(
121 gtk_builder_get_object(handle->builder, "confirm_button")
122 );
123
124 g_signal_connect(
125 handle->confirm_button,
126 "clicked",
127 G_CALLBACK(handle_confirm_button_click),
128 app
129 );
130
131 g_signal_connect(
132 handle->dialog,
133 "destroy",
134 G_CALLBACK(handle_dialog_destroy),
135 app
136 );
137}
138
139void
140ui_delete_messages_dialog_link(UI_DELETE_MESSAGES_Handle *handle,
141 UI_DELETE_MESSAGES_Callback callback,
142 GList *selected)
143{
144 handle->selected = selected;
145 handle->callback = callback;
146}
147
148void
149ui_delete_messages_dialog_cleanup(UI_DELETE_MESSAGES_Handle *handle)
150{
151 g_object_unref(handle->builder);
152}
diff --git a/src/ui/delete_messages.h b/src/ui/delete_messages.h
new file mode 100644
index 0000000..9cf9949
--- /dev/null
+++ b/src/ui/delete_messages.h
@@ -0,0 +1,65 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/*
21 * @author Tobias Frisch
22 * @file ui/delete_messages.h
23 */
24
25#ifndef UI_DELETE_MESSAGES_H_
26#define UI_DELETE_MESSAGES_H_
27
28#include "messenger.h"
29
30typedef void
31(*UI_DELETE_MESSAGES_Callback) (GHashTable *bindings,
32 GList *selected,
33 gulong delay);
34
35typedef struct UI_DELETE_MESSAGES_Handle
36{
37 GList *selected;
38
39 UI_DELETE_MESSAGES_Callback callback;
40
41 GtkBuilder *builder;
42 GtkDialog *dialog;
43
44 GtkListStore *delay_store;
45
46 GtkComboBox *delay_combobox;
47 GtkCheckButton *hide_checkbox;
48
49 GtkButton *cancel_button;
50 GtkButton *confirm_button;
51} UI_DELETE_MESSAGES_Handle;
52
53void
54ui_delete_messages_dialog_init(MESSENGER_Application *app,
55 UI_DELETE_MESSAGES_Handle *handle);
56
57void
58ui_delete_messages_dialog_link(UI_DELETE_MESSAGES_Handle *handle,
59 UI_DELETE_MESSAGES_Callback callback,
60 GList *selected);
61
62void
63ui_delete_messages_dialog_cleanup(UI_DELETE_MESSAGES_Handle *handle);
64
65#endif /* UI_DELETE_MESSAGES_H_ */
diff --git a/src/ui/invite_contact.c b/src/ui/invite_contact.c
index 8e18860..3afeee0 100644
--- a/src/ui/invite_contact.c
+++ b/src/ui/invite_contact.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021--2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -180,11 +180,6 @@ ui_invite_contact_dialog_init(MESSENGER_Application *app,
180 gtk_builder_get_object(handle->builder, "invite_contact_dialog") 180 gtk_builder_get_object(handle->builder, "invite_contact_dialog")
181 ); 181 );
182 182
183 gtk_window_set_title(
184 GTK_WINDOW(handle->dialog),
185 _("Invite Contact")
186 );
187
188 gtk_window_set_transient_for( 183 gtk_window_set_transient_for(
189 GTK_WINDOW(handle->dialog), 184 GTK_WINDOW(handle->dialog),
190 GTK_WINDOW(app->ui.messenger.main_window) 185 GTK_WINDOW(app->ui.messenger.main_window)
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index 058fcbf..c031b1b 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -308,7 +308,7 @@ ui_messenger_init(MESSENGER_Application *app,
308 G_BINDING_INVERT_BOOLEAN 308 G_BINDING_INVERT_BOOLEAN
309 ); 309 );
310 310
311 if (app->ui.mobile) 311 if (app->settings.mobile_design)
312 g_object_bind_property( 312 g_object_bind_property(
313 handle->leaflet_chat, 313 handle->leaflet_chat,
314 "folded", 314 "folded",
diff --git a/src/ui/new_account.c b/src/ui/new_account.c
index fdc53ff..6642261 100644
--- a/src/ui/new_account.c
+++ b/src/ui/new_account.c
@@ -123,11 +123,6 @@ ui_new_account_dialog_init(MESSENGER_Application *app,
123 gtk_builder_get_object(handle->builder, "new_account_dialog") 123 gtk_builder_get_object(handle->builder, "new_account_dialog")
124 ); 124 );
125 125
126 gtk_window_set_title(
127 GTK_WINDOW(handle->dialog),
128 _("New Account")
129 );
130
131 gtk_window_set_transient_for( 126 gtk_window_set_transient_for(
132 GTK_WINDOW(handle->dialog), 127 GTK_WINDOW(handle->dialog),
133 GTK_WINDOW(app->ui.messenger.main_window) 128 GTK_WINDOW(app->ui.messenger.main_window)
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c
index 0713aa9..8188740 100644
--- a/src/ui/new_contact.c
+++ b/src/ui/new_contact.c
@@ -295,11 +295,6 @@ ui_new_contact_dialog_init(MESSENGER_Application *app,
295 gtk_builder_get_object(handle->builder, "new_contact_dialog") 295 gtk_builder_get_object(handle->builder, "new_contact_dialog")
296 ); 296 );
297 297
298 gtk_window_set_title(
299 GTK_WINDOW(handle->dialog),
300 _("New Contact")
301 );
302
303 gtk_window_set_transient_for( 298 gtk_window_set_transient_for(
304 GTK_WINDOW(handle->dialog), 299 GTK_WINDOW(handle->dialog),
305 GTK_WINDOW(app->ui.messenger.main_window) 300 GTK_WINDOW(app->ui.messenger.main_window)
diff --git a/src/ui/new_group.c b/src/ui/new_group.c
index dbad66b..59199dc 100644
--- a/src/ui/new_group.c
+++ b/src/ui/new_group.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021--2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -206,11 +206,6 @@ ui_new_group_dialog_init(MESSENGER_Application *app,
206 gtk_builder_get_object(handle->builder, "new_group_dialog") 206 gtk_builder_get_object(handle->builder, "new_group_dialog")
207 ); 207 );
208 208
209 gtk_window_set_title(
210 GTK_WINDOW(handle->dialog),
211 _("New Group")
212 );
213
214 gtk_window_set_transient_for( 209 gtk_window_set_transient_for(
215 GTK_WINDOW(handle->dialog), 210 GTK_WINDOW(handle->dialog),
216 GTK_WINDOW(app->ui.messenger.main_window) 211 GTK_WINDOW(app->ui.messenger.main_window)
diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c
index 544b7c7..8611432 100644
--- a/src/ui/new_platform.c
+++ b/src/ui/new_platform.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021--2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -108,11 +108,6 @@ ui_new_platform_dialog_init(MESSENGER_Application *app,
108 gtk_builder_get_object(handle->builder, "new_platform_dialog") 108 gtk_builder_get_object(handle->builder, "new_platform_dialog")
109 ); 109 );
110 110
111 gtk_window_set_title(
112 GTK_WINDOW(handle->dialog),
113 _("New Platform")
114 );
115
116 gtk_window_set_transient_for( 111 gtk_window_set_transient_for(
117 GTK_WINDOW(handle->dialog), 112 GTK_WINDOW(handle->dialog),
118 GTK_WINDOW(app->ui.messenger.main_window) 113 GTK_WINDOW(app->ui.messenger.main_window)