Skip to content

Commit 0e5da1c

Browse files
committed
Bring back supported versions section as a dialog
Drops ExmInfoBar in favor of a GtkListBox. Now that the version row has to indicate that it opens another view with go-next-symbolic, we have the perfect excuse to move the subtitles to the row's suffix and get rid of the hacky CSS. We can revisit this in the future with a more friendly widget for horizontal layouts.
1 parent d05e433 commit 0e5da1c

13 files changed

+257
-284
lines changed

src/exm-comment-dialog.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121

2222
#include "exm-comment-dialog.h"
2323

24+
#include "exm-config.h"
2425
#include "exm-comment-tile.h"
2526
#include "web/exm-comment-provider.h"
2627
#include "web/model/exm-comment.h"
2728

2829
#include <glib/gi18n.h>
2930

30-
#include "exm-config.h"
31-
3231
struct _ExmCommentDialog
3332
{
3433
AdwDialog parent_instance;

src/exm-comment-dialog.h

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
/*
2+
* exm-comment-dialog.h
3+
*
4+
* Copyright 2022-2025 Matthew Jakeman <mjakeman26@outlook.co.nz>
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* SPDX-License-Identifier: GPL-3.0-or-later
20+
*/
21+
122
#pragma once
223

3-
#include <glib-object.h>
4-
#include <gtk/gtk.h>
524
#include <adwaita.h>
625

726
G_BEGIN_DECLS

src/exm-detail-view.blp

+49-6
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,50 @@ template $ExmDetailView: Adw.NavigationPage {
190190
}
191191
}
192192

193-
$ExmInfoBar ext_info_bar {}
193+
Adw.PreferencesGroup {
194+
Adw.ActionRow {
195+
[prefix]
196+
Gtk.Image {
197+
icon-name: "folder-download-symbolic";
198+
}
199+
200+
title: C_("Number of downloads", "Downloads");
201+
202+
[suffix]
203+
Gtk.Label downloads_label {
204+
styles [
205+
"numeric",
206+
]
207+
}
208+
}
209+
210+
Adw.ActionRow {
211+
[prefix]
212+
Gtk.Image {
213+
icon-name: "system-software-install-symbolic";
214+
}
215+
216+
action-name: "detail.show-versions";
217+
activatable: true;
218+
title: _("Version");
219+
220+
[suffix]
221+
Gtk.Box {
222+
spacing: 6;
223+
224+
Gtk.Label version_label {
225+
// TODO: Drop when version-label is available
226+
styles [
227+
"numeric",
228+
]
229+
}
230+
231+
Gtk.Image {
232+
icon-name: "go-next-symbolic";
233+
}
234+
}
235+
}
236+
}
194237

