From d650c42d831142351865570f44e80afad8b5cca4 Mon Sep 17 00:00:00 2001 From: Eva M Date: Thu, 14 May 2026 03:29:36 -0700 Subject: [PATCH] init curation rework --- src/bz-curated-appids-info.txt | 10 +++ src/bz-curated-category-info.txt | 21 ------ src/bz-curated-section.txt | 4 +- src/bz-section-view.blp | 122 ++++--------------------------- src/bz-section-view.c | 65 +++++++--------- src/curated-config-schema.xml | 2 +- src/meson.build | 2 +- 7 files changed, 52 insertions(+), 174 deletions(-) create mode 100644 src/bz-curated-appids-info.txt delete mode 100644 src/bz-curated-category-info.txt diff --git a/src/bz-curated-appids-info.txt b/src/bz-curated-appids-info.txt new file mode 100644 index 00000000..0bd852c0 --- /dev/null +++ b/src/bz-curated-appids-info.txt @@ -0,0 +1,10 @@ +prefix=bz +name=curated_appids_info +parent-prefix=g +parent-name=object +author=AUTOGEN + +include= + +property=list GListModel G_TYPE_LIST_MODEL object +property=enable_bulk_install gboolean G_TYPE_BOOLEAN boolean diff --git a/src/bz-curated-category-info.txt b/src/bz-curated-category-info.txt deleted file mode 100644 index d95f5af3..00000000 --- a/src/bz-curated-category-info.txt +++ /dev/null @@ -1,21 +0,0 @@ -prefix=bz -name=curated_category_info -parent-prefix=g -parent-name=object -author=AUTOGEN - -include= - -property=title char G_TYPE_STRING string -property=subtitle char G_TYPE_STRING string -property=description char G_TYPE_STRING string -property=banner char G_TYPE_STRING string -property=light_banner char G_TYPE_STRING string -property=dark_banner char G_TYPE_STRING string -property=banner_height int G_TYPE_INT int -property=banner_fit GtkContentFit GTK_TYPE_CONTENT_FIT enum -property=banner_text_halign GtkAlign GTK_TYPE_ALIGN enum -property=banner_text_valign GtkAlign GTK_TYPE_ALIGN enum -property=banner_text_label_xalign double G_TYPE_DOUBLE double -property=appids GListModel G_TYPE_LIST_MODEL object -property=enable_bulk_install gboolean G_TYPE_BOOLEAN boolean diff --git a/src/bz-curated-section.txt b/src/bz-curated-section.txt index eceed7f3..4f700fb1 100644 --- a/src/bz-curated-section.txt +++ b/src/bz-curated-section.txt @@ -7,7 +7,7 @@ author=AUTOGEN include= include="bz-entry-group.h" -include="bz-curated-category-info.h" +include="bz-curated-appids-info.h" include="bz-curated-markdown-info.h" include="bz-curated-image-info.h" @@ -18,6 +18,6 @@ property=classes GListModel G_TYPE_LIST_MODEL object property=light_classes GListModel G_TYPE_LIST_MODEL object property=dark_classes GListModel G_TYPE_LIST_MODEL object -property=category BzCuratedCategoryInfo BZ_TYPE_CURATED_CATEGORY_INFO object +property=appids BzCuratedAppidsInfo BZ_TYPE_CURATED_APPIDS_INFO object property=markdown BzCuratedMarkdownInfo BZ_TYPE_CURATED_MARKDOWN_INFO object property=image BzCuratedImageInfo BZ_TYPE_CURATED_IMAGE_INFO object diff --git a/src/bz-section-view.blp b/src/bz-section-view.blp index 5bd2a9f3..a5d31ea2 100644 --- a/src/bz-section-view.blp +++ b/src/bz-section-view.blp @@ -3,6 +3,11 @@ using Gio 2.0; using Adw 1; template $BzSectionView: Adw.Bin { + margin-start: 30; + margin-end: 30; + margin-top: 3; + margin-bottom: 3; + hexpand: bind template.section as <$BzCuratedSection>.expand_horizontally; vexpand: bind template.section as <$BzCuratedSection>.expand_vertically; @@ -13,121 +18,20 @@ template $BzSectionView: Adw.Bin { valign: fill; Box { - visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.category) as ) as ; + hexpand: true; + vexpand: true; + visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.appids) as ) as ; orientation: vertical; - spacing: 5; - - Overlay { - hexpand: true; - - child: Picture { - css-name: "banner"; - height-request: bind $clamp_banner_height(template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-height) as ; - - styles [ - "browser-banner", - ] - - can-shrink: true; - paintable: bind $get_banner(template.section as <$BzCuratedSection>.category) as <$GdkPaintable>; - content-fit: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-fit; - }; - - [overlay] - Overlay banner_text_overlay { - css-name: "banner-text-overlay"; - hexpand: false; - vexpand: false; - - child: Box banner_text_bg { - css-name: "banner-text-bg"; - }; - - halign: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-text-halign; - valign: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-text-valign; - - [overlay] - Box banner_text { - css-name: "banner-text"; - hexpand: false; - vexpand: false; - halign: center; - valign: center; - orientation: vertical; - spacing: 5; - - Label { - css-name: "title"; - - styles [ - "browser-banner-title", - ] - - wrap: true; - wrap-mode: word_char; - ellipsize: end; - lines: 3; - margin-start: 25; - margin-end: 25; - - visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.title) as ) as ; - xalign: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-text-label-xalign; - label: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.title; - } - - Label { - css-name: "subtitle"; - - styles [ - "browser-banner-subtitle", - ] - - wrap: true; - wrap-mode: word_char; - ellipsize: end; - lines: 3; - margin-start: 25; - margin-end: 25; - - visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.subtitle) as ) as ; - xalign: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-text-label-xalign; - label: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.subtitle; - } - - Label { - css-name: "description"; - - styles [ - "browser-banner-description", - ] - - wrap: true; - wrap-mode: word_char; - ellipsize: end; - lines: 10; - margin-start: 25; - margin-end: 25; - - visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.description) as ) as ; - xalign: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.banner-text-label-xalign; - label: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.description; - } - } - } - } + spacing: 10; $BzDynamicListView { - margin-start: 25; - margin-end: 25; - margin-top: 20; - margin-bottom: 20; hexpand: true; scroll: false; noscroll-kind: flow-box; child-type: "BzCuratedAppTile"; child-prop: "group"; - model: bind $convert_to_groups(template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.appids) as ; + model: bind $convert_to_groups(template.section as <$BzCuratedSection>.appids as <$BzCuratedAppidsInfo>.list) as ; bind-widget => $bind_widget_cb(template); unbind-widget => $unbind_widget_cb(template); } @@ -140,7 +44,7 @@ template $BzSectionView: Adw.Bin { margin-end: 25; margin-bottom: 20; halign: center; - visible: bind template.section as <$BzCuratedSection>.category as <$BzCuratedCategoryInfo>.enable-bulk-install as ; + visible: bind template.section as <$BzCuratedSection>.appids as <$BzCuratedAppidsInfo>.enable-bulk-install as ; label: _("Install All"); clicked => $install_all_clicked(template); } @@ -167,8 +71,8 @@ template $BzSectionView: Adw.Bin { Picture { css-name: "image"; paintable: bind $get_image(template.section as <$BzCuratedSection>.image) as <$GdkPaintable>; - can-shrink: bind template.section as <$BzCuratedSection>.category as <$BzCuratedImageInfo>.can-shrink; - content-fit: bind template.section as <$BzCuratedSection>.category as <$BzCuratedImageInfo>.fit; + can-shrink: bind template.section as <$BzCuratedSection>.image as <$BzCuratedImageInfo>.can-shrink; + content-fit: bind template.section as <$BzCuratedSection>.image as <$BzCuratedImageInfo>.fit; } } }; diff --git a/src/bz-section-view.c b/src/bz-section-view.c index 8d32fb60..4d856890 100644 --- a/src/bz-section-view.c +++ b/src/bz-section-view.c @@ -41,9 +41,6 @@ struct _BzSectionView GListModel *applied_classes; /* Template widgets */ - GtkOverlay *banner_text_overlay; - GtkBox *banner_text_bg; - GtkBox *banner_text; BgeMarkdownRender *markdown; }; @@ -151,23 +148,23 @@ is_null (gpointer object, return value == NULL; } -static BzAsyncTexture * -get_banner (gpointer object, - BzCuratedCategoryInfo *info) -{ - const char *banner = NULL; - const char *light_banner = NULL; - const char *dark_banner = NULL; - - if (!BZ_IS_CURATED_CATEGORY_INFO (info)) - return NULL; - - banner = bz_curated_category_info_get_banner (info); - light_banner = bz_curated_category_info_get_light_banner (info); - dark_banner = bz_curated_category_info_get_dark_banner (info); - - return choose_image (banner, light_banner, dark_banner); -} +// static BzAsyncTexture * +// get_banner (gpointer object, +// BzCuratedCategoryInfo *info) +// { +// const char *banner = NULL; +// const char *light_banner = NULL; +// const char *dark_banner = NULL; +// +// if (!BZ_IS_CURATED_CATEGORY_INFO (info)) +// return NULL; +// +// banner = bz_curated_category_info_get_banner (info); +// light_banner = bz_curated_category_info_get_light_banner (info); +// dark_banner = bz_curated_category_info_get_dark_banner (info); +// +// return choose_image (banner, light_banner, dark_banner); +// } static BzAsyncTexture * get_image (gpointer object, @@ -241,8 +238,8 @@ install_all_clicked (BzSectionView *self, GtkButton *button) { GtkWidget *window = NULL; - BzCuratedCategoryInfo *category = NULL; - GListModel *appids = NULL; + BzCuratedAppidsInfo *appids = NULL; + GListModel *list = NULL; guint n_appids = 0; BzStateInfo *info = NULL; BzApplicationMapFactory *factory = NULL; @@ -253,11 +250,11 @@ install_all_clicked (BzSectionView *self, return; /* If the button is visible and the user clicked it, this must be non-null */ - category = bz_curated_section_get_category (self->section); - appids = bz_curated_category_info_get_appids (category); - if (appids == NULL) + appids = bz_curated_section_get_appids (self->section); + list = bz_curated_appids_info_get_list (appids); + if (list == NULL) return; - n_appids = g_list_model_get_n_items (appids); + n_appids = g_list_model_get_n_items (list); if (n_appids == 0) return; @@ -265,7 +262,7 @@ install_all_clicked (BzSectionView *self, info = bz_state_info_get_default (); factory = bz_state_info_get_application_factory (info); - groups = bz_application_map_factory_generate (factory, appids); + groups = bz_application_map_factory_generate (factory, list); /* TODO: use signals to chain up the blueprints; it is cleaner, but more work... :( */ bz_window_bulk_install (BZ_WINDOW (window), groups); @@ -365,13 +362,10 @@ bz_section_view_class_init (BzSectionViewClass *klass) g_type_ensure (BZ_TYPE_ASYNC_TEXTURE); gtk_widget_class_set_template_from_resource (widget_class, "/io/github/kolunmi/Bazaar/bz-section-view.ui"); - gtk_widget_class_bind_template_child (widget_class, BzSectionView, banner_text_overlay); - gtk_widget_class_bind_template_child (widget_class, BzSectionView, banner_text_bg); - gtk_widget_class_bind_template_child (widget_class, BzSectionView, banner_text); gtk_widget_class_bind_template_child (widget_class, BzSectionView, markdown); gtk_widget_class_bind_template_callback (widget_class, invert_boolean); gtk_widget_class_bind_template_callback (widget_class, is_null); - gtk_widget_class_bind_template_callback (widget_class, get_banner); + // gtk_widget_class_bind_template_callback (widget_class, get_banner); gtk_widget_class_bind_template_callback (widget_class, get_image); gtk_widget_class_bind_template_callback (widget_class, clamp_banner_height); gtk_widget_class_bind_template_callback (widget_class, clamp_image_dimension); @@ -402,15 +396,6 @@ bz_section_view_init (BzSectionView *self) { gtk_widget_init_template (GTK_WIDGET (self)); - gtk_overlay_set_measure_overlay ( - self->banner_text_overlay, - GTK_WIDGET (self->banner_text), - TRUE); - gtk_overlay_set_clip_overlay ( - self->banner_text_overlay, - GTK_WIDGET (self->banner_text), - TRUE); - self->style_manager = g_object_ref ( adw_style_manager_get_default ()); g_signal_connect_swapped ( diff --git a/src/curated-config-schema.xml b/src/curated-config-schema.xml index 19a9ebc4..16c440a4 100644 --- a/src/curated-config-schema.xml +++ b/src/curated-config-schema.xml @@ -5,5 +5,5 @@ - + diff --git a/src/meson.build b/src/meson.build index 7e8fb2cf..7cf44aa5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -212,7 +212,7 @@ gobject_specs = files( 'bz-comet.txt', 'bz-country-data-point.txt', 'bz-country.txt', - 'bz-curated-category-info.txt', + 'bz-curated-appids-info.txt', 'bz-curated-image-info.txt', 'bz-curated-markdown-info.txt', 'bz-curated-row.txt',