From f7d03abd9ed59fca5a01ac5036857d8a8fed8fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 11:32:46 -0700 Subject: [PATCH 01/87] Initial build attempt --- meson.build | 9 +- src/Application.vala | 44 +- src/Core/Package.vala | 2 +- src/Dialogs/StripeDialog.vala | 116 +++--- src/Dialogs/UninstallConfirmDialog.vala | 2 +- src/MainWindow.vala | 290 +++++++------- src/Services/DBusServer.vala | 26 +- src/Views/AppInfoView.vala | 377 +++++++++--------- src/Views/AppListUpdateView.vala | 41 +- src/Views/CategoryView.vala | 83 ++-- src/Views/Homepage.vala | 82 ++-- src/Views/SearchView.vala | 14 +- src/Widgets/AbstractAppList.vala | 44 +- .../AppContainers/AbstractAppContainer.vala | 25 +- .../AppContainers/AbstractPackageRowGrid.vala | 5 +- .../InstalledPackageRowGrid.vala | 31 +- .../AppContainers/ListPackageRowGrid.vala | 5 +- src/Widgets/Banner.vala | 10 +- src/Widgets/CardNumberEntry.vala | 2 +- src/Widgets/CategoryFlowBox.vala | 62 +-- src/Widgets/HumbleButton.vala | 2 +- src/Widgets/PackageRow.vala | 4 +- src/Widgets/ReleaseListBox.vala | 2 +- src/Widgets/ReleaseRow.vala | 2 +- src/Widgets/SharePopover.vala | 89 +++-- src/Widgets/SizeLabel.vala | 18 +- src/Widgets/UpdateHeaderRow.vala | 6 +- 27 files changed, 683 insertions(+), 710 deletions(-) diff --git a/meson.build b/meson.build index d6db41d9b..7beacad71 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,6 @@ i18n = import('i18n') add_project_arguments( '-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), - '-DHANDY_USE_UNSTABLE_API', '-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE', language:'c' ) @@ -20,9 +19,9 @@ add_project_arguments(['--vapidir', vapi_dir], language: 'vala') glib = dependency ('glib-2.0') gee = dependency ('gee-0.8') -gtk = dependency ('gtk+-3.0', version: '>=3.10') -granite = dependency ('granite', version: '>=6.0.0') -handy = dependency('libhandy-1', version: '>=1.4.0') +gtk = dependency ('gtk4') +granite = dependency ('granite-7', version: '>=7.0.0') +adwaita = dependency('libadwaita-1') packagekit = dependency ('packagekit-glib2') appstream = dependency ('appstream', version: '>=0.15.2') libsoup = dependency ('libsoup-2.4') @@ -39,7 +38,7 @@ dependencies = [ gee, gtk, granite, - handy, + adwaita, packagekit, appstream, libsoup, diff --git a/src/Application.vala b/src/Application.vala index 3ea2206ad..dac9f0c3a 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -160,19 +160,19 @@ public class AppCenter.App : Gtk.Application { var provider = new Gtk.CssProvider (); provider.load_from_resource ("io/elementary/appcenter/application.css"); - Gtk.StyleContext.add_provider_for_screen ( - Gdk.Screen.get_default (), - provider, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); + // Gtk.StyleContext.add_provider_for_screen ( + // Gdk.Screen.get_default (), + // provider, + // Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + // ); var fallback_provider = new Gtk.CssProvider (); fallback_provider.load_from_resource ("io/elementary/appcenter/fallback.css"); - Gtk.StyleContext.add_provider_for_screen ( - Gdk.Screen.get_default (), - fallback_provider, - Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK - ); + // Gtk.StyleContext.add_provider_for_screen ( + // Gdk.Screen.get_default (), + // fallback_provider, + // Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK + // ); var client = AppCenterCore.Client.get_default (); @@ -215,12 +215,12 @@ public class AppCenter.App : Gtk.Application { client.update_cache.begin (true, AppCenterCore.Client.CacheUpdateType.FLATPAK); #endif - main_window.destroy.connect (() => { - main_window = null; - }); + // main_window.destroy.connect (() => { + // main_window = null; + // }); add_window (main_window); - main_window.show_all (); + main_window.present (); if (show_updates) { main_window.go_to_installed (); } @@ -296,12 +296,11 @@ public class AppCenter.App : Gtk.Application { if (package.get_can_launch ()) { // Check if window is focused if (main_window != null) { - var win = main_window.get_window (); - if (win != null && (win.get_state () & Gdk.WindowState.FOCUSED) != 0) { + // if (win != null && (win.get_state () & Gdk.WindowState.FOCUSED) != 0) { main_window.send_installed_toast (package); break; - } + // } } var notification = new Notification (_("The app has been installed")); @@ -318,10 +317,7 @@ public class AppCenter.App : Gtk.Application { } var dialog = new InstallFailDialog (package, error); - - dialog.show_all (); - dialog.run (); - dialog.destroy (); + dialog.present (); } break; @@ -350,9 +346,9 @@ public class AppCenter.App : Gtk.Application { update_fail_dialog = new UpdateFailDialog (format_error_message (error.message), cache_update_type); update_fail_dialog.transient_for = main_window; - update_fail_dialog.destroy.connect (() => { - update_fail_dialog = null; - }); + // update_fail_dialog.destroy.connect (() => { + // update_fail_dialog = null; + // }); } update_fail_dialog.present (); diff --git a/src/Core/Package.vala b/src/Core/Package.vala index 8412e6d6c..01680c391 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -684,7 +684,7 @@ public class AppCenterCore.Package : Object { switch (_icon.get_kind ()) { case AppStream.IconKind.STOCK: unowned string icon_name = _icon.get_name (); - if (Gtk.IconTheme.get_default ().has_icon (icon_name)) { + if (Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).has_icon (icon_name)) { return new ThemedIcon (icon_name); } diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index b110b6ee0..94244c434 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -42,8 +42,8 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { private const string DEFAULT_ERROR_MESSAGE = N_("Please review your payment info and try again."); private Gtk.Grid card_layout; - private Gtk.Grid? processing_layout = null; - private Gtk.Grid? error_layout = null; + private Gtk.Box? processing_layout = null; + private Gtk.Box? error_layout = null; private Gtk.Stack layouts; private AppCenter.Widgets.CardNumberEntry card_number_entry; @@ -75,19 +75,25 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { } construct { - var image = new Gtk.Image.from_icon_name ("payment-card", Gtk.IconSize.DIALOG); - image.valign = Gtk.Align.START; + var image = new Gtk.Image.from_icon_name ("payment-card") { + pixel_size = 48, + valign = Gtk.Align.START + }; - var overlay_image = new Gtk.Image.from_icon_name (Build.PROJECT_NAME, Gtk.IconSize.LARGE_TOOLBAR); - overlay_image.halign = overlay_image.valign = Gtk.Align.END; + var overlay_image = new Gtk.Image.from_icon_name (Build.PROJECT_NAME) { + halign = Gtk.Align.END, + valign = Gtk.Align.END, + pixel_size = 24 + }; - var overlay = new Gtk.Overlay (); - overlay.valign = Gtk.Align.START; - overlay.add (image); + var overlay = new Gtk.Overlay () { + child = image, + valign = Gtk.Align.START + }; overlay.add_overlay (overlay_image); var primary_label = new Gtk.Label (_("Pay $%d for %s").printf (amount, app_name)); - primary_label.get_style_context ().add_class ("primary"); + primary_label.add_css_class ("primary"); primary_label.xalign = 0; var secondary_label = new Gtk.Label ( @@ -118,20 +124,16 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }; var custom_amount = new Gtk.SpinButton.with_range (0, 100, 1) { - activates_default = true, hexpand = true, - primary_icon_name = "currency-dollar-symbolic", value = amount }; - var selection_list = new Gtk.Grid () { - column_spacing = 6 - }; - selection_list.add (custom_amount); - selection_list.add (or_label); - selection_list.add (one_dollar); - selection_list.add (five_dollar); - selection_list.add (ten_dollar); + var selection_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); + selection_box.append (custom_amount); + selection_box.append (or_label); + selection_box.append (one_dollar); + selection_box.append (five_dollar); + selection_box.append (ten_dollar); Regex? email_regex = null; Regex? expiration_regex = null; @@ -164,7 +166,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { wrap = true, xalign = 0 }; - email_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); + email_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); card_number_entry = new AppCenter.Widgets.CardNumberEntry () { activates_default = true, @@ -203,16 +205,17 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { card_grid.attach (card_expiration_entry, 0, 3); card_grid.attach (card_cvc_entry, 1, 3); - var card_grid_revealer = new Gtk.Revealer (); - card_grid_revealer.add (card_grid); + var card_grid_revealer = new Gtk.Revealer () { + child = card_grid + }; card_layout = new Gtk.Grid (); - card_layout.get_style_context ().add_class ("login"); + card_layout.add_css_class ("login"); card_layout.column_spacing = 12; card_layout.attach (overlay, 0, 0, 1, 2); card_layout.attach (primary_label, 1, 0); card_layout.attach (secondary_label, 1, 1); - card_layout.attach (selection_list, 1, 2); + card_layout.attach (selection_box, 1, 2); card_layout.attach (card_grid_revealer, 1, 3); layouts = new Gtk.Stack () { @@ -225,17 +228,15 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { layouts.add_named (card_layout, "card"); layouts.set_visible_child_name ("card"); - var content_area = get_content_area (); - content_area.add (layouts); - content_area.show_all (); + get_content_area ().append (layouts); custom_amount.grab_focus (); cancel_button = (Gtk.Button) add_button (_("Cancel"), Gtk.ResponseType.CLOSE); pay_button = (Gtk.Button) add_button (_("Pay $%d.00").printf (amount), Gtk.ResponseType.APPLY); - pay_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); - pay_button.has_default = true; + pay_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); + // pay_button.has_default = true; pay_button.sensitive = false; response.connect (on_response); @@ -285,13 +286,13 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { is_payment_sensitive (); }); - card_expiration_entry.focus_out_event.connect (() => { - var expiration_text = card_expiration_entry.text; - if (!("/" in expiration_text) && expiration_text.char_count () > 2) { - int position = 2; - card_expiration_entry.insert_text ("/", 1, ref position); - } - }); + // card_expiration_entry.focus_out_event.connect (() => { + // var expiration_text = card_expiration_entry.text; + // if (!("/" in expiration_text) && expiration_text.char_count () > 2) { + // int position = 2; + // card_expiration_entry.insert_text ("/", 1, ref position); + // } + // }); card_cvc_entry.changed.connect (() => { card_cvc_entry.text = card_cvc_entry.text.replace (" ", ""); @@ -301,10 +302,6 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { private void show_spinner_view () { if (processing_layout == null) { - processing_layout = new Gtk.Grid (); - processing_layout.orientation = Gtk.Orientation.VERTICAL; - processing_layout.column_spacing = 12; - var spinner = new Gtk.Spinner (); spinner.width_request = 48; spinner.height_request = 48; @@ -312,18 +309,18 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { var label = new Gtk.Label (_("Processing")); label.hexpand = true; - label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + label.add_css_class (Granite.STYLE_CLASS_H2_LABEL); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12); box.valign = Gtk.Align.CENTER; box.vexpand = true; + box.append (spinner); + box.append (label); - box.add (spinner); - box.add (label); - processing_layout.add (box); + processing_layout = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + processing_layout.append (box); layouts.add_named (processing_layout, "processing"); - layouts.show_all (); } layouts.set_visible_child_name ("processing"); @@ -333,10 +330,8 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { private void show_error_view (string error_reason) { if (error_layout == null) { - error_layout = new Gtk.Grid (); - var primary_label = new Gtk.Label (_("There Was a Problem Processing Your Payment")); - primary_label.get_style_context ().add_class ("primary"); + primary_label.add_css_class ("primary"); primary_label.max_width_chars = 35; primary_label.wrap = true; primary_label.xalign = 0; @@ -346,15 +341,20 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { secondary_error_label.wrap = true; secondary_error_label.xalign = 0; - var icon = new Gtk.Image.from_icon_name (Build.PROJECT_NAME, Gtk.IconSize.DIALOG); + var icon = new Gtk.Image.from_icon_name (Build.PROJECT_NAME) { + pixel_size = 48 + }; - var overlay_icon = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.LARGE_TOOLBAR); - overlay_icon.halign = Gtk.Align.END; - overlay_icon.valign = Gtk.Align.END; + var overlay_icon = new Gtk.Image.from_icon_name ("dialog-warning") { + halign = Gtk.Align.END, + valign = Gtk.Align.END, + pixel_size = 24 + }; - var overlay = new Gtk.Overlay (); - overlay.valign = Gtk.Align.START; - overlay.add (icon); + var overlay = new Gtk.Overlay () { + child = icon, + valign = Gtk.Align.START + }; overlay.add_overlay (overlay_icon); var grid = new Gtk.Grid (); @@ -364,10 +364,10 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { grid.attach (primary_label, 1, 0, 1, 1); grid.attach (secondary_error_label, 1, 1, 1, 1); - error_layout.add (grid); + error_layout = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + error_layout.append (grid); layouts.add_named (error_layout, "error"); - layouts.show_all (); } else { secondary_error_label.label = error_reason; } diff --git a/src/Dialogs/UninstallConfirmDialog.vala b/src/Dialogs/UninstallConfirmDialog.vala index 91b04a914..39702ac48 100644 --- a/src/Dialogs/UninstallConfirmDialog.vala +++ b/src/Dialogs/UninstallConfirmDialog.vala @@ -39,6 +39,6 @@ public class UninstallConfirmDialog : Granite.MessageDialog { } var uninstall_button = add_button (_("Uninstall"), Gtk.ResponseType.ACCEPT); - uninstall_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + uninstall_button.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); } } diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 6fa2a988f..7717f7a2f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -14,19 +14,19 @@ * with this program. If not, see http://www.gnu.org/licenses/. */ -public class AppCenter.MainWindow : Hdy.ApplicationWindow { +public class AppCenter.MainWindow : Adw.ApplicationWindow { public bool working { get; set; } private AppCenter.SearchView search_view; private Gtk.Revealer view_mode_revealer; private Gtk.SearchEntry search_entry; private Gtk.Spinner spinner; - private Gtk.ModelButton refresh_menuitem; + private Gtk.Button refresh_menuitem; private Gtk.Button return_button; private Gtk.Label updates_badge; private Gtk.Revealer updates_badge_revealer; - private Granite.Widgets.Toast toast; - private Hdy.Deck deck; + private Granite.Toast toast; + private Adw.Leaflet leaflet; private AppCenterCore.Package? last_installed_package; private AppCenterCore.Package? selected_package; @@ -42,10 +42,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { public MainWindow (Gtk.Application app) { Object (application: app); - weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_default (); - default_theme.add_resource_path ("/io/elementary/appcenter/icons"); - - search_entry.grab_focus_without_selecting (); + // search_entry.grab_focus_without_selecting (); var go_back = new SimpleAction ("go-back", null); go_back.activate.connect (view_return); @@ -58,31 +55,31 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { app.set_accels_for_action ("win.go-back", {"Left", "Back"}); app.set_accels_for_action ("win.focus-search", {"f"}); - button_release_event.connect ((event) => { - // On back mouse button pressed - if (event.button == 8) { - view_return (); - return true; - } + // button_release_event.connect ((event) => { + // // On back mouse button pressed + // if (event.button == 8) { + // view_return (); + // return true; + // } - return false; - }); + // return false; + // }); search_entry.search_changed.connect (() => trigger_search ()); - search_entry.key_press_event.connect ((event) => { - if (event.keyval == Gdk.Key.Escape) { - search_entry.text = ""; - return true; - } + // search_entry.key_press_event.connect ((event) => { + // if (event.keyval == Gdk.Key.Escape) { + // search_entry.text = ""; + // return true; + // } - if (event.keyval == Gdk.Key.Down) { - search_entry.move_focus (Gtk.DirectionType.TAB_FORWARD); - return true; - } + // if (event.keyval == Gdk.Key.Down) { + // search_entry.move_focus (Gtk.DirectionType.TAB_FORWARD); + // return true; + // } - return false; - }); + // return false; + // }); return_button.clicked.connect (view_return); @@ -91,7 +88,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { notify["working"].connect (() => { Idle.add (() => { - spinner.active = working; + spinner.spinning = working; App.refresh_action.set_enabled (!working); return GLib.Source.REMOVE; }); @@ -99,14 +96,15 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { } construct { - Hdy.init (); icon_name = Build.PROJECT_NAME; set_default_size (910, 640); height_request = 500; + Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).add_resource_path ("/io/elementary/appcenter/icons"); + title = _(Build.APP_NAME); - toast = new Granite.Widgets.Toast (""); + toast = new Granite.Toast (""); toast.default_action.connect (() => { if (last_installed_package != null) { @@ -124,7 +122,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { message_dialog.badge_icon = new ThemedIcon ("dialog-error"); message_dialog.transient_for = this; - message_dialog.show_all (); + message_dialog.present (); message_dialog.response.connect ((response_id) => { message_dialog.destroy (); }); @@ -133,12 +131,15 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { }); return_button = new Gtk.Button () { - no_show_all = true, valign = Gtk.Align.CENTER }; return_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON); - var updates_button = new Gtk.Button.from_icon_name ("software-update-available", Gtk.IconSize.LARGE_TOOLBAR); + var updates_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("software-update-available") { + pixel_size = 24 + } + }; var badge_provider = new Gtk.CssProvider (); badge_provider.load_from_resource ("io/elementary/appcenter/badge.css"); @@ -150,28 +151,23 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { badge_context.add_provider (badge_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); updates_badge_revealer = new Gtk.Revealer () { + child = updates_badge, halign = Gtk.Align.END, valign = Gtk.Align.START, transition_type = Gtk.RevealerTransitionType.CROSSFADE }; - updates_badge_revealer.add (updates_badge); - - var eventbox_badge = new Gtk.EventBox () { - halign = Gtk.Align.END - }; - eventbox_badge.add (updates_badge_revealer); var updates_overlay = new Gtk.Overlay () { + child = updates_button, tooltip_text = C_("view", "Updates & installed apps") }; - updates_overlay.add (updates_button); - updates_overlay.add_overlay (eventbox_badge); + updates_overlay.add_overlay (updates_badge_revealer); view_mode_revealer = new Gtk.Revealer () { + child = updates_overlay, reveal_child = true, transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT }; - view_mode_revealer.add (updates_overlay); search_entry = new Gtk.SearchEntry () { hexpand = true, @@ -179,8 +175,9 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { valign = Gtk.Align.CENTER }; - var search_clamp = new Hdy.Clamp (); - search_clamp.add (search_entry); + var search_clamp = new Adw.Clamp () { + child = search_entry + }; spinner = new Gtk.Spinner (); @@ -193,34 +190,35 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { "app.refresh" ); - refresh_menuitem = new Gtk.ModelButton () { - action_name = "app.refresh" + refresh_menuitem = new Gtk.Button () { + action_name = "app.refresh", + child = refresh_accellabel }; - refresh_menuitem.get_child ().destroy (); - refresh_menuitem.add (refresh_accellabel); var menu_popover_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_bottom = 6, margin_top = 6 }; - menu_popover_box.add (automatic_updates_button); - menu_popover_box.add (refresh_menuitem); - menu_popover_box.show_all (); + menu_popover_box.append (automatic_updates_button); + menu_popover_box.append (refresh_menuitem); - var menu_popover = new Gtk.Popover (null); - menu_popover.add (menu_popover_box); + var menu_popover = new Gtk.Popover () { + child = menu_popover_box + }; var menu_button = new Gtk.MenuButton () { - image = new Gtk.Image.from_icon_name ("open-menu", Gtk.IconSize.LARGE_TOOLBAR), + child = new Gtk.Image.from_icon_name ("open-menu") { + pixel_size = 24 + }, popover = menu_popover, tooltip_text = _("Settings"), valign = Gtk.Align.CENTER }; - var headerbar = new Hdy.HeaderBar () { - show_close_button = true + var headerbar = new Gtk.HeaderBar () { + show_title_buttons = true, + title_widget = search_clamp }; - headerbar.set_custom_title (search_clamp); headerbar.pack_start (return_button); headerbar.pack_end (menu_button); headerbar.pack_end (view_mode_revealer); @@ -229,14 +227,15 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { var homepage = new Homepage (); installed_view = new Views.AppListUpdateView (); - deck = new Hdy.Deck () { - can_swipe_back = true + leaflet = new Adw.Leaflet () { + can_navigate_back = true }; - deck.add (homepage); + leaflet.append (homepage); - var overlay = new Gtk.Overlay (); + var overlay = new Gtk.Overlay () { + child = leaflet + }; overlay.add_overlay (toast); - overlay.add (deck); var network_info_bar_label = new Gtk.Label ("%s %s".printf ( _("Network Not Available."), @@ -249,15 +248,15 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { var network_info_bar = new Gtk.InfoBar () { message_type = Gtk.MessageType.WARNING }; - network_info_bar.get_content_area ().add (network_info_bar_label); + network_info_bar.add_child (network_info_bar_label); network_info_bar.add_button (_("Network Settingsā€¦"), Gtk.ResponseType.ACCEPT); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - box.add (headerbar); - box.add (network_info_bar); - box.add (overlay); + box.append (headerbar); + box.append (network_info_bar); + box.append (overlay); - add (box); + child = box; int window_width, window_height; App.settings.get ("window-size", "(ii)", out window_width, out window_height); @@ -268,7 +267,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { SettingsBindFlags.DEFAULT ); - resize (window_width, window_height); + // resize (window_width, window_height); if (App.settings.get_boolean ("window-maximized")) { maximize (); @@ -287,7 +286,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { network_info_bar.response.connect (() => { try { - Gtk.show_uri_on_window (this, "settings://network", Gdk.CURRENT_TIME); + Gtk.show_uri (this, "settings://network", Gdk.CURRENT_TIME); } catch (GLib.Error e) { critical (e.message); } @@ -297,9 +296,9 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { go_to_installed (); }); - eventbox_badge.button_release_event.connect (() => { - go_to_installed (); - }); + // eventbox_badge.button_release_event.connect (() => { + // go_to_installed (); + // }); homepage.show_category.connect ((category) => { show_category (category); @@ -313,62 +312,62 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { show_package (package); }); - destroy.connect (() => { - installed_view.clear (); - }); + // destroy.connect (() => { + // installed_view.clear (); + // }); - deck.notify["visible-child"].connect (() => { - if (!deck.transition_running) { + leaflet.notify["visible-child"].connect (() => { + if (!leaflet.child_transition_running) { update_navigation (); } }); - deck.notify["transition-running"].connect (() => { - if (!deck.transition_running) { + leaflet.notify["child-transition-running"].connect (() => { + if (!leaflet.child_transition_running) { update_navigation (); } }); } - public override bool configure_event (Gdk.EventConfigure event) { - if (configure_id == 0) { - /* Avoid spamming the settings */ - configure_id = Timeout.add (200, () => { - configure_id = 0; + // public override bool configure_event (Gdk.EventConfigure event) { + // if (configure_id == 0) { + // /* Avoid spamming the settings */ + // configure_id = Timeout.add (200, () => { + // configure_id = 0; - if (is_maximized) { - App.settings.set_boolean ("window-maximized", true); - } else { - App.settings.set_boolean ("window-maximized", false); + // if (is_maximized) { + // App.settings.set_boolean ("window-maximized", true); + // } else { + // App.settings.set_boolean ("window-maximized", false); - int width, height; - get_size (out width, out height); - App.settings.set ("window-size", "(ii)", width, height); - } + // int width, height; + // get_size (out width, out height); + // App.settings.set ("window-size", "(ii)", width, height); + // } - return GLib.Source.REMOVE; - }); - } + // return GLib.Source.REMOVE; + // }); + // } - return base.configure_event (event); - } + // return base.configure_event (event); + // } - public override bool delete_event (Gdk.EventAny event) { - if (working) { - hide (); + // public override bool delete_event (Gdk.EventAny event) { + // if (working) { + // hide (); - notify["working"].connect (() => { - if (!visible && !working) { - destroy (); - } - }); + // notify["working"].connect (() => { + // if (!visible && !working) { + // destroy (); + // } + // }); - AppCenterCore.Client.get_default ().cancel_updates (false); //Timeouts keep running - return true; - } + // AppCenterCore.Client.get_default ().cancel_updates (false); //Timeouts keep running + // return true; + // } - return false; - } + // return false; + // } public void show_update_badge (uint updates_number) { if (updates_number == 0U) { @@ -380,7 +379,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { } public void show_package (AppCenterCore.Package package, bool remember_history = true) { - if (deck.transition_running) { + if (leaflet.child_transition_running) { return; } @@ -388,7 +387,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { var package_hash = package.hash; - var pk_child = deck.get_child_by_name (package_hash) as Views.AppInfoView; + var pk_child = leaflet.get_child_by_name (package_hash) as Views.AppInfoView; if (pk_child != null && pk_child.to_recycle) { // Don't switch to a view that needs recycling pk_child.destroy (); @@ -397,40 +396,39 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { if (pk_child != null) { pk_child.view_entered (); - deck.visible_child = pk_child; + leaflet.visible_child = pk_child; return; } var app_info_view = new Views.AppInfoView (package); - app_info_view.show_all (); - deck.add (app_info_view); - deck.visible_child = app_info_view; + leaflet.append (app_info_view); + leaflet.visible_child = app_info_view; app_info_view.show_other_package.connect ((_package, remember_history, transition) => { if (!transition) { - deck.transition_duration = 0; + leaflet.mode_transition_duration = 0; } show_package (_package, remember_history); if (remember_history) { set_return_name (package.get_name ()); } - deck.transition_duration = 200; + leaflet.mode_transition_duration = 200; }); } private void update_navigation () { - var previous_child = deck.get_adjacent_child (Hdy.NavigationDirection.BACK); + var previous_child = leaflet.get_adjacent_child (Adw.NavigationDirection.BACK); - if (deck.visible_child is Homepage) { + if (leaflet.visible_child is Homepage) { view_mode_revealer.reveal_child = true; configure_search (true, _("Search Apps"), ""); - } else if (deck.visible_child is CategoryView) { - var current_category = ((CategoryView) deck.visible_child).category; + } else if (leaflet.visible_child is CategoryView) { + var current_category = ((CategoryView) leaflet.visible_child).category; view_mode_revealer.reveal_child = false; configure_search (true, _("Search %s").printf (current_category.name), ""); - } else if (deck.visible_child == search_view) { + } else if (leaflet.visible_child == search_view) { if (previous_child is CategoryView) { var previous_category = ((CategoryView) previous_child).category; configure_search (true, _("Search %s").printf (previous_category.name)); @@ -439,10 +437,10 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { configure_search (true); view_mode_revealer.reveal_child = true; } - } else if (deck.visible_child is Views.AppInfoView) { + } else if (leaflet.visible_child is Views.AppInfoView) { view_mode_revealer.reveal_child = false; configure_search (false); - } else if (deck.visible_child is Views.AppListUpdateView) { + } else if (leaflet.visible_child is Views.AppListUpdateView) { view_mode_revealer.reveal_child = true; configure_search (false); } @@ -462,10 +460,10 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { set_return_name (C_("view", "Installed")); } - while (deck.get_adjacent_child (Hdy.NavigationDirection.FORWARD) != null) { - var next_child = deck.get_adjacent_child (Hdy.NavigationDirection.FORWARD); + while (leaflet.get_adjacent_child (Adw.NavigationDirection.FORWARD) != null) { + var next_child = leaflet.get_adjacent_child (Adw.NavigationDirection.FORWARD); if (next_child is AppCenter.Views.AppListUpdateView) { - deck.remove (next_child); + leaflet.remove (next_child); } else { next_child.destroy (); } @@ -473,11 +471,11 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { } public void go_to_installed () { - if (deck.get_children ().find (installed_view) == null) { - deck.add (installed_view); - } - installed_view.show_all (); - deck.visible_child = installed_view; + // if (leaflet.get_children ().find (installed_view) == null) { + leaflet.append (installed_view); + // } + + leaflet.visible_child = installed_view; } public void search (string term, bool mimetype = false) { @@ -512,16 +510,15 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { view_mode_revealer.reveal_child = !query_valid; if (query_valid) { - if (deck.visible_child != search_view) { + if (leaflet.visible_child != search_view) { search_view = new AppCenter.SearchView (); - search_view.show_all (); search_view.show_app.connect ((package) => { show_package (package); }); - deck.add (search_view); - deck.visible_child = search_view; + leaflet.append (search_view); + leaflet.visible_child = search_view; } search_view.clear (); @@ -537,7 +534,7 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { } else { AppStream.Category current_category = null; - var previous_child = deck.get_adjacent_child (Hdy.NavigationDirection.BACK); + var previous_child = leaflet.get_adjacent_child (Adw.NavigationDirection.BACK); if (previous_child is CategoryView) { current_category = ((CategoryView) previous_child).category; } @@ -548,8 +545,8 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { } else { // Prevent navigating away from category views when backspacing - if (deck.visible_child == search_view) { - deck.navigate (Hdy.NavigationDirection.BACK); + if (leaflet.visible_child == search_view) { + leaflet.navigate (Adw.NavigationDirection.BACK); } } @@ -563,7 +560,6 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { return_button.label = return_name; } - return_button.no_show_all = return_name == null; return_button.visible = return_name != null; } @@ -576,26 +572,26 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow { } if (sensitive) { - search_entry.grab_focus_without_selecting (); + // search_entry.grab_focus_without_selecting (); } } private void view_return () { selected_package = null; - deck.navigate (Hdy.NavigationDirection.BACK); + leaflet.navigate (Adw.NavigationDirection.BACK); } private void show_category (AppStream.Category category) { - var child = deck.get_child_by_name (category.name); + var child = leaflet.get_child_by_name (category.name); if (child != null) { - deck.visible_child = child; + leaflet.visible_child = child; return; } var category_view = new CategoryView (category); - deck.add (category_view); - deck.visible_child = category_view; + leaflet.append (category_view); + leaflet.visible_child = category_view; category_view.show_app.connect ((package) => { show_package (package); diff --git a/src/Services/DBusServer.vala b/src/Services/DBusServer.vala index 15666f814..f1687962b 100644 --- a/src/Services/DBusServer.vala +++ b/src/Services/DBusServer.vala @@ -59,19 +59,19 @@ public class DBusServer : Object { var uninstall_confirm_dialog = new UninstallConfirmDialog (package); - if (uninstall_confirm_dialog.run () == Gtk.ResponseType.ACCEPT) { - package.uninstall.begin ((obj, res) => { - try { - package.uninstall.end (res); - } catch (Error e) { - // Disable error dialog for if user clicks cancel. Reason: Failed to obtain authentication - // Pk ErrorEnums are mapped to the error code at an offset of 0xFF (see packagekit-glib2/pk-client.h) - if (!(e is Pk.ClientError) || e.code != Pk.ErrorEnum.NOT_AUTHORIZED + 0xFF) { - new UninstallFailDialog (package, e).present (); - } - } - }); - } + // if (uninstall_confirm_dialog.run () == Gtk.ResponseType.ACCEPT) { + // package.uninstall.begin ((obj, res) => { + // try { + // package.uninstall.end (res); + // } catch (Error e) { + // // Disable error dialog for if user clicks cancel. Reason: Failed to obtain authentication + // // Pk ErrorEnums are mapped to the error code at an offset of 0xFF (see packagekit-glib2/pk-client.h) + // if (!(e is Pk.ClientError) || e.code != Pk.ErrorEnum.NOT_AUTHORIZED + 0xFF) { + // new UninstallFailDialog (package, e).present (); + // } + // } + // }); + // } uninstall_confirm_dialog.destroy (); } diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 91c0fd48e..ee6096bb4 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -42,13 +42,13 @@ namespace AppCenter.Views { private Gtk.ListStore origin_liststore; private Gtk.Overlay screenshot_overlay; private Gtk.Revealer origin_combo_revealer; - private Hdy.Carousel app_screenshots; - private Hdy.Clamp screenshot_not_found_clamp; + private Adw.Carousel app_screenshots; + private Adw.Clamp screenshot_not_found_clamp; private Gtk.Stack screenshot_stack; private Gtk.Label app_description; private Widgets.ReleaseListBox release_list_box; private Widgets.SizeLabel size_label; - private Hdy.CarouselIndicatorDots screenshot_switcher; + private Adw.CarouselIndicatorDots screenshot_switcher; private ArrowButton screenshot_next; private ArrowButton screenshot_previous; private Gtk.FlowBox oars_flowbox; @@ -98,30 +98,30 @@ namespace AppCenter.Views { text_color = Granite.contrasting_foreground_color (bg_rgba).to_string (); accent_css = "@define-color accent_color %s;".printf (primary_color); - accent_provider.load_from_data (accent_css, accent_css.length); + accent_provider.load_from_data (accent_css.data); } } var colored_css = BANNER_STYLE_CSS.printf (bg_color, text_color); colored_css += accent_css; - accent_provider.load_from_data (colored_css, colored_css.length); + accent_provider.load_from_data (colored_css.data); } catch (GLib.Error e) { critical ("Unable to set accent color: %s", e.message); } unowned var action_button_context = action_button.get_style_context (); - action_button_context.add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + action_button_context.add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); action_button_context.add_provider (banner_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); action_button_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); unowned var open_button_context = open_button.get_style_context (); - open_button_context.add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + open_button_context.add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); open_button_context.add_provider (banner_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); open_button_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); unowned var cancel_button_context = cancel_button.get_style_context (); - cancel_button_context.add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + cancel_button_context.add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); cancel_button_context.add_provider (banner_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); cancel_button_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -159,15 +159,16 @@ namespace AppCenter.Views { selection_mode = Gtk.SelectionMode.NONE }; - oars_flowbox_revealer = new Gtk.Revealer (); - oars_flowbox_revealer.add (oars_flowbox); + oars_flowbox_revealer = new Gtk.Revealer () { + child = oars_flowbox + }; - var content_warning_clamp = new Hdy.Clamp () { + var content_warning_clamp = new Adw.Clamp () { + child = oars_flowbox_revealer, margin_start = 24, margin_end = 24, maximum_size = MAX_WIDTH }; - content_warning_clamp.add (oars_flowbox_revealer); #if CURATED if (!package.is_native && !package.is_os_updates) { @@ -177,7 +178,7 @@ namespace AppCenter.Views { "security-low-symbolic" ); - oars_flowbox.add (uncurated); + oars_flowbox.append (uncurated); } #endif @@ -200,7 +201,7 @@ namespace AppCenter.Views { "oars-conflict-symbolic" ); - oars_flowbox.add (conflict); + oars_flowbox.append (conflict); } if ( @@ -223,13 +224,13 @@ namespace AppCenter.Views { "oars-violence-symbolic" ); - oars_flowbox.add (violence); + oars_flowbox.append (violence); } if ( rating.get_value ("drugs-narcotics") > AppStream.ContentRatingValue.NONE ) { - oars_flowbox.add (drugs); + oars_flowbox.append (drugs); } if ( @@ -237,7 +238,7 @@ namespace AppCenter.Views { rating.get_value ("sex-themes") > AppStream.ContentRatingValue.NONE || rating.get_value ("sex-prostitution") > AppStream.ContentRatingValue.NONE ) { - oars_flowbox.add (sex_nudity); + oars_flowbox.append (sex_nudity); } if ( @@ -247,13 +248,13 @@ namespace AppCenter.Views { rating.get_value ("language-humor") > AppStream.ContentRatingValue.MILD || rating.get_value ("language-discrimination") > AppStream.ContentRatingValue.NONE ) { - oars_flowbox.add (language); + oars_flowbox.append (language); } if ( rating.get_value ("money-gambling") > AppStream.ContentRatingValue.NONE ) { - oars_flowbox.add (gambling); + oars_flowbox.append (gambling); } var social_chat_value = rating.get_value ("social-chat"); @@ -268,7 +269,7 @@ namespace AppCenter.Views { "system-users-symbolic" ); - oars_flowbox.add (multiplayer); + oars_flowbox.append (multiplayer); } var social_audio_value = rating.get_value ("social-audio"); @@ -291,7 +292,7 @@ namespace AppCenter.Views { "oars-chat-symbolic" ); - oars_flowbox.add (social); + oars_flowbox.append (social); } if (rating.get_value ("social-location") > AppStream.ContentRatingValue.NONE) { @@ -301,7 +302,7 @@ namespace AppCenter.Views { "find-location-symbolic" ); - oars_flowbox.add (location); + oars_flowbox.append (location); } var social_info_value = rating.get_value ("social-info"); @@ -322,117 +323,105 @@ namespace AppCenter.Views { "oars-socal-info-symbolic" ); - oars_flowbox.add (social_info); + oars_flowbox.append (social_info); } } screenshots = package_component.get_screenshots (); if (screenshots.length > 0) { - app_screenshots = new Hdy.Carousel () { + app_screenshots = new Adw.Carousel () { allow_mouse_drag = true, allow_scroll_wheel = false, height_request = 500 }; screenshot_previous = new ArrowButton ("go-previous-symbolic") { - sensitive = false, - no_show_all = true + sensitive = false }; screenshot_previous.clicked.connect (() => { - GLib.List screenshot_children = app_screenshots.get_children (); - var index = app_screenshots.get_position (); + var index = (int) app_screenshots.position; if (index > 0) { - app_screenshots.scroll_to (screenshot_children.nth_data ((uint) index - 1)); + app_screenshots.scroll_to (app_screenshots.get_nth_page (index - 1), true); } }); - screenshot_next = new ArrowButton ("go-next-symbolic") { - no_show_all = true - }; + screenshot_next = new ArrowButton ("go-next-symbolic"); screenshot_next.clicked.connect (() => { - GLib.List screenshot_children = app_screenshots.get_children (); - var index = app_screenshots.get_position (); - if (index < screenshot_children.length () - 1) { - app_screenshots.scroll_to (screenshot_children.nth_data ((uint) index + 1)); + var index = (int) app_screenshots.position; + if (index < app_screenshots.n_pages - 1) { + app_screenshots.scroll_to (app_screenshots.get_nth_page (index + 1), true); } }); app_screenshots.page_changed.connect ((index) => { screenshot_previous.sensitive = screenshot_next.sensitive = true; - GLib.List screenshot_children = app_screenshots.get_children (); - if (index == 0) { screenshot_previous.sensitive = false; - } else if (index == screenshot_children.length () - 1) { + } else if (index == app_screenshots.n_pages - 1) { screenshot_next.sensitive = false; } }); var screenshot_arrow_revealer_p = new Gtk.Revealer () { + child = screenshot_previous, halign = Gtk.Align.START, valign = Gtk.Align.CENTER, transition_type = Gtk.RevealerTransitionType.CROSSFADE }; - screenshot_arrow_revealer_p.add (screenshot_previous); var screenshot_arrow_revealer_n = new Gtk.Revealer () { + child = screenshot_next, halign = Gtk.Align.END, valign = Gtk.Align.CENTER, transition_type = Gtk.RevealerTransitionType.CROSSFADE }; - screenshot_arrow_revealer_n.add (screenshot_next); - screenshot_overlay = new Gtk.Overlay (); - screenshot_overlay.add (app_screenshots); + screenshot_overlay = new Gtk.Overlay () { + child = app_screenshots + }; screenshot_overlay.add_overlay (screenshot_arrow_revealer_p); screenshot_overlay.add_overlay (screenshot_arrow_revealer_n); - app_screenshots.add_events (Gdk.EventMask.ENTER_NOTIFY_MASK); - app_screenshots.add_events (Gdk.EventMask.LEAVE_NOTIFY_MASK); - - screenshot_overlay.add_events (Gdk.EventMask.ENTER_NOTIFY_MASK); - screenshot_overlay.add_events (Gdk.EventMask.LEAVE_NOTIFY_MASK); - - screenshot_overlay.enter_notify_event.connect (() => { - screenshot_arrow_revealer_n.reveal_child = true; - screenshot_arrow_revealer_p.reveal_child = true; - return false; - }); - - screenshot_overlay.leave_notify_event.connect ((event) => { - // Prevent hiding prev/next button when they're marked as insensitive - if (event.mode != Gdk.CrossingMode.STATE_CHANGED) { - screenshot_arrow_revealer_n.reveal_child = false; - screenshot_arrow_revealer_p.reveal_child = false; - } - - return false; - }); - - app_screenshots.enter_notify_event.connect (() => { - screenshot_arrow_revealer_n.reveal_child = true; - screenshot_arrow_revealer_p.reveal_child = true; - return false; - }); - - app_screenshots.leave_notify_event.connect ((event) => { - // Prevent hiding prev/next button when they're marked as insensitive - if (event.mode != Gdk.CrossingMode.STATE_CHANGED) { - screenshot_arrow_revealer_n.reveal_child = false; - screenshot_arrow_revealer_p.reveal_child = false; - } - - return false; - }); - - screenshot_switcher = new Hdy.CarouselIndicatorDots () { + // screenshot_overlay.enter_notify_event.connect (() => { + // screenshot_arrow_revealer_n.reveal_child = true; + // screenshot_arrow_revealer_p.reveal_child = true; + // return false; + // }); + + // screenshot_overlay.leave_notify_event.connect ((event) => { + // // Prevent hiding prev/next button when they're marked as insensitive + // if (event.mode != Gdk.CrossingMode.STATE_CHANGED) { + // screenshot_arrow_revealer_n.reveal_child = false; + // screenshot_arrow_revealer_p.reveal_child = false; + // } + + // return false; + // }); + + // app_screenshots.enter_notify_event.connect (() => { + // screenshot_arrow_revealer_n.reveal_child = true; + // screenshot_arrow_revealer_p.reveal_child = true; + // return false; + // }); + + // app_screenshots.leave_notify_event.connect ((event) => { + // // Prevent hiding prev/next button when they're marked as insensitive + // if (event.mode != Gdk.CrossingMode.STATE_CHANGED) { + // screenshot_arrow_revealer_n.reveal_child = false; + // screenshot_arrow_revealer_p.reveal_child = false; + // } + + // return false; + // }); + + screenshot_switcher = new Adw.CarouselIndicatorDots () { carousel = app_screenshots }; var app_screenshot_spinner = new Gtk.Spinner () { - active = true, + spinning = true, halign = Gtk.Align.CENTER, valign = Gtk.Align.CENTER }; @@ -443,19 +432,19 @@ namespace AppCenter.Views { screenshot_not_found_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); screenshot_not_found_context.add_provider (screenshot_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); screenshot_not_found_context.add_class ("screenshot"); - screenshot_not_found_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); + screenshot_not_found_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); - screenshot_not_found_clamp = new Hdy.Clamp () { + screenshot_not_found_clamp = new Adw.Clamp () { + child = screenshot_not_found, maximum_size = MAX_WIDTH }; - screenshot_not_found_clamp.add (screenshot_not_found); screenshot_stack = new Gtk.Stack () { transition_type = Gtk.StackTransitionType.CROSSFADE }; - screenshot_stack.add (app_screenshot_spinner); - screenshot_stack.add (screenshot_overlay); - screenshot_stack.add (screenshot_not_found_clamp); + screenshot_stack.add_child (app_screenshot_spinner); + screenshot_stack.add_child (screenshot_overlay); + screenshot_stack.add_child (screenshot_not_found_clamp); stack_context = screenshot_stack.get_style_context (); stack_context.add_class ("loading"); @@ -474,9 +463,9 @@ namespace AppCenter.Views { }; var app_icon_overlay = new Gtk.Overlay () { + child = app_icon, valign = Gtk.Align.START }; - app_icon_overlay.add (app_icon); var scale_factor = get_scale_factor (); @@ -501,14 +490,14 @@ namespace AppCenter.Views { wrap = true, xalign = 0 }; - package_name.get_style_context ().add_class (Granite.STYLE_CLASS_H1_LABEL); + package_name.add_css_class (Granite.STYLE_CLASS_H1_LABEL); author_label = new Gtk.Label (null) { selectable = true, valign = Gtk.Align.START, xalign = 0 }; - author_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + author_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); package_summary = new Gtk.Label (null) { label = package.get_summary (), @@ -518,7 +507,7 @@ namespace AppCenter.Views { valign = Gtk.Align.CENTER, xalign = 0 }; - package_summary.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + package_summary.add_css_class (Granite.STYLE_CLASS_H2_LABEL); app_description = new Gtk.Label (null) { // Allow wrapping but prevent expanding the parent @@ -526,7 +515,7 @@ namespace AppCenter.Views { wrap = true, xalign = 0 }; - app_description.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); + app_description.add_css_class (Granite.STYLE_CLASS_H3_LABEL); var links_flowbox = new Gtk.FlowBox () { column_spacing = 12, @@ -543,49 +532,48 @@ namespace AppCenter.Views { var license_button = new UrlButton (_(license_copy), license_url, "text-x-copying-symbolic"); - links_flowbox.add (license_button); + links_flowbox.append (license_button); } var homepage_url = package_component.get_url (AppStream.UrlKind.HOMEPAGE); if (homepage_url != null) { var website_button = new UrlButton (_("Homepage"), homepage_url, "web-browser-symbolic"); - links_flowbox.add (website_button); + links_flowbox.append (website_button); } var translate_url = package_component.get_url (AppStream.UrlKind.TRANSLATE); if (translate_url != null) { var translate_button = new UrlButton (_("Translate"), translate_url, "preferences-desktop-locale-symbolic"); - links_flowbox.add (translate_button); + links_flowbox.append (translate_button); } var bugtracker_url = package_component.get_url (AppStream.UrlKind.BUGTRACKER); if (bugtracker_url != null) { var bugtracker_button = new UrlButton (_("Send Feedback"), bugtracker_url, "bug-symbolic"); - links_flowbox.add (bugtracker_button); + links_flowbox.append (bugtracker_button); } var help_url = package_component.get_url (AppStream.UrlKind.HELP); if (help_url != null) { var help_button = new UrlButton (_("Help"), help_url, "dialog-question-symbolic"); - links_flowbox.add (help_button); + links_flowbox.append (help_button); } #if PAYMENTS if (package.get_payments_key () != null) { var fund_button = new FundButton (package); - links_flowbox.add (fund_button); + links_flowbox.append (fund_button); } #endif var whats_new_label = new Gtk.Label (_("What's New:")) { xalign = 0 }; - whats_new_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + whats_new_label.add_css_class (Granite.STYLE_CLASS_H2_LABEL); release_list_box = new Widgets.ReleaseListBox (package); release_grid = new Gtk.Grid () { - no_show_all = true, row_spacing = 12 }; release_grid.attach (whats_new_label, 0, 0); @@ -593,9 +581,9 @@ namespace AppCenter.Views { release_grid.hide (); var content_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 24); - content_box.add (package_summary); - content_box.add (app_description); - content_box.add (release_grid); + content_box.append (package_summary); + content_box.append (app_description); + content_box.append (release_grid); if (package_component.get_addons ().length > 0) { extension_box = new Gtk.ListBox () { @@ -613,14 +601,14 @@ namespace AppCenter.Views { halign = Gtk.Align.START, margin_top = 12 }; - extension_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + extension_label.add_css_class (Granite.STYLE_CLASS_H2_LABEL); - content_box.add (extension_label); - content_box.add (extension_box); + content_box.append (extension_label); + content_box.append (extension_box); load_extensions.begin (); } - content_box.add (links_flowbox); + content_box.append (links_flowbox); origin_liststore = new Gtk.ListStore (2, typeof (AppCenterCore.Package), typeof (string)); origin_combo = new Gtk.ComboBox.with_model (origin_liststore) { @@ -628,8 +616,9 @@ namespace AppCenter.Views { valign = Gtk.Align.START }; - origin_combo_revealer = new Gtk.Revealer (); - origin_combo_revealer.add (origin_combo); + origin_combo_revealer = new Gtk.Revealer () { + child = origin_combo + }; var renderer = new Gtk.CellRendererText (); origin_combo.pack_start (renderer, true); @@ -640,14 +629,14 @@ namespace AppCenter.Views { }; unowned var uninstall_button_context = uninstall_button.get_style_context (); - uninstall_button_context.add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + uninstall_button_context.add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); uninstall_button_context.add_provider (banner_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); uninstall_button_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); uninstall_button_revealer = new Gtk.Revealer () { + child = uninstall_button, transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT }; - uninstall_button_revealer.add (uninstall_button); action_button_group.add_widget (uninstall_button); @@ -656,8 +645,8 @@ namespace AppCenter.Views { valign = Gtk.Align.END, hexpand = true }; - button_box.add (uninstall_button_revealer); - button_box.add (action_stack); + button_box.append (uninstall_button_revealer); + button_box.append (action_stack); var header_grid = new Gtk.Grid () { column_spacing = 12, @@ -675,40 +664,40 @@ namespace AppCenter.Views { halign = Gtk.Align.END, valign = Gtk.Align.START }; - size_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + size_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); action_button_group.add_widget (size_label); header_grid.attach (size_label, 3, 1); } - var header_clamp = new Hdy.Clamp () { + var header_clamp = new Adw.Clamp () { + child = header_grid, margin_top = 24, margin_end = 24, margin_bottom = 24, margin_start = 24, maximum_size = MAX_WIDTH }; - header_clamp.add (header_grid); - var header_box = new Gtk.Grid () { + var header_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { hexpand = true }; - header_box.add (header_clamp); + header_box.append (header_clamp); unowned var header_box_context = header_box.get_style_context (); header_box_context.add_class ("banner"); header_box_context.add_provider (banner_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); header_box_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - var body_clamp = new Hdy.Clamp () { + var body_clamp = new Adw.Clamp () { + child = content_box, margin_top = 24, margin_end = 24, margin_bottom = 24, margin_start = 24, maximum_size = MAX_WIDTH }; - body_clamp.add (content_box); var other_apps_bar = new OtherAppsBar (package, MAX_WIDTH); @@ -717,73 +706,75 @@ namespace AppCenter.Views { }); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12); - box.add (header_box); - box.add (content_warning_clamp); + box.append (header_box); + box.append (content_warning_clamp); if (screenshots.length > 0) { - box.add (screenshot_stack); + box.append (screenshot_stack); if (screenshots.length > 1) { - box.add (screenshot_switcher); + box.append (screenshot_switcher); } } - box.add (body_clamp); - box.add (other_apps_bar); + box.append (body_clamp); + box.append (other_apps_bar); - var scrolled = new Gtk.ScrolledWindow (null, null) { + var scrolled = new Gtk.ScrolledWindow () { + child = box, hscrollbar_policy = Gtk.PolicyType.NEVER, hexpand = true, vexpand = true }; - scrolled.add (box); - var toast = new Granite.Widgets.Toast (_("Link copied to clipboard")); + var toast = new Granite.Toast (_("Link copied to clipboard")); - var overlay = new Gtk.Overlay (); - overlay.add (scrolled); + var overlay = new Gtk.Overlay () { + child = scrolled + }; overlay.add_overlay (toast); - add (overlay); + append (overlay); - open_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + open_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); #if SHARING if (package.is_shareable) { var body = _("Check out %s on AppCenter:").printf (package.get_name ()); var uri = "https://appcenter.elementary.io/%s".printf (package.component.get_id ()); var share_popover = new SharePopover (body, uri); - var share_icon = new Gtk.Image.from_icon_name ("send-to-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var share_icon = new Gtk.Image.from_icon_name ("send-to-symbolic") { + pixel_size = 24, valign = Gtk.Align.CENTER }; var share_label = new Gtk.Label (_("Share")); var share_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); - share_box.add (share_icon); - share_box.add (share_label); + share_box.append (share_icon); + share_box.append (share_label); var share_button = new Gtk.MenuButton () { + child = share_box, direction = Gtk.ArrowType.UP, popover = share_popover }; - share_button.add (share_box); unowned var share_button_context = share_button.get_style_context (); - share_button_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); - share_button_context.add_class (Gtk.STYLE_CLASS_FLAT); + share_button_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); + share_button_context.add_class (Granite.STYLE_CLASS_FLAT); share_popover.link_copied.connect (() => { toast.send_notification (); }); - links_flowbox.add (share_button); + links_flowbox.append (share_button); } #endif view_entered (); set_up_package (); - if (oars_flowbox.get_children ().length () > 0) { + if (oars_flowbox.get_first_child != null) { oars_flowbox_revealer.reveal_child = true; } @@ -834,7 +825,7 @@ namespace AppCenter.Views { var row = new Widgets.PackageRow.list (extension_package); if (extension_box != null) { - extension_box.add (row); + extension_box.append (row); } }); } @@ -880,7 +871,6 @@ namespace AppCenter.Views { is_runtime_warning_shown = true; oars_flowbox.insert (runtime_warning, 0); - oars_flowbox.show_all (); oars_flowbox_revealer.reveal_child = true; } } @@ -935,8 +925,7 @@ namespace AppCenter.Views { Idle.add (() => { if (release_list_box.populate ()) { - release_grid.no_show_all = false; - release_grid.show_all (); + release_grid.visible = true; } return false; @@ -1013,18 +1002,9 @@ namespace AppCenter.Views { } Idle.add (() => { - var number_of_screenshots = app_screenshots.get_children ().length (); - - if (number_of_screenshots > 0) { + if (app_screenshots.n_pages > 0) { screenshot_stack.visible_child = screenshot_overlay; stack_context.remove_class ("loading"); - - if (number_of_screenshots > 1) { - screenshot_next.no_show_all = false; - screenshot_next.show_all (); - screenshot_previous.no_show_all = false; - screenshot_previous.show_all (); - } } else { screenshot_stack.visible_child = screenshot_not_found_clamp; stack_context.remove_class ("loading"); @@ -1069,14 +1049,13 @@ namespace AppCenter.Views { label_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); label_context.add_provider (screenshot_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - box.add (label); + box.append (label); } - box.add (image); + box.append (image); Idle.add (() => { - box.show_all (); - app_screenshots.add (box); + app_screenshots.append (box); return GLib.Source.REMOVE; }); } catch (Error e) { @@ -1168,57 +1147,57 @@ namespace AppCenter.Views { class UrlButton : Gtk.Box { public UrlButton (string label, string? uri, string icon_name) { - get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + add_css_class (Granite.STYLE_CLASS_DIM_LABEL); tooltip_text = uri; - var icon = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.SMALL_TOOLBAR) { + var icon = new Gtk.Image.from_icon_name (icon_name) { valign = Gtk.Align.CENTER }; var title = new Gtk.Label (label); var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); - box.add (icon); - box.add (title); + box.append (icon); + box.append (title); if (uri != null) { - var button = new Gtk.Button (); - button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var button = new Gtk.Button () { + child = box + }; + button.add_css_class (Granite.STYLE_CLASS_FLAT); - button.add (box); - add (button); + append (button); button.clicked.connect (() => { try { - Gtk.show_uri_on_window ((Gtk.Window) get_toplevel (), uri, Gdk.CURRENT_TIME); + Gtk.show_uri (((Gtk.Application) Application.get_default ()).active_window, uri, Gdk.CURRENT_TIME); } catch (Error e) { critical (e.message); } }); } else { - add (box); + append (box); } } } class FundButton : Gtk.Button { public FundButton (AppCenterCore.Package package) { - get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); - get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + add_css_class (Granite.STYLE_CLASS_FLAT); - var icon = new Gtk.Image.from_icon_name ("credit-card-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var icon = new Gtk.Image.from_icon_name ("credit-card-symbolic") { valign = Gtk.Align.CENTER }; var title = new Gtk.Label (_("Fund")); var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); - box.add (icon); - box.add (title); + box.append (icon); + box.append (title); tooltip_text = _("Fund the development of this app"); - - add (box); + child = box; clicked.connect (() => { var stripe = new Widgets.StripeDialog ( @@ -1227,7 +1206,7 @@ namespace AppCenter.Views { package.normalized_component_id, package.get_payments_key () ); - stripe.transient_for = (Gtk.Window) get_toplevel (); + // stripe.transient_for = ((Gtk.Application) Application.get_default ()).active_window; stripe.download_requested.connect (() => { if (stripe.amount != 0) { @@ -1245,7 +1224,9 @@ namespace AppCenter.Views { public ArrowButton (string icon_name) { Object ( - image: new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.LARGE_TOOLBAR) + child: new Gtk.Image.from_icon_name (icon_name) { + pixel_size = 24 + } ); } @@ -1260,7 +1241,7 @@ namespace AppCenter.Views { valign = Gtk.Align.CENTER; unowned var context = get_style_context (); - context.add_class (Gtk.STYLE_CLASS_FLAT); + context.add_class (Granite.STYLE_CLASS_FLAT); context.add_class ("circular"); context.add_class ("arrow"); context.add_provider (arrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -1281,9 +1262,10 @@ namespace AppCenter.Views { public ContentType (string title, string description, string icon_name) { can_focus = false; - var icon = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.DND) { + var icon = new Gtk.Image.from_icon_name (icon_name) { halign = Gtk.Align.START, - margin_bottom = 6 + margin_bottom = 6, + pixel_size = 32 }; var label = new Gtk.Label (title) { @@ -1296,20 +1278,19 @@ namespace AppCenter.Views { xalign = 0 }; - unowned var description_label_context = description_label.get_style_context (); - description_label_context.add_class (Granite.STYLE_CLASS_SMALL_LABEL); - description_label_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); + add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); + add_css_class (Granite.STYLE_CLASS_DIM_LABEL); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3); - box.add (icon); - box.add (label); - box.add (description_label); + box.append (icon); + box.append (label); + box.append (description_label); - add (box); + child = box; } } - private class OtherAppsBar : Gtk.Grid { + private class OtherAppsBar : Gtk.ActionBar { public signal void show_other_package (AppCenterCore.Package package); public AppCenterCore.Package package { get; construct; } @@ -1349,24 +1330,24 @@ namespace AppCenter.Views { } var other_app = new AppCenter.Widgets.ListPackageRowGrid (author_package); - flowbox.add (other_app); + flowbox.append (other_app); } var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12); - box.add (header); - box.add (flowbox); + box.append (header); + box.append (flowbox); - var clamp = new Hdy.Clamp () { + var clamp = new Adw.Clamp () { + child = box, margin_top = 24, margin_end = 24, margin_bottom = 24, margin_start = 24, maximum_size = max_width }; - clamp.add (box); - add (clamp); - get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR); + set_center_widget (clamp); + add_css_class (Granite.STYLE_CLASS_FLAT); flowbox.child_activated.connect ((child) => { var package_row_grid = (AppCenter.Widgets.ListPackageRowGrid) child.get_child (); diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index d7f12c768..743f308bb 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -30,23 +30,20 @@ namespace AppCenter.Views { construct { action_button_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH); - var loading_view = new Granite.Widgets.AlertView ( - _("Checking for Updates"), - _("Downloading a list of available updates to the OS and installed apps"), - "sync-synchronizing" - ); - loading_view.show_all (); + var loading_view = new Granite.Placeholder (_("Checking for Updates")) { + description = _("Downloading a list of available updates to the OS and installed apps"), + icon = new ThemedIcon ("sync-synchronizing") + }; list_box.set_header_func ((Gtk.ListBoxUpdateHeaderFunc) row_update_header); list_box.set_placeholder (loading_view); var info_label = new Gtk.Label (_("A restart is required to finish installing updates")); - info_label.show (); - var infobar = new Gtk.InfoBar (); - infobar.message_type = Gtk.MessageType.WARNING; - infobar.no_show_all = true; - infobar.get_content_area ().add (info_label); + var infobar = new Gtk.InfoBar () { + message_type = Gtk.MessageType.WARNING + }; + infobar.add_child (info_label); var restart_button = infobar.add_button (_("Restart Now"), 0); action_button_group.add_widget (restart_button); @@ -67,8 +64,8 @@ namespace AppCenter.Views { AppCenterCore.UpdateManager.get_default ().bind_property ("restart-required", infobar, "visible", BindingFlags.SYNC_CREATE); - add (infobar); - add (scrolled); + append (infobar); + append (scrolled); get_apps.begin (); @@ -124,7 +121,7 @@ namespace AppCenter.Views { // Only add row if this package needs an update or it's not a font or plugin if (needs_update || (package.kind != AppStream.ComponentKind.ADDON && package.kind != AppStream.ComponentKind.FONT)) { var row = new Widgets.PackageRow.installed (package, action_button_group); - list_box.add (row); + list_box.append (row); } } @@ -249,13 +246,11 @@ namespace AppCenter.Views { } update_all_button.valign = Gtk.Align.CENTER; - update_all_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + update_all_button.get_style_context ().add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); update_all_button.clicked.connect (on_update_all); action_button_group.add_widget (update_all_button); - header.add (update_all_button); - - header.show_all (); + header.append (update_all_button); row.set_header (header); } else if (is_driver) { if (before != null && is_driver == before_is_driver) { @@ -264,7 +259,6 @@ namespace AppCenter.Views { } var header = new Widgets.UpdateHeaderRow.drivers (); - header.show_all (); row.set_header (header); } else { if (before != null && is_driver == before_is_driver && update_available == before_update_available) { @@ -273,7 +267,6 @@ namespace AppCenter.Views { } var header = new Widgets.UpdateHeaderRow.up_to_date (); - header.show_all (); row.set_header (header); } } @@ -289,11 +282,13 @@ namespace AppCenter.Views { updating_all_apps = true; - foreach (var row in list_box.get_children ()) { + var row = list_box.get_first_child (); + while (row != null) { if (row is Widgets.PackageRow) { ((Widgets.PackageRow) row).set_action_sensitive (false); } - }; + row = row.get_next_sibling (); + } foreach (var package in get_packages ()) { if (package.update_available && !package.should_pay) { @@ -306,7 +301,7 @@ namespace AppCenter.Views { } else { var fail_dialog = new UpgradeFailDialog (package, e.message) { modal = true, - transient_for = (Gtk.Window) get_toplevel () + transient_for = ((Gtk.Application) Application.get_default ()).active_window }; fail_dialog.present (); break; diff --git a/src/Views/CategoryView.vala b/src/Views/CategoryView.vala index 62b6b62a3..4aafcb6ed 100644 --- a/src/Views/CategoryView.vala +++ b/src/Views/CategoryView.vala @@ -44,8 +44,8 @@ public class AppCenter.CategoryView : Gtk.Stack { recently_updated_flowbox = new SubcategoryFlowbox (); recently_updated_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - recently_updated_box.add (recently_updated_header); - recently_updated_box.add (recently_updated_flowbox); + recently_updated_box.append (recently_updated_header); + recently_updated_box.append (recently_updated_flowbox); var paid_header = new Granite.HeaderLabel (_("Paid Apps")) { margin_start = 12 @@ -55,8 +55,8 @@ public class AppCenter.CategoryView : Gtk.Stack { paid_flowbox = new SubcategoryFlowbox (); paid_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - paid_box.add (paid_header); - paid_box.add (paid_flowbox); + paid_box.append (paid_header); + paid_box.append (paid_flowbox); var free_header = new Granite.HeaderLabel (_("Free Apps")) { margin_start = 12 @@ -66,8 +66,8 @@ public class AppCenter.CategoryView : Gtk.Stack { free_flowbox = new SubcategoryFlowbox (); free_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - free_box.add (free_header); - free_box.add (free_flowbox); + free_box.append (free_header); + free_box.append (free_flowbox); var uncurated_header = new Granite.HeaderLabel (_("Non-Curated Apps")) { margin_start = 12 @@ -78,8 +78,8 @@ public class AppCenter.CategoryView : Gtk.Stack { #if CURATED uncurated_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - uncurated_box.add (uncurated_header); - uncurated_box.add (uncurated_flowbox); + uncurated_box.append (uncurated_header); + uncurated_box.append (uncurated_flowbox); #endif box = new Gtk.Box (Gtk.Orientation.VERTICAL, 48) { @@ -89,19 +89,18 @@ public class AppCenter.CategoryView : Gtk.Stack { margin_start = 12 }; - scrolled = new Gtk.ScrolledWindow (null, null) { + scrolled = new Gtk.ScrolledWindow () { + child = box, hscrollbar_policy = Gtk.PolicyType.NEVER }; - scrolled.add (box); var spinner = new Gtk.Spinner () { halign = Gtk.Align.CENTER }; spinner.start (); - add (spinner); - add (scrolled); - show_all (); + add_child (spinner); + add_child (scrolled); populate (); @@ -132,25 +131,25 @@ public class AppCenter.CategoryView : Gtk.Stack { private void populate () { get_packages.begin ((obj, res) => { - foreach (unowned var child in box.get_children ()) { - box.remove (child); - } + while (box.get_first_child () != null) { + box.remove (box.get_first_child ()); + }; - foreach (unowned var child in recently_updated_flowbox.get_children ()) { - child.destroy (); - } + while (recently_updated_flowbox.get_first_child () != null) { + recently_updated_flowbox.get_first_child ().destroy (); + }; - foreach (unowned var child in free_flowbox.get_children ()) { - child.destroy (); - } + while (free_flowbox.get_first_child () != null) { + free_flowbox.get_first_child ().destroy (); + }; - foreach (unowned var child in paid_flowbox.get_children ()) { - child.destroy (); - } + while (paid_flowbox.get_first_child () != null) { + paid_flowbox.get_first_child ().destroy (); + }; - foreach (unowned var child in uncurated_flowbox.get_children ()) { - child.destroy (); - } + while (uncurated_flowbox.get_first_child () != null) { + uncurated_flowbox.get_first_child ().destroy (); + }; var packages = get_packages.end (res); foreach (var package in packages) { @@ -158,15 +157,15 @@ public class AppCenter.CategoryView : Gtk.Stack { #if CURATED if (package.is_native) { if (package.get_payments_key () != null && package.get_suggested_amount () != "0") { - paid_flowbox.add (package_row); + paid_flowbox.append (package_row); } else { - free_flowbox.add (package_row); + free_flowbox.append (package_row); } } else { - uncurated_flowbox.add (package_row); + uncurated_flowbox.append (package_row); } #else - uncurated_flowbox.add (package_row); + uncurated_flowbox.append (package_row); #endif } @@ -200,32 +199,31 @@ public class AppCenter.CategoryView : Gtk.Stack { if (!recent_package.installed) { var package_row = new AppCenter.Widgets.ListPackageRowGrid (recent_package); - recently_updated_flowbox.add (package_row); + recently_updated_flowbox.append (package_row); recent_count++; } } #if CURATED if (recently_updated_flowbox.get_child_at_index (0) != null) { - box.add (recently_updated_box); + box.append (recently_updated_box); } if (paid_flowbox.get_child_at_index (0) != null) { - box.add (paid_box); + box.append (paid_box); } if (free_flowbox.get_child_at_index (0) != null) { - box.add (free_box); + box.append (free_box); } if (uncurated_flowbox.get_child_at_index (0) != null) { - box.add (uncurated_box); + box.append (uncurated_box); } #else - box.add (uncurated_flowbox); + box.append (uncurated_flowbox); #endif - show_all (); visible_child = scrolled; }); } @@ -263,10 +261,11 @@ public class AppCenter.CategoryView : Gtk.Stack { valign = Gtk.Align.START; set_sort_func ((Gtk.FlowBoxSortFunc) package_row_compare); + } - add.connect ((widget) => { - size_group.add_widget (widget); - }); + public new void append (Gtk.Widget widget) { + size_group.add_widget (widget); + base.append (widget); } [CCode (instance_pos = -1)] diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 0f444b458..1bc332dcb 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -28,7 +28,7 @@ public class AppCenter.Homepage : Gtk.Box { private Gtk.FlowBox category_flow; private Gtk.ScrolledWindow scrolled_window; - private Hdy.Carousel banner_carousel; + private Adw.Carousel banner_carousel; private Gtk.Revealer banner_revealer; private Gtk.FlowBox recently_updated_carousel; private Gtk.Revealer recently_updated_revealer; @@ -36,28 +36,25 @@ public class AppCenter.Homepage : Gtk.Box { private uint banner_timeout_id; construct { - get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); - expand = true; + add_css_class (Granite.STYLE_CLASS_VIEW); + hexpand = true; + vexpand = true; - banner_carousel = new Hdy.Carousel () { + banner_carousel = new Adw.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 () { + var banner_dots = new Adw.CarouselIndicatorDots () { carousel = banner_carousel }; var banner_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - banner_box.add (banner_event_box); - banner_box.add (banner_dots); + banner_box.append (banner_carousel); + banner_box.append (banner_dots); - banner_revealer = new Gtk.Revealer (); - banner_revealer.add (banner_box); + banner_revealer = new Gtk.Revealer () { + child = banner_box + }; var recently_updated_label = new Granite.HeaderLabel (_("Recently Updated")) { margin_start = 12 @@ -78,8 +75,9 @@ public class AppCenter.Homepage : Gtk.Box { 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 ); + recently_updated_revealer = new Gtk.Revealer () { + child = recently_updated_grid + }; var categories_label = new Granite.HeaderLabel (_("Categories")) { margin_start = 24, @@ -93,17 +91,17 @@ public class AppCenter.Homepage : Gtk.Box { }; var box = new Gtk.Box (orientation = Gtk.Orientation.VERTICAL, 0); - box.add (banner_revealer); - box.add (recently_updated_revealer); - box.add (categories_label); - box.add (category_flow); + box.append (banner_revealer); + box.append (recently_updated_revealer); + box.append (categories_label); + box.append (category_flow); - scrolled_window = new Gtk.ScrolledWindow (null, null) { + scrolled_window = new Gtk.ScrolledWindow () { + child = scrolled_window, hscrollbar_policy = Gtk.PolicyType.NEVER }; - scrolled_window.add (box); - add (scrolled_window); + append (scrolled_window); var local_package = App.local_package; if (local_package != null) { @@ -127,23 +125,23 @@ public class AppCenter.Homepage : Gtk.Box { AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { Idle.add (() => { // Clear the cached categories when the AppStream pool is updated - foreach (weak Gtk.Widget child in category_flow.get_children ()) { - var item = (Widgets.CategoryFlowBox.AbstractCategoryCard) child; - var category_components = item.category.get_components (); - category_components.remove_range (0, category_components.length); - } + // foreach (weak Gtk.Widget child in category_flow.get_children ()) { + // var item = (Widgets.CategoryFlowBox.AbstractCategoryCard) child; + // var category_components = item.category.get_components (); + // category_components.remove_range (0, category_components.length); + // } return GLib.Source.REMOVE; }); }); - banner_event_box.enter_notify_event.connect (() => { - banner_timeout_stop (); - }); + // banner_event_box.enter_notify_event.connect (() => { + // banner_timeout_stop (); + // }); - banner_event_box.leave_notify_event.connect (() => { - banner_timeout_start (); - }); + // 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 (); @@ -191,16 +189,15 @@ public class AppCenter.Homepage : Gtk.Box { show_package (package); }); - banner_carousel.add (banner); + banner_carousel.append (banner); } - banner_carousel.show_all (); banner_revealer.reveal_child = true; foreach (var package in packages_by_release_date) { - if (recently_updated_carousel.get_children ().length () >= MAX_PACKAGES_IN_CAROUSEL) { - break; - } + // if (recently_updated_carousel.get_children ().length () >= MAX_PACKAGES_IN_CAROUSEL) { + // break; + // } var installed = false; foreach (var origin_package in package.origin_packages) { @@ -216,11 +213,10 @@ public class AppCenter.Homepage : Gtk.Box { if (!installed && !(package in packages_in_banner)) { var package_row = new AppCenter.Widgets.ListPackageRowGrid (package); - recently_updated_carousel.add (package_row); + recently_updated_carousel.append (package_row); } } - recently_updated_carousel.show_all (); - recently_updated_revealer.reveal_child = recently_updated_carousel.get_children ().length () > 0; + recently_updated_revealer.reveal_child = recently_updated_carousel.get_first_child () != null; } private void banner_timeout_start () { @@ -240,7 +236,7 @@ public class AppCenter.Homepage : Gtk.Box { new_index = 0; } - banner_carousel.switch_child (new_index, Granite.TRANSITION_DURATION_OPEN); + // banner_carousel.switch_child (new_index, Granite.TRANSITION_DURATION_OPEN); return Source.CONTINUE; }); diff --git a/src/Views/SearchView.vala b/src/Views/SearchView.vala index 0e8908594..1b2ad7cf4 100644 --- a/src/Views/SearchView.vala +++ b/src/Views/SearchView.vala @@ -26,12 +26,10 @@ public class AppCenter.SearchView : AbstractAppList { construct { var flathub_link = "%s".printf (_("Flathub")); - var alert_view = new Granite.Widgets.AlertView ( - _("No Apps Found"), - _("Try changing search terms. You can also sideload Flatpak apps e.g. from %s").printf (flathub_link), - "edit-find-symbolic" - ); - alert_view.show_all (); + var alert_view = new Granite.Placeholder (_("No Apps Found")) { + description = _("Try changing search terms. You can also sideload Flatpak apps e.g. from %s").printf (flathub_link), + icon = new ThemedIcon ("edit-find-symbolic") + }; list_box.set_placeholder (alert_view); @@ -42,7 +40,7 @@ public class AppCenter.SearchView : AbstractAppList { } }); - add (scrolled); + append (scrolled); notify["current-search-term"].connect (() => { var dyn_flathub_link = "%s".printf (current_search_term, _("Flathub")); @@ -92,7 +90,7 @@ public class AppCenter.SearchView : AbstractAppList { while (current_visible_index < list_store.get_n_items ()) { var package = (AppCenterCore.Package?) list_store.get_object (current_visible_index); var row = new Widgets.PackageRow.list (package); - list_box.add (row); + list_box.append (row); current_visible_index++; if (old_index + 20 < current_visible_index) { diff --git a/src/Widgets/AbstractAppList.vala b/src/Widgets/AbstractAppList.vala index ceaf456e7..77eaa9d41 100644 --- a/src/Widgets/AbstractAppList.vala +++ b/src/Widgets/AbstractAppList.vala @@ -32,21 +32,21 @@ public abstract class AppCenter.AbstractAppList : Gtk.Box { hexpand = true, vexpand = true }; - list_box.set_sort_func ((Gtk.ListBoxSortFunc) package_row_compare); + + scrolled = new Gtk.ScrolledWindow () { + child = list_box, + hscrollbar_policy = Gtk.PolicyType.NEVER + }; + list_box.row_activated.connect ((r) => { var row = (Widgets.PackageRow)r; show_app (row.get_package ()); }); - scrolled = new Gtk.ScrolledWindow (null, null); - scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER; - scrolled.add (list_box); - - list_box.add.connect ((row) => { - row.show_all (); - ((Widgets.PackageRow) row).get_package ().changing.connect (on_package_changing); - }); + // list_box.add.connect ((row) => { + // ((Widgets.PackageRow) row).get_package ().changing.connect (on_package_changing); + // }); } public abstract void add_packages (Gee.Collection packages); @@ -54,42 +54,40 @@ public abstract class AppCenter.AbstractAppList : Gtk.Box { public void remove_package (AppCenterCore.Package package) { package.changing.disconnect (on_package_changing); - foreach (weak Gtk.Widget r in list_box.get_children ()) { - weak Widgets.PackageRow row = r as Widgets.PackageRow; + unowned var row = (Widgets.PackageRow) list_box.get_first_child (); + while (row != null) { if (row.get_package () == package) { row.destroy (); break; } + row = (Widgets.PackageRow) row.get_next_sibling (); } list_box.invalidate_sort (); } public virtual void clear () { - foreach (weak Gtk.Widget r in list_box.get_children ()) { - weak Widgets.PackageRow row = r as Widgets.PackageRow; - if (row == null) { - continue; - } - + unowned var row = (Widgets.PackageRow) list_box.get_first_child (); + while (row != null) { var package = row.get_package (); package.changing.disconnect (on_package_changing); row.destroy (); - }; + + row = (Widgets.PackageRow) row.get_next_sibling (); + } list_box.invalidate_sort (); } protected virtual Gee.Collection get_packages () { var tree_set = new Gee.TreeSet (); - foreach (weak Gtk.Widget r in list_box.get_children ()) { - weak Widgets.PackageRow row = r as Widgets.PackageRow; - if (row == null) { - continue; - } + unowned var row = (Widgets.PackageRow) list_box.get_first_child (); + while (row != null) { tree_set.add (row.get_package ()); + + row = (Widgets.PackageRow) row.get_next_sibling (); } return tree_set; diff --git a/src/Widgets/AppContainers/AbstractAppContainer.vala b/src/Widgets/AppContainers/AbstractAppContainer.vala index c4f38041a..4bc85a36f 100644 --- a/src/Widgets/AppContainers/AbstractAppContainer.vala +++ b/src/Widgets/AppContainers/AbstractAppContainer.vala @@ -18,7 +18,7 @@ */ namespace AppCenter { - public abstract class AbstractAppContainer : Gtk.Bin { + public abstract class AbstractAppContainer : Gtk.Box { public AppCenterCore.Package package { get; construct set; } protected bool show_open { get; set; default = true; } @@ -45,9 +45,10 @@ namespace AppCenter { construct { action_button = new Widgets.HumbleButton (package); - action_button_revealer = new Gtk.Revealer (); - action_button_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT; - action_button_revealer.add (action_button); + action_button_revealer = new Gtk.Revealer () { + child = action_button, + transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT + }; action_button.download_requested.connect (() => { action_clicked.begin (); @@ -55,15 +56,16 @@ namespace AppCenter { open_button = new Gtk.Button.with_label (_("Open")); - open_button_revealer = new Gtk.Revealer (); - open_button_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT; - open_button_revealer.add (open_button); + open_button_revealer = new Gtk.Revealer () { + child = open_button, + transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT + }; open_button.clicked.connect (launch_package_app); button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - button_box.add (action_button_revealer); - button_box.add (open_button_revealer); + button_box.append (action_button_revealer); + button_box.append (open_button_revealer); cancel_button = new ProgressButton () { label = _("Cancel") @@ -83,7 +85,6 @@ namespace AppCenter { }; action_stack.add_named (button_box, "buttons"); action_stack.add_named (cancel_button, "progress"); - action_stack.show_all (); destroy.connect (() => { if (state_source > 0) { @@ -125,7 +126,7 @@ namespace AppCenter { var css = CSS.printf ((int) (fraction * 100)); try { - provider.load_from_data (css, css.length); + provider.load_from_data (css.data); style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Error e) { critical (e.message); @@ -267,7 +268,7 @@ namespace AppCenter { if (!(e is GLib.IOError.CANCELLED)) { var fail_dialog = new UpgradeFailDialog (package, e.message) { modal = true, - transient_for = (Gtk.Window) get_toplevel () + transient_for = ((Gtk.Application) Application.get_default ()).active_window }; fail_dialog.present (); } diff --git a/src/Widgets/AppContainers/AbstractPackageRowGrid.vala b/src/Widgets/AppContainers/AbstractPackageRowGrid.vala index 02702e7f0..4ff848703 100644 --- a/src/Widgets/AppContainers/AbstractPackageRowGrid.vala +++ b/src/Widgets/AppContainers/AbstractPackageRowGrid.vala @@ -39,8 +39,9 @@ public abstract class AppCenter.Widgets.AbstractPackageRowGrid : AbstractAppCont pixel_size = 24 }; - app_icon_overlay = new Gtk.Overlay (); - app_icon_overlay.add (app_icon); + app_icon_overlay = new Gtk.Overlay () { + child = app_icon + }; var scale_factor = get_scale_factor (); diff --git a/src/Widgets/AppContainers/InstalledPackageRowGrid.vala b/src/Widgets/AppContainers/InstalledPackageRowGrid.vala index 29887bc85..565795cb1 100644 --- a/src/Widgets/AppContainers/InstalledPackageRowGrid.vala +++ b/src/Widgets/AppContainers/InstalledPackageRowGrid.vala @@ -49,19 +49,19 @@ public class AppCenter.Widgets.InstalledPackageRowGrid : AbstractPackageRowGrid valign = Gtk.Align.START, xalign = 0 }; - app_version.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + app_version.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); - var release_button = new Gtk.Button.from_icon_name ("dialog-information-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var release_button = new Gtk.Button.from_icon_name ("dialog-information-symbolic") { valign = Gtk.Align.CENTER }; release_button_revealer = new Gtk.Revealer () { + child = release_button, halign = Gtk.Align.END, hexpand = true, tooltip_text = _("Release notes"), transition_type = Gtk.RevealerTransitionType.CROSSFADE }; - release_button_revealer.add (release_button); action_stack.hexpand = false; @@ -75,13 +75,13 @@ public class AppCenter.Widgets.InstalledPackageRowGrid : AbstractPackageRowGrid grid.attach (release_button_revealer, 2, 0, 1, 2); grid.attach (action_stack, 3, 0, 1, 2); - add (grid); + append (grid); release_button.clicked.connect (() => { var releases_dialog = new ReleaseDialog (package) { - transient_for = (Gtk.Window) get_toplevel () + transient_for = ((Gtk.Application) Application.get_default ()).active_window }; - releases_dialog.show_all (); + releases_dialog.present (); }); } @@ -121,7 +121,7 @@ public class AppCenter.Widgets.InstalledPackageRowGrid : AbstractPackageRowGrid changed (); } - private class ReleaseDialog : Hdy.Window { + private class ReleaseDialog : Granite.Dialog { public AppCenterCore.Package package { get; construct; } public ReleaseDialog (AppCenterCore.Package package) { @@ -130,7 +130,6 @@ public class AppCenter.Widgets.InstalledPackageRowGrid : AbstractPackageRowGrid construct { title = _("What's new in %s %s").printf (package.get_name (), package.get_version ()); - type_hint = Gdk.WindowTypeHint.DIALOG; modal = true; var releases_title = new Gtk.Label (title) { @@ -147,24 +146,18 @@ public class AppCenter.Widgets.InstalledPackageRowGrid : AbstractPackageRowGrid xalign = 0 }; - var dialog_close_button = new Gtk.Button.with_label (_("Close")) { - halign = Gtk.Align.END, - valign = Gtk.Align.END, - vexpand = true, - margin_top = 12 - }; - var releases_dialog_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) { margin_top = 12, margin_end = 12, margin_bottom = 12, margin_start = 12 }; - releases_dialog_box.add (releases_title); - releases_dialog_box.add (release_description); - releases_dialog_box.add (dialog_close_button); + releases_dialog_box.append (releases_title); + releases_dialog_box.append (release_description); + + child = releases_dialog_box; - add (releases_dialog_box); + var dialog_close_button = (Gtk.Button) add_button (_("Close"), Gtk.ResponseType.CLOSE); dialog_close_button.clicked.connect (() => { close (); diff --git a/src/Widgets/AppContainers/ListPackageRowGrid.vala b/src/Widgets/AppContainers/ListPackageRowGrid.vala index e22cc20d6..dc869d547 100644 --- a/src/Widgets/AppContainers/ListPackageRowGrid.vala +++ b/src/Widgets/AppContainers/ListPackageRowGrid.vala @@ -46,7 +46,7 @@ public class AppCenter.Widgets.ListPackageRowGrid : AbstractPackageRowGrid { wrap = true, xalign = 0 }; - package_summary.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + package_summary.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); var grid = new Gtk.Grid () { column_spacing = 12, @@ -57,14 +57,13 @@ public class AppCenter.Widgets.ListPackageRowGrid : AbstractPackageRowGrid { grid.attach (package_summary, 1, 1); grid.attach (action_stack, 2, 0, 1, 2); - add (grid); + append (grid); } protected override void set_up_package () { package_summary.label = package.get_summary (); if (package.is_local) { - action_stack.no_show_all = true; action_stack.visible = false; } diff --git a/src/Widgets/Banner.vala b/src/Widgets/Banner.vala index 618b33da3..acfbdccaf 100644 --- a/src/Widgets/Banner.vala +++ b/src/Widgets/Banner.vala @@ -72,10 +72,8 @@ public class AppCenter.Widgets.Banner : Gtk.Button { xalign = 0 }; - var icon_image = new Gtk.Image.from_gicon ( - package.get_icon (128, get_scale_factor ()), - Gtk.IconSize.INVALID - ) { + var icon_image = new Gtk.Image () { + gicon = package.get_icon (128, get_scale_factor ()), pixel_size = 128 }; @@ -99,7 +97,7 @@ public class AppCenter.Widgets.Banner : Gtk.Button { style_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); hexpand = true; - add (package_grid); + child = package_grid; var provider = new Gtk.CssProvider (); try { @@ -119,7 +117,7 @@ public class AppCenter.Widgets.Banner : Gtk.Button { } var colored_css = BANNER_STYLE_CSS.printf (bg_color, text_color); - provider.load_from_data (colored_css, colored_css.length); + provider.load_from_data (colored_css.data); style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (GLib.Error e) { critical ("Unable to set accent color: %s", e.message); diff --git a/src/Widgets/CardNumberEntry.vala b/src/Widgets/CardNumberEntry.vala index 57caa8ae8..3a4936f1c 100644 --- a/src/Widgets/CardNumberEntry.vala +++ b/src/Widgets/CardNumberEntry.vala @@ -70,7 +70,7 @@ public class AppCenter.Widgets.CardNumberEntry : Gtk.Entry { var new_offset = (text.char_count () - 1) - cursor_position; if (end_offset != new_offset) { Idle.add (() => { - move_cursor (Gtk.MovementStep.LOGICAL_POSITIONS, new_offset - end_offset, false); + // move_cursor (Gtk.MovementStep.LOGICAL_POSITIONS, new_offset - end_offset, false); return false; }); } diff --git a/src/Widgets/CategoryFlowBox.vala b/src/Widgets/CategoryFlowBox.vala index 8ab60233d..b4756dfee 100644 --- a/src/Widgets/CategoryFlowBox.vala +++ b/src/Widgets/CategoryFlowBox.vala @@ -26,9 +26,9 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { var games_card = new GamesCard (); - add (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); - add (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); - add (new LegacyCard (_("Communication"), "", { + append (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); + append (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); + append (new LegacyCard (_("Communication"), "", { "Chat", "ContactManagement", "Email", @@ -37,7 +37,7 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Telephony", "VideoConference" }, "communication")); - add (new LegacyCard (_("Development"), "", { + append (new LegacyCard (_("Development"), "", { "Database", "Debugger", "Development", @@ -47,13 +47,13 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "TerminalEmulator", "WebDevelopment" }, "development")); - add (new LegacyCard (_("Education"), "", {"Education"}, "education")); - add (new LegacyCard (_("Finance"), "payment-card-symbolic", { + append (new LegacyCard (_("Education"), "", {"Education"}, "education")); + append (new LegacyCard (_("Finance"), "payment-card-symbolic", { "Economy", "Finance" }, "finance")); - add (games_card); - add (new LegacyCard (_("Graphics"), "", { + append (games_card); + append (new LegacyCard (_("Graphics"), "", { "2DGraphics", "3DGraphics", "Graphics", @@ -62,11 +62,11 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "RasterGraphics", "VectorGraphics" }, "graphics")); - add (new LegacyCard (_("Internet"), "applications-internet", { + append (new LegacyCard (_("Internet"), "applications-internet", { "Network", "P2P" }, "internet")); - add (new LegacyCard (_("Math, Science, & Engineering"), "", { + append (new LegacyCard (_("Math, Science, & Engineering"), "", { "ArtificialIntelligence", "Astronomy", "Biology", @@ -85,31 +85,31 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Robotics", "Science" }, "science")); - add (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { + append (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { "AudioVideoEditing", "Midi", "Mixer", "Recorder", "Sequencer" }, "media-production")); - add (new LegacyCard (_("Office"), "applications-office-symbolic", { + append (new LegacyCard (_("Office"), "applications-office-symbolic", { "Office", "Presentation", "Publishing", "Spreadsheet", "WordProcessor" }, "office")); - add (new LegacyCard (_("System"), "applications-system-symbolic", { + append (new LegacyCard (_("System"), "applications-system-symbolic", { "Monitor", "System" }, "system")); - add (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); - add (new LegacyCard (_("Video"), "applications-video-symbolic", { + append (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); + append (new LegacyCard (_("Video"), "applications-video-symbolic", { "Tuner", "TV", "Video" }, "video")); - add (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { + append (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { "Dictionary", "Languages", "Literature", @@ -119,7 +119,7 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Translation", "WordProcessor" }, "writing-language")); - add (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { + append (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { "Security", }, "privacy-security")); @@ -163,13 +163,12 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { margin_bottom = 12, margin_start = 12 }; - content_area.add (expanded_grid); + content_area.attach (expanded_grid, 0, 0); - style_context = content_area.get_style_context (); - style_context.add_class (Granite.STYLE_CLASS_CARD); - style_context.add_class (Granite.STYLE_CLASS_ROUNDED); - style_context.add_class ("category"); - style_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + add_css_class (Granite.STYLE_CLASS_CARD); + add_css_class (Granite.STYLE_CLASS_ROUNDED); + add_css_class ("category"); + content_area.get_style_context ().add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); child = content_area; } @@ -185,10 +184,11 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { category.add_desktop_group (group); } - var display_image = new Gtk.Image (); - display_image.icon_size = Gtk.IconSize.DIALOG; - display_image.valign = Gtk.Align.CENTER; - display_image.halign = Gtk.Align.END; + var display_image = new Gtk.Image () { + pixel_size = 32, + halign = Gtk.Align.END, + valign = Gtk.Align.CENTER + }; var name_label = new Gtk.Label (null); name_label.wrap = true; @@ -203,8 +203,8 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { margin_bottom = 32, margin_start = 16 }; - box.add (display_image); - box.add (name_label); + box.append (display_image); + box.append (name_label); content_area.attach (box, 0, 0); @@ -217,7 +217,7 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { name_label.justify = Gtk.Justification.CENTER; } - style_context.add_class (style); + add_css_class (style); if (style == "accessibility") { name_label.label = category.name.up (); @@ -289,7 +289,7 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { content_area.attach (grid, 0, 0); - style_context.add_class ("games"); + add_css_class ("games"); } } } diff --git a/src/Widgets/HumbleButton.vala b/src/Widgets/HumbleButton.vala index 1a37828c1..81603db9b 100644 --- a/src/Widgets/HumbleButton.vala +++ b/src/Widgets/HumbleButton.vala @@ -98,7 +98,7 @@ public class AppCenter.Widgets.HumbleButton : Gtk.Button { package.normalized_component_id, package.get_payments_key () ) { - transient_for = (Gtk.Window) get_toplevel () + transient_for = ((Gtk.Application) Application.get_default ()).active_window }; stripe_dialog.download_requested.connect (() => { diff --git a/src/Widgets/PackageRow.vala b/src/Widgets/PackageRow.vala index 1cc2adbe8..c5aad1807 100644 --- a/src/Widgets/PackageRow.vala +++ b/src/Widgets/PackageRow.vala @@ -24,7 +24,7 @@ namespace AppCenter.Widgets { public PackageRow.installed (AppCenterCore.Package package, Gtk.SizeGroup? action_size_group) { grid = new InstalledPackageRowGrid (package, action_size_group); - add (grid); + child = grid; ((InstalledPackageRowGrid) grid).changed.connect (() => { changed (); }); @@ -32,7 +32,7 @@ namespace AppCenter.Widgets { public PackageRow.list (AppCenterCore.Package package) { grid = new ListPackageRowGrid (package); - add (grid); + child = grid; } public AppCenterCore.Package? get_package () { diff --git a/src/Widgets/ReleaseListBox.vala b/src/Widgets/ReleaseListBox.vala index e43103438..e7989c629 100644 --- a/src/Widgets/ReleaseListBox.vala +++ b/src/Widgets/ReleaseListBox.vala @@ -31,7 +31,7 @@ public class AppCenter.Widgets.ReleaseListBox : Gtk.ListBox { var releases = package.get_newest_releases (MIN_RELEASES, MAX_RELEASES); foreach (var release in releases) { var row = new ReleaseRow (release); - add (row); + append (row); } return releases.size > 0; diff --git a/src/Widgets/ReleaseRow.vala b/src/Widgets/ReleaseRow.vala index 4dafe2c27..068504441 100644 --- a/src/Widgets/ReleaseRow.vala +++ b/src/Widgets/ReleaseRow.vala @@ -49,7 +49,7 @@ public class AppCenter.Widgets.ReleaseRow : Gtk.ListBoxRow { grid.attach (header_label, 0, 0, 1, 1); grid.attach (description_label, 0, 1, 1, 1); - add (grid); + child = grid; } public static string format_release_header (AppStream.Release release, bool with_date) { diff --git a/src/Widgets/SharePopover.vala b/src/Widgets/SharePopover.vala index fc446a9a5..95c4a34ce 100644 --- a/src/Widgets/SharePopover.vala +++ b/src/Widgets/SharePopover.vala @@ -35,34 +35,60 @@ public class SharePopover : Gtk.Popover { var mail_appinfo = AppInfo.get_default_for_uri_scheme ("mailto"); if (mail_appinfo != null) { - email_button.image = new Gtk.Image.from_gicon (mail_appinfo.get_icon (), Gtk.IconSize.DND); + email_button.child = new Gtk.Image.from_gicon (mail_appinfo.get_icon ()) { + pixel_size = 32 + }; email_button.tooltip_text = mail_appinfo.get_display_name (); - email_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + email_button.add_css_class (Granite.STYLE_CLASS_FLAT); } - var facebook_button = new Gtk.Button.from_icon_name ("online-account-facebook", Gtk.IconSize.DND); + var facebook_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("online-account-facebook") { + pixel_size = 32 + } + }; facebook_button.tooltip_text = _("Facebook"); - facebook_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + facebook_button.add_css_class (Granite.STYLE_CLASS_FLAT); - var twitter_button = new Gtk.Button.from_icon_name ("online-account-twitter", Gtk.IconSize.DND); + var twitter_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("online-account-twitter") { + pixel_size = 32 + } + }; twitter_button.tooltip_text = _("Twitter"); - twitter_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + twitter_button.add_css_class (Granite.STYLE_CLASS_FLAT); - var reddit_button = new Gtk.Button.from_icon_name ("online-account-reddit", Gtk.IconSize.DND); + var reddit_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("online-account-reddit") { + pixel_size = 32 + } + }; reddit_button.tooltip_text = _("Reddit"); - reddit_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + reddit_button.add_css_class (Granite.STYLE_CLASS_FLAT); - var tumblr_button = new Gtk.Button.from_icon_name ("online-account-tumblr", Gtk.IconSize.DND); + var tumblr_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("online-account-tumblr") { + pixel_size = 32 + } + }; tumblr_button.tooltip_text = _("Tumblr"); - tumblr_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + tumblr_button.add_css_class (Granite.STYLE_CLASS_FLAT); - var telegram_button = new Gtk.Button.from_icon_name ("online-account-telegram", Gtk.IconSize.DND); + var telegram_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("online-account-telegram") { + pixel_size = 32 + } + }; telegram_button.tooltip_text = _("Telegram"); - telegram_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + telegram_button.add_css_class (Granite.STYLE_CLASS_FLAT); - var copy_link_button = new Gtk.Button.from_icon_name ("edit-copy-symbolic", Gtk.IconSize.LARGE_TOOLBAR); + var copy_link_button = new Gtk.Button () { + child = new Gtk.Image.from_icon_name ("edit-copy-symbolic") { + pixel_size = 32 + } + }; copy_link_button.tooltip_text = _("Copy link"); - copy_link_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + copy_link_button.add_css_class (Granite.STYLE_CLASS_FLAT); var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH); size_group.add_widget (email_button); @@ -75,13 +101,13 @@ public class SharePopover : Gtk.Popover { margin_start = 6 }; if (mail_appinfo != null) { - service_box.add (email_button); + service_box.append (email_button); } - service_box.add (facebook_button); - service_box.add (twitter_button); - service_box.add (reddit_button); - service_box.add (tumblr_button); - service_box.add (telegram_button); + service_box.append (facebook_button); + service_box.append (twitter_button); + service_box.append (reddit_button); + service_box.append (tumblr_button); + service_box.append (telegram_button); var system_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { margin_top = 6, @@ -89,24 +115,23 @@ public class SharePopover : Gtk.Popover { margin_bottom = 6, margin_start = 6 }; - system_box.add (copy_link_button); + system_box.append (copy_link_button); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - box.add (service_box); - box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); - box.add (system_box); - box.show_all (); + box.append (service_box); + box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + box.append (system_box); - add (box); + child = box; - copy_link_button.clicked.connect (() => { - var clipboard = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); - clipboard.set_text (uri, -1); + // copy_link_button.clicked.connect (() => { + // var clipboard = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); + // clipboard.set_text (uri, -1); - link_copied (); + // link_copied (); - hide (); - }); + // hide (); + // }); email_button.clicked.connect (() => { try { diff --git a/src/Widgets/SizeLabel.vala b/src/Widgets/SizeLabel.vala index b7fdfeea3..3b2fe1a4a 100644 --- a/src/Widgets/SizeLabel.vala +++ b/src/Widgets/SizeLabel.vala @@ -16,7 +16,7 @@ * */ -public class AppCenter.Widgets.SizeLabel : Gtk.Grid { +public class AppCenter.Widgets.SizeLabel : Gtk.Box { public bool using_flatpak { get; construct; } public uint64 size { get; construct; } @@ -39,16 +39,16 @@ public class AppCenter.Widgets.SizeLabel : Gtk.Grid { size_label.hexpand = true; size_label.xalign = 1; - var icon = new Gtk.Image.from_icon_name ("dialog-information-symbolic", Gtk.IconSize.BUTTON); + var icon = new Gtk.Image.from_icon_name ("dialog-information-symbolic"); icon.margin_start = 6; - icon_revealer = new Gtk.Revealer (); - icon_revealer.transition_type = Gtk.RevealerTransitionType.NONE; - icon_revealer.add (icon); + icon_revealer = new Gtk.Revealer () { + child = icon, + transition_type = Gtk.RevealerTransitionType.NONE + }; - add (size_label); - add (icon_revealer); - show_all (); + append (size_label); + append (icon_revealer); update (size, using_flatpak); } @@ -66,10 +66,8 @@ public class AppCenter.Widgets.SizeLabel : Gtk.Grid { } if (size > 0) { - no_show_all = false; show (); } else { - no_show_all = true; hide (); } } diff --git a/src/Widgets/UpdateHeaderRow.vala b/src/Widgets/UpdateHeaderRow.vala index 3cb540784..2cb997273 100644 --- a/src/Widgets/UpdateHeaderRow.vala +++ b/src/Widgets/UpdateHeaderRow.vala @@ -33,9 +33,9 @@ public class AppCenter.Widgets.UpdateHeaderRow : Gtk.Box { halign = Gtk.Align.START, hexpand = true }; - label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); - add (label); + append (label); } public UpdateHeaderRow.updatable (uint num_updates, uint64 update_size, bool using_flatpak) { @@ -49,7 +49,7 @@ public class AppCenter.Widgets.UpdateHeaderRow : Gtk.Box { }; size_label.update (update_size, using_flatpak); - add (size_label); + append (size_label); } public UpdateHeaderRow.drivers () { From e2d6f7d01b82f29a20e8dbeadce0c05f1814c31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 11:49:39 -0700 Subject: [PATCH 02/87] solve appinfoview --- src/Views/AppInfoView.vala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index ee6096bb4..e206e5a0b 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1290,7 +1290,7 @@ namespace AppCenter.Views { } } - private class OtherAppsBar : Gtk.ActionBar { + private class OtherAppsBar : Gtk.Box { public signal void show_other_package (AppCenterCore.Package package); public AppCenterCore.Package package { get; construct; } @@ -1346,7 +1346,8 @@ namespace AppCenter.Views { maximum_size = max_width }; - set_center_widget (clamp); + append (clamp); + add_css_class ("bottom-toolbar"); add_css_class (Granite.STYLE_CLASS_FLAT); flowbox.child_activated.connect ((child) => { From ff42225eca254129c8c5b14fdc56e6ba38d806c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:09:41 -0700 Subject: [PATCH 03/87] CategoryView: don't subclass Gtk.FlowBox --- src/Views/CategoryView.vala | 176 +++++++++++++++++------------------- 1 file changed, 81 insertions(+), 95 deletions(-) diff --git a/src/Views/CategoryView.vala b/src/Views/CategoryView.vala index 62b6b62a3..f91aeded8 100644 --- a/src/Views/CategoryView.vala +++ b/src/Views/CategoryView.vala @@ -20,12 +20,8 @@ public class AppCenter.CategoryView : Gtk.Stack { public AppStream.Category category { get; construct; } - private Gtk.Box box; - private Gtk.Box free_box; - private Gtk.Box paid_box; - private Gtk.Box recently_updated_box; - private Gtk.Box uncurated_box; private Gtk.ScrolledWindow scrolled; + private Gtk.Box box; private SubcategoryFlowbox free_flowbox; private SubcategoryFlowbox paid_flowbox; private SubcategoryFlowbox recently_updated_flowbox; @@ -36,50 +32,16 @@ public class AppCenter.CategoryView : Gtk.Stack { } construct { - var recently_updated_header = new Granite.HeaderLabel (_("Recently Updated")) { - margin_start = 12 - }; - recently_updated_header.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); - - recently_updated_flowbox = new SubcategoryFlowbox (); - - recently_updated_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - recently_updated_box.add (recently_updated_header); - recently_updated_box.add (recently_updated_flowbox); - - var paid_header = new Granite.HeaderLabel (_("Paid Apps")) { - margin_start = 12 - }; - paid_header.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); - - paid_flowbox = new SubcategoryFlowbox (); - - paid_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - paid_box.add (paid_header); - paid_box.add (paid_flowbox); - - var free_header = new Granite.HeaderLabel (_("Free Apps")) { - margin_start = 12 - }; - free_header.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); - - free_flowbox = new SubcategoryFlowbox (); + recently_updated_flowbox = new SubcategoryFlowbox (_("Recently Updated")); - free_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - free_box.add (free_header); - free_box.add (free_flowbox); - - var uncurated_header = new Granite.HeaderLabel (_("Non-Curated Apps")) { - margin_start = 12 - }; - uncurated_header.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + paid_flowbox = new SubcategoryFlowbox (_("Paid Apps")); - uncurated_flowbox = new SubcategoryFlowbox (); + free_flowbox = new SubcategoryFlowbox (_("Free Apps")); #if CURATED - uncurated_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - uncurated_box.add (uncurated_header); - uncurated_box.add (uncurated_flowbox); + uncurated_flowbox = new SubcategoryFlowbox (_("Non-Curated Apps")); +#else + uncurated_flowbox = new SubcategoryFlowbox (); #endif box = new Gtk.Box (Gtk.Orientation.VERTICAL, 48) { @@ -105,24 +67,20 @@ public class AppCenter.CategoryView : Gtk.Stack { populate (); - recently_updated_flowbox.child_activated.connect ((child) => { - var row = (Widgets.ListPackageRowGrid) child.get_child (); - show_app (row.package); + recently_updated_flowbox.show_package.connect ((package) => { + show_app (package); }); - paid_flowbox.child_activated.connect ((child) => { - var row = (Widgets.ListPackageRowGrid) child.get_child (); - show_app (row.package); + paid_flowbox.show_package.connect ((package) => { + show_app (package); }); - free_flowbox.child_activated.connect ((child) => { - var row = (Widgets.ListPackageRowGrid) child.get_child (); - show_app (row.package); + free_flowbox.show_package.connect ((package) => { + show_app (package); }); - uncurated_flowbox.child_activated.connect ((child) => { - var row = (Widgets.ListPackageRowGrid) child.get_child (); - show_app (row.package); + uncurated_flowbox.show_package.connect ((package) => { + show_app (package); }); AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { @@ -136,21 +94,10 @@ public class AppCenter.CategoryView : Gtk.Stack { box.remove (child); } - foreach (unowned var child in recently_updated_flowbox.get_children ()) { - child.destroy (); - } - - foreach (unowned var child in free_flowbox.get_children ()) { - child.destroy (); - } - - foreach (unowned var child in paid_flowbox.get_children ()) { - child.destroy (); - } - - foreach (unowned var child in uncurated_flowbox.get_children ()) { - child.destroy (); - } + recently_updated_flowbox.clear (); + free_flowbox.clear (); + paid_flowbox.clear (); + uncurated_flowbox.clear (); var packages = get_packages.end (res); foreach (var package in packages) { @@ -158,15 +105,15 @@ public class AppCenter.CategoryView : Gtk.Stack { #if CURATED if (package.is_native) { if (package.get_payments_key () != null && package.get_suggested_amount () != "0") { - paid_flowbox.add (package_row); + paid_flowbox.append (package_row); } else { - free_flowbox.add (package_row); + free_flowbox.append (package_row); } } else { - uncurated_flowbox.add (package_row); + uncurated_flowbox.append (package_row); } #else - uncurated_flowbox.add (package_row); + uncurated_flowbox.append (package_row); #endif } @@ -200,26 +147,26 @@ public class AppCenter.CategoryView : Gtk.Stack { if (!recent_package.installed) { var package_row = new AppCenter.Widgets.ListPackageRowGrid (recent_package); - recently_updated_flowbox.add (package_row); + recently_updated_flowbox.append (package_row); recent_count++; } } #if CURATED - if (recently_updated_flowbox.get_child_at_index (0) != null) { - box.add (recently_updated_box); + if (recently_updated_flowbox.has_children) { + box.add (recently_updated_flowbox); } - if (paid_flowbox.get_child_at_index (0) != null) { - box.add (paid_box); + if (paid_flowbox.has_children) { + box.add (paid_flowbox); } - if (free_flowbox.get_child_at_index (0) != null) { - box.add (free_box); + if (free_flowbox.has_children) { + box.add (free_flowbox); } - if (uncurated_flowbox.get_child_at_index (0) != null) { - box.add (uncurated_box); + if (uncurated_flowbox.has_children) { + box.add (uncurated_flowbox); } #else box.add (uncurated_flowbox); @@ -248,27 +195,66 @@ public class AppCenter.CategoryView : Gtk.Stack { return packages; } - private class SubcategoryFlowbox : Gtk.FlowBox { + private class SubcategoryFlowbox : Gtk.Box { + public signal void show_package (AppCenterCore.Package package); + + public string? label { get; construct; } + + public bool has_children { + get { + return flowbox.get_child_at_index (0) != null; + } + } + private static Gtk.SizeGroup size_group; + private Gtk.FlowBox flowbox; static construct { size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL); } - construct { - column_spacing = 24; - homogeneous = true; - max_children_per_line = 4; - row_spacing = 12; - valign = Gtk.Align.START; + public SubcategoryFlowbox (string? label = null) { + Object (label: label); + } - set_sort_func ((Gtk.FlowBoxSortFunc) package_row_compare); + construct { + flowbox = new Gtk.FlowBox () { + column_spacing = 24, + homogeneous = true, + max_children_per_line = 4, + row_spacing = 12, + valign = Gtk.Align.START + }; + flowbox.set_sort_func ((Gtk.FlowBoxSortFunc) package_row_compare); + + orientation = Gtk.Orientation.VERTICAL; + + if (label != null) { + var header = new Granite.HeaderLabel (label) { + margin_start = 12 + }; + header.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + add (header); + } + add (flowbox); - add.connect ((widget) => { - size_group.add_widget (widget); + flowbox.child_activated.connect ((child) => { + var row = (Widgets.ListPackageRowGrid) child.get_child (); + show_package (row.package); }); } + public void append (Gtk.Widget widget) { + size_group.add_widget (widget); + flowbox.add (widget); + } + + public void clear () { + foreach (unowned var child in flowbox.get_children ()) { + child.destroy (); + } + } + [CCode (instance_pos = -1)] protected virtual int package_row_compare (Gtk.FlowBoxChild child1, Gtk.FlowBoxChild child2) { var row1 = (Widgets.ListPackageRowGrid) child1.get_child (); From 64c62e7bddd5a026b9937412ecfb683440781093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:27:07 -0700 Subject: [PATCH 04/87] CategoryFlowBox: subclass box --- src/Views/Homepage.vala | 8 ++--- src/Widgets/CategoryFlowBox.vala | 54 +++++++++++++++++++------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 1bc332dcb..2adfe9266 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -25,7 +25,7 @@ public class AppCenter.Homepage : Gtk.Box { private const int MAX_PACKAGES_IN_BANNER = 5; private const int MAX_PACKAGES_IN_CAROUSEL = 12; - private Gtk.FlowBox category_flow; + private Widgets.CategoryFlowBox category_flow; private Gtk.ScrolledWindow scrolled_window; private Adw.Carousel banner_carousel; @@ -87,6 +87,7 @@ public class AppCenter.Homepage : Gtk.Box { category_flow = new Widgets.CategoryFlowBox () { margin_start = 12, margin_end =12, + margin_bottom = 12, valign = Gtk.Align.START }; @@ -117,9 +118,8 @@ public class AppCenter.Homepage : Gtk.Box { banner_timeout_start (); load_banners_and_carousels.begin (); - category_flow.child_activated.connect ((child) => { - var card = (Widgets.CategoryFlowBox.AbstractCategoryCard) child; - show_category (card.category); + category_flow.show_category.connect ((category) => { + show_category (category); }); AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { diff --git a/src/Widgets/CategoryFlowBox.vala b/src/Widgets/CategoryFlowBox.vala index b4756dfee..8283faae4 100644 --- a/src/Widgets/CategoryFlowBox.vala +++ b/src/Widgets/CategoryFlowBox.vala @@ -18,17 +18,20 @@ * Authored by: Corentin NoĆ«l */ -public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { +public class AppCenter.Widgets.CategoryFlowBox : Gtk.Box { + public signal void show_category (AppStream.Category category); + construct { - activate_on_single_click = true; - homogeneous = true; - margin_bottom = 12; + var flowbox = new Gtk.FlowBox () { + activate_on_single_click = true, + homogeneous = true + }; var games_card = new GamesCard (); - append (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); - append (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); - append (new LegacyCard (_("Communication"), "", { + flowbox.append (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); + flowbox.append (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); + flowbox.append (new LegacyCard (_("Communication"), "", { "Chat", "ContactManagement", "Email", @@ -37,7 +40,7 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Telephony", "VideoConference" }, "communication")); - append (new LegacyCard (_("Development"), "", { + flowbox.append (new LegacyCard (_("Development"), "", { "Database", "Debugger", "Development", @@ -47,13 +50,13 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "TerminalEmulator", "WebDevelopment" }, "development")); - append (new LegacyCard (_("Education"), "", {"Education"}, "education")); - append (new LegacyCard (_("Finance"), "payment-card-symbolic", { + flowbox.append (new LegacyCard (_("Education"), "", {"Education"}, "education")); + flowbox.append (new LegacyCard (_("Finance"), "payment-card-symbolic", { "Economy", "Finance" }, "finance")); - append (games_card); - append (new LegacyCard (_("Graphics"), "", { + flowbox.append (games_card); + flowbox.append (new LegacyCard (_("Graphics"), "", { "2DGraphics", "3DGraphics", "Graphics", @@ -62,11 +65,11 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "RasterGraphics", "VectorGraphics" }, "graphics")); - append (new LegacyCard (_("Internet"), "applications-internet", { + flowbox.append (new LegacyCard (_("Internet"), "applications-internet", { "Network", "P2P" }, "internet")); - append (new LegacyCard (_("Math, Science, & Engineering"), "", { + flowbox.append (new LegacyCard (_("Math, Science, & Engineering"), "", { "ArtificialIntelligence", "Astronomy", "Biology", @@ -85,31 +88,31 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Robotics", "Science" }, "science")); - append (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { + flowbox.append (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { "AudioVideoEditing", "Midi", "Mixer", "Recorder", "Sequencer" }, "media-production")); - append (new LegacyCard (_("Office"), "applications-office-symbolic", { + flowbox.append (new LegacyCard (_("Office"), "applications-office-symbolic", { "Office", "Presentation", "Publishing", "Spreadsheet", "WordProcessor" }, "office")); - append (new LegacyCard (_("System"), "applications-system-symbolic", { + flowbox.append (new LegacyCard (_("System"), "applications-system-symbolic", { "Monitor", "System" }, "system")); - append (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); - append (new LegacyCard (_("Video"), "applications-video-symbolic", { + flowbox.append (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); + flowbox.append (new LegacyCard (_("Video"), "applications-video-symbolic", { "Tuner", "TV", "Video" }, "video")); - append (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { + flowbox.append (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { "Dictionary", "Languages", "Literature", @@ -119,11 +122,11 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Translation", "WordProcessor" }, "writing-language")); - append (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { + flowbox.append (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { "Security", }, "privacy-security")); - set_sort_func ((child1, child2) => { + flowbox.set_sort_func ((child1, child2) => { var item1 = (AbstractCategoryCard) child1; var item2 = (AbstractCategoryCard) child2; if (item1 != null && item2 != null) { @@ -132,6 +135,13 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { return 0; }); + + flowbox.child_activated.connect ((child) => { + var card = (Widgets.CategoryFlowBox.AbstractCategoryCard) child; + show_category (card.category); + }); + + append (flowbox); } public abstract class AbstractCategoryCard : Gtk.FlowBoxChild { From 195df4642316e8da95dc53ca21f2b8ca574563dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:34:37 -0700 Subject: [PATCH 05/87] CategoryFlowBox: subclass Gtk.Box --- src/Views/Homepage.vala | 21 ++-------- src/Widgets/CategoryFlowBox.vala | 67 +++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 0f444b458..c0ef08e2e 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -25,7 +25,7 @@ public class AppCenter.Homepage : Gtk.Box { private const int MAX_PACKAGES_IN_BANNER = 5; private const int MAX_PACKAGES_IN_CAROUSEL = 12; - private Gtk.FlowBox category_flow; + private Widgets.CategoryFlowBox category_flow; private Gtk.ScrolledWindow scrolled_window; private Hdy.Carousel banner_carousel; @@ -89,6 +89,7 @@ public class AppCenter.Homepage : Gtk.Box { category_flow = new Widgets.CategoryFlowBox () { margin_start = 12, margin_end =12, + margin_bottom = 12, valign = Gtk.Align.START }; @@ -119,22 +120,8 @@ public class AppCenter.Homepage : Gtk.Box { banner_timeout_start (); load_banners_and_carousels.begin (); - category_flow.child_activated.connect ((child) => { - var card = (Widgets.CategoryFlowBox.AbstractCategoryCard) child; - show_category (card.category); - }); - - AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { - Idle.add (() => { - // Clear the cached categories when the AppStream pool is updated - foreach (weak Gtk.Widget child in category_flow.get_children ()) { - var item = (Widgets.CategoryFlowBox.AbstractCategoryCard) child; - var category_components = item.category.get_components (); - category_components.remove_range (0, category_components.length); - } - - return GLib.Source.REMOVE; - }); + category_flow.show_category.connect ((category) => { + show_category (category); }); banner_event_box.enter_notify_event.connect (() => { diff --git a/src/Widgets/CategoryFlowBox.vala b/src/Widgets/CategoryFlowBox.vala index 8ab60233d..5755dbe84 100644 --- a/src/Widgets/CategoryFlowBox.vala +++ b/src/Widgets/CategoryFlowBox.vala @@ -18,17 +18,20 @@ * Authored by: Corentin NoĆ«l */ -public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { +public class AppCenter.Widgets.CategoryFlowBox : Gtk.Box { + public signal void show_category (AppStream.Category category); + construct { - activate_on_single_click = true; - homogeneous = true; - margin_bottom = 12; + var flowbox = new Gtk.FlowBox () { + activate_on_single_click = true, + homogeneous = true + }; var games_card = new GamesCard (); - add (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); - add (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); - add (new LegacyCard (_("Communication"), "", { + flowbox.add (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); + flowbox.add (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); + flowbox.add (new LegacyCard (_("Communication"), "", { "Chat", "ContactManagement", "Email", @@ -37,7 +40,7 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Telephony", "VideoConference" }, "communication")); - add (new LegacyCard (_("Development"), "", { + flowbox.add (new LegacyCard (_("Development"), "", { "Database", "Debugger", "Development", @@ -47,13 +50,13 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "TerminalEmulator", "WebDevelopment" }, "development")); - add (new LegacyCard (_("Education"), "", {"Education"}, "education")); - add (new LegacyCard (_("Finance"), "payment-card-symbolic", { + flowbox.add (new LegacyCard (_("Education"), "", {"Education"}, "education")); + flowbox.add (new LegacyCard (_("Finance"), "payment-card-symbolic", { "Economy", "Finance" }, "finance")); - add (games_card); - add (new LegacyCard (_("Graphics"), "", { + flowbox.add (games_card); + flowbox.add (new LegacyCard (_("Graphics"), "", { "2DGraphics", "3DGraphics", "Graphics", @@ -62,11 +65,11 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "RasterGraphics", "VectorGraphics" }, "graphics")); - add (new LegacyCard (_("Internet"), "applications-internet", { + flowbox.add (new LegacyCard (_("Internet"), "applications-internet", { "Network", "P2P" }, "internet")); - add (new LegacyCard (_("Math, Science, & Engineering"), "", { + flowbox.add (new LegacyCard (_("Math, Science, & Engineering"), "", { "ArtificialIntelligence", "Astronomy", "Biology", @@ -85,31 +88,31 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Robotics", "Science" }, "science")); - add (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { + flowbox.add (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { "AudioVideoEditing", "Midi", "Mixer", "Recorder", "Sequencer" }, "media-production")); - add (new LegacyCard (_("Office"), "applications-office-symbolic", { + flowbox.add (new LegacyCard (_("Office"), "applications-office-symbolic", { "Office", "Presentation", "Publishing", "Spreadsheet", "WordProcessor" }, "office")); - add (new LegacyCard (_("System"), "applications-system-symbolic", { + flowbox.add (new LegacyCard (_("System"), "applications-system-symbolic", { "Monitor", "System" }, "system")); - add (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); - add (new LegacyCard (_("Video"), "applications-video-symbolic", { + flowbox.add (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); + flowbox.add (new LegacyCard (_("Video"), "applications-video-symbolic", { "Tuner", "TV", "Video" }, "video")); - add (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { + flowbox.add (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { "Dictionary", "Languages", "Literature", @@ -119,11 +122,11 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { "Translation", "WordProcessor" }, "writing-language")); - add (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { + flowbox.add (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { "Security", }, "privacy-security")); - set_sort_func ((child1, child2) => { + flowbox.set_sort_func ((child1, child2) => { var item1 = (AbstractCategoryCard) child1; var item2 = (AbstractCategoryCard) child2; if (item1 != null && item2 != null) { @@ -132,6 +135,26 @@ public class AppCenter.Widgets.CategoryFlowBox : Gtk.FlowBox { return 0; }); + + flowbox.child_activated.connect ((child) => { + var card = (AbstractCategoryCard) child; + show_category (card.category); + }); + + add (flowbox); + + AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { + Idle.add (() => { + // Clear the cached categories when the AppStream pool is updated + foreach (unowned var child in flowbox.get_children ()) { + var item = (AbstractCategoryCard) child; + var category_components = item.category.get_components (); + category_components.remove_range (0, category_components.length); + } + + return GLib.Source.REMOVE; + }); + }); } public abstract class AbstractCategoryCard : Gtk.FlowBoxChild { From c2e16ef703caac3895be0103793b163c09eddcb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:42:44 -0700 Subject: [PATCH 06/87] Homepage: absorb categoryflowbox --- src/Views/Homepage.vala | 292 +++++++++++++++++++++++++++- src/Widgets/CategoryFlowBox.vala | 318 ------------------------------- src/meson.build | 1 - 3 files changed, 288 insertions(+), 323 deletions(-) delete mode 100644 src/Widgets/CategoryFlowBox.vala diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index c0ef08e2e..932aa13dc 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -25,7 +25,7 @@ public class AppCenter.Homepage : Gtk.Box { private const int MAX_PACKAGES_IN_BANNER = 5; private const int MAX_PACKAGES_IN_CAROUSEL = 12; - private Widgets.CategoryFlowBox category_flow; + private Gtk.FlowBox category_flow; private Gtk.ScrolledWindow scrolled_window; private Hdy.Carousel banner_carousel; @@ -86,13 +86,124 @@ public class AppCenter.Homepage : Gtk.Box { margin_top = 24 }; - category_flow = new Widgets.CategoryFlowBox () { + category_flow = new Gtk.FlowBox () { + activate_on_single_click = true, + homogeneous = true, margin_start = 12, margin_end =12, margin_bottom = 12, valign = Gtk.Align.START }; + category_flow.set_sort_func ((child1, child2) => { + var item1 = (AbstractCategoryCard) child1; + var item2 = (AbstractCategoryCard) child2; + if (item1 != null && item2 != null) { + return item1.category.name.collate (item2.category.name); + } + + return 0; + }); + + var games_card = new GamesCard (); + + category_flow.add (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); + category_flow.add (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); + category_flow.add (new LegacyCard (_("Communication"), "", { + "Chat", + "ContactManagement", + "Email", + "InstantMessaging", + "IRCClient", + "Telephony", + "VideoConference" + }, "communication")); + category_flow.add (new LegacyCard (_("Development"), "", { + "Database", + "Debugger", + "Development", + "GUIDesigner", + "IDE", + "RevisionControl", + "TerminalEmulator", + "WebDevelopment" + }, "development")); + category_flow.add (new LegacyCard (_("Education"), "", {"Education"}, "education")); + category_flow.add (new LegacyCard (_("Finance"), "payment-card-symbolic", { + "Economy", + "Finance" + }, "finance")); + category_flow.add (games_card); + category_flow.add (new LegacyCard (_("Graphics"), "", { + "2DGraphics", + "3DGraphics", + "Graphics", + "ImageProcessing", + "Photography", + "RasterGraphics", + "VectorGraphics" + }, "graphics")); + category_flow.add (new LegacyCard (_("Internet"), "applications-internet", { + "Network", + "P2P" + }, "internet")); + category_flow.add (new LegacyCard (_("Math, Science, & Engineering"), "", { + "ArtificialIntelligence", + "Astronomy", + "Biology", + "Calculator", + "Chemistry", + "ComputerScience", + "DataVisualization", + "Electricity", + "Electronics", + "Engineering", + "Geology", + "Geoscience", + "Math", + "NumericalAnalysis", + "Physics", + "Robotics", + "Science" + }, "science")); + category_flow.add (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { + "AudioVideoEditing", + "Midi", + "Mixer", + "Recorder", + "Sequencer" + }, "media-production")); + category_flow.add (new LegacyCard (_("Office"), "applications-office-symbolic", { + "Office", + "Presentation", + "Publishing", + "Spreadsheet", + "WordProcessor" + }, "office")); + category_flow.add (new LegacyCard (_("System"), "applications-system-symbolic", { + "Monitor", + "System" + }, "system")); + category_flow.add (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); + category_flow.add (new LegacyCard (_("Video"), "applications-video-symbolic", { + "Tuner", + "TV", + "Video" + }, "video")); + category_flow.add (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { + "Dictionary", + "Languages", + "Literature", + "OCR", + "TextEditor", + "TextTools", + "Translation", + "WordProcessor" + }, "writing-language")); + category_flow.add (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { + "Security", + }, "privacy-security")); + var box = new Gtk.Box (orientation = Gtk.Orientation.VERTICAL, 0); box.add (banner_revealer); box.add (recently_updated_revealer); @@ -120,8 +231,9 @@ public class AppCenter.Homepage : Gtk.Box { banner_timeout_start (); load_banners_and_carousels.begin (); - category_flow.show_category.connect ((category) => { - show_category (category); + category_flow.child_activated.connect ((child) => { + var card = (AbstractCategoryCard) child; + show_category (card.category); }); banner_event_box.enter_notify_event.connect (() => { @@ -138,6 +250,19 @@ public class AppCenter.Homepage : Gtk.Box { show_package (package_row_grid.package); }); + AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { + Idle.add (() => { + // Clear the cached categories when the AppStream pool is updated + foreach (unowned var child in category_flow.get_children ()) { + var item = (AbstractCategoryCard) child; + var category_components = item.category.get_components (); + category_components.remove_range (0, category_components.length); + } + + return GLib.Source.REMOVE; + }); + }); + destroy.connect (() => { banner_timeout_stop (); }); @@ -239,4 +364,163 @@ public class AppCenter.Homepage : Gtk.Box { banner_timeout_id = 0; } } + + public abstract class AbstractCategoryCard : Gtk.FlowBoxChild { + public AppStream.Category category { get; protected set; } + + protected Gtk.Grid content_area; + protected unowned Gtk.StyleContext style_context; + + protected static Gtk.CssProvider category_provider; + + static construct { + category_provider = new Gtk.CssProvider (); + category_provider.load_from_resource ("io/elementary/appcenter/categories.css"); + } + + construct { + var expanded_grid = new Gtk.Grid () { + hexpand = true, + vexpand = true, + margin_top = 12, + margin_end = 12, + margin_bottom = 12, + margin_start = 12 + }; + + content_area = new Gtk.Grid () { + margin_top = 12, + margin_end = 12, + margin_bottom = 12, + margin_start = 12 + }; + content_area.add (expanded_grid); + + style_context = content_area.get_style_context (); + style_context.add_class (Granite.STYLE_CLASS_CARD); + style_context.add_class (Granite.STYLE_CLASS_ROUNDED); + style_context.add_class ("category"); + style_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + child = content_area; + } + } + + private class LegacyCard : AbstractCategoryCard { + public LegacyCard (string name, string icon, string[] groups, string style) { + category = new AppStream.Category (); + category.set_name (name); + category.set_icon (icon); + + foreach (var group in groups) { + category.add_desktop_group (group); + } + + var display_image = new Gtk.Image (); + display_image.icon_size = Gtk.IconSize.DIALOG; + display_image.valign = Gtk.Align.CENTER; + display_image.halign = Gtk.Align.END; + + var name_label = new Gtk.Label (null); + name_label.wrap = true; + name_label.max_width_chars = 15; + name_label.get_style_context ().add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { + halign = Gtk.Align.CENTER, + valign = Gtk.Align.CENTER, + margin_top = 32, + margin_end = 16, + margin_bottom = 32, + margin_start = 16 + }; + box.add (display_image); + box.add (name_label); + + content_area.attach (box, 0, 0); + + if (category.icon != "") { + display_image.icon_name = category.icon; + name_label.xalign = 0; + name_label.halign = Gtk.Align.START; + } else { + display_image.destroy (); + name_label.justify = Gtk.Justification.CENTER; + } + + style_context.add_class (style); + + if (style == "accessibility") { + name_label.label = category.name.up (); + } else { + name_label.label = category.name; + } + + if (style == "science") { + name_label.justify = Gtk.Justification.CENTER; + } + } + } + + private class GamesCard : AbstractCategoryCard { + construct { + category = new AppStream.Category () { + name = _("Fun & Games"), + icon = "applications-games-symbolic" + }; + category.add_desktop_group ("ActionGame"); + category.add_desktop_group ("AdventureGame"); + category.add_desktop_group ("Amusement"); + category.add_desktop_group ("ArcadeGame"); + category.add_desktop_group ("BlocksGame"); + category.add_desktop_group ("BoardGame"); + category.add_desktop_group ("CardGame"); + category.add_desktop_group ("Game"); + category.add_desktop_group ("KidsGame"); + category.add_desktop_group ("LogicGame"); + category.add_desktop_group ("RolePlaying"); + category.add_desktop_group ("Shooter"); + category.add_desktop_group ("Simulation"); + category.add_desktop_group ("SportsGame"); + category.add_desktop_group ("StrategyGame"); + + var image = new Gtk.Image () { + icon_name = "applications-games-symbolic", + pixel_size = 64 + }; + + unowned var image_context = image.get_style_context (); + image_context.add_class (Granite.STYLE_CLASS_ACCENT); + image_context.add_class ("slate"); + + var fun_label = new Gtk.Label (_("Fun &")) { + halign = Gtk.Align.START + }; + + unowned var fun_label_context = fun_label.get_style_context (); + fun_label_context.add_class (Granite.STYLE_CLASS_ACCENT); + fun_label_context.add_class ("pink"); + fun_label_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + var games_label = new Gtk.Label (_("Games")); + + unowned var games_label_context = games_label.get_style_context (); + games_label_context.add_class (Granite.STYLE_CLASS_ACCENT); + games_label_context.add_class ("blue"); + games_label_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + + var grid = new Gtk.Grid () { + column_spacing = 12, + halign = Gtk.Align.CENTER, + valign = Gtk.Align.CENTER + }; + grid.attach (image, 0, 0, 1, 2); + grid.attach (fun_label, 1, 0); + grid.attach (games_label, 1, 1); + + content_area.attach (grid, 0, 0); + + style_context.add_class ("games"); + } + } } diff --git a/src/Widgets/CategoryFlowBox.vala b/src/Widgets/CategoryFlowBox.vala deleted file mode 100644 index 5755dbe84..000000000 --- a/src/Widgets/CategoryFlowBox.vala +++ /dev/null @@ -1,318 +0,0 @@ -// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- -/*- - * Copyright (c) 2014-2018 elementary, Inc. (https://elementary.io) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authored by: Corentin NoĆ«l - */ - -public class AppCenter.Widgets.CategoryFlowBox : Gtk.Box { - public signal void show_category (AppStream.Category category); - - construct { - var flowbox = new Gtk.FlowBox () { - activate_on_single_click = true, - homogeneous = true - }; - - var games_card = new GamesCard (); - - flowbox.add (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); - flowbox.add (new LegacyCard (_("Audio"), "applications-audio-symbolic", {"Audio", "Music"}, "audio")); - flowbox.add (new LegacyCard (_("Communication"), "", { - "Chat", - "ContactManagement", - "Email", - "InstantMessaging", - "IRCClient", - "Telephony", - "VideoConference" - }, "communication")); - flowbox.add (new LegacyCard (_("Development"), "", { - "Database", - "Debugger", - "Development", - "GUIDesigner", - "IDE", - "RevisionControl", - "TerminalEmulator", - "WebDevelopment" - }, "development")); - flowbox.add (new LegacyCard (_("Education"), "", {"Education"}, "education")); - flowbox.add (new LegacyCard (_("Finance"), "payment-card-symbolic", { - "Economy", - "Finance" - }, "finance")); - flowbox.add (games_card); - flowbox.add (new LegacyCard (_("Graphics"), "", { - "2DGraphics", - "3DGraphics", - "Graphics", - "ImageProcessing", - "Photography", - "RasterGraphics", - "VectorGraphics" - }, "graphics")); - flowbox.add (new LegacyCard (_("Internet"), "applications-internet", { - "Network", - "P2P" - }, "internet")); - flowbox.add (new LegacyCard (_("Math, Science, & Engineering"), "", { - "ArtificialIntelligence", - "Astronomy", - "Biology", - "Calculator", - "Chemistry", - "ComputerScience", - "DataVisualization", - "Electricity", - "Electronics", - "Engineering", - "Geology", - "Geoscience", - "Math", - "NumericalAnalysis", - "Physics", - "Robotics", - "Science" - }, "science")); - flowbox.add (new LegacyCard (_("Media Production"), "applications-multimedia-symbolic", { - "AudioVideoEditing", - "Midi", - "Mixer", - "Recorder", - "Sequencer" - }, "media-production")); - flowbox.add (new LegacyCard (_("Office"), "applications-office-symbolic", { - "Office", - "Presentation", - "Publishing", - "Spreadsheet", - "WordProcessor" - }, "office")); - flowbox.add (new LegacyCard (_("System"), "applications-system-symbolic", { - "Monitor", - "System" - }, "system")); - flowbox.add (new LegacyCard (_("Universal Access"), "applications-accessibility-symbolic", {"Accessibility"}, "accessibility")); - flowbox.add (new LegacyCard (_("Video"), "applications-video-symbolic", { - "Tuner", - "TV", - "Video" - }, "video")); - flowbox.add (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { - "Dictionary", - "Languages", - "Literature", - "OCR", - "TextEditor", - "TextTools", - "Translation", - "WordProcessor" - }, "writing-language")); - flowbox.add (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { - "Security", - }, "privacy-security")); - - flowbox.set_sort_func ((child1, child2) => { - var item1 = (AbstractCategoryCard) child1; - var item2 = (AbstractCategoryCard) child2; - if (item1 != null && item2 != null) { - return item1.category.name.collate (item2.category.name); - } - - return 0; - }); - - flowbox.child_activated.connect ((child) => { - var card = (AbstractCategoryCard) child; - show_category (card.category); - }); - - add (flowbox); - - AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { - Idle.add (() => { - // Clear the cached categories when the AppStream pool is updated - foreach (unowned var child in flowbox.get_children ()) { - var item = (AbstractCategoryCard) child; - var category_components = item.category.get_components (); - category_components.remove_range (0, category_components.length); - } - - return GLib.Source.REMOVE; - }); - }); - } - - public abstract class AbstractCategoryCard : Gtk.FlowBoxChild { - public AppStream.Category category { get; protected set; } - - protected Gtk.Grid content_area; - protected unowned Gtk.StyleContext style_context; - - protected static Gtk.CssProvider category_provider; - - static construct { - category_provider = new Gtk.CssProvider (); - category_provider.load_from_resource ("io/elementary/appcenter/categories.css"); - } - - construct { - var expanded_grid = new Gtk.Grid () { - hexpand = true, - vexpand = true, - margin_top = 12, - margin_end = 12, - margin_bottom = 12, - margin_start = 12 - }; - - content_area = new Gtk.Grid () { - margin_top = 12, - margin_end = 12, - margin_bottom = 12, - margin_start = 12 - }; - content_area.add (expanded_grid); - - style_context = content_area.get_style_context (); - style_context.add_class (Granite.STYLE_CLASS_CARD); - style_context.add_class (Granite.STYLE_CLASS_ROUNDED); - style_context.add_class ("category"); - style_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - - child = content_area; - } - } - - private class LegacyCard : AbstractCategoryCard { - public LegacyCard (string name, string icon, string[] groups, string style) { - category = new AppStream.Category (); - category.set_name (name); - category.set_icon (icon); - - foreach (var group in groups) { - category.add_desktop_group (group); - } - - var display_image = new Gtk.Image (); - display_image.icon_size = Gtk.IconSize.DIALOG; - display_image.valign = Gtk.Align.CENTER; - display_image.halign = Gtk.Align.END; - - var name_label = new Gtk.Label (null); - name_label.wrap = true; - name_label.max_width_chars = 15; - name_label.get_style_context ().add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - - var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { - halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER, - margin_top = 32, - margin_end = 16, - margin_bottom = 32, - margin_start = 16 - }; - box.add (display_image); - box.add (name_label); - - content_area.attach (box, 0, 0); - - if (category.icon != "") { - display_image.icon_name = category.icon; - name_label.xalign = 0; - name_label.halign = Gtk.Align.START; - } else { - display_image.destroy (); - name_label.justify = Gtk.Justification.CENTER; - } - - style_context.add_class (style); - - if (style == "accessibility") { - name_label.label = category.name.up (); - } else { - name_label.label = category.name; - } - - if (style == "science") { - name_label.justify = Gtk.Justification.CENTER; - } - } - } - - private class GamesCard : AbstractCategoryCard { - construct { - category = new AppStream.Category () { - name = _("Fun & Games"), - icon = "applications-games-symbolic" - }; - category.add_desktop_group ("ActionGame"); - category.add_desktop_group ("AdventureGame"); - category.add_desktop_group ("Amusement"); - category.add_desktop_group ("ArcadeGame"); - category.add_desktop_group ("BlocksGame"); - category.add_desktop_group ("BoardGame"); - category.add_desktop_group ("CardGame"); - category.add_desktop_group ("Game"); - category.add_desktop_group ("KidsGame"); - category.add_desktop_group ("LogicGame"); - category.add_desktop_group ("RolePlaying"); - category.add_desktop_group ("Shooter"); - category.add_desktop_group ("Simulation"); - category.add_desktop_group ("SportsGame"); - category.add_desktop_group ("StrategyGame"); - - var image = new Gtk.Image () { - icon_name = "applications-games-symbolic", - pixel_size = 64 - }; - - unowned var image_context = image.get_style_context (); - image_context.add_class (Granite.STYLE_CLASS_ACCENT); - image_context.add_class ("slate"); - - var fun_label = new Gtk.Label (_("Fun &")) { - halign = Gtk.Align.START - }; - - unowned var fun_label_context = fun_label.get_style_context (); - fun_label_context.add_class (Granite.STYLE_CLASS_ACCENT); - fun_label_context.add_class ("pink"); - fun_label_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - - var games_label = new Gtk.Label (_("Games")); - - unowned var games_label_context = games_label.get_style_context (); - games_label_context.add_class (Granite.STYLE_CLASS_ACCENT); - games_label_context.add_class ("blue"); - games_label_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - - var grid = new Gtk.Grid () { - column_spacing = 12, - halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER - }; - grid.attach (image, 0, 0, 1, 2); - grid.attach (fun_label, 1, 0); - grid.attach (games_label, 1, 1); - - content_area.attach (grid, 0, 0); - - style_context.add_class ("games"); - } - } -} diff --git a/src/meson.build b/src/meson.build index 4615abdc5..0284abaa3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -33,7 +33,6 @@ appcenter_files = files( 'Widgets/AbstractAppList.vala', 'Widgets/Banner.vala', 'Widgets/CardNumberEntry.vala', - 'Widgets/CategoryFlowBox.vala', 'Widgets/HumbleButton.vala', 'Widgets/PackageRow.vala', 'Widgets/ReleaseListBox.vala', From ecd33029080edbe55a58a7a87383b47b467a8418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:43:46 -0700 Subject: [PATCH 07/87] less diff --- src/Views/Homepage.vala | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 932aa13dc..6274feae2 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -236,6 +236,19 @@ public class AppCenter.Homepage : Gtk.Box { show_category (card.category); }); + AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { + Idle.add (() => { + // Clear the cached categories when the AppStream pool is updated + foreach (unowned var child in category_flow.get_children ()) { + var item = (AbstractCategoryCard) child; + var category_components = item.category.get_components (); + category_components.remove_range (0, category_components.length); + } + + return GLib.Source.REMOVE; + }); + }); + banner_event_box.enter_notify_event.connect (() => { banner_timeout_stop (); }); @@ -250,19 +263,6 @@ public class AppCenter.Homepage : Gtk.Box { show_package (package_row_grid.package); }); - AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { - Idle.add (() => { - // Clear the cached categories when the AppStream pool is updated - foreach (unowned var child in category_flow.get_children ()) { - var item = (AbstractCategoryCard) child; - var category_components = item.category.get_components (); - category_components.remove_range (0, category_components.length); - } - - return GLib.Source.REMOVE; - }); - }); - destroy.connect (() => { banner_timeout_stop (); }); From 5f343aba6be37263da2164e937b8602bbfcfb58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:45:48 -0700 Subject: [PATCH 08/87] scope down --- src/Views/Homepage.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 6274feae2..68f00d39c 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -365,7 +365,7 @@ public class AppCenter.Homepage : Gtk.Box { } } - public abstract class AbstractCategoryCard : Gtk.FlowBoxChild { + private abstract class AbstractCategoryCard : Gtk.FlowBoxChild { public AppStream.Category category { get; protected set; } protected Gtk.Grid content_area; From c57153019fe050b91dc178e47d676a092cf1ea86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 12:48:14 -0700 Subject: [PATCH 09/87] POTFILES --- po/POTFILES | 1 - 1 file changed, 1 deletion(-) diff --git a/po/POTFILES b/po/POTFILES index a59707dd0..88426c295 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -32,7 +32,6 @@ src/Views/SearchView.vala src/Widgets/AbstractAppList.vala src/Widgets/Banner.vala src/Widgets/CardNumberEntry.vala -src/Widgets/CategoryFlowBox.vala src/Widgets/HumbleButton.vala src/Widgets/PackageRow.vala src/Widgets/ReleaseListBox.vala From 7d3b2a5cb1377ca0107b72108bfbac544611d75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 13:33:54 -0700 Subject: [PATCH 10/87] CategoryView: don't subclass stack --- src/Views/CategoryView.vala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Views/CategoryView.vala b/src/Views/CategoryView.vala index 4aafcb6ed..cb84db0e6 100644 --- a/src/Views/CategoryView.vala +++ b/src/Views/CategoryView.vala @@ -15,11 +15,12 @@ * along with this program. If not, see . */ -public class AppCenter.CategoryView : Gtk.Stack { +public class AppCenter.CategoryView : Gtk.Box { public signal void show_app (AppCenterCore.Package package); public AppStream.Category category { get; construct; } + private Gtk.Stack stack; private Gtk.Box box; private Gtk.Box free_box; private Gtk.Box paid_box; @@ -99,8 +100,11 @@ public class AppCenter.CategoryView : Gtk.Stack { }; spinner.start (); - add_child (spinner); - add_child (scrolled); + stack = new Gtk.Stack (); + stack.add_child (spinner); + stack.add_child (scrolled); + + append (stack); populate (); @@ -224,7 +228,7 @@ public class AppCenter.CategoryView : Gtk.Stack { box.append (uncurated_flowbox); #endif - visible_child = scrolled; + stack.visible_child = scrolled; }); } From f8d6d303ed108e345a4d4db0143ea843a1f50e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 13:39:30 -0700 Subject: [PATCH 11/87] AppInfoView: absorb ReleaseListBox --- po/POTFILES | 1 - src/Views/AppInfoView.vala | 15 ++++++++++--- src/Widgets/ReleaseListBox.vala | 39 --------------------------------- src/meson.build | 1 - 4 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 src/Widgets/ReleaseListBox.vala diff --git a/po/POTFILES b/po/POTFILES index a59707dd0..21dd67382 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -35,7 +35,6 @@ src/Widgets/CardNumberEntry.vala src/Widgets/CategoryFlowBox.vala src/Widgets/HumbleButton.vala src/Widgets/PackageRow.vala -src/Widgets/ReleaseListBox.vala src/Widgets/ReleaseRow.vala src/Widgets/SharePopover.vala src/Widgets/SizeLabel.vala diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 91c0fd48e..d63491b51 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -46,7 +46,7 @@ namespace AppCenter.Views { private Hdy.Clamp screenshot_not_found_clamp; private Gtk.Stack screenshot_stack; private Gtk.Label app_description; - private Widgets.ReleaseListBox release_list_box; + private Gtk.ListBox release_list_box; private Widgets.SizeLabel size_label; private Hdy.CarouselIndicatorDots screenshot_switcher; private ArrowButton screenshot_next; @@ -582,7 +582,10 @@ namespace AppCenter.Views { }; whats_new_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); - release_list_box = new Widgets.ReleaseListBox (package); + release_list_box = new Gtk.ListBox () { + selection_mode = Gtk.SelectionMode.NONE + }; + release_list_box.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); release_grid = new Gtk.Grid () { no_show_all = true, @@ -934,7 +937,13 @@ namespace AppCenter.Views { get_app_download_size.begin (); Idle.add (() => { - if (release_list_box.populate ()) { + var releases = package.get_newest_releases (1, 5); + foreach (var release in releases) { + var row = new AppCenter.Widgets.ReleaseRow (release); + release_list_box.add (row); + } + + if (releases.size > 0) { release_grid.no_show_all = false; release_grid.show_all (); } diff --git a/src/Widgets/ReleaseListBox.vala b/src/Widgets/ReleaseListBox.vala deleted file mode 100644 index e43103438..000000000 --- a/src/Widgets/ReleaseListBox.vala +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2017 elementary LLC. (https://elementary.io) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authored by: Adam Bieńkowski - */ - -public class AppCenter.Widgets.ReleaseListBox : Gtk.ListBox { - private const int MIN_RELEASES = 1; - private const int MAX_RELEASES = 5; - - public AppCenterCore.Package package { get; construct; } - - public ReleaseListBox (AppCenterCore.Package package) { - Object (package: package, selection_mode: Gtk.SelectionMode.NONE); - } - - public bool populate () { - var releases = package.get_newest_releases (MIN_RELEASES, MAX_RELEASES); - foreach (var release in releases) { - var row = new ReleaseRow (release); - add (row); - } - - return releases.size > 0; - } -} diff --git a/src/meson.build b/src/meson.build index 4615abdc5..78eb08647 100644 --- a/src/meson.build +++ b/src/meson.build @@ -36,7 +36,6 @@ appcenter_files = files( 'Widgets/CategoryFlowBox.vala', 'Widgets/HumbleButton.vala', 'Widgets/PackageRow.vala', - 'Widgets/ReleaseListBox.vala', 'Widgets/ReleaseRow.vala', 'Widgets/SharePopover.vala', 'Widgets/SizeLabel.vala', From 1325b38d3935afa83c6fe9a59e5a8480b8259a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:25:30 -0700 Subject: [PATCH 12/87] Don't use Adw.Window --- src/MainWindow.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 7717f7a2f..be731350f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -14,7 +14,7 @@ * with this program. If not, see http://www.gnu.org/licenses/. */ -public class AppCenter.MainWindow : Adw.ApplicationWindow { +public class AppCenter.MainWindow : Gtk.ApplicationWindow { public bool working { get; set; } private AppCenter.SearchView search_view; From 6b96a6ec38021573c922b1605a5844b5cd8d36f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:32:50 -0700 Subject: [PATCH 13/87] Avoid invalid casts --- src/Widgets/AbstractAppList.vala | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Widgets/AbstractAppList.vala b/src/Widgets/AbstractAppList.vala index 77eaa9d41..774b0eb34 100644 --- a/src/Widgets/AbstractAppList.vala +++ b/src/Widgets/AbstractAppList.vala @@ -55,26 +55,31 @@ public abstract class AppCenter.AbstractAppList : Gtk.Box { public void remove_package (AppCenterCore.Package package) { package.changing.disconnect (on_package_changing); - unowned var row = (Widgets.PackageRow) list_box.get_first_child (); + unowned var row = list_box.get_first_child (); while (row != null) { - if (row.get_package () == package) { - row.destroy (); - break; + if (row is Widgets.PackageRow) { + if (((Widgets.PackageRow) row).get_package () == package) { + row.destroy (); + break; + } } - row = (Widgets.PackageRow) row.get_next_sibling (); + + row = row.get_next_sibling (); } list_box.invalidate_sort (); } public virtual void clear () { - unowned var row = (Widgets.PackageRow) list_box.get_first_child (); + unowned var row = list_box.get_first_child (); while (row != null) { - var package = row.get_package (); - package.changing.disconnect (on_package_changing); - row.destroy (); + if (row is Widgets.PackageRow) { + var package = ((Widgets.PackageRow) row).get_package (); + package.changing.disconnect (on_package_changing); + row.destroy (); + } - row = (Widgets.PackageRow) row.get_next_sibling (); + row = row.get_next_sibling (); } list_box.invalidate_sort (); @@ -83,11 +88,13 @@ public abstract class AppCenter.AbstractAppList : Gtk.Box { protected virtual Gee.Collection get_packages () { var tree_set = new Gee.TreeSet (); - unowned var row = (Widgets.PackageRow) list_box.get_first_child (); + unowned var row = list_box.get_first_child (); while (row != null) { - tree_set.add (row.get_package ()); + if (row is Widgets.PackageRow) { + tree_set.add (((Widgets.PackageRow) row).get_package ()); + } - row = (Widgets.PackageRow) row.get_next_sibling (); + row = row.get_next_sibling (); } return tree_set; From bd49a0b0b7e033d61563aa4f88084f550cfd9903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:33:57 -0700 Subject: [PATCH 14/87] Fix headerbar --- src/MainWindow.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index be731350f..8a573e398 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -252,11 +252,11 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { network_info_bar.add_button (_("Network Settingsā€¦"), Gtk.ResponseType.ACCEPT); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - box.append (headerbar); box.append (network_info_bar); box.append (overlay); child = box; + set_titlebar (headerbar); int window_width, window_height; App.settings.get ("window-size", "(ii)", out window_width, out window_height); From 194a4d93fa1509f04be9ac2cf43a8ae4bd3a9b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:38:25 -0700 Subject: [PATCH 15/87] misc fixes --- data/styles/arrow.css | 18 +++++++++--------- src/MainWindow.vala | 8 +++++--- src/Views/Homepage.vala | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/data/styles/arrow.css b/data/styles/arrow.css index d859fef4b..296495cc4 100644 --- a/data/styles/arrow.css +++ b/data/styles/arrow.css @@ -18,10 +18,10 @@ .arrow { background: @base_color; box-shadow: - inset 0 0 0 1px alpha (@bg_highlight_color, 0.05), - inset 0 1px 0 0 alpha (@bg_highlight_color, 0.45), - inset 0 -1px 0 0 alpha (@bg_highlight_color, 0.15), - 0 0 0 1px alpha (#000, 0.05), + inset 0 0 0 1px alpha(@bg_highlight_color, 0.05), + inset 0 1px 0 0 alpha(@bg_highlight_color, 0.45), + inset 0 -1px 0 0 alpha(@bg_highlight_color, 0.15), + 0 0 0 1px alpha(#000, 0.05), 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); margin: 12px; @@ -33,9 +33,9 @@ .arrow:disabled { background-color: @insensitive_bg_color; box-shadow: - inset 0 0 0 1px alpha (@bg_highlight_color, 0.05), - inset 0 1px 0 0 alpha (@bg_highlight_color, 0.45), - inset 0 -1px 0 0 alpha (@bg_highlight_color, 0.15), - 0 0 0 1px alpha (#000, 0.05), - 0 1px 2px alpha (#000, 0.22); + inset 0 0 0 1px alpha(@bg_highlight_color, 0.05), + inset 0 1px 0 0 alpha(@bg_highlight_color, 0.45), + inset 0 -1px 0 0 alpha(@bg_highlight_color, 0.15), + 0 0 0 1px alpha(#000, 0.05), + 0 1px 2px alpha(#000, 0.22); } diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8a573e398..cf2d5392e 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -131,9 +131,10 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { }); return_button = new Gtk.Button () { - valign = Gtk.Align.CENTER + valign = Gtk.Align.CENTER, + visible = false }; - return_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON); + return_button.add_css_class (Granite.STYLE_CLASS_BACK_BUTTON); var updates_button = new Gtk.Button () { child = new Gtk.Image.from_icon_name ("software-update-available") { @@ -228,7 +229,8 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { installed_view = new Views.AppListUpdateView (); leaflet = new Adw.Leaflet () { - can_navigate_back = true + can_navigate_back = true, + can_unfold = false }; leaflet.append (homepage); diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index d10b0867a..0371b8dc8 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -209,7 +209,7 @@ public class AppCenter.Homepage : Gtk.Box { box.append (category_flow); scrolled_window = new Gtk.ScrolledWindow () { - child = scrolled_window, + child = box, hscrollbar_policy = Gtk.PolicyType.NEVER }; From 2813a63c08a54030fa1f26b20f09d177c8d4eadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:40:42 -0700 Subject: [PATCH 16/87] Back button handling is built in --- src/MainWindow.vala | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index cf2d5392e..3efe0a7ca 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -55,16 +55,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { app.set_accels_for_action ("win.go-back", {"Left", "Back"}); app.set_accels_for_action ("win.focus-search", {"f"}); - // button_release_event.connect ((event) => { - // // On back mouse button pressed - // if (event.button == 8) { - // view_return (); - // return true; - // } - - // return false; - // }); - search_entry.search_changed.connect (() => trigger_search ()); // search_entry.key_press_event.connect ((event) => { From 232cc2df03d61c5b5452bba215deb4688ea0aac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:52:29 -0700 Subject: [PATCH 17/87] Fix header button style --- src/MainWindow.vala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 3efe0a7ca..b19edfae1 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -126,11 +126,8 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { }; return_button.add_css_class (Granite.STYLE_CLASS_BACK_BUTTON); - var updates_button = new Gtk.Button () { - child = new Gtk.Image.from_icon_name ("software-update-available") { - pixel_size = 24 - } - }; + var updates_button = new Gtk.Button.from_icon_name ("software-update-available"); + ((Gtk.Image) updates_button.child).pixel_size = 24; var badge_provider = new Gtk.CssProvider (); badge_provider.load_from_resource ("io/elementary/appcenter/badge.css"); @@ -201,6 +198,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { child = new Gtk.Image.from_icon_name ("open-menu") { pixel_size = 24 }, + has_frame = false, popover = menu_popover, tooltip_text = _("Settings"), valign = Gtk.Align.CENTER From 9deaff2fdc9a902474d5b1bc568bb9887d15b91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 15:57:54 -0700 Subject: [PATCH 18/87] Fix menuitem styles --- src/MainWindow.vala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b19edfae1..7743dd540 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -182,17 +182,16 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { action_name = "app.refresh", child = refresh_accellabel }; + refresh_menuitem.add_css_class (Granite.STYLE_CLASS_MENUITEM); - var menu_popover_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - margin_bottom = 6, - margin_top = 6 - }; + var menu_popover_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); menu_popover_box.append (automatic_updates_button); menu_popover_box.append (refresh_menuitem); var menu_popover = new Gtk.Popover () { child = menu_popover_box }; + menu_popover.add_css_class (Granite.STYLE_CLASS_MENU); var menu_button = new Gtk.MenuButton () { child = new Gtk.Image.from_icon_name ("open-menu") { From d15b469ac6e3427fcf82853f3e5658314f73792a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 18:45:14 -0700 Subject: [PATCH 19/87] style fixes --- src/Application.vala | 20 ++++++++++---------- src/Views/Homepage.vala | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index dac9f0c3a..66f40fef0 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -160,19 +160,19 @@ public class AppCenter.App : Gtk.Application { var provider = new Gtk.CssProvider (); provider.load_from_resource ("io/elementary/appcenter/application.css"); - // Gtk.StyleContext.add_provider_for_screen ( - // Gdk.Screen.get_default (), - // provider, - // Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - // ); + Gtk.StyleContext.add_provider_for_display ( + Gdk.Display.get_default (), + provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); var fallback_provider = new Gtk.CssProvider (); fallback_provider.load_from_resource ("io/elementary/appcenter/fallback.css"); - // Gtk.StyleContext.add_provider_for_screen ( - // Gdk.Screen.get_default (), - // fallback_provider, - // Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK - // ); + Gtk.StyleContext.add_provider_for_display ( + Gdk.Display.get_default (), + fallback_provider, + Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK + ); var client = AppCenterCore.Client.get_default (); diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 0371b8dc8..8d5be623b 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -391,9 +391,9 @@ public class AppCenter.Homepage : Gtk.Box { }; content_area.attach (expanded_grid, 0, 0); - add_css_class (Granite.STYLE_CLASS_CARD); - add_css_class (Granite.STYLE_CLASS_ROUNDED); - add_css_class ("category"); + content_area.add_css_class (Granite.STYLE_CLASS_CARD); + content_area.add_css_class (Granite.STYLE_CLASS_ROUNDED); + content_area.add_css_class ("category"); content_area.get_style_context ().add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); child = content_area; @@ -443,7 +443,7 @@ public class AppCenter.Homepage : Gtk.Box { name_label.justify = Gtk.Justification.CENTER; } - add_css_class (style); + content_area.add_css_class (style); if (style == "accessibility") { name_label.label = category.name.up (); @@ -483,10 +483,8 @@ public class AppCenter.Homepage : Gtk.Box { icon_name = "applications-games-symbolic", pixel_size = 64 }; - - unowned var image_context = image.get_style_context (); - image_context.add_class (Granite.STYLE_CLASS_ACCENT); - image_context.add_class ("slate"); + image.add_css_class (Granite.STYLE_CLASS_ACCENT); + image.add_css_class ("slate"); var fun_label = new Gtk.Label (_("Fun &")) { halign = Gtk.Align.START @@ -498,11 +496,9 @@ public class AppCenter.Homepage : Gtk.Box { fun_label_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var games_label = new Gtk.Label (_("Games")); - - unowned var games_label_context = games_label.get_style_context (); - games_label_context.add_class (Granite.STYLE_CLASS_ACCENT); - games_label_context.add_class ("blue"); - games_label_context.add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + games_label.add_css_class (Granite.STYLE_CLASS_ACCENT); + games_label.add_css_class ("blue"); + games_label.get_style_context ().add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var grid = new Gtk.Grid () { column_spacing = 12, @@ -515,7 +511,7 @@ public class AppCenter.Homepage : Gtk.Box { content_area.attach (grid, 0, 0); - add_css_class ("games"); + content_area.add_css_class ("games"); } } } From e4aa9867b3441a16728d419c515662ab67904b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 18:50:28 -0700 Subject: [PATCH 20/87] fix number of packages on homepage --- src/Views/Homepage.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 8d5be623b..129f56237 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -307,9 +307,9 @@ public class AppCenter.Homepage : Gtk.Box { banner_revealer.reveal_child = true; foreach (var package in packages_by_release_date) { - // if (recently_updated_carousel.get_children ().length () >= MAX_PACKAGES_IN_CAROUSEL) { - // break; - // } + if (recently_updated_carousel.get_child_at_index (MAX_PACKAGES_IN_CAROUSEL - 1) != null) { + break; + } var installed = false; foreach (var origin_package in package.origin_packages) { From 971066c01bca05f15f2b49284db2a463fe3c7485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 18:53:17 -0700 Subject: [PATCH 21/87] Fix revealer clipping --- src/Widgets/AppContainers/AbstractAppContainer.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Widgets/AppContainers/AbstractAppContainer.vala b/src/Widgets/AppContainers/AbstractAppContainer.vala index 4bc85a36f..11aa59422 100644 --- a/src/Widgets/AppContainers/AbstractAppContainer.vala +++ b/src/Widgets/AppContainers/AbstractAppContainer.vala @@ -47,6 +47,7 @@ namespace AppCenter { action_button_revealer = new Gtk.Revealer () { child = action_button, + overflow = Gtk.Overflow.VISIBLE, transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT }; From fab127b3136c3ab550bbf5cd2f581ab888b6ac21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 27 Aug 2022 18:55:13 -0700 Subject: [PATCH 22/87] Fix share button style --- src/Views/AppInfoView.vala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 8a5671a3e..1eaa5e34f 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -747,7 +747,6 @@ namespace AppCenter.Views { var share_popover = new SharePopover (body, uri); var share_icon = new Gtk.Image.from_icon_name ("send-to-symbolic") { - pixel_size = 24, valign = Gtk.Align.CENTER }; @@ -759,13 +758,11 @@ namespace AppCenter.Views { var share_button = new Gtk.MenuButton () { child = share_box, + has_frame = false, direction = Gtk.ArrowType.UP, popover = share_popover }; - - unowned var share_button_context = share_button.get_style_context (); - share_button_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); - share_button_context.add_class (Granite.STYLE_CLASS_FLAT); + share_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); share_popover.link_copied.connect (() => { toast.send_notification (); From 94fb3ffb85403cd204889278e58e4e11f54093ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 28 Aug 2022 08:28:53 -0700 Subject: [PATCH 23/87] SharePopover: code style and DRY --- src/Widgets/SharePopover.vala | 120 ++++++++++++++-------------------- 1 file changed, 50 insertions(+), 70 deletions(-) diff --git a/src/Widgets/SharePopover.vala b/src/Widgets/SharePopover.vala index fc446a9a5..fda7739d9 100644 --- a/src/Widgets/SharePopover.vala +++ b/src/Widgets/SharePopover.vala @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017 elementary LLC. (https://elementary.io) + * Copyright 2017-2022 elementary, Inc. (https://elementary.io) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Authored by: Daniel ForĆ© + * Authored by: Danielle ForĆ© */ public class SharePopover : Gtk.Popover { @@ -31,41 +31,32 @@ public class SharePopover : Gtk.Popover { } construct { - var email_button = new Gtk.Button (); - - var mail_appinfo = AppInfo.get_default_for_uri_scheme ("mailto"); - if (mail_appinfo != null) { - email_button.image = new Gtk.Image.from_gicon (mail_appinfo.get_icon (), Gtk.IconSize.DND); - email_button.tooltip_text = mail_appinfo.get_display_name (); - email_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); - } - - var facebook_button = new Gtk.Button.from_icon_name ("online-account-facebook", Gtk.IconSize.DND); - facebook_button.tooltip_text = _("Facebook"); - facebook_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var facebook_button = new Gtk.Button.from_icon_name ("online-account-facebook", Gtk.IconSize.DND) { + tooltip_text = _("Facebook") + }; - var twitter_button = new Gtk.Button.from_icon_name ("online-account-twitter", Gtk.IconSize.DND); - twitter_button.tooltip_text = _("Twitter"); - twitter_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var twitter_button = new Gtk.Button.from_icon_name ("online-account-twitter", Gtk.IconSize.DND) { + tooltip_text = _("Twitter") + }; - var reddit_button = new Gtk.Button.from_icon_name ("online-account-reddit", Gtk.IconSize.DND); - reddit_button.tooltip_text = _("Reddit"); - reddit_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var reddit_button = new Gtk.Button.from_icon_name ("online-account-reddit", Gtk.IconSize.DND) { + tooltip_text = _("Reddit") + }; - var tumblr_button = new Gtk.Button.from_icon_name ("online-account-tumblr", Gtk.IconSize.DND); - tumblr_button.tooltip_text = _("Tumblr"); - tumblr_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var tumblr_button = new Gtk.Button.from_icon_name ("online-account-tumblr", Gtk.IconSize.DND) { + tooltip_text = _("Tumblr") + }; - var telegram_button = new Gtk.Button.from_icon_name ("online-account-telegram", Gtk.IconSize.DND); - telegram_button.tooltip_text = _("Telegram"); - telegram_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var telegram_button = new Gtk.Button.from_icon_name ("online-account-telegram", Gtk.IconSize.DND) { + tooltip_text = _("Telegram") + }; - var copy_link_button = new Gtk.Button.from_icon_name ("edit-copy-symbolic", Gtk.IconSize.LARGE_TOOLBAR); - copy_link_button.tooltip_text = _("Copy link"); - copy_link_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + var copy_link_button = new Gtk.Button.from_icon_name ("edit-copy-symbolic", Gtk.IconSize.LARGE_TOOLBAR) { + tooltip_text = _("Copy link") + }; var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH); - size_group.add_widget (email_button); + size_group.add_widget (facebook_button); size_group.add_widget (copy_link_button); var service_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { @@ -74,9 +65,21 @@ public class SharePopover : Gtk.Popover { margin_bottom = 6, margin_start = 6 }; + + var mail_appinfo = AppInfo.get_default_for_uri_scheme ("mailto"); if (mail_appinfo != null) { + var email_button = new Gtk.Button () { + image = new Gtk.Image.from_gicon (mail_appinfo.get_icon (), Gtk.IconSize.DND), + tooltip_text = mail_appinfo.get_display_name () + }; + service_box.add (email_button); + + email_button.clicked.connect (() => { + show_uri ("mailto:?subject=%s&body=%s".printf (body, uri)); + }); } + service_box.add (facebook_button); service_box.add (twitter_button); service_box.add (reddit_button); @@ -105,61 +108,38 @@ public class SharePopover : Gtk.Popover { link_copied (); - hide (); - }); - - email_button.clicked.connect (() => { - try { - AppInfo.launch_default_for_uri ("mailto:?body=%s %s".printf (body, uri), null); - } catch (Error e) { - warning ("%s", e.message); - } - hide (); + popdown (); }); facebook_button.clicked.connect (() => { - try { - AppInfo.launch_default_for_uri ("https://www.facebook.com/sharer/sharer.php?u=%s".printf (uri), null); - } catch (Error e) { - warning ("%s", e.message); - } - hide (); + show_uri ("https://www.facebook.com/sharer/sharer.php?u=%s".printf (uri)); }); twitter_button.clicked.connect (() => { - try { - AppInfo.launch_default_for_uri ("https://twitter.com/intent/tweet?text=%s&url=%s".printf (body, uri), null); - } catch (Error e) { - warning ("%s", e.message); - } - hide (); + show_uri ("https://twitter.com/intent/tweet?text=%s&url=%s".printf (body, uri)); }); reddit_button.clicked.connect (() => { - try { - AppInfo.launch_default_for_uri ("http://www.reddit.com/submit?title=%s&url=%s".printf (body, uri), null); - } catch (Error e) { - warning ("%s", e.message); - } - hide (); + show_uri ("http://www.reddit.com/submit?title=%s&url=%s".printf (body, uri)); }); tumblr_button.clicked.connect (() => { - try { - AppInfo.launch_default_for_uri ("https://www.tumblr.com/share/link?url=%s".printf (uri), null); - } catch (Error e) { - warning ("%s", e.message); - } - hide (); + show_uri ("https://www.tumblr.com/share/link?url=%s".printf (uri)); }); telegram_button.clicked.connect (() => { - try { - AppInfo.launch_default_for_uri ("https://t.me/share/url?url=%s".printf (uri), null); - } catch (Error e) { - warning ("%s", e.message); - } - hide (); + show_uri ("https://t.me/share/url?url=%s".printf (uri)); }); } + + private void show_uri (string uri) { + var main_window = ((Gtk.Application) Application.get_default ()).active_window; + try { + Gtk.show_uri_on_window (main_window, uri, Gdk.CURRENT_TIME); + } catch (Error e) { + critical (e.message); + } + + popdown (); + } } From 6c1a3699fdbc603c70a2d2e7d7f2e501825409ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 29 Aug 2022 09:05:11 -0700 Subject: [PATCH 24/87] Rewrite state save/restore --- data/io.elementary.appcenter.gschema.xml | 13 +++++++--- src/Application.vala | 25 ++++++++++++------ src/MainWindow.vala | 33 ------------------------ 3 files changed, 26 insertions(+), 45 deletions(-) diff --git a/data/io.elementary.appcenter.gschema.xml b/data/io.elementary.appcenter.gschema.xml index 10e63dc56..63458d48d 100644 --- a/data/io.elementary.appcenter.gschema.xml +++ b/data/io.elementary.appcenter.gschema.xml @@ -6,10 +6,15 @@ Whether the window was maximized on last run Whether the window was maximized on last run - - (1100, 660) - Most recent window size - Most recent window size (width, height) + + 660 + Most recent window height + Most recent window height + + + 1024 + Most recent window width + Most recent window width false diff --git a/src/Application.vala b/src/Application.vala index 66f40fef0..08aead957 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -220,15 +220,24 @@ public class AppCenter.App : Gtk.Application { // }); add_window (main_window); - main_window.present (); - if (show_updates) { - main_window.go_to_installed (); - } - } else { - if (show_updates) { - main_window.go_to_installed (); - main_window.present (); + + /* + * This is very finicky. Bind size after present else set_titlebar gives us bad sizes + * Set maximize after height/width else window is min size on unmaximize + * Bind maximize as SET else get get bad sizes + */ + settings.bind ("window-height", main_window, "default-height", SettingsBindFlags.DEFAULT); + settings.bind ("window-width", main_window, "default-width", SettingsBindFlags.DEFAULT); + + if (settings.get_boolean ("window-maximized")) { + main_window.maximize (); } + + settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); + } + + if (show_updates) { + main_window.go_to_installed (); } main_window.present (); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 7743dd540..969304853 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -31,8 +31,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { private AppCenterCore.Package? last_installed_package; private AppCenterCore.Package? selected_package; - private uint configure_id; - private bool mimetype; private const int VALID_QUERY_LENGTH = 3; @@ -247,8 +245,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { child = box; set_titlebar (headerbar); - int window_width, window_height; - App.settings.get ("window-size", "(ii)", out window_width, out window_height); App.settings.bind ( "automatic-updates", automatic_updates_button, @@ -256,12 +252,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { SettingsBindFlags.DEFAULT ); - // resize (window_width, window_height); - - if (App.settings.get_boolean ("window-maximized")) { - maximize (); - } - automatic_updates_button.notify["active"].connect (() => { if (automatic_updates_button.active) { AppCenterCore.Client.get_default ().update_cache.begin (true, AppCenterCore.Client.CacheUpdateType.FLATPAK); @@ -318,29 +308,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { }); } - // public override bool configure_event (Gdk.EventConfigure event) { - // if (configure_id == 0) { - // /* Avoid spamming the settings */ - // configure_id = Timeout.add (200, () => { - // configure_id = 0; - - // if (is_maximized) { - // App.settings.set_boolean ("window-maximized", true); - // } else { - // App.settings.set_boolean ("window-maximized", false); - - // int width, height; - // get_size (out width, out height); - // App.settings.set ("window-size", "(ii)", width, height); - // } - - // return GLib.Source.REMOVE; - // }); - // } - - // return base.configure_event (event); - // } - // public override bool delete_event (Gdk.EventAny event) { // if (working) { // hide (); From 5787b6287d9fee449ac3849465e76e677494d954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 29 Aug 2022 09:51:39 -0700 Subject: [PATCH 25/87] remove unreachable catch --- src/Widgets/SharePopover.vala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Widgets/SharePopover.vala b/src/Widgets/SharePopover.vala index 30713b304..9743a880b 100644 --- a/src/Widgets/SharePopover.vala +++ b/src/Widgets/SharePopover.vala @@ -138,12 +138,7 @@ public class SharePopover : Gtk.Popover { private void show_uri (string uri) { var main_window = ((Gtk.Application) Application.get_default ()).active_window; - try { - Gtk.show_uri (main_window, uri, Gdk.CURRENT_TIME); - } catch (Error e) { - critical (e.message); - } - + Gtk.show_uri (main_window, uri, Gdk.CURRENT_TIME); popdown (); } } From d652e329642989dc6031696b8b0c10e3c10c9823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 09:42:19 -0700 Subject: [PATCH 26/87] Remove unreachable catch --- src/Views/AppInfoView.vala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 1eaa5e34f..727e52eb6 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1175,11 +1175,7 @@ namespace AppCenter.Views { append (button); button.clicked.connect (() => { - try { - Gtk.show_uri (((Gtk.Application) Application.get_default ()).active_window, uri, Gdk.CURRENT_TIME); - } catch (Error e) { - critical (e.message); - } + Gtk.show_uri (((Gtk.Application) Application.get_default ()).active_window, uri, Gdk.CURRENT_TIME); }); } else { append (box); From 452f8cab4550618c1ad80f4899f6bf6449f6c53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 13:01:33 -0700 Subject: [PATCH 27/87] MainWindow: search entry grab focus --- src/MainWindow.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 969304853..ce25589b8 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -40,7 +40,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { public MainWindow (Gtk.Application app) { Object (application: app); - // search_entry.grab_focus_without_selecting (); + search_entry.grab_focus (); var go_back = new SimpleAction ("go-back", null); go_back.activate.connect (view_return); @@ -528,7 +528,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { } if (sensitive) { - // search_entry.grab_focus_without_selecting (); + search_entry.grab_focus (); } } From 0074161a62f04be92910e25ccc134145981d4d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 13:05:13 -0700 Subject: [PATCH 28/87] Add search entry key controller --- src/MainWindow.vala | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index ce25589b8..f6f32726d 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -55,20 +55,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { search_entry.search_changed.connect (() => trigger_search ()); - // search_entry.key_press_event.connect ((event) => { - // if (event.keyval == Gdk.Key.Escape) { - // search_entry.text = ""; - // return true; - // } - - // if (event.keyval == Gdk.Key.Down) { - // search_entry.move_focus (Gtk.DirectionType.TAB_FORWARD); - // return true; - // } - - // return false; - // }); - return_button.clicked.connect (view_return); unowned var aggregator = AppCenterCore.BackendAggregator.get_default (); @@ -155,11 +141,14 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT }; + var search_entry_eventcontrollerkey = new Gtk.EventControllerKey (); + search_entry = new Gtk.SearchEntry () { hexpand = true, placeholder_text = _("Search Apps"), valign = Gtk.Align.CENTER }; + search_entry.add_controller (search_entry_eventcontrollerkey); var search_clamp = new Adw.Clamp () { child = search_entry @@ -306,6 +295,20 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { update_navigation (); } }); + + + search_entry_eventcontrollerkey.key_released.connect ((keyval, keycode, state) => { + switch (keyval) { + case Gdk.Key.Down: + search_entry.move_focus (Gtk.DirectionType.TAB_FORWARD); + break; + case Gdk.Key.Escape: + search_entry.text = ""; + break; + default: + break; + } + }); } // public override bool delete_event (Gdk.EventAny event) { From 6a7f375df73580bc97666e783d16ab507a2387de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 13:10:08 -0700 Subject: [PATCH 29/87] MainWindow: set updates revealer can_target false --- src/MainWindow.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index f6f32726d..2bcf62126 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -123,6 +123,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { badge_context.add_provider (badge_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); updates_badge_revealer = new Gtk.Revealer () { + can_target = false, child = updates_badge, halign = Gtk.Align.END, valign = Gtk.Align.START, From 62d0e2e64d734f01c2c5cb20a9a52496b64e15ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 13:11:12 -0700 Subject: [PATCH 30/87] remove dead eventbox signal --- src/MainWindow.vala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 2bcf62126..8ba7c4a61 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -265,10 +265,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { go_to_installed (); }); - // eventbox_badge.button_release_event.connect (() => { - // go_to_installed (); - // }); - homepage.show_category.connect ((category) => { show_category (category); }); From 20ad6ff76948026559c6942f7576763c6b0610f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 13:35:45 -0700 Subject: [PATCH 31/87] StripeDialog: set_default_widget --- src/Dialogs/StripeDialog.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index 94244c434..edab9ce77 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -236,9 +236,10 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { pay_button = (Gtk.Button) add_button (_("Pay $%d.00").printf (amount), Gtk.ResponseType.APPLY); pay_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); - // pay_button.has_default = true; pay_button.sensitive = false; + set_default_widget (pay_button); + response.connect (on_response); bind_property ("amount", custom_amount, "value", BindingFlags.BIDIRECTIONAL); From e79b5f5a7e575158c31650f182b91edded951ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 14:26:20 -0700 Subject: [PATCH 32/87] MainWindow: connect to close request instead of delete --- src/MainWindow.vala | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8ba7c4a61..e54b164d2 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -277,9 +277,24 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { show_package (package); }); - // destroy.connect (() => { - // installed_view.clear (); - // }); + close_request.connect (() => { + installed_view.clear (); + + if (working) { + hide (); + + notify["working"].connect (() => { + if (!visible && !working) { + destroy (); + } + }); + + AppCenterCore.Client.get_default ().cancel_updates (false); //Timeouts keep running + return true; + } + + return false; + }); leaflet.notify["visible-child"].connect (() => { if (!leaflet.child_transition_running) { @@ -308,23 +323,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { }); } - // public override bool delete_event (Gdk.EventAny event) { - // if (working) { - // hide (); - - // notify["working"].connect (() => { - // if (!visible && !working) { - // destroy (); - // } - // }); - - // AppCenterCore.Client.get_default ().cancel_updates (false); //Timeouts keep running - // return true; - // } - - // return false; - // } - public void show_update_badge (uint updates_number) { if (updates_number == 0U) { updates_badge_revealer.reveal_child = false; From 345295f57e30d492daa6c6c71e7c72536a63bca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 14:32:05 -0700 Subject: [PATCH 33/87] other direction --- src/MainWindow.vala | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index e54b164d2..3e53ca78e 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -277,25 +277,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { show_package (package); }); - close_request.connect (() => { - installed_view.clear (); - - if (working) { - hide (); - - notify["working"].connect (() => { - if (!visible && !working) { - destroy (); - } - }); - - AppCenterCore.Client.get_default ().cancel_updates (false); //Timeouts keep running - return true; - } - - return false; - }); - leaflet.notify["visible-child"].connect (() => { if (!leaflet.child_transition_running) { update_navigation (); @@ -323,6 +304,25 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { }); } + public override bool close_request () { + installed_view.clear (); + + if (working) { + hide (); + + notify["working"].connect (() => { + if (!visible && !working) { + destroy (); + } + }); + + AppCenterCore.Client.get_default ().cancel_updates (false); //Timeouts keep running + return true; + } + + return false; + } + public void show_update_badge (uint updates_number) { if (updates_number == 0U) { updates_badge_revealer.reveal_child = false; From 71b9d52087e77f9910bc46a059cbe4ecb9dfac3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 30 Aug 2022 14:41:16 -0700 Subject: [PATCH 34/87] MainWindow: look for installed view by name --- src/MainWindow.vala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 3e53ca78e..a79e47670 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -201,7 +201,9 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { headerbar.pack_end (spinner); var homepage = new Homepage (); - installed_view = new Views.AppListUpdateView (); + installed_view = new Views.AppListUpdateView () { + name = "installed-view" + }; leaflet = new Adw.Leaflet () { can_navigate_back = true, @@ -425,9 +427,9 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { } public void go_to_installed () { - // if (leaflet.get_children ().find (installed_view) == null) { + if (leaflet.get_child_by_name ("installed-view") == null) { leaflet.append (installed_view); - // } + } leaflet.visible_child = installed_view; } From 908640497fb6da390c28e13f4328190eca2aef0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 11:42:33 -0700 Subject: [PATCH 35/87] Application: replace destroy connect with close_request --- src/Application.vala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 08aead957..75ccc11fa 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -355,9 +355,10 @@ public class AppCenter.App : Gtk.Application { update_fail_dialog = new UpdateFailDialog (format_error_message (error.message), cache_update_type); update_fail_dialog.transient_for = main_window; - // update_fail_dialog.destroy.connect (() => { - // update_fail_dialog = null; - // }); + update_fail_dialog.close_request.connect (() => { + update_fail_dialog = null; + return Gdk.EVENT_PROPAGATE; + }); } update_fail_dialog.present (); From b5734335a028eb5aad005dd820e4bac2a604c66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 11:47:26 -0700 Subject: [PATCH 36/87] Application: fix focus checking for installed toast --- src/Application.vala | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 75ccc11fa..d647a4338 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -304,12 +304,9 @@ public class AppCenter.App : Gtk.Application { if (error == null) { if (package.get_can_launch ()) { // Check if window is focused - if (main_window != null) { - // if (win != null && (win.get_state () & Gdk.WindowState.FOCUSED) != 0) { - main_window.send_installed_toast (package); - - break; - // } + if (active_window != null && active_window.is_active) { + ((MainWindow) active_window).send_installed_toast (package); + break; } var notification = new Notification (_("The app has been installed")); From 54ec038cff2e9ad887bb5dc438f6e6bdc938e7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 12:22:32 -0700 Subject: [PATCH 37/87] Homepage: theoretically add focus controller --- src/Views/Homepage.vala | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 3e4bcfe14..45c42d162 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -40,9 +40,12 @@ public class AppCenter.Homepage : Gtk.Box { hexpand = true; vexpand = true; + var banner_focus_controller = new Gtk.EventControllerFocus (); + banner_carousel = new Adw.Carousel () { allow_long_swipes = true }; + banner_carousel.add_controller (banner_focus_controller); var banner_dots = new Adw.CarouselIndicatorDots () { carousel = banner_carousel @@ -237,23 +240,26 @@ public class AppCenter.Homepage : Gtk.Box { AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { Idle.add (() => { // Clear the cached categories when the AppStream pool is updated - // foreach (unowned var child in category_flow.get_children ()) { - // var item = (AbstractCategoryCard) child; - // var category_components = item.category.get_components (); - // category_components.remove_range (0, category_components.length); - // } + var child = category_flow.get_first_child (); + while (child != null) { + var item = (AbstractCategoryCard) child; + var category_components = item.category.get_components (); + category_components.remove_range (0, category_components.length); + + child = child.get_next_sibling (); + } return GLib.Source.REMOVE; }); }); - // banner_event_box.enter_notify_event.connect (() => { - // banner_timeout_stop (); - // }); + banner_focus_controller.enter.connect (() => { + banner_timeout_stop (); + }); - // banner_event_box.leave_notify_event.connect (() => { - // banner_timeout_start (); - // }); + banner_focus_controller.leave.connect (() => { + banner_timeout_start (); + }); recently_updated_carousel.child_activated.connect ((child) => { var package_row_grid = (AppCenter.Widgets.ListPackageRowGrid) child.get_child (); @@ -348,7 +354,7 @@ public class AppCenter.Homepage : Gtk.Box { new_index = 0; } - // banner_carousel.switch_child (new_index, Granite.TRANSITION_DURATION_OPEN); + banner_carousel.scroll_to (banner_carousel.get_nth_page (new_index), true); return Source.CONTINUE; }); From 11ace14d40100fa264027e6dce18266f13631ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 13:16:55 -0700 Subject: [PATCH 38/87] Entry fuckery --- src/Dialogs/StripeDialog.vala | 24 ++++++++++++++---------- src/Widgets/CardNumberEntry.vala | 6 +----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index 0067ab90a..2454ea97d 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -175,6 +175,8 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }; card_number_entry.bind_property ("has-focus", card_number_entry, "visibility"); + var expiration_focus_controller = new Gtk.EventControllerFocus (); + card_expiration_entry = new Granite.ValidatedEntry.from_regex (expiration_regex) { activates_default = true, hexpand = true, @@ -183,6 +185,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { /// TRANSLATORS: Don't change the order, only transliterate placeholder_text = _("MM / YY") }; + card_expiration_entry.add_controller (expiration_focus_controller); card_cvc_entry = new Granite.ValidatedEntry.from_regex (cvc_regex) { activates_default = true, @@ -270,7 +273,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }); email_entry.changed.connect (() => { - email_entry.text = email_entry.text.replace (" ", "").down (); + // email_entry.text = email_entry.text.replace (" ", "").down (); is_payment_sensitive (); }); @@ -280,7 +283,8 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }); card_expiration_entry.changed.connect (() => { - card_expiration_entry.text = card_expiration_entry.text.replace (" ", ""); + // card_expiration_entry.text = card_expiration_entry.text.replace (" ", ""); + if (card_expiration_entry.text.length < 4) { card_expiration_entry.is_valid = false; } @@ -288,16 +292,16 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { is_payment_sensitive (); }); - // card_expiration_entry.focus_out_event.connect (() => { - // var expiration_text = card_expiration_entry.text; - // if (!("/" in expiration_text) && expiration_text.char_count () > 2) { - // int position = 2; - // card_expiration_entry.insert_text ("/", 1, ref position); - // } - // }); + expiration_focus_controller.leave.connect (() => { + var expiration_text = card_expiration_entry.text; + if (!("/" in expiration_text) && expiration_text.char_count () > 2) { + int position = 2; + card_expiration_entry.insert_text ("/", 1, ref position); + } + }); card_cvc_entry.changed.connect (() => { - card_cvc_entry.text = card_cvc_entry.text.replace (" ", ""); + // card_cvc_entry.text = card_cvc_entry.text.replace (" ", ""); is_payment_sensitive (); }); } diff --git a/src/Widgets/CardNumberEntry.vala b/src/Widgets/CardNumberEntry.vala index 3a4936f1c..0f11ed982 100644 --- a/src/Widgets/CardNumberEntry.vala +++ b/src/Widgets/CardNumberEntry.vala @@ -32,7 +32,6 @@ public class AppCenter.Widgets.CardNumberEntry : Gtk.Entry { } private CardType card_type = CardType.UNKNOWN; - private uint timeout = 0; private bool insertion = true; construct { @@ -49,9 +48,6 @@ public class AppCenter.Widgets.CardNumberEntry : Gtk.Entry { }); changed.connect (() => { - if (timeout > 0) { - GLib.Source.remove (timeout); - } update_number (); detect_card (); change_card_icon (); @@ -66,7 +62,7 @@ public class AppCenter.Widgets.CardNumberEntry : Gtk.Entry { } var end_offset = (text.char_count () - 1) - cursor_position; - text = builder.str; + // text = builder.str; var new_offset = (text.char_count () - 1) - cursor_position; if (end_offset != new_offset) { Idle.add (() => { From 988007dc58e122310dfd6397fc34c93d53447f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 13:30:12 -0700 Subject: [PATCH 39/87] Force icon back into spinbutton --- src/Dialogs/StripeDialog.vala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index 2454ea97d..b0c21b989 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -128,6 +128,12 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { value = amount }; + var custom_image = new Gtk.Image.from_icon_name ("currency-dollar-symbolic") { + margin_start = 3, + margin_end = 3 + }; + custom_image.insert_before (custom_amount, custom_amount.get_first_child ()); + var selection_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); selection_box.append (custom_amount); selection_box.append (or_label); From 810db19b3e6bdac96f9efc566e3325ececfeabf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 13:37:34 -0700 Subject: [PATCH 40/87] Leave margin to system stylesheet --- src/Dialogs/StripeDialog.vala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index b0c21b989..e2cd39391 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -128,10 +128,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { value = amount }; - var custom_image = new Gtk.Image.from_icon_name ("currency-dollar-symbolic") { - margin_start = 3, - margin_end = 3 - }; + var custom_image = new Gtk.Image.from_icon_name ("currency-dollar-symbolic"); custom_image.insert_before (custom_amount, custom_amount.get_first_child ()); var selection_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); From 4257577774a03c8b11ea8e87aaece90cf7ee28af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 13:49:31 -0700 Subject: [PATCH 41/87] Motion controllers --- src/Views/AppInfoView.vala | 44 +++++++++++--------------------------- src/Views/Homepage.vala | 2 +- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 727e52eb6..c7b50ddf7 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -378,43 +378,25 @@ namespace AppCenter.Views { transition_type = Gtk.RevealerTransitionType.CROSSFADE }; + var screenshot_focus_controller = new Gtk.EventControllerMotion (); + screenshot_overlay = new Gtk.Overlay () { child = app_screenshots }; screenshot_overlay.add_overlay (screenshot_arrow_revealer_p); screenshot_overlay.add_overlay (screenshot_arrow_revealer_n); + screenshot_overlay.add_controller (screenshot_focus_controller); + - // screenshot_overlay.enter_notify_event.connect (() => { - // screenshot_arrow_revealer_n.reveal_child = true; - // screenshot_arrow_revealer_p.reveal_child = true; - // return false; - // }); - - // screenshot_overlay.leave_notify_event.connect ((event) => { - // // Prevent hiding prev/next button when they're marked as insensitive - // if (event.mode != Gdk.CrossingMode.STATE_CHANGED) { - // screenshot_arrow_revealer_n.reveal_child = false; - // screenshot_arrow_revealer_p.reveal_child = false; - // } - - // return false; - // }); - - // app_screenshots.enter_notify_event.connect (() => { - // screenshot_arrow_revealer_n.reveal_child = true; - // screenshot_arrow_revealer_p.reveal_child = true; - // return false; - // }); - - // app_screenshots.leave_notify_event.connect ((event) => { - // // Prevent hiding prev/next button when they're marked as insensitive - // if (event.mode != Gdk.CrossingMode.STATE_CHANGED) { - // screenshot_arrow_revealer_n.reveal_child = false; - // screenshot_arrow_revealer_p.reveal_child = false; - // } - - // return false; - // }); + screenshot_focus_controller.enter.connect (() => { + screenshot_arrow_revealer_n.reveal_child = true; + screenshot_arrow_revealer_p.reveal_child = true; + }); + + screenshot_focus_controller.leave.connect (() => { + screenshot_arrow_revealer_n.reveal_child = false; + screenshot_arrow_revealer_p.reveal_child = false; + }); screenshot_switcher = new Adw.CarouselIndicatorDots () { carousel = app_screenshots diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 45c42d162..1dc1f3a12 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -40,7 +40,7 @@ public class AppCenter.Homepage : Gtk.Box { hexpand = true; vexpand = true; - var banner_focus_controller = new Gtk.EventControllerFocus (); + var banner_focus_controller = new Gtk.EventControllerMotion (); banner_carousel = new Adw.Carousel () { allow_long_swipes = true From e34564da0bcd68a8025c4e5c0a8af9f1224e9f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 13:52:14 -0700 Subject: [PATCH 42/87] Rename --- src/Views/AppInfoView.vala | 8 ++++---- src/Views/Homepage.vala | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index c7b50ddf7..811bf909d 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -378,22 +378,22 @@ namespace AppCenter.Views { transition_type = Gtk.RevealerTransitionType.CROSSFADE }; - var screenshot_focus_controller = new Gtk.EventControllerMotion (); + var screenshot_motion_controller = new Gtk.EventControllerMotion (); screenshot_overlay = new Gtk.Overlay () { child = app_screenshots }; screenshot_overlay.add_overlay (screenshot_arrow_revealer_p); screenshot_overlay.add_overlay (screenshot_arrow_revealer_n); - screenshot_overlay.add_controller (screenshot_focus_controller); + screenshot_overlay.add_controller (screenshot_motion_controller); - screenshot_focus_controller.enter.connect (() => { + screenshot_motion_controller.enter.connect (() => { screenshot_arrow_revealer_n.reveal_child = true; screenshot_arrow_revealer_p.reveal_child = true; }); - screenshot_focus_controller.leave.connect (() => { + screenshot_motion_controller.leave.connect (() => { screenshot_arrow_revealer_n.reveal_child = false; screenshot_arrow_revealer_p.reveal_child = false; }); diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 1dc1f3a12..09dd13051 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -40,12 +40,12 @@ public class AppCenter.Homepage : Gtk.Box { hexpand = true; vexpand = true; - var banner_focus_controller = new Gtk.EventControllerMotion (); + var banner_motion_controller = new Gtk.EventControllerMotion (); banner_carousel = new Adw.Carousel () { allow_long_swipes = true }; - banner_carousel.add_controller (banner_focus_controller); + banner_carousel.add_controller (banner_motion_controller); var banner_dots = new Adw.CarouselIndicatorDots () { carousel = banner_carousel @@ -253,11 +253,11 @@ public class AppCenter.Homepage : Gtk.Box { }); }); - banner_focus_controller.enter.connect (() => { + banner_motion_controller.enter.connect (() => { banner_timeout_stop (); }); - banner_focus_controller.leave.connect (() => { + banner_motion_controller.leave.connect (() => { banner_timeout_start (); }); From f36129fee82307cce834ac297264dee42c00ec58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 14:00:09 -0700 Subject: [PATCH 43/87] Don't show arrows for single screenshot --- src/Views/AppInfoView.vala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 811bf909d..fd45293ba 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -337,7 +337,8 @@ namespace AppCenter.Views { }; screenshot_previous = new ArrowButton ("go-previous-symbolic") { - sensitive = false + sensitive = false, + visible = false }; screenshot_previous.clicked.connect (() => { var index = (int) app_screenshots.position; @@ -346,7 +347,9 @@ namespace AppCenter.Views { } }); - screenshot_next = new ArrowButton ("go-next-symbolic"); + screenshot_next = new ArrowButton ("go-next-symbolic") { + visible = false + }; screenshot_next.clicked.connect (() => { var index = (int) app_screenshots.position; if (index < app_screenshots.n_pages - 1) { @@ -993,6 +996,11 @@ namespace AppCenter.Views { if (app_screenshots.n_pages > 0) { screenshot_stack.visible_child = screenshot_overlay; stack_context.remove_class ("loading"); + + if (app_screenshots.n_pages > 1) { + screenshot_next.visible = true; + screenshot_previous.visible = true; + } } else { screenshot_stack.visible_child = screenshot_not_found_clamp; stack_context.remove_class ("loading"); From 95ff0b331353fc7a8f59a7f46d1b795d0f4c3b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 14:03:34 -0700 Subject: [PATCH 44/87] Remove comment --- src/Views/AppInfoView.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index fd45293ba..8c9488c68 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1198,7 +1198,7 @@ namespace AppCenter.Views { package.normalized_component_id, package.get_payments_key () ); - // stripe.transient_for = ((Gtk.Application) Application.get_default ()).active_window; + stripe.transient_for = ((Gtk.Application) Application.get_default ()).active_window; stripe.download_requested.connect (() => { if (stripe.amount != 0) { From 4056543bece131a3796fcdbcaaf1a29cab7c3540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 14:11:50 -0700 Subject: [PATCH 45/87] Code style --- src/Widgets/AbstractAppList.vala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Widgets/AbstractAppList.vala b/src/Widgets/AbstractAppList.vala index 774b0eb34..0cbb44a08 100644 --- a/src/Widgets/AbstractAppList.vala +++ b/src/Widgets/AbstractAppList.vala @@ -57,11 +57,9 @@ public abstract class AppCenter.AbstractAppList : Gtk.Box { unowned var row = list_box.get_first_child (); while (row != null) { - if (row is Widgets.PackageRow) { - if (((Widgets.PackageRow) row).get_package () == package) { - row.destroy (); - break; - } + if (row is Widgets.PackageRow && ((Widgets.PackageRow) row).get_package () == package) { + row.destroy (); + break; } row = row.get_next_sibling (); From 5d7b162a70c8f6f66bd16e74909a5332afae335f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 31 Aug 2022 14:24:49 -0700 Subject: [PATCH 46/87] Always remove leaflet child --- src/MainWindow.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index a79e47670..b47272b07 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -418,9 +418,9 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { while (leaflet.get_adjacent_child (Adw.NavigationDirection.FORWARD) != null) { var next_child = leaflet.get_adjacent_child (Adw.NavigationDirection.FORWARD); - if (next_child is AppCenter.Views.AppListUpdateView) { - leaflet.remove (next_child); - } else { + leaflet.remove (next_child); + + if (!(next_child is AppCenter.Views.AppListUpdateView)) { next_child.destroy (); } } From 4e59eee7d4eaacb28d952bc4bc56a1bdc862ab7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 1 Sep 2022 15:44:23 -0700 Subject: [PATCH 47/87] MainWindow: Use large-icons class --- src/MainWindow.vala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b47272b07..d21136365 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -111,7 +111,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { return_button.add_css_class (Granite.STYLE_CLASS_BACK_BUTTON); var updates_button = new Gtk.Button.from_icon_name ("software-update-available"); - ((Gtk.Image) updates_button.child).pixel_size = 24; + updates_button.add_css_class ("large-icons"); var badge_provider = new Gtk.CssProvider (); badge_provider.load_from_resource ("io/elementary/appcenter/badge.css"); @@ -182,14 +182,12 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { menu_popover.add_css_class (Granite.STYLE_CLASS_MENU); var menu_button = new Gtk.MenuButton () { - child = new Gtk.Image.from_icon_name ("open-menu") { - pixel_size = 24 - }, - has_frame = false, + icon_name = "open-menu", popover = menu_popover, tooltip_text = _("Settings"), valign = Gtk.Align.CENTER }; + menu_button.add_css_class ("large-icons"); var headerbar = new Gtk.HeaderBar () { show_title_buttons = true, From 2b38d7971060a127aeab4fcac203028c2f3c0f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 1 Sep 2022 16:06:11 -0700 Subject: [PATCH 48/87] Fix style issues with category cards --- data/styles/categories.css | 42 +++++++++++++++++++------------------- src/Views/Homepage.vala | 10 ++++----- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/data/styles/categories.css b/data/styles/categories.css index 2dfee022d..334ccbec7 100644 --- a/data/styles/categories.css +++ b/data/styles/categories.css @@ -176,27 +176,27 @@ background-image: linear-gradient( to right, - transparent 0.47em, - alpha(white, 0.05) 0.47em, - alpha(white, 0.05) 0.5em, - transparent 0.5em + transparent 4px, + alpha(white, 0.05) 4px, + alpha(white, 0.05) 5px, + transparent 5px ), linear-gradient( to bottom, - transparent 0.47em, - alpha(white, 0.05) 0.47em, - alpha(white, 0.05) 0.5em, - transparent 0.5em + transparent 4px, + alpha(white, 0.05) 4px, + alpha(white, 0.05) 5px, + transparent 5px ), linear-gradient( to right, - transparent 0.97em, - alpha(white, 0.125) 0.97em + transparent 9px, + alpha(white, 0.125) 9px ), linear-gradient( to bottom, - transparent 0.97em, - alpha(white, 0.125) 0.97em + transparent 9px, + alpha(white, 0.125) 9px ), linear-gradient( to bottom right, @@ -206,15 +206,15 @@ background-position: center center; background-repeat: repeat; background-size: - 1em 1em, - 1em 1em, - 1em 1em, - 1em 1em, + 9px 9px, + 9px 9px, + 9px 9px, + 9px 9px, cover; - border-color: alpha(@GRAPE_900, 0.7); - color: white; - font-family: "Lobster"; - text-shadow: 0 2px 0 alpha(@GRAPE_900, 0.5); + border-color: alpha(@GRAPE_900, 0.7); + color: white; + font-family: "Lobster"; + text-shadow: 0 2px 0 alpha(@GRAPE_900, 0.5); } .category.education { @@ -601,7 +601,7 @@ radial-gradient( circle, alpha(@STRAWBERRY_900, 0) 65%, - alpha(shade(@STRAWBERRY_900, 0.6), 0.35) 4% + alpha(shade(@STRAWBERRY_900, 0.6), 0.35) 66% ), linear-gradient( to bottom, diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 09dd13051..d670d65f1 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -435,20 +435,20 @@ public class AppCenter.Homepage : Gtk.Box { margin_bottom = 32, margin_start = 16 }; - box.append (display_image); - box.append (name_label); - - content_area.attach (box, 0, 0); if (category.icon != "") { display_image.icon_name = category.icon; + box.append (display_image); + name_label.xalign = 0; name_label.halign = Gtk.Align.START; } else { - display_image.destroy (); name_label.justify = Gtk.Justification.CENTER; } + box.append (name_label); + + content_area.attach (box, 0, 0); content_area.add_css_class (style); if (style == "accessibility") { From bb3f05c2e116e487f9db4a64f9d3875d9d9728f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 10:15:18 -0700 Subject: [PATCH 49/87] AppInfoView: use Gtk.Picture --- src/Views/AppInfoView.vala | 61 ++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 8c9488c68..58c57f81b 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1015,48 +1015,39 @@ namespace AppCenter.Views { // We need to first download the screenshot locally so that it doesn't freeze the interface. private void load_screenshot (string? caption, string path) { - var scale_factor = get_scale_factor (); - try { - var pixbuf = new Gdk.Pixbuf.from_file_at_scale (path, MAX_WIDTH * scale_factor, 600 * scale_factor, true); - - var image = new Gtk.Image () { - height_request = 500, - icon_name = "image-x-generic", - vexpand = true - }; - image.gicon = pixbuf; + var image = new Gtk.Picture.for_filename (path) { + height_request = 500, + vexpand = true + }; - var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - halign = Gtk.Align.CENTER - }; + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { + halign = Gtk.Align.CENTER + }; - unowned var box_context = box.get_style_context (); - box_context.add_class ("screenshot"); - box_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - box_context.add_provider (screenshot_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + unowned var box_context = box.get_style_context (); + box_context.add_class ("screenshot"); + box_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + box_context.add_provider (screenshot_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - if (caption != null) { - var label = new Gtk.Label (caption) { - max_width_chars = 50, - wrap = true - }; + if (caption != null) { + var label = new Gtk.Label (caption) { + max_width_chars = 50, + wrap = true + }; - unowned var label_context = label.get_style_context (); - label_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - label_context.add_provider (screenshot_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + unowned var label_context = label.get_style_context (); + label_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + label_context.add_provider (screenshot_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - box.append (label); - } + box.append (label); + } - box.append (image); + box.append (image); - Idle.add (() => { - app_screenshots.append (box); - return GLib.Source.REMOVE; - }); - } catch (Error e) { - critical (e.message); - } + Idle.add (() => { + app_screenshots.append (box); + return GLib.Source.REMOVE; + }); } private void parse_license (string project_license, out string license_copy, out string license_url) { From 5c80eabe0b45c7930fcd4e12141a5b0126e0b390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 10:26:06 -0700 Subject: [PATCH 50/87] CategoryView: expand spinner --- src/Views/CategoryView.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Views/CategoryView.vala b/src/Views/CategoryView.vala index dd27e2b08..1962ecaf1 100644 --- a/src/Views/CategoryView.vala +++ b/src/Views/CategoryView.vala @@ -58,7 +58,8 @@ public class AppCenter.CategoryView : Gtk.Box { }; var spinner = new Gtk.Spinner () { - halign = Gtk.Align.CENTER + halign = Gtk.Align.CENTER, + hexpand = true }; spinner.start (); From d562b0c0b53d12a59f36fdea463696f4ac0fb3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 11:12:48 -0700 Subject: [PATCH 51/87] We have a problem with remote icons --- src/Core/Package.vala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Core/Package.vala b/src/Core/Package.vala index d02ec3edf..efe02f533 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -678,9 +678,8 @@ public class AppCenterCore.Package : Object { uint current_scale = 0; uint pixel_size = size * scale_factor; - weak GenericArray icons = component.get_icons (); - for (int i = 0; i < icons.length; i++) { - weak AppStream.Icon _icon = icons[i]; + unowned var icons = component.get_icons (); + foreach (unowned var _icon in icons) { switch (_icon.get_kind ()) { case AppStream.IconKind.STOCK: unowned string icon_name = _icon.get_name (); @@ -710,9 +709,9 @@ public class AppCenterCore.Package : Object { bool has_better_dpi = (icon_width == current_size && current_scale < icon_scale && scale_factor <= icon_scale); if (is_bigger || has_better_dpi) { var file = File.new_for_uri (_icon.get_url ()); - icon = new FileIcon (file); - current_size = icon_width; - current_scale = icon_scale; + // icon = new FileIcon (file); + // current_size = icon_width; + // current_scale = icon_scale; } break; From 5ab646307ee32234fe55a148e4b911d2f4300515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 11:25:28 -0700 Subject: [PATCH 52/87] Minor list fixes --- src/MainWindow.vala | 2 +- src/Views/AppListUpdateView.vala | 8 +++++--- src/Views/SearchView.vala | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index a60bf7ec4..cfcd55519 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -432,7 +432,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { } public void go_to_installed () { - if (leaflet.get_child_by_name ("installed-view") == null) { + if (installed_view.parent == null) { leaflet.append (installed_view); } diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index 8e595aef6..bf58784a6 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -340,7 +340,7 @@ namespace AppCenter.Views { private Gee.Collection get_packages () { var tree_set = new Gee.TreeSet (); - var child = list_box.get_next_sibling (); + var child = list_box.get_first_child (); while (child != null) { if (child is Widgets.PackageRow) { tree_set.add (((Widgets.PackageRow) child).get_package ()); @@ -364,12 +364,13 @@ namespace AppCenter.Views { } public async void remove_app (AppCenterCore.Package package) { - var child = list_box.get_next_sibling (); + var child = list_box.get_first_child (); while (child != null) { if (child is Widgets.PackageRow) { unowned var row = (Widgets.PackageRow) child; if (row.get_package () == package) { + list_box.remove (row); row.destroy (); break; } @@ -382,9 +383,10 @@ namespace AppCenter.Views { } public void clear () { - var child = list_box.get_next_sibling (); + var child = list_box.get_first_child (); while (child != null) { if (child is Widgets.PackageRow) { + list_box.remove (child); child.destroy (); } diff --git a/src/Views/SearchView.vala b/src/Views/SearchView.vala index 154b6eafd..c6d36a3da 100644 --- a/src/Views/SearchView.vala +++ b/src/Views/SearchView.vala @@ -92,9 +92,10 @@ public class AppCenter.SearchView : Gtk.Box { } public void clear () { - var child = list_box.get_next_sibling (); + var child = list_box.get_first_child (); while (child != null) { if (child is Widgets.PackageRow) { + list_box.remove (child); child.destroy (); } From 09c4d69993ba4d829754fa328edb618afb8c67dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 11:34:47 -0700 Subject: [PATCH 53/87] Fix row clears --- src/Views/AppListUpdateView.vala | 11 ++--------- src/Views/SearchView.vala | 10 ++-------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index bf58784a6..fe29a9984 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -371,7 +371,6 @@ namespace AppCenter.Views { if (row.get_package () == package) { list_box.remove (row); - row.destroy (); break; } } @@ -383,14 +382,8 @@ namespace AppCenter.Views { } public void clear () { - var child = list_box.get_first_child (); - while (child != null) { - if (child is Widgets.PackageRow) { - list_box.remove (child); - child.destroy (); - } - - child = child.get_next_sibling (); + while (list_box.get_first_child () != null) { + list_box.remove (list_box.get_first_child ()); } list_box.invalidate_sort (); diff --git a/src/Views/SearchView.vala b/src/Views/SearchView.vala index c6d36a3da..d5b1f61c7 100644 --- a/src/Views/SearchView.vala +++ b/src/Views/SearchView.vala @@ -92,14 +92,8 @@ public class AppCenter.SearchView : Gtk.Box { } public void clear () { - var child = list_box.get_first_child (); - while (child != null) { - if (child is Widgets.PackageRow) { - list_box.remove (child); - child.destroy (); - } - - child = child.get_next_sibling (); + while (list_box.get_first_child () != null) { + list_box.remove (list_box.get_first_child ()); } list_store.remove_all (); From ed9bcf4c271f495b3a0147880157eaf88bfec031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 15:50:09 -0700 Subject: [PATCH 54/87] Fix most crashes --- src/Dialogs/StripeDialog.vala | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index e2cd39391..57f2f3a0c 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -153,6 +153,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { activates_default = true, hexpand = true, input_purpose = Gtk.InputPurpose.EMAIL, + input_hints = Gtk.InputHints.LOWERCASE, margin_bottom = 6, placeholder_text = _("Email"), primary_icon_name = "internet-mail-symbolic" @@ -276,7 +277,10 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }); email_entry.changed.connect (() => { - // email_entry.text = email_entry.text.replace (" ", "").down (); + if (" " in email_entry.text) { + email_entry.text = card_expiration_entry.text.replace (" ", ""); + } + is_payment_sensitive (); }); @@ -286,7 +290,9 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }); card_expiration_entry.changed.connect (() => { - // card_expiration_entry.text = card_expiration_entry.text.replace (" ", ""); + if (" " in card_expiration_entry.text) { + card_expiration_entry.text = card_expiration_entry.text.replace (" ", ""); + } if (card_expiration_entry.text.length < 4) { card_expiration_entry.is_valid = false; @@ -304,7 +310,10 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }); card_cvc_entry.changed.connect (() => { - // card_cvc_entry.text = card_cvc_entry.text.replace (" ", ""); + if (" " in card_cvc_entry.text) { + card_cvc_entry.text = card_cvc_entry.text.replace (" ", ""); + } + is_payment_sensitive (); }); } @@ -465,6 +474,8 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { string expiration_dateyear = card_expiration_entry.text.replace ("/", ""); var year = (int.parse (expiration_dateyear[2:4]) + 2000).to_string (); + email_entry.text = email_entry.text.down (); + var data = get_stripe_data (stripe_key, email_entry.text, (amount * 100).to_string (), card_number_entry.text, expiration_dateyear[0:2], year, card_cvc_entry.text); debug ("Stripe data:%s", data); string? error = null; From 7e14dac41443ce714f61cf6ef0de885a37e76e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 16:32:13 -0700 Subject: [PATCH 55/87] StripeDialog: fix visiblity on focus out --- src/Dialogs/StripeDialog.vala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index 57f2f3a0c..121bce025 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -172,12 +172,14 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { }; email_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); + var card_number_entry_controllerfocus = new Gtk.EventControllerFocus (); + card_number_entry = new AppCenter.Widgets.CardNumberEntry () { activates_default = true, hexpand = true, margin_bottom = 6 }; - card_number_entry.bind_property ("has-focus", card_number_entry, "visibility"); + card_number_entry.add_controller (card_number_entry_controllerfocus); var expiration_focus_controller = new Gtk.EventControllerFocus (); @@ -289,6 +291,8 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { is_payment_sensitive (); }); + card_number_entry_controllerfocus.bind_property ("contains-focus", card_number_entry, "visibility"); + card_expiration_entry.changed.connect (() => { if (" " in card_expiration_entry.text) { card_expiration_entry.text = card_expiration_entry.text.replace (" ", ""); From ab777164f7c2a7dcb485b2b8f923b85f0ae70215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 17:30:02 -0700 Subject: [PATCH 56/87] CardNumberEntry: solve pos and crash --- src/Widgets/CardNumberEntry.vala | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Widgets/CardNumberEntry.vala b/src/Widgets/CardNumberEntry.vala index 0f11ed982..a2aca9279 100644 --- a/src/Widgets/CardNumberEntry.vala +++ b/src/Widgets/CardNumberEntry.vala @@ -51,6 +51,7 @@ public class AppCenter.Widgets.CardNumberEntry : Gtk.Entry { update_number (); detect_card (); change_card_icon (); + int[] pattern = get_card_pattern (); var number_chars = card_number.to_utf8 (); var builder = new GLib.StringBuilder (); @@ -61,14 +62,16 @@ public class AppCenter.Widgets.CardNumberEntry : Gtk.Entry { } } - var end_offset = (text.char_count () - 1) - cursor_position; - // text = builder.str; - var new_offset = (text.char_count () - 1) - cursor_position; - if (end_offset != new_offset) { - Idle.add (() => { - // move_cursor (Gtk.MovementStep.LOGICAL_POSITIONS, new_offset - end_offset, false); - return false; - }); + if (text != builder.str) { + var end_offset = (text.char_count () - 1) - cursor_position; + text = builder.str; + var new_offset = (text.char_count () - 1) - cursor_position; + if (end_offset != new_offset) { + Idle.add (() => { + set_position (new_offset + end_offset + 1); + return false; + }); + } } max_length = get_card_max_length () + pattern.length; From 09a8b951d965b6d0c063fecfbc67d6be22781491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 17:40:56 -0700 Subject: [PATCH 57/87] StripeDialog: add keyrelease handler to spinbutton --- src/Dialogs/StripeDialog.vala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index 121bce025..f82537d08 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -123,10 +123,13 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { margin_end = 3 }; + var custom_amount_controllerkey = new Gtk.EventControllerKey (); + var custom_amount = new Gtk.SpinButton.with_range (0, 100, 1) { hexpand = true, value = amount }; + custom_amount.add_controller (custom_amount_controllerkey); var custom_image = new Gtk.Image.from_icon_name ("currency-dollar-symbolic"); custom_image.insert_before (custom_amount, custom_amount.get_first_child ()); @@ -278,6 +281,12 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { amount = 10; }); + custom_amount_controllerkey.key_released.connect ((keyval, keycode, state) => { + if (keyval == Gdk.Key.Return || keyval == Gdk.Key.KP_Enter) { + activate_default (); + } + }); + email_entry.changed.connect (() => { if (" " in email_entry.text) { email_entry.text = card_expiration_entry.text.replace (" ", ""); From 5b04a032d65db3f9cdef3b361e979b30c3568ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 18:01:51 -0700 Subject: [PATCH 58/87] Fix symbolic icon coloring --- data/icons/categories.gresource.xml | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/data/icons/categories.gresource.xml b/data/icons/categories.gresource.xml index 47d700b9e..44e5bed8d 100644 --- a/data/icons/categories.gresource.xml +++ b/data/icons/categories.gresource.xml @@ -1,32 +1,31 @@ - applications-accessibility-symbolic.svg - applications-audio-symbolic.svg - applications-games-symbolic.svg - applications-office-symbolic.svg - applications-video-rtl-symbolic.svg - applications-video-rtl-symbolic.svg - applications-video-symbolic.svg - currency-dollar-symbolic.svg + applications-accessibility-symbolic.svg + applications-audio-symbolic.svg + applications-games-symbolic.svg + applications-office-symbolic.svg + applications-video-rtl-symbolic.svg + applications-video-symbolic.svg + currency-dollar-symbolic.svg online-account-facebook.svg - internet-mail-symbolic.svg + internet-mail-symbolic.svg online-account-reddit.svg online-account-tumblr.svg online-account-twitter.svg online-account-telegram.svg - text-x-copying-symbolic.svg + text-x-copying-symbolic.svg - oars/old-runtime.svg + oars/old-runtime.svg - oars/chat.svg - oars/conflict.svg - oars/gambling.svg - oars/language.svg - oars/nudity.svg - oars/social-info.svg - oars/substance.svg - oars/violence.svg + oars/chat.svg + oars/conflict.svg + oars/gambling.svg + oars/language.svg + oars/nudity.svg + oars/social-info.svg + oars/substance.svg + oars/violence.svg audio.svg From 9bdfebb12545517720e6d233ccde766b6a337ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 18:14:03 -0700 Subject: [PATCH 59/87] Package: copy remote icons --- src/Core/Package.vala | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Core/Package.vala b/src/Core/Package.vala index efe02f533..2d9f66f9f 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -708,10 +708,22 @@ public class AppCenterCore.Package : Object { bool is_bigger = (icon_width > current_size && current_size < pixel_size); bool has_better_dpi = (icon_width == current_size && current_scale < icon_scale && scale_factor <= icon_scale); if (is_bigger || has_better_dpi) { - var file = File.new_for_uri (_icon.get_url ()); - // icon = new FileIcon (file); - // current_size = icon_width; - // current_scale = icon_scale; + var server_file = File.new_for_uri (_icon.get_url ()); + var local_file = File.new_for_path ( + Path.build_filename (Environment.get_tmp_dir (), server_file.get_basename ()) + ); + + // FIXME: Copy this async + try { + server_file.copy (local_file, FileCopyFlags.OVERWRITE, null, null); + + icon = new FileIcon (local_file); + current_size = icon_width; + current_scale = icon_scale; + } catch (Error e) { + critical ("Unable to download remote icon: %s", e.message); + } + } break; From fba379206a4dc6537825288f939a0a0791d6d983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 20:09:44 -0700 Subject: [PATCH 60/87] AppInfoView: fix style classes --- src/Views/AppInfoView.vala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index 58c57f81b..b5eafb074 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1260,9 +1260,8 @@ namespace AppCenter.Views { wrap = true, xalign = 0 }; - - add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); - add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + description_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); + description_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3); box.append (icon); From e58f1ffeaae51d83f9069ed8a69bf84936cf6835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 4 Sep 2022 20:13:18 -0700 Subject: [PATCH 61/87] ArrowButton: set icon size in CSS --- data/styles/arrow.css | 1 + src/Views/AppInfoView.vala | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/data/styles/arrow.css b/data/styles/arrow.css index 12fc0c43b..c6e41eea7 100644 --- a/data/styles/arrow.css +++ b/data/styles/arrow.css @@ -29,6 +29,7 @@ margin: 12px; padding: 6px; color: @text_color; + -gtk-icon-size: 24px; } .arrow:active, diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index b5eafb074..d33adfffd 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1206,11 +1206,7 @@ namespace AppCenter.Views { private static Gtk.CssProvider arrow_provider; public ArrowButton (string icon_name) { - Object ( - child: new Gtk.Image.from_icon_name (icon_name) { - pixel_size = 24 - } - ); + Object (icon_name: icon_name); } static construct { @@ -1225,7 +1221,7 @@ namespace AppCenter.Views { unowned var context = get_style_context (); context.add_class (Granite.STYLE_CLASS_FLAT); - context.add_class ("circular"); + context.add_class (Granite.STYLE_CLASS_CIRCULAR); context.add_class ("arrow"); context.add_provider (arrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } From 9ecc88ba6817e569d62674a39525294387044974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 5 Sep 2022 10:09:02 -0700 Subject: [PATCH 62/87] Categories.css: Fix writing and lang background --- data/styles/categories.css | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data/styles/categories.css b/data/styles/categories.css index 1c197cde0..d56894690 100644 --- a/data/styles/categories.css +++ b/data/styles/categories.css @@ -656,19 +656,19 @@ background-image: linear-gradient( to right, - transparent 42px, - alpha(@STRAWBERRY_100, 0.25) 42px, - alpha(@STRAWBERRY_100, 0.25) 44px, - transparent 44px + transparent 1.3em, + alpha(@STRAWBERRY_100, 0.25) 1.3em, + alpha(@STRAWBERRY_100, 0.25) calc(1.3em + 2px), + transparent calc(1.3em + 2px) ), linear-gradient( to bottom, - white 90%, - alpha(@BLUEBERRY_100, 0.2) 90% + transparent 0.9em, + alpha(@BLUEBERRY_100, 0.2) 0.9em ); - background-position: center center; - background-repeat: repeat-y; - background-size: 100% 1em; + background-position: center center, center 0.7em; + background-repeat: no-repeat, repeat-y; + background-size: auto auto, 110% 1em; /* Gtk.CSS bug requiring over 100% width maybe? */ color: @BLACK_300; font-size: 24px; } From f69cf4a3063076525525a4425eb6dabe7bf5f8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 5 Sep 2022 10:18:33 -0700 Subject: [PATCH 63/87] StripeDialog: Use granite title label class --- src/Dialogs/StripeDialog.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index f82537d08..ded19132d 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -94,7 +94,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { var primary_label = new Gtk.Label (_("Pay $%d for %s").printf (amount, app_name)) { xalign = 0 }; - primary_label.add_css_class ("primary"); + primary_label.add_css_class (Granite.STYLE_CLASS_TITLE_LABEL); var secondary_label = new Gtk.Label ( _("This is a one time payment suggested by the developer. You can also choose your own price.") From fdfa3d56867d630324fe8013a2a0d03739d442c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 5 Sep 2022 10:21:41 -0700 Subject: [PATCH 64/87] MainWindow: now unused name --- src/MainWindow.vala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index cfcd55519..ba1b8685a 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -197,9 +197,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { headerbar.pack_end (spinner); var homepage = new Homepage (); - installed_view = new Views.AppListUpdateView () { - name = "installed-view" - }; + installed_view = new Views.AppListUpdateView (); leaflet = new Adw.Leaflet () { can_navigate_back = true, From 48647b6e21b9dccdc5d41669cf2a86613ed0fd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 8 Sep 2022 12:59:48 -0700 Subject: [PATCH 65/87] lint --- src/Views/AppInfoView.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index d33adfffd..9e25a9b28 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -997,7 +997,7 @@ namespace AppCenter.Views { screenshot_stack.visible_child = screenshot_overlay; stack_context.remove_class ("loading"); - if (app_screenshots.n_pages > 1) { + if (app_screenshots.n_pages > 1) { screenshot_next.visible = true; screenshot_previous.visible = true; } From e0eaf0218a52fc74473715e812154504f22b366f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 3 Oct 2022 09:47:15 -0700 Subject: [PATCH 66/87] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f9a0ccb2f..bcac2c038 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y gettext libappstream-dev libflatpak-dev libgee-0.8-dev libgranite-dev libgtk-3-dev libhandy-1-dev libjson-glib-dev libpackagekit-glib2-dev libsoup2.4-dev libxml2-dev libxml2-utils libpolkit-gobject-1-dev meson valac + apt install -y gettext libadwaita-1-dev libappstream-dev libflatpak-dev libgee-0.8-dev libgranite-7-dev libgtk-4-dev libjson-glib-dev libpackagekit-glib2-dev libsoup2.4-dev libxml2-dev libxml2-utils libpolkit-gobject-1-dev meson valac - name: Build env: DESTDIR: out From 2efd684e97d70e8c9140d6190bef36346c8bca91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 5 Oct 2022 12:52:16 -0700 Subject: [PATCH 67/87] Update src/Dialogs/StripeDialog.vala Co-authored-by: Ryan Kornheisl --- src/Dialogs/StripeDialog.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dialogs/StripeDialog.vala b/src/Dialogs/StripeDialog.vala index ded19132d..3a641f631 100644 --- a/src/Dialogs/StripeDialog.vala +++ b/src/Dialogs/StripeDialog.vala @@ -289,7 +289,7 @@ public class AppCenter.Widgets.StripeDialog : Granite.Dialog { email_entry.changed.connect (() => { if (" " in email_entry.text) { - email_entry.text = card_expiration_entry.text.replace (" ", ""); + email_entry.text = email_entry.text.replace (" ", ""); } is_payment_sensitive (); From 69a5982b077b9188e6429cafbf720ac8cc516ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Oct 2022 17:07:26 -0700 Subject: [PATCH 68/87] Require Granite 7.1.0 --- meson.build | 2 +- src/MainWindow.vala | 4 ++-- src/Widgets/SharePopover.vala | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 7beacad71..d3b434381 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,7 @@ add_project_arguments(['--vapidir', vapi_dir], language: 'vala') glib = dependency ('glib-2.0') gee = dependency ('gee-0.8') gtk = dependency ('gtk4') -granite = dependency ('granite-7', version: '>=7.0.0') +granite = dependency ('granite-7', version: '>=7.1.0') adwaita = dependency('libadwaita-1') packagekit = dependency ('packagekit-glib2') appstream = dependency ('appstream', version: '>=0.15.2') diff --git a/src/MainWindow.vala b/src/MainWindow.vala index bd9cd70c8..c6ebee344 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -135,7 +135,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { return_button.add_css_class (Granite.STYLE_CLASS_BACK_BUTTON); var updates_button = new Gtk.Button.from_icon_name ("software-update-available"); - updates_button.add_css_class ("large-icons"); + updates_button.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var badge_provider = new Gtk.CssProvider (); badge_provider.load_from_resource ("io/elementary/appcenter/badge.css"); @@ -209,7 +209,7 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { tooltip_text = _("Settings"), valign = Gtk.Align.CENTER }; - menu_button.add_css_class ("large-icons"); + menu_button.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var headerbar = new Gtk.HeaderBar () { show_title_buttons = true, diff --git a/src/Widgets/SharePopover.vala b/src/Widgets/SharePopover.vala index 9743a880b..92e85ae4f 100644 --- a/src/Widgets/SharePopover.vala +++ b/src/Widgets/SharePopover.vala @@ -34,27 +34,27 @@ public class SharePopover : Gtk.Popover { var facebook_button = new Gtk.Button.from_icon_name ("online-account-facebook") { tooltip_text = _("Facebook") }; - facebook_button.child.add_css_class ("large-icons"); + facebook_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var twitter_button = new Gtk.Button.from_icon_name ("online-account-twitter") { tooltip_text = _("Twitter") }; - twitter_button.child.add_css_class ("large-icons"); + twitter_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var reddit_button = new Gtk.Button.from_icon_name ("online-account-reddit") { tooltip_text = _("Reddit") }; - reddit_button.child.add_css_class ("large-icons"); + reddit_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var tumblr_button = new Gtk.Button.from_icon_name ("online-account-tumblr") { tooltip_text = _("Tumblr") }; - tumblr_button.child.add_css_class ("large-icons"); + tumblr_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var telegram_button = new Gtk.Button.from_icon_name ("online-account-telegram") { tooltip_text = _("Telegram") }; - telegram_button.child.add_css_class ("large-icons"); + telegram_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var copy_link_button = new Gtk.Button.from_icon_name ("edit-copy-symbolic") { tooltip_text = _("Copy link") @@ -79,7 +79,7 @@ public class SharePopover : Gtk.Popover { tooltip_text = mail_appinfo.get_display_name () }; email_button.add_css_class ("image-button"); - email_button.child.add_css_class ("large-icons"); + email_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); service_box.append (email_button); From 770a217980ca244991cddf881978e007a1a62c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Oct 2022 17:11:12 -0700 Subject: [PATCH 69/87] Update README --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d171e68b7..56305473a 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ An open, pay-what-you-want app store for indie developers. ## Building, Testing, and Installation You'll need the following dependencies: + * gettext -* libappstream-dev (>= 0.10) -* libflatpak-dev +* libadwaita-1-dev +* libappstream-dev (>= 0.15.2) +* libflatpak-dev (>= 1.0.7) * libgee-0.8-dev -* libgranite-dev (>=5.2.5) -* libgtk-3-dev -* libhandy-1-dev (>=1.3.0) +* libgranite-7-dev (>=7.1.0) +* libgtk-4-dev * libjson-glib-dev * libpackagekit-glib2-dev * libpolkit-gobject-1-dev @@ -32,7 +33,7 @@ Run `meson build` to configure the build environment. Change to the build direct To install, use `ninja install`, then execute with `io.elementary.appcenter` - sudo ninja install + ninja install io.elementary.appcenter ## Debugging From c6dae86a86d6b64d15c87d0bc3f3f3146c27d45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Oct 2022 17:12:26 -0700 Subject: [PATCH 70/87] Remove extra line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 56305473a..76391c3f8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ An open, pay-what-you-want app store for indie developers. ## Building, Testing, and Installation You'll need the following dependencies: - * gettext * libadwaita-1-dev * libappstream-dev (>= 0.15.2) From b94b1da56881a2d5776c3a0b01fa958fb5c0cd6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Oct 2022 17:18:47 -0700 Subject: [PATCH 71/87] SharePopover: large-icons on container --- src/Widgets/SharePopover.vala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Widgets/SharePopover.vala b/src/Widgets/SharePopover.vala index 92e85ae4f..5a5b67c3d 100644 --- a/src/Widgets/SharePopover.vala +++ b/src/Widgets/SharePopover.vala @@ -34,27 +34,22 @@ public class SharePopover : Gtk.Popover { var facebook_button = new Gtk.Button.from_icon_name ("online-account-facebook") { tooltip_text = _("Facebook") }; - facebook_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var twitter_button = new Gtk.Button.from_icon_name ("online-account-twitter") { tooltip_text = _("Twitter") }; - twitter_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var reddit_button = new Gtk.Button.from_icon_name ("online-account-reddit") { tooltip_text = _("Reddit") }; - reddit_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var tumblr_button = new Gtk.Button.from_icon_name ("online-account-tumblr") { tooltip_text = _("Tumblr") }; - tumblr_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var telegram_button = new Gtk.Button.from_icon_name ("online-account-telegram") { tooltip_text = _("Telegram") }; - telegram_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var copy_link_button = new Gtk.Button.from_icon_name ("edit-copy-symbolic") { tooltip_text = _("Copy link") @@ -71,6 +66,7 @@ public class SharePopover : Gtk.Popover { margin_bottom = 6, margin_start = 6 }; + service_box.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); var mail_appinfo = AppInfo.get_default_for_uri_scheme ("mailto"); if (mail_appinfo != null) { @@ -79,7 +75,6 @@ public class SharePopover : Gtk.Popover { tooltip_text = mail_appinfo.get_display_name () }; email_button.add_css_class ("image-button"); - email_button.child.add_css_class (Granite.STYLE_CLASS_LARGE_ICONS); service_box.append (email_button); From 6fd5edfa751d0a4e48a37fb26a4991091ce8562b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 27 Oct 2022 11:34:56 -0700 Subject: [PATCH 72/87] AppInfoView: action button grab focus on realize --- src/Views/AppInfoView.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index ea05c03ba..dbda41956 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -1034,6 +1034,8 @@ namespace AppCenter.Views { return null; }); + + action_button.grab_focus (); } // We need to first download the screenshot locally so that it doesn't freeze the interface. From ccddde74b2aae89304c6cb9d55c8e70cde74179d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 20 Aug 2023 11:34:30 -0700 Subject: [PATCH 73/87] Fix headerbar issue --- src/MainWindow.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index a5f7e32c9..bf321259f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -229,7 +229,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { network_info_bar.add_button (_("Network Settingsā€¦"), Gtk.ResponseType.ACCEPT); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - box.append (headerbar); box.append (network_info_bar); if (Utils.is_running_in_demo_mode ()) { From 36a6353c1a1128362d9ae1d44bf81812e3fbffb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 11:52:05 -0700 Subject: [PATCH 74/87] Fix infinite loop --- src/Views/AppListUpdateView.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index 6e70d118e..e90dfd842 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -398,6 +398,8 @@ namespace AppCenter.Views { if (child is Widgets.PackageRow) { ((Widgets.PackageRow) child).set_action_sensitive (false); } + + child = child.get_next_sibling (); } for (int i = 0; i < package_liststore.get_n_items (); i++) { @@ -419,8 +421,6 @@ namespace AppCenter.Views { } } } - - child = child.get_next_sibling (); } unowned AppCenterCore.Client client = AppCenterCore.Client.get_default (); From 71ccee271993f06e10c4743053c7527a7794d89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 11:56:20 -0700 Subject: [PATCH 75/87] load application.css automatically --- data/io.elementary.appcenter.gresource.xml | 2 +- src/Application.vala | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/data/io.elementary.appcenter.gresource.xml b/data/io.elementary.appcenter.gresource.xml index 99a170a36..d40e5a5ec 100644 --- a/data/io.elementary.appcenter.gresource.xml +++ b/data/io.elementary.appcenter.gresource.xml @@ -1,7 +1,7 @@ - styles/application.css + styles/application.css styles/AppInfoView.css styles/AppListUpdateView.css styles/arrow.css diff --git a/src/Application.vala b/src/Application.vala index 4f9c88905..6330e41b0 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -114,6 +114,8 @@ public class AppCenter.App : Gtk.Application { protected override void startup () { base.startup (); + Granite.init (); + var granite_settings = Granite.Settings.get_default (); var gtk_settings = Gtk.Settings.get_default (); @@ -123,14 +125,6 @@ public class AppCenter.App : Gtk.Application { gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; }); - var provider = new Gtk.CssProvider (); - provider.load_from_resource ("io/elementary/appcenter/application.css"); - Gtk.StyleContext.add_provider_for_display ( - Gdk.Display.get_default (), - provider, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - var fallback_provider = new Gtk.CssProvider (); fallback_provider.load_from_resource ("io/elementary/appcenter/fallback.css"); Gtk.StyleContext.add_provider_for_display ( From ee207aa2aaa07570bfb31311c351aa96f168020b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 11:59:17 -0700 Subject: [PATCH 76/87] Palette fallbacks now in Granite --- data/io.elementary.appcenter.gresource.xml | 1 - data/styles/fallback.css | 81 ---------------------- src/Application.vala | 8 --- 3 files changed, 90 deletions(-) delete mode 100644 data/styles/fallback.css diff --git a/data/io.elementary.appcenter.gresource.xml b/data/io.elementary.appcenter.gresource.xml index d40e5a5ec..4bdc4a3b2 100644 --- a/data/io.elementary.appcenter.gresource.xml +++ b/data/io.elementary.appcenter.gresource.xml @@ -8,7 +8,6 @@ styles/badge.css styles/banner.css styles/categories.css - styles/fallback.css styles/loading.css styles/ProgressButton.css diff --git a/data/styles/fallback.css b/data/styles/fallback.css deleted file mode 100644 index 2d9816367..000000000 --- a/data/styles/fallback.css +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2020 elementary, Inc. (https://elementary.io) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* elementary-specific stylesheet variables */ - -@define-color fg_color @theme_text_color; - -/* Palette */ -@define-color STRAWBERRY_100 #ff8c82; -@define-color STRAWBERRY_300 #ed5353; -@define-color STRAWBERRY_500 #c6262e; -@define-color STRAWBERRY_700 #a10705; -@define-color STRAWBERRY_900 #7a0000; - -@define-color ORANGE_100 #ffc27d; -@define-color ORANGE_300 #ffa154; -@define-color ORANGE_500 #f37329; -@define-color ORANGE_700 #cc3b02; -@define-color ORANGE_900 #a62100; - -@define-color BANANA_100 #fff394; -@define-color BANANA_300 #ffe16b; -@define-color BANANA_500 #f9c440; -@define-color BANANA_700 #d48e15; -@define-color BANANA_900 #ad5f00; - -@define-color LIME_100 #d1ff82; -@define-color LIME_300 #9bdb4d; -@define-color LIME_500 #68b723; -@define-color LIME_700 #3a9104; -@define-color LIME_900 #206b00; - -@define-color BLUEBERRY_100 #8cd5ff; -@define-color BLUEBERRY_300 #64baff; -@define-color BLUEBERRY_500 #3689e6; -@define-color BLUEBERRY_700 #0d52bf; -@define-color BLUEBERRY_900 #002e99; - -@define-color GRAPE_100 #e4c6fa; -@define-color GRAPE_300 #cd9ef7; -@define-color GRAPE_500 #a56de2; -@define-color GRAPE_700 #7239b3; -@define-color GRAPE_900 #452981; - -@define-color COCOA_100 #a3907c; -@define-color COCOA_300 #8a715e; -@define-color COCOA_500 #715344; -@define-color COCOA_700 #57392d; -@define-color COCOA_900 #3d211b; - -@define-color SILVER_100 #fafafa; -@define-color SILVER_300 #d4d4d4; -@define-color SILVER_500 #abacae; -@define-color SILVER_700 #7e8087; -@define-color SILVER_900 #555761; - -@define-color SLATE_100 #95a3ab; -@define-color SLATE_300 #667885; -@define-color SLATE_500 #485a6c; -@define-color SLATE_700 #273445; -@define-color SLATE_900 #0e141f; - -@define-color BLACK_100 #666; -@define-color BLACK_300 #4d4d4d; -@define-color BLACK_500 #333; -@define-color BLACK_700 #1a1a1a; -@define-color BLACK_900 #000; diff --git a/src/Application.vala b/src/Application.vala index 6330e41b0..93001e4d0 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -125,14 +125,6 @@ public class AppCenter.App : Gtk.Application { gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; }); - var fallback_provider = new Gtk.CssProvider (); - fallback_provider.load_from_resource ("io/elementary/appcenter/fallback.css"); - Gtk.StyleContext.add_provider_for_display ( - Gdk.Display.get_default (), - fallback_provider, - Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK - ); - var quit_action = new SimpleAction ("quit", null); quit_action.activate.connect (() => { if (active_window != null) { From 51927fc14798556779ba3693b27e37f0516ba95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 12:12:26 -0700 Subject: [PATCH 77/87] Avoid loop/crash --- src/Views/Homepage.vala | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 1c392237a..00b2471d9 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -241,25 +241,6 @@ public class AppCenter.Homepage : Gtk.Box { show_category (card.category); }); - AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { - Idle.add (() => { - // Clear the cached categories when the AppStream pool is updated - var child = category_flow.get_first_child (); - while (child != null) { - var item = (AbstractCategoryCard) child; - if (item.visible) { - continue; - } - var category_components = item.category.get_components (); - category_components.remove_range (0, category_components.length); - - child = child.get_next_sibling (); - } - - return GLib.Source.REMOVE; - }); - }); - banner_motion_controller.enter.connect (() => { banner_timeout_stop (); }); @@ -347,7 +328,7 @@ public class AppCenter.Homepage : Gtk.Box { } } - recently_updated_revealer.reveal_child = recently_updated_carousel.get_first_child != null; + recently_updated_revealer.reveal_child = recently_updated_carousel.get_first_child () != null; } private void banner_timeout_start () { @@ -406,6 +387,20 @@ public class AppCenter.Homepage : Gtk.Box { content_area.get_style_context ().add_provider (category_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); child = content_area; + + AppCenterCore.Client.get_default ().installed_apps_changed.connect (() => { + Idle.add (() => { + // Clear the cached categories when the AppStream pool is updated + if (visible) { + return GLib.Source.REMOVE; + } + + var category_components = category.get_components (); + category_components.remove_range (0, category_components.length); + + return GLib.Source.REMOVE; + }); + }); } } From 68ab561274b25203954fcdf0203830daca69a83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 12:19:37 -0700 Subject: [PATCH 78/87] Reduce diff slightly --- src/Widgets/Banner.vala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Widgets/Banner.vala b/src/Widgets/Banner.vala index a0255fbdd..d57b6612e 100644 --- a/src/Widgets/Banner.vala +++ b/src/Widgets/Banner.vala @@ -72,8 +72,9 @@ public class AppCenter.Widgets.Banner : Gtk.Button { xalign = 0 }; - var icon_image = new Gtk.Image () { - gicon = package.get_icon (128, get_scale_factor ()), + var icon_image = new Gtk.Image.from_gicon ( + package.get_icon (128, get_scale_factor ()) + ) { pixel_size = 128 }; From 1845a9ec37d31b233a11b3961a32fca2b5f0bd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 12:32:40 -0700 Subject: [PATCH 79/87] Fix broken screenshot arrows --- src/Views/AppInfoView.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index b3d2fa3d5..ffbe052cd 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -515,8 +515,8 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer { }; screenshot_previous.clicked.connect (() => { var index = (int) screenshot_carousel.position; - if (index < screenshot_carousel.n_pages - 1) { - screenshot_carousel.scroll_to (screenshot_carousel.get_nth_page (index + 1), true); + if (index > 0) { + screenshot_carousel.scroll_to (screenshot_carousel.get_nth_page (index - 1), true); } }); @@ -527,7 +527,7 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer { screenshot_next.clicked.connect (() => { var index = (int) screenshot_carousel.position; if (index < screenshot_carousel.n_pages - 1) { - screenshot_carousel.scroll_to (screenshot_carousel.get_nth_page (index - 1), true); + screenshot_carousel.scroll_to (screenshot_carousel.get_nth_page (index + 1), true); } }); From 5ccda251a9a0d837809d34a060e6fa1d4594ae6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 12:37:50 -0700 Subject: [PATCH 80/87] Fix share button frame --- src/Views/AppInfoView.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index ffbe052cd..30ebf4671 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -764,12 +764,11 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer { var share_button = new Gtk.MenuButton () { child = share_box, + has_frame = false, direction = Gtk.ArrowType.UP, popover = share_popover }; - share_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); - share_button.add_css_class (Granite.STYLE_CLASS_FLAT); share_popover.link_copied.connect (() => { toast.send_notification (); From 28ecc6247a0fb83bd9a03cda312f3fab56f77dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 23 Aug 2023 12:41:32 -0700 Subject: [PATCH 81/87] fix missing web browser icon --- data/icons/categories.gresource.xml | 1 + data/icons/web-browser-symbolic.svg | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 data/icons/web-browser-symbolic.svg diff --git a/data/icons/categories.gresource.xml b/data/icons/categories.gresource.xml index f29bce713..18d239338 100644 --- a/data/icons/categories.gresource.xml +++ b/data/icons/categories.gresource.xml @@ -13,6 +13,7 @@ currency-dollar-symbolic.svg online-account-facebook.svg internet-mail-symbolic.svg + web-browser-symbolic.svg online-account-reddit.svg online-account-tumblr.svg online-account-twitter.svg diff --git a/data/icons/web-browser-symbolic.svg b/data/icons/web-browser-symbolic.svg new file mode 100644 index 000000000..66f853d9f --- /dev/null +++ b/data/icons/web-browser-symbolic.svg @@ -0,0 +1,36 @@ + + + + + + image/svg+xml + + + + + + + + + From 093334e3d197f0fcf75ef7b8af04370adadbcb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 24 Aug 2023 10:36:57 -0700 Subject: [PATCH 82/87] bump granite requirement --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8fa1101a3..fcfb91538 100644 --- a/meson.build +++ b/meson.build @@ -21,7 +21,7 @@ add_project_arguments(['--vapidir', vapi_dir], language: 'vala') glib = dependency ('glib-2.0') gee = dependency ('gee-0.8') gtk = dependency ('gtk4') -granite = dependency ('granite-7', version: '>=7.1.0') +granite = dependency ('granite-7', version: '>=7.3.0') adwaita = dependency('libadwaita-1') appstream = dependency ('appstream', version: '>=0.15.2') libsoup = dependency ('libsoup-2.4') From 10605af4aa65121519e6f2b4ee545c6af6963be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 7 Feb 2024 09:59:12 -0800 Subject: [PATCH 83/87] Remove problematic remote icon code --- src/Core/Package.vala | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/Core/Package.vala b/src/Core/Package.vala index 1ad5387ae..762da0b83 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -748,31 +748,6 @@ public class AppCenterCore.Package : Object { current_scale = icon_scale; } - break; - case AppStream.IconKind.REMOTE: - var icon_scale = _icon.get_scale (); - var icon_width = _icon.get_width () * icon_scale; - bool is_bigger = (icon_width > current_size && current_size < pixel_size); - bool has_better_dpi = (icon_width == current_size && current_scale < icon_scale && scale_factor <= icon_scale); - if (is_bigger || has_better_dpi) { - var server_file = File.new_for_uri (_icon.get_url ()); - var local_file = File.new_for_path ( - Path.build_filename (Environment.get_tmp_dir (), server_file.get_basename ()) - ); - - // FIXME: Copy this async - try { - server_file.copy (local_file, FileCopyFlags.OVERWRITE, null, null); - - icon = new FileIcon (local_file); - current_size = icon_width; - current_scale = icon_scale; - } catch (Error e) { - critical ("Unable to download remote icon: %s", e.message); - } - - } - break; case AppStream.IconKind.UNKNOWN: From abb68286d21b3b12aca6255eb932e3bd35a01b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 7 Feb 2024 10:15:40 -0800 Subject: [PATCH 84/87] Fix uninstall button style --- data/styles/banner.css | 2 +- src/Views/AppInfoView.vala | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/styles/banner.css b/data/styles/banner.css index cc03591da..8e4c71801 100644 --- a/data/styles/banner.css +++ b/data/styles/banner.css @@ -77,7 +77,7 @@ /*Hack to make the button square-ish*/ .banner button.image-button.raised { - padding: 0.333rem 0.444rem; + padding: 0 0.333em; } .banner button:not(.suggested-action) { diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index fd1a1aefe..a50731458 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -185,15 +185,16 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer { tooltip_text = _("Uninstall"), margin_end = 12 }; + uninstall_button.add_css_class ("raised"); unowned var uninstall_button_context = uninstall_button.get_style_context (); - uninstall_button_context.add_class ("raised"); uninstall_button_context.add_provider (banner_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); uninstall_button_context.add_provider (accent_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); uninstall_button_revealer = new Gtk.Revealer () { child = uninstall_button, - transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT + transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT, + overflow = VISIBLE }; var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { From 7f1dc778e431746c8d0dff86670ac589fd402923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 14 Feb 2024 13:32:05 -0800 Subject: [PATCH 85/87] Remove restart infobar --- src/Views/AppListUpdateView.vala | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index 51b178253..4406b6379 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -127,37 +127,10 @@ namespace AppCenter.Views { }; scrolled.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - var info_label = new Gtk.Label (_("A restart is required to finish installing updates")); - - var infobar = new Gtk.InfoBar () { - message_type = Gtk.MessageType.WARNING - }; - infobar.add_child (info_label); - - var restart_button = infobar.add_button (_("Restart Now"), 0); - action_button_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH); action_button_group.add_widget (update_all_button); - action_button_group.add_widget (restart_button); - - infobar.response.connect ((response) => { - if (response == 0) { - try { - SuspendControl.get_default ().reboot (); - } catch (GLib.Error e) { - if (!(e is IOError.CANCELLED)) { - info_label.label = _("Requesting a restart failed. Restart manually to finish installing updates"); - infobar.message_type = Gtk.MessageType.ERROR; - restart_button.visible = false; - } - } - } - }); - - AppCenterCore.UpdateManager.get_default ().bind_property ("restart-required", infobar, "visible", BindingFlags.SYNC_CREATE); var main_box = new Gtk.Box (VERTICAL, 0); - main_box.append (infobar); main_box.append (updated_revealer); main_box.append (header_revealer); main_box.append (scrolled); From f180dc084dd78f9660531a46e10771f2a05ca573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 14 Feb 2024 13:41:03 -0800 Subject: [PATCH 86/87] move request_background to close_request override --- src/MainWindow.vala | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index f2f2a056d..7bcc90273 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -324,12 +324,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { break; } }); - - close_request.connect (() => { - ((AppCenter.App) application).request_background.begin (() => destroy ()); - - return false; - }); } public override bool close_request () { @@ -348,6 +342,8 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { return true; } + ((AppCenter.App) application).request_background.begin (() => destroy ()); + return false; } From bb7190f2c879440567c2978abb8071adefb7f3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 14 Feb 2024 13:45:21 -0800 Subject: [PATCH 87/87] Use remove --- src/Views/CategoryView.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/CategoryView.vala b/src/Views/CategoryView.vala index 4c0240e62..48c544a98 100644 --- a/src/Views/CategoryView.vala +++ b/src/Views/CategoryView.vala @@ -231,8 +231,8 @@ public class AppCenter.CategoryView : Gtk.Box { public void clear () { while (flowbox.get_first_child () != null) { - flowbox.get_first_child ().destroy (); - }; + flowbox.remove (flowbox.get_first_child ()); + } } [CCode (instance_pos = -1)]