195238
Adw.PreferencesGroup {
196239
title: _("Links");
@@ -201,9 +244,9 @@ template $ExmDetailView: Adw.NavigationPage {
201244
icon-name: "go-home-symbolic";
202245
}
203246

204-
title: _("Homepage");
205-
activatable: true;
206247
action-name: "detail.open-homepage";
248+
activatable: true;
249+
title: _("Homepage");
207250

208251
[suffix]
209252
Gtk.Image {
@@ -226,9 +269,9 @@ template $ExmDetailView: Adw.NavigationPage {
226269
icon-name: "web-browser-symbolic";
227270
}
228271

229-
title: _("View on Extensions");
230-
activatable: true;
231272
action-name: "detail.open-extensions";
273+
activatable: true;
274+
title: _("View on Extensions");
232275

233276
[suffix]
234277
Gtk.Image {
@@ -247,8 +290,8 @@ template $ExmDetailView: Adw.NavigationPage {
247290
]
248291

249292
label: _("Reviews and Comments");
250-
xalign: 0;
251293
selectable: true;
294+
xalign: 0;
252295
}
253296

254297
// TODO: Abstract into common class

src/exm-detail-view.c

+49-22
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,21 @@
2121

2222
#include "exm-detail-view.h"
2323

24-
#include "exm-screenshot.h"
25-
#include "exm-screenshot-view.h"
26-
#include "exm-info-bar.h"
27-
#include "exm-comment-tile.h"
24+
#include "exm-config.h"
2825
#include "exm-comment-dialog.h"
26+
#include "exm-comment-tile.h"
27+
#include "exm-enums.h"
2928
#include "exm-install-button.h"
3029
#include "exm-screenshot.h"
31-
30+
#include "exm-screenshot-view.h"
31+
#include "exm-types.h"
32+
#include "exm-versions-dialog.h"
33+
#include "local/exm-manager.h"
34+
#include "web/exm-comment-provider.h"
3235
#include "web/exm-data-provider.h"
3336
#include "web/exm-image-resolver.h"
34-
#include "web/exm-comment-provider.h"
35-
#include "web/model/exm-shell-version-map.h"
3637
#include "web/model/exm-comment.h"
37-
#include "local/exm-manager.h"
38-
39-
#include "exm-types.h"
40-
#include "exm-enums.h"
41-
42-
#include "exm-config.h"
38+
#include "web/model/exm-shell-version-map.h"
4339

4440
#include <glib/gi18n.h>
4541

@@ -69,7 +65,9 @@ struct _ExmDetailView
6965
ExmScreenshot *ext_screenshot;
7066
GtkOverlay *ext_screenshot_container;
7167
GtkButton *ext_screenshot_popout_button;
72-
ExmInfoBar *ext_info_bar;
68+
GtkLabel *downloads_label;
69+
GtkLabel *version_label;
70+
ExmVersionsDialog *ext_versions_dialog;
7371
GtkScrolledWindow *scroll_area;
7472
GtkStack *comment_stack;
7573
GtkFlowBox *comment_box;
@@ -447,7 +445,7 @@ on_data_loaded (GObject *source,
447445
gtk_label_set_label (self->ext_title, name);
448446
gtk_label_set_label (self->ext_author, creator);
449447
gtk_label_set_label (self->ext_description, description);
450-
g_object_set (self->ext_info_bar, "downloads", downloads, NULL);
448+
gtk_label_set_label (self->downloads_label, g_strdup_printf ("%'d", downloads));
451449

452450
if (self->resolver_cancel)
453451
{
@@ -506,7 +504,14 @@ on_data_loaded (GObject *source,
506504
adw_action_row_set_subtitle (self->link_homepage, self->uri_homepage);
507505
adw_action_row_set_subtitle (self->link_extensions, self->uri_extensions);
508506

509-
g_object_set (self->ext_info_bar, "version", 0.0, NULL);
507+
gtk_label_set_label (self->version_label, _("Unsupported"));
508+
509+
if (self->ext_versions_dialog)
510+
{
511+
g_object_unref (self->ext_versions_dialog);
512+
self->ext_versions_dialog = NULL;
513+
}
514+
self->ext_versions_dialog = exm_versions_dialog_new ();
510515

511516
for (version_iter = version_map->map;
512517
version_iter != NULL;
@@ -522,10 +527,17 @@ on_data_loaded (GObject *source,
522527
else
523528
version = g_strdup_printf ("%s.0", entry->shell_major_version);
524529

525-
if (version != NULL && self->shell_version != NULL &&
526-
(strcmp (version, self->shell_version) == 0 ||
527-
strncmp(version, self->shell_version, strchr(version, '.') - version) == 0))
528-
g_object_set (self->ext_info_bar, "version", entry->extension_version, NULL);
530+
if (version != NULL && self->shell_version != NULL)
531+
{
532+
exm_versions_dialog_add_version (self->ext_versions_dialog, entry->shell_minor_version
533+
? version
534+
: entry->shell_major_version);
535+
536+
if (strcmp (version, self->shell_version) == 0 ||
537+
strncmp(version, self->shell_version, strchr(version, '.') - version) == 0)
538+
gtk_label_set_label (self->version_label,
539+
g_strdup_printf ("%.f", entry->extension_version));
540+
}
529541

530542
g_free (version);
531543
}
@@ -578,6 +590,20 @@ exm_detail_view_update (ExmDetailView *self)
578590
g_object_set (self->ext_install, "state", EXM_INSTALL_BUTTON_STATE_INSTALLED, NULL);
579591
}
580592

593+
static void
594+
show_versions (GtkWidget *widget,
595+
const char *action_name G_GNUC_UNUSED,
596+
GVariant *parameter G_GNUC_UNUSED)
597+
{
598+
ExmDetailView *self;
599+
GtkWidget *toplevel;
600+
601+
self = EXM_DETAIL_VIEW (widget);
602+
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (self)));
603+
604+
adw_dialog_present (ADW_DIALOG (g_object_ref (self->ext_versions_dialog)), toplevel);
605+
}
606+
581607
static void
582608
open_link (ExmDetailView *self,
583609
const char *action_name,
@@ -708,7 +734,8 @@ exm_detail_view_class_init (ExmDetailViewClass *klass)
708734
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, ext_screenshot);
709735
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, ext_screenshot_container);
710736
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, ext_screenshot_popout_button);
711-
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, ext_info_bar);
737+
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, downloads_label);
738+
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, version_label);
712739
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, link_homepage);
713740
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, links_donations);
714741
gtk_widget_class_bind_template_child (widget_class, ExmDetailView, link_extensions);
@@ -722,6 +749,7 @@ exm_detail_view_class_init (ExmDetailViewClass *klass)
722749
gtk_widget_class_bind_template_callback (widget_class, screenshot_view_cb);
723750
gtk_widget_class_bind_template_callback (widget_class, install_remote);
724751

