summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-01-14 11:09:10 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2022-04-16 19:59:35 +0200
commit8bec4ebacb090f56d76ee2b5d669a5b563e2e3c6 (patch)
tree7046395d00c7a8a3a44555ffdad47dd5358d1731 /data
parent0195ceb72bb8a5d0fdd1f33a8b9a0bf33a9e9263 (diff)
downloadgnome-contacts-8bec4ebacb090f56d76ee2b5d669a5b563e2e3c6.tar.gz
Use selection and filter models to list contacts
GTK4 added some interesting concepts on top of / in conjunction with list models, for example to map one list model on another by sorting and/or filtering. Another example is to use this with selections. This commit applies that concept to Contacts, which now uses the `Contacts.Store` to build a base list model on top of the `Folks.IndividualAggregator`, on top a sorted model (which can be adjusted to sort on First/Last name, and finally a filter model, to filter on the text in the search entry. Another reason to do this, is that it allows us to use a `Gtk.ListView` in the future. It's not possible to do so already due to the fact that we need to differentiate between "Favorites" and "Other Contacts", which needs extra API on Gtk.Listview side.
Diffstat (limited to 'data')
-rw-r--r--data/contacts.gresource.xml1
-rw-r--r--data/ui/contacts-list-pane.ui49
-rw-r--r--data/ui/contacts-main-window.ui60
-rw-r--r--data/ui/style.css2
4 files changed, 55 insertions, 57 deletions
diff --git a/data/contacts.gresource.xml b/data/contacts.gresource.xml
index 0455ec7..533e3d0 100644
--- a/data/contacts.gresource.xml
+++ b/data/contacts.gresource.xml
@@ -21,7 +21,6 @@
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-editor-menu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-link-suggestion-grid.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-linked-personas-dialog.ui</file>
- <file compressed="true" preprocess="xml-stripblanks">ui/contacts-list-pane.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-main-window.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-setup-window.ui</file>
</gresource>
diff --git a/data/ui/contacts-list-pane.ui b/data/ui/contacts-list-pane.ui
deleted file mode 100644
index e67fa21..0000000
--- a/data/ui/contacts-list-pane.ui
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <template class="ContactsListPane" parent="AdwBin">
- <child>
- <object class="GtkBox" id="box">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkSearchEntry" id="filter_entry">
- <property name="placeholder-text" translatable="yes">Type to search</property>
- <signal name="search-changed" handler="filter_entry_changed"/>
- <style>
- <class name="contacts-filter-entry"/>
- </style>
- </object>
- </child>
- <child>
- <object class="AdwBin" id="contacts_list_container">
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkActionBar" id="actions_bar">
- <property name="revealed">False</property>
- <child>
- <object class="GtkButton" id="link_button">
- <property name="focus_on_click">False</property>
- <property name="label" translatable="yes" comments="Link refers to the verb, from linking contacts together">Link</property>
- <property name="sensitive">False</property>
- <signal name="clicked" handler="on_link_button_clicked"/>
- </object>
- </child>
- <child type="end">
- <object class="GtkButton" id="delete_button">
- <property name="focus_on_click">False</property>
- <property name="label" translatable="yes">Remove</property>
- <property name="sensitive">False</property>
- <signal name="clicked" handler="on_delete_button_clicked"/>
- <style>
- <class name="destructive-action"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </template>
-</interface>
diff --git a/data/ui/contacts-main-window.ui b/data/ui/contacts-main-window.ui
index 41b99e8..deab856 100644
--- a/data/ui/contacts-main-window.ui
+++ b/data/ui/contacts-main-window.ui
@@ -5,12 +5,12 @@
<attribute name="label" translatable="yes">List Contacts By:</attribute>
<item>
<attribute name="label" translatable="yes">First Name</attribute>
- <attribute name="action">window.sort-on</attribute>
+ <attribute name="action">win.sort-on</attribute>
<attribute name="target">firstname</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Surname</attribute>
- <attribute name="action">window.sort-on</attribute>
+ <attribute name="action">win.sort-on</attribute>
<attribute name="target">surname</attribute>
</item>
</section>
@@ -52,7 +52,7 @@
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;n</property>
- <property name="action">action(window.new-contact)</property>
+ <property name="action">action(win.new-contact)</property>
</object>
</child>
</object>
@@ -81,7 +81,7 @@
<object class="GtkButton" id="add_button">
<property name="tooltip-text" translatable="yes">Create new contact</property>
<property name="icon-name">list-add-symbolic</property>
- <property name="action-name">window.new-contact</property>
+ <property name="action-name">win.new-contact</property>
</object>
</child>
@@ -112,6 +112,7 @@
<child>
<object class="GtkStack" id="list_pane_stack">
<property name="hexpand">False</property>
+ <!-- The loading spinner page -->
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
@@ -135,6 +136,49 @@
</child>
</object>
</child>
+ <!-- The list pane with the actual contacts -->
+ <child>
+ <object class="GtkBox" id="list_pane">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkSearchEntry" id="filter_entry">
+ <property name="placeholder-text" translatable="yes">Type to search</property>
+ <signal name="search-changed" handler="filter_entry_changed"/>
+ <style>
+ <class name="contacts-filter-entry"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="AdwBin" id="contacts_list_container">
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkActionBar" id="actions_bar">
+ <property name="revealed">False</property>
+ <child>
+ <object class="GtkButton" id="link_button">
+ <property name="focus_on_click">False</property>
+ <property name="label" translatable="yes" comments="Link refers to the verb, from linking contacts together">Link</property>
+ <property name="action-name">win.link-marked-contacts</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkButton" id="delete_button">
+ <property name="focus_on_click">False</property>
+ <property name="label" translatable="yes">Remove</property>
+ <property name="action-name">win.delete-marked-contacts</property>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -185,6 +229,8 @@
<property name="label" translatable="yes">_Cancel</property>
<property name="use_underline">True</property>
<signal name="notify::visible" handler="on_cancel_visible" object="ContactsMainWindow" after="yes" swapped="no"/>
+ <property name="action-name">win.stop-editing-contact</property>
+ <property name="action-target">true</property>
</object>
</child>
<child type="end">
@@ -202,14 +248,14 @@
<child>
<object class="GtkButton" id="edit_contact_button">
<property name="icon-name">document-edit-symbolic</property>
- <property name="action-name">window.edit-contact</property>
+ <property name="action-name">win.edit-contact</property>
<property name="tooltip-text" translatable="yes">Edit Contact</property>
</object>
</child>
<child>
<object class="GtkButton" id="delete_contact_button">
<property name="icon-name">user-trash-symbolic</property>
- <property name="action-name">window.delete-contact</property>
+ <property name="action-name">win.delete-contact</property>
<property name="tooltip-text" translatable="yes">Delete Contact</property>
</object>
</child>
@@ -221,6 +267,8 @@
<property name="use_underline">True</property>
<property name="label" translatable="yes">Done</property>
<property name="valign">center</property>
+ <property name="action-name">win.stop-editing-contact</property>
+ <property name="action-target">false</property>
<style>
<class name="suggested-action"/>
</style>
diff --git a/data/ui/style.css b/data/ui/style.css
index c80cfb8..6bb5f58 100644
--- a/data/ui/style.css
+++ b/data/ui/style.css
@@ -13,7 +13,7 @@
}
/* Draw a little shadow about the contact list when scrolling */
-.contacts-list-scrolled-window undershoot.top {
+.contact-list-scrolled-window undershoot.top {
box-shadow: inset 0 1px @borders;
}