Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/Views/Homepage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public class AppCenter.Homepage : Adw.NavigationPage {

var local_package = App.local_package;
if (local_package != null) {
banner_carousel.prepend (new Widgets.Banner.from_package (local_package));
banner_carousel.prepend (new Widgets.Banner (local_package));
}

load_banners_and_carousels ();
Expand Down Expand Up @@ -222,7 +222,7 @@ public class AppCenter.Homepage : Adw.NavigationPage {

if (!installed) {
packages_in_banner.add (package);
banner_carousel.append (new Widgets.Banner.from_package (package));
banner_carousel.append (new Widgets.Banner (package));
}
}

Expand Down
33 changes: 13 additions & 20 deletions src/Widgets/Banner.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,23 @@
const int MILLISECONDS_BETWEEN_BANNER_ITEMS = 5000;

public class AppCenter.Widgets.Banner : Gtk.Button {
public AppIcon app_icon { get; construct; }
public string brand_color { get; construct; }
public string description { get; construct; }
public string app_name { get; construct; }
public string summary { get; construct; }
public AppCenterCore.Package package { get; construct; }

public Banner.from_package (AppCenterCore.Package package) {
public Banner (AppCenterCore.Package package) {
Object (package: package);
}

construct {
var app_icon = new AppIcon (128) {
package = package
};

Object (
app_name: package.name,
summary: package.get_summary (),
description: package.get_description (),
app_icon: app_icon,
brand_color: package.get_color_primary (),
action_name: MainWindow.ACTION_PREFIX + MainWindow.ACTION_SHOW_PACKAGE,
action_target: new Variant.string (package.uid)
);
}

construct {
var header = new Granite.HeaderLabel (app_name) {
secondary_text = summary,
var header = new Granite.HeaderLabel (package.name) {
secondary_text = package.get_summary (),
size = H1
};

var description = package.get_description ();
if (description != null && description != "") {
// We only want the first line/paragraph
description = description.split ("\n")[0];
Expand Down Expand Up @@ -81,9 +70,13 @@ public class AppCenter.Widgets.Banner : Gtk.Button {
hexpand = true;
child = outer_box;

var brand_color = package.get_color_primary ();
if (brand_color != null) {
set_accent_color (brand_color, this);
}

action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_SHOW_PACKAGE;
action_target = new Variant.string (package.uid);
}

private static Gee.HashMap<string, Gtk.CssProvider>? providers;
Expand Down