752+
gtk_widget_class_install_action (widget_class, "detail.show-versions", NULL, show_versions);
725753
gtk_widget_class_install_action (widget_class, "detail.open-extensions", NULL, (GtkWidgetActionActivateFunc) open_link);
726754
gtk_widget_class_install_action (widget_class, "detail.open-homepage", NULL, (GtkWidgetActionActivateFunc) open_link);
727755
gtk_widget_class_install_action (widget_class, "detail.open-donation", "i", (GtkWidgetActionActivateFunc) open_link);
@@ -734,7 +762,6 @@ exm_detail_view_init (ExmDetailView *self)
734762

735763
g_type_ensure (EXM_TYPE_INSTALL_BUTTON);
736764
g_type_ensure (EXM_TYPE_SCREENSHOT);
737-
g_type_ensure (EXM_TYPE_INFO_BAR);
738765

739766
gtk_widget_init_template (GTK_WIDGET (self));
740767

src/exm-detail-view.h

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* exm-detail-view.h
3+
*
4+
* Copyright 2022-2025 Matthew Jakeman <mjakeman26@outlook.co.nz>
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* SPDX-License-Identifier: GPL-3.0-or-later
20+
*/
21+
122
#pragma once
223

324
#include <adwaita.h>
@@ -8,13 +29,11 @@ G_BEGIN_DECLS
829

930
G_DECLARE_FINAL_TYPE (ExmDetailView, exm_detail_view, EXM, DETAIL_VIEW, AdwNavigationPage)
1031

11-
ExmDetailView *exm_detail_view_new (void);
32+
ExmDetailView *exm_detail_view_new (void);
1233

13-
void
14-
exm_detail_view_load_for_uuid (ExmDetailView *self,
15-
gchar *uuid);
34+
void exm_detail_view_load_for_uuid (ExmDetailView *self,
35+
gchar *uuid);
1636

17-
void
18-
exm_detail_view_update (ExmDetailView *self);
37+
void exm_detail_view_update (ExmDetailView *self);
1938

2039
G_END_DECLS

src/exm-info-bar.blp

-54
This file was deleted.

0 commit comments

Comments
 (0)