search-locations: Use AdwButtonRow in the "Add Location..." button
Also, remove the list box placeholder since the button will appear even when the list is empty. The button now acts like a placeholder too. Co-authored-by: Matthijs Velsink <mvelsink@gnome.org>
This commit is contained in:
parent
09a001e47a
commit
8082f9be8f
2 changed files with 21 additions and 30 deletions
|
@ -52,7 +52,6 @@ struct _CcSearchLocationsPage {
|
|||
GtkWidget *bookmarks_group;
|
||||
GtkWidget *bookmarks_list;
|
||||
GtkWidget *others_list;
|
||||
GtkWidget *locations_add;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CcSearchLocationsPage, cc_search_locations_page, ADW_TYPE_NAVIGATION_PAGE)
|
||||
|
@ -555,6 +554,13 @@ place_compare_func (GtkListBoxRow *row_a,
|
|||
g_autofree char *path_a = NULL;
|
||||
g_autofree char *path_b = NULL;
|
||||
|
||||
/* If an Add... AdwButtonRow is present, sort it last */
|
||||
if (ADW_IS_BUTTON_ROW (row_a))
|
||||
return 1;
|
||||
|
||||
if (ADW_IS_BUTTON_ROW (row_b))
|
||||
return -1;
|
||||
|
||||
place_a = g_object_get_data (G_OBJECT (row_a), "place");
|
||||
place_b = g_object_get_data (G_OBJECT (row_b), "place");
|
||||
|
||||
|
@ -717,8 +723,13 @@ other_places_refresh (CcSearchLocationsPage *self)
|
|||
GList *l;
|
||||
GtkListBoxRow *widget;
|
||||
|
||||
/* Clear the list rows, but not if it's an Add... AdwButtonRow, which should come last */
|
||||
while ((widget = gtk_list_box_get_row_at_index (GTK_LIST_BOX (self->others_list), 0)))
|
||||
gtk_list_box_remove (GTK_LIST_BOX (self->others_list), GTK_WIDGET (widget));
|
||||
{
|
||||
if (ADW_IS_BUTTON_ROW (widget))
|
||||
break;
|
||||
gtk_list_box_remove (GTK_LIST_BOX (self->others_list), GTK_WIDGET (widget));
|
||||
}
|
||||
|
||||
places = get_places_list (self);
|
||||
for (l = places; l != NULL; l = l->next)
|
||||
|
@ -774,7 +785,6 @@ cc_search_locations_page_class_init (CcSearchLocationsPageClass *klass)
|
|||
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsPage, bookmarks_group);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsPage, bookmarks_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsPage, others_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsPage, locations_add);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, add_button_clicked);
|
||||
gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
|
||||
|
|
|
@ -48,43 +48,24 @@
|
|||
<child>
|
||||
<object class="AdwPreferencesGroup" id="others_group">
|
||||
<property name="title" translatable="yes">Custom Locations</property>
|
||||
<property name="header-suffix">
|
||||
<object class="GtkButton" id="locations_add">
|
||||
<property name="valign">center</property>
|
||||
<property name="child">
|
||||
<object class="AdwButtonContent">
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="label" translatable="yes">_Add Location…</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</property>
|
||||
<signal name="clicked" handler="add_button_clicked" object="CcSearchLocationsPage" swapped="yes"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="others_list">
|
||||
<property name="selection-mode">none</property>
|
||||
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcSearchLocationsPage" swapped="yes"/>
|
||||
<child>
|
||||
<object class="AdwButtonRow">
|
||||
<property name="title" translatable="yes">_Add Location</property>
|
||||
<property name="start-icon-name">list-add-symbolic</property>
|
||||
<property name="use-underline">True</property>
|
||||
<signal name="activated" handler="add_button_clicked" object="CcSearchLocationsPage" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">others_group</relation>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="boxed-list"/>
|
||||
</style>
|
||||
<child type="placeholder">
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="yes">No custom search locations</property>
|
||||
<property name="wrap">true</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<style>
|
||||
<class name="dim-label" />
|
||||
<class name="cc-placeholder-row" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Add table
Reference in a new issue