commit e4f21c04bc978487afcabb595703e50759a92a10
parent 1c66a5e7ba39f6dde7afad4bdc4be067bc6a7da3
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Sat, 15 Jan 2022 21:40:55 +0100
Added visual changes to select messages for deletion
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
7 files changed, 261 insertions(+), 81 deletions(-)
diff --git a/resources/css/style.css b/resources/css/style.css
@@ -45,7 +45,7 @@
}
.message-box.sent {
- background-color: @theme_selected_bg_color;
+ background-color: mix(@theme_bg_color, @theme_selected_bg_color, 0.8);
color: @theme_selected_fg_color;
}
diff --git a/resources/ui.gresource.xml b/resources/ui.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnunet/Messenger">
<file compressed="true">ui/chat_entry.ui</file>
<file compressed="true">ui/chat.ui</file>
+ <file compressed="true">ui/contact_entry.ui</file>
<file compressed="true">ui/contacts.ui</file>
<file compressed="true">ui/file_load_entry.ui</file>
<file compressed="true">ui/invite_contact.ui</file>
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2
-Copyright (C) 2021 GNUnet e.V.
+Copyright (C) 2021‑‑2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -40,48 +40,156 @@ Author: Tobias Frisch
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkBox">
+ <object class="GtkStack" id="chat_title_stack">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="border-width">8</property>
- <property name="spacing">8</property>
+ <property name="transition-type">slide-down</property>
<child>
- <object class="GtkButton" id="back_button">
+ <object class="GtkBox" id="title_box">
<property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <property name="relief">none</property>
+ <property name="can-focus">False</property>
+ <property name="border-width">8</property>
+ <property name="spacing">8</property>
<child>
- <object class="GtkImage">
+ <object class="GtkButton" id="back_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="icon-name">go-previous-symbolic</property>
+ <property name="margin-start">4</property>
+ <property name="margin-end">4</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="chat_title">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="ellipsize">end</property>
+ <property name="single-line-mode">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="chat_subtitle">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="ellipsize">end</property>
+ <property name="single-line-mode">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="light"/>
+ </attributes>
+ <style>
+ <class name="header-subtitle"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
+ <child>
+ <object class="GtkButton" id="chat_details_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">view-more-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="chat_load_button">
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkSpinner">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="active">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <style>
+ <class name="header-box"/>
+ </style>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="name">page0</property>
+ <property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="selection_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="margin-start">4</property>
- <property name="margin-end">4</property>
- <property name="orientation">vertical</property>
+ <property name="border-width">8</property>
+ <property name="spacing">8</property>
<child>
- <object class="GtkLabel" id="chat_title">
+ <object class="GtkButton" id="selection_close_button">
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="ellipsize">end</property>
- <property name="single-line-mode">True</property>
- <property name="xalign">0</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">window-close-symbolic</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -90,18 +198,12 @@ Author: Tobias Frisch
</packing>
</child>
<child>
- <object class="GtkLabel" id="chat_subtitle">
+ <object class="GtkLabel" id="selection_count_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="ellipsize">end</property>
- <property name="single-line-mode">True</property>
- <property name="xalign">0</property>
<attributes>
- <attribute name="weight" value="light"/>
+ <attribute name="weight" value="semibold"/>
</attributes>
- <style>
- <class name="header-subtitle"/>
- </style>
</object>
<packing>
<property name="expand">False</property>
@@ -109,57 +211,37 @@ Author: Tobias Frisch
<property name="position">1</property>
</packing>
</child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="chat_details_button">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <property name="relief">none</property>
<child>
- <object class="GtkImage">
+ <object class="GtkButton" id="selection_delete_button">
<property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">view-more-symbolic</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">user-trash-symbolic</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">2</property>
+ </packing>
</child>
+ <style>
+ <class name="header-box"/>
+ </style>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack-type">end</property>
+ <property name="name">page1</property>
+ <property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="chat_load_button">
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <property name="relief">none</property>
- <child>
- <object class="GtkSpinner">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="active">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack-type">end</property>
- <property name="position">3</property>
- </packing>
- </child>
- <style>
- <class name=".header-box"/>
- </style>
</object>
<packing>
<property name="expand">False</property>
@@ -179,7 +261,7 @@ Author: Tobias Frisch
<object class="GtkListBox" id="messages_listbox">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="selection-mode">none</property>
+ <property name="selection-mode">multiple</property>
<property name="activate-on-single-click">False</property>
</object>
</child>
diff --git a/src/event.c b/src/event.c
@@ -269,7 +269,7 @@ event_joining_contact(MESSENGER_Application *app,
gtk_label_set_text(message->text_label, join_message);
gtk_label_set_text(message->timestamp_label, time? time : "");
- ui_chat_add_message(handle->chat, message);
+ ui_chat_add_message(handle->chat, app, message);
ui_chat_entry_update(handle, app, context);
}
@@ -353,7 +353,7 @@ event_invitation(MESSENGER_Application *app,
gtk_widget_show(GTK_WIDGET(message->deny_button));
gtk_widget_show(GTK_WIDGET(message->accept_button));
- ui_chat_add_message(handle->chat, message);
+ ui_chat_add_message(handle->chat, app, message);
ui_chat_entry_update(handle, app, context);
}
@@ -412,6 +412,6 @@ event_receive_message(MESSENGER_Application *app,
gtk_label_set_text(message->text_label, text? text : "");
gtk_label_set_text(message->timestamp_label, time? time : "");
- ui_chat_add_message(handle->chat, message);
+ ui_chat_add_message(handle->chat, app, message);
ui_chat_entry_update(handle, app, context);
}
diff --git a/src/file.c b/src/file.c
@@ -75,7 +75,19 @@ file_update_upload_info(const struct GNUNET_CHAT_File *file,
if (!info)
return;
- // TODO
+ GList *list = info->file_messages;
+
+ while (list)
+ {
+ UI_MESSAGE_Handle *message = (UI_MESSAGE_Handle*) list->data;
+
+ gtk_progress_bar_set_fraction(
+ message->file_progress_bar,
+ 1.0 * completed / size
+ );
+
+ list = list->next;
+ }
}
void
diff --git a/src/ui/chat.c b/src/ui/chat.c
@@ -143,6 +143,41 @@ handle_back_button_click(UNUSED GtkButton *button,
}
static void
+handle_chat_messages_selected_rows_changed(GtkListBox *listbox,
+ gpointer user_data)
+{
+ UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
+
+ GList *selected = gtk_list_box_get_selected_rows(listbox);
+ uint32_t count = 0;
+
+ while (selected)
+ {
+ count++;
+ selected = selected->next;
+ }
+
+ GString *counter = g_string_new("");
+ g_string_append_printf(counter, "%u", count);
+ gtk_label_set_text(handle->selection_count_label, counter->str);
+ g_string_free(counter, TRUE);
+
+ if (count > 0)
+ gtk_stack_set_visible_child(handle->chat_title_stack, handle->selection_box);
+ else
+ gtk_stack_set_visible_child(handle->chat_title_stack, handle->title_box);
+}
+
+static void
+handle_chat_selection_close_button_click(UNUSED GtkButton *button,
+ gpointer user_data)
+{
+ GtkListBox *listbox = GTK_LIST_BOX(user_data);
+
+ gtk_list_box_unselect_all(listbox);
+}
+
+static void
handle_attach_file_button_click(GtkButton *button,
gpointer user_data)
{
@@ -326,6 +361,18 @@ ui_chat_new(MESSENGER_Application *app)
gtk_builder_get_object(handle->builder, "flap_chat_details")
);
+ handle->chat_title_stack = GTK_STACK(
+ gtk_builder_get_object(handle->builder, "chat_title_stack")
+ );
+
+ handle->title_box = GTK_WIDGET(
+ gtk_builder_get_object(handle->builder, "title_box")
+ );
+
+ handle->selection_box = GTK_WIDGET(
+ gtk_builder_get_object(handle->builder, "selection_box")
+ );
+
handle->chat_title = GTK_LABEL(
gtk_builder_get_object(handle->builder, "chat_title")
);
@@ -383,6 +430,18 @@ ui_chat_new(MESSENGER_Application *app)
gtk_builder_get_object(handle->builder, "chat_details_contacts_box")
);
+ handle->selection_close_button = GTK_BUTTON(
+ gtk_builder_get_object(handle->builder, "selection_close_button")
+ );
+
+ handle->selection_count_label = GTK_LABEL(
+ gtk_builder_get_object(handle->builder, "selection_count_label")
+ );
+
+ handle->selection_delete_button = GTK_BUTTON(
+ gtk_builder_get_object(handle->builder, "selection_delete_button")
+ );
+
handle->chat_scrolled_window = GTK_SCROLLED_WINDOW(
gtk_builder_get_object(handle->builder, "chat_scrolled_window")
);
@@ -404,6 +463,20 @@ ui_chat_new(MESSENGER_Application *app)
g_signal_connect(
handle->messages_listbox,
+ "selected-rows-changed",
+ G_CALLBACK(handle_chat_messages_selected_rows_changed),
+ handle
+ );
+
+ g_signal_connect(
+ handle->selection_close_button,
+ "clicked",
+ G_CALLBACK(handle_chat_selection_close_button_click),
+ handle->messages_listbox
+ );
+
+ g_signal_connect(
+ handle->messages_listbox,
"size-allocate",
G_CALLBACK(handle_chat_messages_listbox_size_allocate),
handle
@@ -674,6 +747,7 @@ ui_chat_delete(UI_CHAT_Handle *handle)
void
ui_chat_add_message(UI_CHAT_Handle *handle,
+ GNUNET_UNUSED MESSENGER_Application *app,
UI_MESSAGE_Handle *message)
{
GNUNET_assert((handle) && (message));
@@ -688,6 +762,7 @@ ui_chat_add_message(UI_CHAT_Handle *handle,
void
ui_chat_remove_message(UI_CHAT_Handle *handle,
+ GNUNET_UNUSED MESSENGER_Application *app,
UI_MESSAGE_Handle *message)
{
GNUNET_assert((handle) && (message));
diff --git a/src/ui/chat.h b/src/ui/chat.h
@@ -50,6 +50,10 @@ typedef struct UI_CHAT_Handle
HdyFlap *flap_chat_details;
+ GtkStack *chat_title_stack;
+ GtkWidget *title_box;
+ GtkWidget *selection_box;
+
GtkLabel *chat_title;
GtkLabel *chat_subtitle;
@@ -62,6 +66,10 @@ typedef struct UI_CHAT_Handle
GtkButton *hide_chat_details_button;
GtkBox *chat_details_contacts_box;
+ GtkButton *selection_close_button;
+ GtkLabel *selection_count_label;
+ GtkButton *selection_delete_button;
+
GtkScrolledWindow *chat_scrolled_window;
GtkListBox *chat_contacts_listbox;
@@ -91,10 +99,12 @@ ui_chat_delete(UI_CHAT_Handle *handle);
void
ui_chat_add_message(UI_CHAT_Handle *handle,
+ MESSENGER_Application *app,
UI_MESSAGE_Handle *message);
void
ui_chat_remove_message(UI_CHAT_Handle *handle,
+ MESSENGER_Application *app,
UI_MESSAGE_Handle *message);
void