aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-12-07 00:29:59 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-12-07 00:29:59 +0100
commit141e52eab14ae9f48844e175bc150753c8e3f002 (patch)
tree85167f6954fb962f628bcabe12bc92274eee678c
parent53334c28a6a97e480299c6cef1e2e0402b4265ed (diff)
downloadmessenger-gtk-141e52eab14ae9f48844e175bc150753c8e3f002.tar.gz
messenger-gtk-141e52eab14ae9f48844e175bc150753c8e3f002.zip
Deactivated chats without other members
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--resources/ui/chat.ui5
-rw-r--r--src/event.c5
-rw-r--r--src/ui/chat.c11
-rw-r--r--src/ui/chat.h3
-rw-r--r--src/ui/chat_entry.c6
-rw-r--r--src/ui/chat_entry.h3
-rw-r--r--src/ui/contacts.c45
7 files changed, 36 insertions, 42 deletions
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui
index f6e8cc8..ca93f9d 100644
--- a/resources/ui/chat.ui
+++ b/resources/ui/chat.ui
@@ -195,6 +195,7 @@ Author: Tobias Frisch
195 <child> 195 <child>
196 <object class="GtkButton" id="attach_file_button"> 196 <object class="GtkButton" id="attach_file_button">
197 <property name="visible">True</property> 197 <property name="visible">True</property>
198 <property name="sensitive">False</property>
198 <property name="can-focus">True</property> 199 <property name="can-focus">True</property>
199 <property name="receives-default">True</property> 200 <property name="receives-default">True</property>
200 <property name="valign">center</property> 201 <property name="valign">center</property>
@@ -218,8 +219,10 @@ Author: Tobias Frisch
218 <property name="width-request">210</property> 219 <property name="width-request">210</property>
219 <property name="height-request">48</property> 220 <property name="height-request">48</property>
220 <property name="visible">True</property> 221 <property name="visible">True</property>
222 <property name="sensitive">False</property>
221 <property name="can-focus">True</property> 223 <property name="can-focus">True</property>
222 <property name="valign">end</property> 224 <property name="valign">end</property>
225 <property name="editable">False</property>
223 <property name="wrap-mode">word-char</property> 226 <property name="wrap-mode">word-char</property>
224 <property name="left-margin">8</property> 227 <property name="left-margin">8</property>
225 <property name="right-margin">8</property> 228 <property name="right-margin">8</property>
@@ -236,6 +239,7 @@ Author: Tobias Frisch
236 <child> 239 <child>
237 <object class="GtkButton" id="emoji_button"> 240 <object class="GtkButton" id="emoji_button">
238 <property name="visible">True</property> 241 <property name="visible">True</property>
242 <property name="sensitive">False</property>
239 <property name="can-focus">True</property> 243 <property name="can-focus">True</property>
240 <property name="receives-default">True</property> 244 <property name="receives-default">True</property>
241 <property name="valign">center</property> 245 <property name="valign">center</property>
@@ -257,6 +261,7 @@ Author: Tobias Frisch
257 <child> 261 <child>
258 <object class="GtkButton" id="send_record_button"> 262 <object class="GtkButton" id="send_record_button">
259 <property name="visible">True</property> 263 <property name="visible">True</property>
264 <property name="sensitive">False</property>
260 <property name="can-focus">True</property> 265 <property name="can-focus">True</property>
261 <property name="receives-default">True</property> 266 <property name="receives-default">True</property>
262 <property name="valign">center</property> 267 <property name="valign">center</property>
diff --git a/src/event.c b/src/event.c
index dfc7b8e..a1cb4fc 100644
--- a/src/event.c
+++ b/src/event.c
@@ -181,6 +181,11 @@ event_joining_contact(MESSENGER_Application *app,
181 if (!handle) 181 if (!handle)
182 return; 182 return;
183 183
184 int status = GNUNET_CHAT_context_get_status(context);
185
186 if (GNUNET_OK == status)
187 ui_chat_entry_activate(handle);
188
184 UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); 189 UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS);
185 190
186 const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( 191 const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender(
diff --git a/src/ui/chat.c b/src/ui/chat.c
index 42943c3..73e014c 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -272,6 +272,17 @@ ui_chat_new(MESSENGER_Application *app)
272} 272}
273 273
274void 274void
275ui_chat_activate(UI_CHAT_Handle *handle)
276{
277 gtk_text_view_set_editable(handle->send_text_view, TRUE);
278 gtk_widget_set_sensitive(GTK_WIDGET(handle->send_text_view), TRUE);
279
280 gtk_widget_set_sensitive(GTK_WIDGET(handle->attach_file_button), TRUE);
281 gtk_widget_set_sensitive(GTK_WIDGET(handle->emoji_button), TRUE);
282 gtk_widget_set_sensitive(GTK_WIDGET(handle->send_record_button), TRUE);
283}
284
285void
275ui_chat_delete(UI_CHAT_Handle *handle) 286ui_chat_delete(UI_CHAT_Handle *handle)
276{ 287{
277 ui_picker_delete(handle->picker); 288 ui_picker_delete(handle->picker);
diff --git a/src/ui/chat.h b/src/ui/chat.h
index 77e4553..68b2eb3 100644
--- a/src/ui/chat.h
+++ b/src/ui/chat.h
@@ -60,6 +60,9 @@ UI_CHAT_Handle*
60ui_chat_new(MESSENGER_Application *app); 60ui_chat_new(MESSENGER_Application *app);
61 61
62void 62void
63ui_chat_activate(UI_CHAT_Handle *handle);
64
65void
63ui_chat_delete(UI_CHAT_Handle *handle); 66ui_chat_delete(UI_CHAT_Handle *handle);
64 67
65#endif /* UI_CHAT_H_ */ 68#endif /* UI_CHAT_H_ */
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c
index 21b793e..33d969c 100644
--- a/src/ui/chat_entry.c
+++ b/src/ui/chat_entry.c
@@ -62,6 +62,12 @@ ui_chat_entry_new(MESSENGER_Application *app)
62} 62}
63 63
64void 64void
65ui_chat_entry_activate(UI_CHAT_ENTRY_Handle *handle)
66{
67 ui_chat_activate(handle->chat);
68}
69
70void
65ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle) 71ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle)
66{ 72{
67 ui_chat_delete(handle->chat); 73 ui_chat_delete(handle->chat);
diff --git a/src/ui/chat_entry.h b/src/ui/chat_entry.h
index 48f3116..743429a 100644
--- a/src/ui/chat_entry.h
+++ b/src/ui/chat_entry.h
@@ -47,6 +47,9 @@ UI_CHAT_ENTRY_Handle*
47ui_chat_entry_new(MESSENGER_Application *app); 47ui_chat_entry_new(MESSENGER_Application *app);
48 48
49void 49void
50ui_chat_entry_activate(UI_CHAT_ENTRY_Handle *handle);
51
52void
50ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle); 53ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle);
51 54
52#endif /* UI_CHAT_ENTRY_H_ */ 55#endif /* UI_CHAT_ENTRY_H_ */
diff --git a/src/ui/contacts.c b/src/ui/contacts.c
index 1a9b83b..842cfb5 100644
--- a/src/ui/contacts.c
+++ b/src/ui/contacts.c
@@ -71,50 +71,11 @@ handle_contacts_listbox_row_activated(UNUSED GtkListBox* listbox,
71 contact 71 contact
72 ); 72 );
73 73
74 UI_MESSENGER_Handle *ui = &(app->ui.messenger); 74 if (!context)
75
76 char context_id [9];
77 g_snprintf(context_id, sizeof(context_id), "%08lx", (gulong) context);
78
79 if (gtk_stack_get_child_by_name(ui->chats_stack, context_id))
80 goto close_dialog; 75 goto close_dialog;
81 76
82 const char *title = GNUNET_CHAT_contact_get_name(contact); 77 if (GNUNET_SYSERR == GNUNET_CHAT_context_get_status(context))
83 78 GNUNET_CHAT_context_request(context);
84 UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(app);
85 gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box);
86 GNUNET_CHAT_context_set_user_pointer(context, entry);
87
88 if (title)
89 {
90 gtk_label_set_text(entry->title_label, title);
91 hdy_avatar_set_text(entry->entry_avatar, title);
92
93 gtk_label_set_text(entry->chat->chat_title, title);
94 }
95
96 gtk_widget_set_name(entry->entry_box, context_id);
97
98 gtk_stack_add_named(
99 ui->chats_stack,
100 entry->chat->chat_box,
101 context_id
102 );
103
104 g_hash_table_insert(
105 app->ui.bindings,
106 entry->chat->send_text_view,
107 context
108 );
109
110 ui->chat_entries = g_list_append(ui->chat_entries, entry);
111
112 GtkListBoxRow *entry_row = GTK_LIST_BOX_ROW(
113 gtk_widget_get_parent(entry->entry_box)
114 );
115
116 gtk_list_box_select_row(ui->chats_listbox, entry_row);
117 gtk_widget_activate(GTK_WIDGET(entry_row));
118 79
119close_dialog: 80close_dialog:
120 gtk_window_close(GTK_WINDOW(app->ui.contacts.dialog)); 81 gtk_window_close(GTK_WINDOW(app->ui.contacts.dialog));