diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 9a71479fa..780d1f192 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -218,7 +218,7 @@ public class AppCenter.Homepage : Adw.NavigationPage { var local_package = App.local_package; if (local_package != null) { - var banner = new Widgets.Banner (local_package); + var banner = new Widgets.Banner.from_package (local_package); banner_carousel.prepend (banner); @@ -226,12 +226,14 @@ public class AppCenter.Homepage : Adw.NavigationPage { show_package (local_package); }); } else { -#if PACKAGEKIT_BACKEND appcenter_banner = new Widgets.Banner ( - AppCenterCore.PackageKitBackend.get_default ().lookup_package_by_id ("appcenter") + _("AppCenter"), + _("Browse and manage apps"), + _("The open source, pay-what-you-want app store from elementary. Reviewed and curated by elementary to ensure a native, privacy-respecting, and secure experience. Browse by categories or search and discover new apps. AppCenter is also used for updating your system to the latest and greatest version for new features and fixes."), + new ThemedIcon ("io.elementary.appcenter"), + "#7239b3" ); banner_carousel.append (appcenter_banner); -#endif banner_carousel.page_changed.connect (page_changed_handler ); } @@ -295,7 +297,7 @@ public class AppCenter.Homepage : Adw.NavigationPage { if (!installed) { packages_in_banner.add (package); - var banner = new Widgets.Banner (package); + var banner = new Widgets.Banner.from_package (package); banner.clicked.connect (() => { show_package (package); }); diff --git a/src/Widgets/Banner.vala b/src/Widgets/Banner.vala index 2fe8579db..a71afa331 100644 --- a/src/Widgets/Banner.vala +++ b/src/Widgets/Banner.vala @@ -27,14 +27,35 @@ const string DEFAULT_BANNER_COLOR_PRIMARY_TEXT = "mix(@accent_color, @text_color const int MILLISECONDS_BETWEEN_BANNER_ITEMS = 5000; public class AppCenter.Widgets.Banner : Gtk.Button { - public AppCenterCore.Package package { get; construct; } + public Icon icon { get; construct; } + public string brand_color { get; construct; } + public string description { get; construct; } + public string name { get; construct; } + public string summary { get; construct; } + + public Banner (string name, string summary, string description, Icon icon, string brand_color) { + Object ( + brand_color: brand_color, + description: description, + icon: icon, + name: name, + summary: summary + ); + } - public Banner (AppCenterCore.Package package) { - Object (package: package); + public Banner.from_package (AppCenterCore.Package package) { + Object ( + name: package.get_name (), + summary: package.get_summary (), + description: package.get_description (), + icon: package.get_icon (128, get_scale_factor ()), + brand_color: package.get_color_primary () + ); } + construct { - var name_label = new Gtk.Label (package.get_name ()) { + var name_label = new Gtk.Label (name) { max_width_chars = 50, use_markup = true, wrap = true, @@ -42,7 +63,7 @@ public class AppCenter.Widgets.Banner : Gtk.Button { }; name_label.add_css_class ("name"); - var summary_label = new Gtk.Label (package.get_summary ()) { + var summary_label = new Gtk.Label (summary) { max_width_chars = 50, use_markup = true, wrap = true, @@ -50,10 +71,9 @@ public class AppCenter.Widgets.Banner : Gtk.Button { }; summary_label.add_css_class ("summary"); - string description = ""; - if (package.get_description () != null) { + if (description != null && description != "") { // We only want the first line/paragraph - description = package.get_description ().split ("\n")[0]; + description = description.split ("\n")[0]; } var description_label = new Gtk.Label (description) { @@ -66,9 +86,7 @@ public class AppCenter.Widgets.Banner : Gtk.Button { }; description_label.add_css_class ("description"); - var icon_image = new Gtk.Image.from_gicon ( - package.get_icon (128, get_scale_factor ()) - ); + var icon_image = new Gtk.Image.from_gicon (icon); var inner_box = new Gtk.Box (VERTICAL, 0) { valign = CENTER @@ -95,16 +113,12 @@ public class AppCenter.Widgets.Banner : Gtk.Button { string bg_color = DEFAULT_BANNER_COLOR_PRIMARY; string text_color = DEFAULT_BANNER_COLOR_PRIMARY_TEXT; - if (package != null) { - var primary_color = package.get_color_primary (); - - if (primary_color != null) { - var bg_rgba = Gdk.RGBA (); - bg_rgba.parse (primary_color); + if (brand_color != null) { + var bg_rgba = Gdk.RGBA (); + bg_rgba.parse (brand_color); - bg_color = primary_color; - text_color = Granite.contrasting_foreground_color (bg_rgba).to_string (); - } + bg_color = brand_color; + text_color = Granite.contrasting_foreground_color (bg_rgba).to_string (); } var colored_css = BANNER_STYLE_CSS.printf (bg_color, text_color);