From b1e09653d755ca6ffd03a1e3e67750e6bcc2bc6f Mon Sep 17 00:00:00 2001 From: Bobby Rong Date: Wed, 22 Sep 2021 11:54:48 +0800 Subject: [PATCH 2/2] Drop homepage banner --- src/Views/Homepage.vala | 181 +--------------------------------------- 1 file changed, 1 insertion(+), 180 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 576fc02c..80a1d221 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -31,67 +31,12 @@ public class AppCenter.Homepage : AbstractView { public bool viewing_package { get; private set; default = false; } public AppStream.Category currently_viewed_category; - private Hdy.Carousel banner_carousel; - private Gtk.Revealer banner_revealer; - private Gtk.FlowBox recently_updated_carousel; - private Gtk.Revealer recently_updated_revealer; - - private uint banner_timeout_id; construct { - banner_carousel = new Hdy.Carousel () { - allow_long_swipes = true - }; - - var banner_event_box = new Gtk.EventBox (); - banner_event_box.events |= Gdk.EventMask.ENTER_NOTIFY_MASK; - banner_event_box.events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; - banner_event_box.add (banner_carousel); - - var banner_dots = new Hdy.CarouselIndicatorDots () { - carousel = banner_carousel - }; - - var banner_grid = new Gtk.Grid () { - orientation = Gtk.Orientation.VERTICAL - }; - banner_grid.add (banner_event_box); - banner_grid.add (banner_dots); - - banner_revealer = new Gtk.Revealer (); - banner_revealer.add (banner_grid); - - var recently_updated_label = new Granite.HeaderLabel (_("Recently Updated")) { - margin_start = 12 - }; - - recently_updated_carousel = new Gtk.FlowBox () { - activate_on_single_click = true, - column_spacing = 12, - row_spacing = 12, - homogeneous = true, - max_children_per_line = 5, - min_children_per_line = 3 - }; - - var recently_updated_grid = new Gtk.Grid () { - margin_end = 12, - margin_start = 12 - }; - recently_updated_grid.attach (recently_updated_label, 0, 0); - recently_updated_grid.attach (recently_updated_carousel, 0, 1); - - recently_updated_revealer = new Gtk.Revealer (); - recently_updated_revealer.add (recently_updated_grid ); - - var categories_label = new Granite.HeaderLabel (_("Categories")) { - margin_start = 24, - margin_top = 24 - }; - category_flow = new Widgets.CategoryFlowBox () { margin_start = 12, margin_end =12, + margin_top = 12, valign = Gtk.Align.START }; @@ -99,9 +44,6 @@ public class AppCenter.Homepage : AbstractView { column_spacing = 24, orientation = Gtk.Orientation.VERTICAL }; - grid.add (banner_revealer); - grid.add (recently_updated_revealer); - grid.add (categories_label); grid.add (category_flow); scrolled_window = new Gtk.ScrolledWindow (null, null) { @@ -111,19 +53,6 @@ public class AppCenter.Homepage : AbstractView { add (scrolled_window); - var local_package = App.local_package; - if (local_package != null) { - var banner = new Widgets.Banner (local_package); - - banner_carousel.prepend (banner); - - banner.clicked.connect (() => { - show_package (local_package); - }); - } - - load_banners_and_carousels.begin (); - category_flow.child_activated.connect ((child) => { var item = child as Widgets.CategoryItem; if (item != null) { @@ -159,94 +88,8 @@ public class AppCenter.Homepage : AbstractView { } } } - - return GLib.Source.REMOVE; }); }); - - banner_event_box.enter_notify_event.connect (() => { - banner_timeout_stop (); - }); - - banner_event_box.leave_notify_event.connect (() => { - banner_timeout_start (); - }); - - recently_updated_carousel.child_activated.connect ((child) => { - var package_row_grid = (AppCenter.Widgets.ListPackageRowGrid) child.get_child (); - - show_package (package_row_grid.package); - }); - } - - private async void load_banners_and_carousels () { - unowned var fp_client = AppCenterCore.FlatpakBackend.get_default (); - var packages_by_release_date = fp_client.get_featured_packages_by_release_date (); - var packages_in_banner = new Gee.LinkedList (); - - int package_count = 0; - foreach (var package in packages_by_release_date) { - if (package_count >= MAX_PACKAGES_IN_BANNER) { - break; - } - - var installed = false; - foreach (var origin_package in package.origin_packages) { - try { - if (yield origin_package.backend.is_package_installed (origin_package)) { - installed = true; - break; - } - } catch (Error e) { - continue; - } - } - - if (!installed) { - packages_in_banner.add (package); - package_count++; - } - } - - foreach (var package in packages_in_banner) { - var banner = new Widgets.Banner (package); - banner.clicked.connect (() => { - show_package (package); - }); - - banner_carousel.add (banner); - } - - banner_carousel.show_all (); - banner_revealer.reveal_child = true; - banner_timeout_start (); - - foreach (var package in packages_by_release_date) { - if (recently_updated_carousel.get_children ().length () >= MAX_PACKAGES_IN_CAROUSEL) { - break; - } - - var installed = false; - foreach (var origin_package in package.origin_packages) { - try { - if (yield origin_package.backend.is_package_installed (origin_package)) { - installed = true; - break; - } - } catch (Error e) { - continue; - } - } - - if (!installed && !(package in packages_in_banner) && !package.is_explicit) { - var package_row = new AppCenter.Widgets.ListPackageRowGrid (package); - recently_updated_carousel.add (package_row); - } - } - recently_updated_carousel.show_all (); - recently_updated_revealer.reveal_child = recently_updated_carousel.get_children ().length () > 0; - - page_loaded (); } public override void show_package ( @@ -307,26 +150,4 @@ public class AppCenter.Homepage : AbstractView { var apps = client.get_applications_for_category (category); app_list_view.add_packages (apps); } - - private void banner_timeout_start () { - banner_timeout_id = Timeout.add (MILLISECONDS_BETWEEN_BANNER_ITEMS, () => { - var new_index = (uint) banner_carousel.position + 1; - var max_index = banner_carousel.n_pages - 1; // 0-based index - - if (banner_carousel.position >= max_index) { - new_index = 0; - } - - banner_carousel.switch_child (new_index, Granite.TRANSITION_DURATION_OPEN); - - return Source.CONTINUE; - }); - } - - private void banner_timeout_stop () { - if (banner_timeout_id != 0) { - Source.remove (banner_timeout_id); - banner_timeout_id = 0; - } - } }