messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit 141e52eab14ae9f48844e175bc150753c8e3f002
parent 53334c28a6a97e480299c6cef1e2e0402b4265ed
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Tue,  7 Dec 2021 00:29:59 +0100

Deactivated chats without other members

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Mresources/ui/chat.ui | 5+++++
Msrc/event.c | 5+++++
Msrc/ui/chat.c | 11+++++++++++
Msrc/ui/chat.h | 3+++
Msrc/ui/chat_entry.c | 6++++++
Msrc/ui/chat_entry.h | 3+++
Msrc/ui/contacts.c | 45+++------------------------------------------
7 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui @@ -195,6 +195,7 @@ Author: Tobias Frisch <child> <object class="GtkButton" id="attach_file_button"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">True</property> <property name="receives-default">True</property> <property name="valign">center</property> @@ -218,8 +219,10 @@ Author: Tobias Frisch <property name="width-request">210</property> <property name="height-request">48</property> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">True</property> <property name="valign">end</property> + <property name="editable">False</property> <property name="wrap-mode">word-char</property> <property name="left-margin">8</property> <property name="right-margin">8</property> @@ -236,6 +239,7 @@ Author: Tobias Frisch <child> <object class="GtkButton" id="emoji_button"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">True</property> <property name="receives-default">True</property> <property name="valign">center</property> @@ -257,6 +261,7 @@ Author: Tobias Frisch <child> <object class="GtkButton" id="send_record_button"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">True</property> <property name="receives-default">True</property> <property name="valign">center</property> diff --git a/src/event.c b/src/event.c @@ -181,6 +181,11 @@ event_joining_contact(MESSENGER_Application *app, if (!handle) return; + int status = GNUNET_CHAT_context_get_status(context); + + if (GNUNET_OK == status) + ui_chat_entry_activate(handle); + UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( diff --git a/src/ui/chat.c b/src/ui/chat.c @@ -272,6 +272,17 @@ ui_chat_new(MESSENGER_Application *app) } void +ui_chat_activate(UI_CHAT_Handle *handle) +{ + gtk_text_view_set_editable(handle->send_text_view, TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(handle->send_text_view), TRUE); + + gtk_widget_set_sensitive(GTK_WIDGET(handle->attach_file_button), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(handle->emoji_button), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(handle->send_record_button), TRUE); +} + +void ui_chat_delete(UI_CHAT_Handle *handle) { ui_picker_delete(handle->picker); diff --git a/src/ui/chat.h b/src/ui/chat.h @@ -60,6 +60,9 @@ UI_CHAT_Handle* ui_chat_new(MESSENGER_Application *app); void +ui_chat_activate(UI_CHAT_Handle *handle); + +void ui_chat_delete(UI_CHAT_Handle *handle); #endif /* UI_CHAT_H_ */ diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c @@ -62,6 +62,12 @@ ui_chat_entry_new(MESSENGER_Application *app) } void +ui_chat_entry_activate(UI_CHAT_ENTRY_Handle *handle) +{ + ui_chat_activate(handle->chat); +} + +void ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle) { ui_chat_delete(handle->chat); diff --git a/src/ui/chat_entry.h b/src/ui/chat_entry.h @@ -47,6 +47,9 @@ UI_CHAT_ENTRY_Handle* ui_chat_entry_new(MESSENGER_Application *app); void +ui_chat_entry_activate(UI_CHAT_ENTRY_Handle *handle); + +void ui_chat_entry_delete(UI_CHAT_ENTRY_Handle *handle); #endif /* UI_CHAT_ENTRY_H_ */ diff --git a/src/ui/contacts.c b/src/ui/contacts.c @@ -71,50 +71,11 @@ handle_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, contact ); - UI_MESSENGER_Handle *ui = &(app->ui.messenger); - - char context_id [9]; - g_snprintf(context_id, sizeof(context_id), "%08lx", (gulong) context); - - if (gtk_stack_get_child_by_name(ui->chats_stack, context_id)) + if (!context) goto close_dialog; - const char *title = GNUNET_CHAT_contact_get_name(contact); - - UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(app); - gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box); - GNUNET_CHAT_context_set_user_pointer(context, entry); - - if (title) - { - gtk_label_set_text(entry->title_label, title); - hdy_avatar_set_text(entry->entry_avatar, title); - - gtk_label_set_text(entry->chat->chat_title, title); - } - - gtk_widget_set_name(entry->entry_box, context_id); - - gtk_stack_add_named( - ui->chats_stack, - entry->chat->chat_box, - context_id - ); - - g_hash_table_insert( - app->ui.bindings, - entry->chat->send_text_view, - context - ); - - ui->chat_entries = g_list_append(ui->chat_entries, entry); - - GtkListBoxRow *entry_row = GTK_LIST_BOX_ROW( - gtk_widget_get_parent(entry->entry_box) - ); - - gtk_list_box_select_row(ui->chats_listbox, entry_row); - gtk_widget_activate(GTK_WIDGET(entry_row)); + if (GNUNET_SYSERR == GNUNET_CHAT_context_get_status(context)) + GNUNET_CHAT_context_request(context); close_dialog: gtk_window_close(GTK_WINDOW(app->ui.contacts.dialog));