Skip to content

Commit

Permalink
browse-page: Port load more results button to AdwButtonRow
Browse files Browse the repository at this point in the history
  • Loading branch information
oscfdezdz committed Sep 16, 2024
1 parent 0014e01 commit 7c9147d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/exm-browse-page.blp
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,28 @@ template $ExmBrowsePage: Gtk.Widget {

child: Gtk.Box {
orientation: vertical;
spacing: 12;

Gtk.ListBox search_results {
styles [
"boxed-list"
]

valign: start;
selection-mode: none;
}

Gtk.Button more_results_btn {
label: _("_Load More Results");
halign: center;
margin-top: 24;
use-underline: true;
clicked => $on_load_more_results();
Gtk.ListBox more_results_list {
styles [
"boxed-list"
]

selection-mode: none;

Adw.ButtonRow more_results_btn {
title: _("_Load More Results");
use-underline: true;
activated => $on_load_more_results();
}
}
};
}
Expand Down
6 changes: 4 additions & 2 deletions src/exm-browse-page.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct _ExmBrowsePage
GtkListBox *search_results;
GtkStack *search_stack;
GtkDropDown *search_dropdown;
GtkListBox *more_results_list;
GtkButton *more_results_btn;
};

Expand Down Expand Up @@ -146,7 +147,7 @@ static void
update_load_more_btn (ExmBrowsePage *self)
{
// Hide button if we are the last page
gtk_widget_set_visible (GTK_WIDGET (self->more_results_btn), self->current_page != self->max_pages);
gtk_widget_set_visible (GTK_WIDGET (self->more_results_list), self->current_page != self->max_pages);

// Make it clickable
gtk_widget_set_sensitive (GTK_WIDGET (self->more_results_btn), TRUE);
Expand Down Expand Up @@ -231,7 +232,7 @@ on_next_page_result (GObject *source,
}

static void
on_load_more_results (GtkButton *btn,
on_load_more_results (AdwButtonRow *row,
ExmBrowsePage *self)
{
const char *query;
Expand Down Expand Up @@ -390,6 +391,7 @@ exm_browse_page_class_init (ExmBrowsePageClass *klass)
gtk_widget_class_bind_template_child (widget_class, ExmBrowsePage, search_results);
gtk_widget_class_bind_template_child (widget_class, ExmBrowsePage, search_stack);
gtk_widget_class_bind_template_child (widget_class, ExmBrowsePage, search_dropdown);
gtk_widget_class_bind_template_child (widget_class, ExmBrowsePage, more_results_list);
gtk_widget_class_bind_template_child (widget_class, ExmBrowsePage, more_results_btn);

gtk_widget_class_bind_template_callback (widget_class, on_search_entry_realize);
Expand Down

0 comments on commit 7c9147d

Please sign in to comment.