Skip to content

Commit

Permalink
Merge pull request #491 from mjakeman/oscfdezdz/no-comments
Browse files Browse the repository at this point in the history
detail-view: Hide "Show All Reviews" button when there are none
  • Loading branch information
mjakeman authored Oct 8, 2023
2 parents b9c35bc + 4d5efa1 commit 0b09818
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/exm-detail-view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ template $ExmDetailView : Adw.NavigationPage {
};
}

Gtk.StackPage {
name: "page_empty";

child: Gtk.Label {
label: _("There are no comments.");
valign: start;
xalign: 0;
};
}

Gtk.StackPage {
name: "page_comments";

Expand Down
9 changes: 8 additions & 1 deletion src/exm-detail-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ on_get_comments (GObject *source,
return;
}

gtk_stack_set_visible_child_name (self->comment_stack, "page_comments");
if (g_list_model_get_n_items (model) == 0)
{
gtk_stack_set_visible_child_name (self->comment_stack, "page_empty");
}
else
{
gtk_stack_set_visible_child_name (self->comment_stack, "page_comments");
}

gtk_flow_box_bind_model (self->comment_box, model,
(GtkListBoxCreateWidgetFunc) comment_factory,
Expand Down

0 comments on commit 0b09818

Please sign in to comment.