commit 4a798618d5d59449d139ae3c1b8452be5bddffca
parent bcbfdfdc27481f4c97aa3795e4947c9a047a2b50
Author: Jacki <jacki@thejackimonster.de>
Date: Tue, 12 Mar 2024 01:21:57 +0100
Add search bar to chat
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
3 files changed, 103 insertions(+), 24 deletions(-)
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui
@@ -51,26 +51,6 @@ Author: Tobias Frisch
<property name="border-width">8</property>
<property name="spacing">8</property>
<child>
- <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>
@@ -118,7 +98,27 @@ Author: Tobias Frisch
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <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>
@@ -139,7 +139,7 @@ Author: Tobias Frisch
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -151,6 +151,27 @@ Author: Tobias Frisch
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="chat_search_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">edit-find-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>
@@ -171,7 +192,7 @@ Author: Tobias Frisch
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<style>
@@ -262,6 +283,27 @@ Author: Tobias Frisch
</packing>
</child>
<child>
+ <object class="HdySearchBar" id="chat_search_bar">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="show-close-button">True</property>
+ <child>
+ <object class="GtkSearchEntry" id="chat_search_entry">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="primary-icon-name">edit-find-symbolic</property>
+ <property name="primary-icon-activatable">False</property>
+ <property name="primary-icon-sensitive">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkScrolledWindow" id="chat_scrolled_window">
<property name="visible">True</property>
<property name="can-focus">True</property>
@@ -283,7 +325,7 @@ Author: Tobias Frisch
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
diff --git a/src/ui/chat.c b/src/ui/chat.c
@@ -939,6 +939,20 @@ handle_recording_play_button_click(UNUSED GtkButton *button,
}
static void
+handle_search_button_click(UNUSED GtkButton *button,
+ gpointer user_data)
+{
+ g_assert(user_data);
+
+ HdySearchBar *search_bar = HDY_SEARCH_BAR(user_data);
+
+ hdy_search_bar_set_search_mode(
+ search_bar,
+ !hdy_search_bar_get_search_mode(search_bar)
+ );
+}
+
+static void
handle_picker_button_click(UNUSED GtkButton *button,
gpointer user_data)
{
@@ -1221,6 +1235,25 @@ ui_chat_new(MESSENGER_Application *app)
handle->chat_load_popover
);
+ handle->chat_search_button = GTK_BUTTON(
+ gtk_builder_get_object(handle->builder, "chat_search_button")
+ );
+
+ handle->chat_search_bar = HDY_SEARCH_BAR(
+ gtk_builder_get_object(handle->builder, "chat_search_bar")
+ );
+
+ handle->chat_search_entry = GTK_SEARCH_ENTRY(
+ gtk_builder_get_object(handle->builder, "chat_search_entry")
+ );
+
+ g_signal_connect(
+ handle->chat_search_button,
+ "clicked",
+ G_CALLBACK(handle_search_button_click),
+ handle->chat_search_bar
+ );
+
handle->chat_details_button = GTK_BUTTON(
gtk_builder_get_object(handle->builder, "chat_details_button")
);
diff --git a/src/ui/chat.h b/src/ui/chat.h
@@ -88,6 +88,10 @@ typedef struct UI_CHAT_Handle
GtkPopover *chat_load_popover;
GtkListBox *chat_load_listbox;
+ GtkButton *chat_search_button;
+ HdySearchBar *chat_search_bar;
+ GtkSearchEntry *chat_search_entry;
+
GtkButton *chat_details_button;
GtkLabel *chat_details_label;
GtkButton *hide_chat_details_button;