Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
e759707a by wurstsalat at 2024-11-24T19:08:16+01:00
cfix: StartChat: Move 'Start New Chat' to the bottom

- - - - -
d57a4a3e by wurstsalat at 2024-11-24T19:15:02+01:00
imprv: Start Chat: Include contact groups in search

- - - - -


1 changed file:

- gajim/gtk/start_chat.py


Changes:

=====================================
gajim/gtk/start_chat.py
=====================================
@@ -9,6 +9,7 @@
 from typing import Generic
 from typing import TypeVar
 
+import locale
 import logging
 from enum import Enum
 
@@ -834,12 +835,7 @@ def __init__(self) -> None:
         self._scroll_id = None
         self._search_string_list: list[str] = []
 
-        expression = Gtk.PropertyExpression.new(
-            this_type=ContactListItem,
-            expression=None,
-            property_name="name",
-        )
-        sorter = Gtk.StringSorter(expression=expression)
+        sorter = Gtk.CustomSorter.new(sort_func=self._sort_func)
         self._sort_model = Gtk.SortListModel(sorter=sorter)
 
         self._custom_filter = Gtk.CustomFilter.new(self._filter_func)
@@ -918,6 +914,17 @@ def _filter_func(self, item: ContactListItem) -> bool:
 
         return type_ == ChatTypeFilter.GROUPCHAT and is_groupchat
 
+    @staticmethod
+    def _sort_func(
+        obj1: Any,
+        obj2: Any,
+        _user_data: object | None,
+    ) -> int:
+        if obj1.is_new:
+            return 1
+
+        return locale.strcoll(obj1.name, obj2.name)
+
     def add(self, item: ContactViewItem) -> None:
         self._model.append(item)
 
@@ -1001,7 +1008,7 @@ def __init__(
         else:
             avatar_paintable = contact.get_avatar(AvatarSize.CHAT, scale)
 
-        search_string = "|".join((name, str(jid), account_label)).lower()
+        search_string = "|".join((name, str(jid), account_label, 
*groups)).lower()
 
         super().__init__(
             account=account,



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/601400dea1bb511f5a90cc39b1bfcd745e409442...d57a4a3e7cdaffb38c9563eac9eba5e0f5e17498

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/601400dea1bb511f5a90cc39b1bfcd745e409442...d57a4a3e7cdaffb38c9563eac9eba5e0f5e17498
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to