Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/bz-curated-appids-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=bz
name=curated_appids_info
parent-prefix=g
parent-name=object
author=AUTOGEN

include=<gtk/gtk.h>

property=list GListModel G_TYPE_LIST_MODEL object
property=enable_bulk_install gboolean G_TYPE_BOOLEAN boolean
21 changes: 0 additions & 21 deletions src/bz-curated-category-info.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/bz-curated-section.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ author=AUTOGEN
include=<gtk/gtk.h>

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"

Expand All @@ -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
122 changes: 13 additions & 109 deletions src/bz-section-view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -13,121 +18,20 @@ template $BzSectionView: Adw.Bin {
valign: fill;

Box {
visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.category) as <bool>) as <bool>;
hexpand: true;
vexpand: true;
visible: bind $invert_boolean($is_null(template.section as <$BzCuratedSection>.appids) as <bool>) as <bool>;

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 <int>;

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 <bool>) as <bool>;
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 <bool>) as <bool>;
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 <bool>) as <bool>;
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 <Gio.ListModel>;
model: bind $convert_to_groups(template.section as <$BzCuratedSection>.appids as <$BzCuratedAppidsInfo>.list) as <Gio.ListModel>;
bind-widget => $bind_widget_cb(template);
unbind-widget => $unbind_widget_cb(template);
}
Expand All @@ -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 <bool>;
visible: bind template.section as <$BzCuratedSection>.appids as <$BzCuratedAppidsInfo>.enable-bulk-install as <bool>;
label: _("Install All");
clicked => $install_all_clicked(template);
}
Expand All @@ -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;
}
}
};
Expand Down
65 changes: 25 additions & 40 deletions src/bz-section-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ struct _BzSectionView
GListModel *applied_classes;

/* Template widgets */
GtkOverlay *banner_text_overlay;
GtkBox *banner_text_bg;
GtkBox *banner_text;
BgeMarkdownRender *markdown;
};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -253,19 +250,19 @@ 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;

/* TODO: bind state via object properties */
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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion src/curated-config-schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<typehint name="rows.sections.classes" type="GtkStringObject"/>
<typehint name="rows.sections.light-classes" type="GtkStringObject"/>
<typehint name="rows.sections.dark-classes" type="GtkStringObject"/>
<typehint name="rows.sections.category.appids" type="GtkStringObject"/>
<typehint name="rows.sections.appids.list" type="GtkStringObject"/>
</object>
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading