Skip to content

Commit 2fefbab

Browse files
committed
detail-view: Hide "Show All Reviews" button when unneeded
We retrieve comments in the details view and the comment dialog using different queries. Therefore, we must display the button in extensions that have exactly five reviews/comments, as we do not know the total count until we query all comments when the dialog is opened. Also rewords strings containing comment or review to use both terms as they are both possible and adds pill style to the button. Close #781
1 parent 7f50fe1 commit 2fefbab

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

src/exm-comment-dialog.blp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ template $ExmCommentDialog: Adw.Dialog {
1010
content-height: 600;
1111
width-request: 360;
1212
height-request: 294;
13-
title: _("Comments");
13+
title: _("Reviews and Comments");
1414

1515
child: Adw.ToolbarView {
1616
[top]
@@ -22,7 +22,7 @@ template $ExmCommentDialog: Adw.Dialog {
2222

2323
child: Adw.StatusPage loading_status {
2424
paintable: spinner;
25-
title: _("Loading Comments");
25+
title: _("Loading");
2626
};
2727
}
2828

@@ -42,7 +42,7 @@ template $ExmCommentDialog: Adw.Dialog {
4242
Adw.PreferencesGroup {
4343
Gtk.ListBox list_box {
4444
styles [
45-
"boxed-list"
45+
"boxed-list",
4646
]
4747

4848
selection-mode: none;

src/exm-detail-view.blp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ template $ExmDetailView: Adw.NavigationPage {
7272

7373
Gtk.Box {
7474
styles [
75-
"detail"
75+
"detail",
7676
]
7777

7878
orientation: vertical;
@@ -100,7 +100,7 @@ template $ExmDetailView: Adw.NavigationPage {
100100

101101
Gtk.Label ext_title {
102102
styles [
103-
"title-1"
103+
"title-1",
104104
]
105105

106106
ellipsize: end;
@@ -117,7 +117,7 @@ template $ExmDetailView: Adw.NavigationPage {
117117

118118
Gtk.Label ext_author {
119119
styles [
120-
"dim-label"
120+
"dim-label",
121121
]
122122

123123
xalign: 0;
@@ -142,7 +142,7 @@ template $ExmDetailView: Adw.NavigationPage {
142142
Gtk.Button ext_screenshot_popout_button {
143143
styles [
144144
"osd",
145-
"circular"
145+
"circular",
146146
]
147147

148148
icon-name: "pip-out-symbolic";
@@ -167,7 +167,7 @@ template $ExmDetailView: Adw.NavigationPage {
167167
Gtk.Label description {
168168
styles [
169169
"title-4",
170-
"detail-heading"
170+
"detail-heading",
171171
]
172172

173173
label: _("Description");
@@ -176,7 +176,7 @@ template $ExmDetailView: Adw.NavigationPage {
176176

177177
Gtk.Label ext_description {
178178
styles [
179-
"multiline"
179+
"multiline",
180180
]
181181

182182
xalign: 0;
@@ -243,10 +243,10 @@ template $ExmDetailView: Adw.NavigationPage {
243243
Gtk.Label {
244244
styles [
245245
"title-4",
246-
"detail-heading"
246+
"detail-heading",
247247
]
248248

249-
label: _("User Reviews");
249+
label: _("Reviews and Comments");
250250
xalign: 0;
251251
selectable: true;
252252
}
@@ -269,10 +269,11 @@ template $ExmDetailView: Adw.NavigationPage {
269269
name: "page_disabled";
270270

271271
child: Gtk.Label {
272-
label: _("Comments are disabled for this extension");
272+
label: _("Reviews and comments are disabled for this extension");
273+
selectable: true;
273274
valign: start;
275+
wrap: true;
274276
xalign: 0;
275-
selectable: true;
276277
};
277278
}
278279

@@ -285,7 +286,7 @@ template $ExmDetailView: Adw.NavigationPage {
285286

286287
Gtk.Label {
287288
styles [
288-
"heading"
289+
"heading",
289290
]
290291

291292
label: _("Connection Error");
@@ -296,7 +297,7 @@ template $ExmDetailView: Adw.NavigationPage {
296297

297298
Gtk.Label error_label {
298299
styles [
299-
"body"
300+
"body",
300301
]
301302

302303
selectable: true;
@@ -311,10 +312,11 @@ template $ExmDetailView: Adw.NavigationPage {
311312
name: "page_empty";
312313

313314
child: Gtk.Label {
314-
label: _("No comments yet");
315+
label: _("There are no reviews or comments");
316+
selectable: true;
315317
valign: start;
318+
wrap: true;
316319
xalign: 0;
317-
selectable: true;
318320
};
319321
}
320322

@@ -335,9 +337,13 @@ template $ExmDetailView: Adw.NavigationPage {
335337
}
336338

337339
Gtk.Button show_more_btn {
338-
label: _("_Show All Reviews");
340+
styles [
341+
"pill",
342+
]
343+
339344
can-shrink: true;
340345
halign: center;
346+
label: _("_Show All");
341347
use-underline: true;
342348
}
343349
};

src/exm-detail-view.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,17 @@ on_get_comments (GObject *source,
248248
return;
249249
}
250250

251-
if (g_list_model_get_n_items (model) == 0)
251+
guint n_comments = g_list_model_get_n_items (model);
252+
253+
if (!n_comments)
254+
{
252255
gtk_stack_set_visible_child_name (self->comment_stack, "page_empty");
256+
}
253257
else
258+
{
259+
gtk_widget_set_visible (GTK_WIDGET (self->show_more_btn), n_comments >= 5);
254260
gtk_stack_set_visible_child_name (self->comment_stack, "page_comments");
261+
}
255262

256263
gtk_flow_box_bind_model (self->comment_box, model,
257264
(GtkFlowBoxCreateWidgetFunc) comment_factory,

0 commit comments

Comments
 (0)