From bc13d1f5432756de41492efdc9889e0e6cc8edba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 6 Mar 2025 12:24:08 -0800 Subject: [PATCH 1/3] Introduce CategoryManager --- data/styles/Category.scss | 39 ++-- po/POTFILES | 1 + src/Core/CategoryManager.vala | 165 ++++++++++++++++ src/Views/Homepage.vala | 350 ++++++++++++++-------------------- src/meson.build | 1 + 5 files changed, 327 insertions(+), 229 deletions(-) create mode 100644 src/Core/CategoryManager.vala diff --git a/data/styles/Category.scss b/data/styles/Category.scss index 3a88b6d45b..5a6908ef20 100644 --- a/data/styles/Category.scss +++ b/data/styles/Category.scss @@ -13,11 +13,19 @@ inset 0 -1px 0 0 rgba(white, 0.15), 0 3px 2px -1px rgba(black, 0.15), 0 3px 5px rgba(black, 0.1); - font-size: 2em; + font-size: 1.5em; font-weight: 600; margin: rem(12px); - padding: rem(12px); - min-height: 3em; + padding: rem(6px); + -gtk-icon-size: 32px; + -gtk-icon-style: symbolic; + + &.communication, + &.media-production, + &.writing-language, + &.internet { + -gtk-icon-style: regular; + } &.accessibility { background-image: @@ -258,30 +266,20 @@ 0 0 0 1px rgba(black, 0.15), 0 3px 2px -1px rgba(black, 0.15), 0 3px 5px rgba(black, 0.1); - font-weight: 900; - letter-spacing: -1px; - -gtk-icon-shadow: - 0 1px 2px #{'alpha(@SLATE_900, 0.2)'}, - 0 2px 6px #{'alpha(@SLATE_900, 0.1)'}; - label.pink { - font-size: 1em; - text-shadow: - 0 1px 2px #{'alpha(@BUBBLEGUM_900, 0.2)'}, - 0 2px 6px #{'alpha(@BUBBLEGUM_900, 0.1)'}; - margin-bottom: -12px; + image { + color: #{'@SLATE_500'}; + -gtk-icon-shadow: + 0 1px 2px #{'alpha(@SLATE_900, 0.2)'}, + 0 2px 6px #{'alpha(@SLATE_900, 0.1)'}; } - label.blue { - font-size: 1.5em; + label { + color: #{'@BLUEBERRY_500'}; text-shadow: 0 1px 2px #{'alpha(@BLUEBERRY_900, 0.2)'}, 0 2px 6px #{'alpha(@BLUEBERRY_900, 0.1)'}; } - - image { - -gtk-icon-size: rem(64px); - } } &.graphics { @@ -488,7 +486,6 @@ 0 3px 5px rgba(black, 0.1); color: #{'@BANANA_300'}; text-shadow: 0 1px 2px #{'alpha(@SLATE_900, 0.75)'}; - -gtk-icon-shadow: 0 1px 2px #{'alpha(@SLATE_900, 0.75)'}; } &.office { diff --git a/po/POTFILES b/po/POTFILES index c79a779e14..59fdb8e146 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -3,6 +3,7 @@ src/AsyncMutex.vala src/MainWindow.vala src/SuspendControl.vala src/Utils.vala +src/Core/CategoryManager.vala src/Core/ChangeInformation.vala src/Core/FlatpakBackend.vala src/Core/Job.vala diff --git a/src/Core/CategoryManager.vala b/src/Core/CategoryManager.vala new file mode 100644 index 0000000000..965657f6b9 --- /dev/null +++ b/src/Core/CategoryManager.vala @@ -0,0 +1,165 @@ +/* + * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +public class AppCenter.CategoryManager : Object { + public GenericArray categories { get; private set; } + + private static GLib.Once instance; + public static unowned CategoryManager get_default () { + return instance.once (() => { return new CategoryManager (); }); + } + + private CategoryManager () {} + + construct { + categories = new GenericArray (); + + append ("accessories", _("Accessories"), "applications-accessories", {"Utility"}); + append ("audio", _("Audio"), "appcenter-audio", {"Audio", "Music"}); + + // FIXME: This is an app icon, not a category icon + append ("communication", _("Communication"), "internet-chat", { + "Chat", + "ContactManagement", + "Email", + "InstantMessaging", + "IRCClient", + "Telephony", + "VideoConference" + }); + + append ("development", _("Development"), "applications-development", { + "Database", + "Debugger", + "Development", + "GUIDesigner", + "IDE", + "RevisionControl", + "TerminalEmulator", + "WebDevelopment" + }); + + // FIXME: Icon missing + append ("education", _("Education"), "", {"Education"}); + + append ("finance", _("Finance"), "appcenter-finance", { + "Economy", + "Finance" + }); + + append ("games", _("Fun & Games"), "applications-games", { + "ActionGame", + "AdventureGame", + "Amusement", + "ArcadeGame", + "BlocksGame", + "BoardGame", + "CardGame", + "Game", + "KidsGame", + "LogicGame", + "RolePlaying", + "Shooter", + "Simulation", + "SportsGame", + "StrategyGame" + }); + + append ("graphics", _("Graphics"), "applications-graphics", { + "2DGraphics", + "3DGraphics", + "Graphics", + "ImageProcessing", + "Photography", + "RasterGraphics", + "VectorGraphics" + }); + + append ("internet", _("Internet"), "applications-internet", { + "Network", + "P2P" + }); + + append ("science", _("Math, Science, & Engineering"), "applications-science", { + "ArtificialIntelligence", + "Astronomy", + "Biology", + "Calculator", + "Chemistry", + "ComputerScience", + "DataVisualization", + "Electricity", + "Electronics", + "Engineering", + "Geology", + "Geoscience", + "Math", + "NumericalAnalysis", + "Physics", + "Robotics", + "Science" + }); + + append ("media-production", _("Media Production"), "applications-multimedia", { + "AudioVideoEditing", + "Midi", + "Mixer", + "Recorder", + "Sequencer" + }); + + append ("office", _("Office"), "applications-office", { + "Office", + "Presentation", + "Publishing", + "Spreadsheet", + "WordProcessor" + }); + + append ("system", _("System"), "applications-system", { + "Monitor", + "System" + }); + + append ("accessibility", _("Universal Access"), "preferences-desktop-accessibility", {"Accessibility"}); + + append ("video", _("Video"), "appcenter-video", { + "Tuner", + "TV", + "Video" + }); + + append ("writing-language", _("Writing & Language"), "preferences-desktop-locale", { + "Dictionary", + "Languages", + "Literature", + "OCR", + "TextEditor", + "TextTools", + "Translation", + "WordProcessor" + }); + + // FIXME: MISSING ICON + append ("privacy-security", _("Privacy & Security"), "preferences-system-privacy", { + "Security" + }); + } + + private void append (string id, string name, string icon, string[] groups) { + var category = new AppStream.Category () { + name = name, + icon = icon, + id = id + }; + + foreach (unowned var group in groups) { + category.add_desktop_group (group); + } + + categories.add (category); + } +} diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 7c099468af..c26d16c4ff 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -96,8 +96,8 @@ public class AppCenter.Homepage : Adw.NavigationPage { }; category_flow.set_sort_func ((child1, child2) => { - var item1 = (AbstractCategoryCard) child1; - var item2 = (AbstractCategoryCard) child2; + var item1 = (CategoryCard) child1; + var item2 = (CategoryCard) child2; if (item1 != null && item2 != null) { return item1.category.name.collate (item2.category.name); } @@ -105,104 +105,108 @@ public class AppCenter.Homepage : Adw.NavigationPage { return 0; }); - var games_card = new GamesCard (); - - category_flow.append (new LegacyCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); - category_flow.append (new LegacyCard (_("Audio"), "appcenter-audio-symbolic", {"Audio", "Music"}, "audio")); - category_flow.append (new LegacyCard (_("Communication"), "", { - "Chat", - "ContactManagement", - "Email", - "InstantMessaging", - "IRCClient", - "Telephony", - "VideoConference" - }, "communication")); - category_flow.append (new LegacyCard (_("Development"), "", { - "Database", - "Debugger", - "Development", - "GUIDesigner", - "IDE", - "RevisionControl", - "TerminalEmulator", - "WebDevelopment" - }, "development")); - category_flow.append (new LegacyCard (_("Education"), "", {"Education"}, "education")); - category_flow.append (new LegacyCard (_("Finance"), "appcenter-finance-symbolic", { - "Economy", - "Finance" - }, "finance")); - category_flow.append (games_card); - category_flow.append (new LegacyCard (_("Graphics"), "", { - "2DGraphics", - "3DGraphics", - "Graphics", - "ImageProcessing", - "Photography", - "RasterGraphics", - "VectorGraphics" - }, "graphics")); - category_flow.append (new LegacyCard (_("Internet"), "applications-internet", { - "Network", - "P2P" - }, "internet")); - category_flow.append (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.append (new LegacyCard (_("Media Production"), "appcenter-multimedia-symbolic", { - "AudioVideoEditing", - "Midi", - "Mixer", - "Recorder", - "Sequencer" - }, "media-production")); - category_flow.append (new LegacyCard (_("Office"), "appcenter-office-symbolic", { - "Office", - "Presentation", - "Publishing", - "Spreadsheet", - "WordProcessor" - }, "office")); - category_flow.append (new LegacyCard (_("System"), "applications-system-symbolic", { - "Monitor", - "System" - }, "system")); - category_flow.append (new LegacyCard (_("Universal Access"), "appcenter-accessibility-symbolic", {"Accessibility"}, "accessibility")); - category_flow.append (new LegacyCard (_("Video"), "appcenter-video-symbolic", { - "Tuner", - "TV", - "Video" - }, "video")); - category_flow.append (new LegacyCard (_("Writing & Language"), "preferences-desktop-locale", { - "Dictionary", - "Languages", - "Literature", - "OCR", - "TextEditor", - "TextTools", - "Translation", - "WordProcessor" - }, "writing-language")); - category_flow.append (new LegacyCard (_("Privacy & Security"), "preferences-system-privacy", { - "Security", - }, "privacy-security")); + foreach (unowned var category in CategoryManager.get_default ().categories) { + category_flow.append (new CategoryCard (category.name, category.icon, {}, category.id)); + } + + // var games_card = new GamesCard (); + + // category_flow.append (new CategoryCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); + // category_flow.append (new CategoryCard (_("Audio"), "appcenter-audio-symbolic", {"Audio", "Music"}, "audio")); + // category_flow.append (new CategoryCard (_("Communication"), "", { + // "Chat", + // "ContactManagement", + // "Email", + // "InstantMessaging", + // "IRCClient", + // "Telephony", + // "VideoConference" + // }, "communication")); + // category_flow.append (new CategoryCard (_("Development"), "", { + // "Database", + // "Debugger", + // "Development", + // "GUIDesigner", + // "IDE", + // "RevisionControl", + // "TerminalEmulator", + // "WebDevelopment" + // }, "development")); + // category_flow.append (new CategoryCard (_("Education"), "", {"Education"}, "education")); + // category_flow.append (new CategoryCard (_("Finance"), "appcenter-finance-symbolic", { + // "Economy", + // "Finance" + // }, "finance")); + // category_flow.append (games_card); + // category_flow.append (new CategoryCard (_("Graphics"), "", { + // "2DGraphics", + // "3DGraphics", + // "Graphics", + // "ImageProcessing", + // "Photography", + // "RasterGraphics", + // "VectorGraphics" + // }, "graphics")); + // category_flow.append (new CategoryCard (_("Internet"), "applications-internet", { + // "Network", + // "P2P" + // }, "internet")); + // category_flow.append (new CategoryCard (_("Math, Science, & Engineering"), "", { + // "ArtificialIntelligence", + // "Astronomy", + // "Biology", + // "Calculator", + // "Chemistry", + // "ComputerScience", + // "DataVisualization", + // "Electricity", + // "Electronics", + // "Engineering", + // "Geology", + // "Geoscience", + // "Math", + // "NumericalAnalysis", + // "Physics", + // "Robotics", + // "Science" + // }, "science")); + // category_flow.append (new CategoryCard (_("Media Production"), "appcenter-multimedia-symbolic", { + // "AudioVideoEditing", + // "Midi", + // "Mixer", + // "Recorder", + // "Sequencer" + // }, "media-production")); + // category_flow.append (new CategoryCard (_("Office"), "appcenter-office-symbolic", { + // "Office", + // "Presentation", + // "Publishing", + // "Spreadsheet", + // "WordProcessor" + // }, "office")); + // category_flow.append (new CategoryCard (_("System"), "applications-system-symbolic", { + // "Monitor", + // "System" + // }, "system")); + // category_flow.append (new CategoryCard (_("Universal Access"), "appcenter-accessibility-symbolic", {"Accessibility"}, "accessibility")); + // category_flow.append (new CategoryCard (_("Video"), "appcenter-video-symbolic", { + // "Tuner", + // "TV", + // "Video" + // }, "video")); + // category_flow.append (new CategoryCard (_("Writing & Language"), "preferences-desktop-locale", { + // "Dictionary", + // "Languages", + // "Literature", + // "OCR", + // "TextEditor", + // "TextTools", + // "Translation", + // "WordProcessor" + // }, "writing-language")); + // category_flow.append (new CategoryCard (_("Privacy & Security"), "preferences-system-privacy", { + // "Security", + // }, "privacy-security")); var box = new Gtk.Box (VERTICAL, 0); box.append (banner_carousel); @@ -293,7 +297,7 @@ public class AppCenter.Homepage : Adw.NavigationPage { }); category_flow.child_activated.connect ((child) => { - var card = (AbstractCategoryCard) child; + var card = (CategoryCard) child; show_category (card.category); }); @@ -427,22 +431,55 @@ public class AppCenter.Homepage : Adw.NavigationPage { }); } - private abstract class AbstractCategoryCard : Gtk.FlowBoxChild { - public AppStream.Category category { get; protected set; } + private class CategoryCard : Gtk.FlowBoxChild { + public AppStream.Category category { get; construct; } - protected Gtk.Grid content_area; + public CategoryCard (string name, string icon, string[] groups, string style) { + var category = new AppStream.Category () { + id = style + }; + category.set_name (name); + category.set_icon (icon); + + foreach (var group in groups) { + category.add_desktop_group (group); + } + + Object (category: category); + } construct { + var display_image = new Gtk.Image.from_icon_name (category.icon) { + halign = END, + valign = CENTER, + }; + + var name_label = new Gtk.Label (category.name) { + halign = START, + wrap = true, + max_width_chars = 15, + xalign = 0 + }; + + var box = new Gtk.Box (HORIZONTAL, 6) { + halign = CENTER, + valign = CENTER + }; + box.append (display_image); + box.append (name_label); + var expanded_grid = new Gtk.Grid () { hexpand = true, vexpand = true }; - content_area = new Gtk.Grid (); + var content_area = new Gtk.Grid (); + content_area.attach (box, 0, 0); content_area.attach (expanded_grid, 0, 0); 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.add_css_class (category.id); child = content_area; @@ -461,107 +498,4 @@ public class AppCenter.Homepage : Adw.NavigationPage { }); } } - - 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 name_label = new Gtk.Label (null); - name_label.wrap = true; - name_label.max_width_chars = 15; - - var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { - halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER - }; - - if (category.icon != "") { - var display_image = new Gtk.Image.from_icon_name (category.icon) { - halign = Gtk.Align.END, - valign = Gtk.Align.CENTER, - pixel_size = 48 - }; - - box.append (display_image); - - name_label.xalign = 0; - name_label.halign = Gtk.Align.START; - } else { - 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") { - 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 = "appcenter-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 = "appcenter-games-symbolic" - }; - image.add_css_class (Granite.STYLE_CLASS_ACCENT); - image.add_css_class ("slate"); - - var fun_label = new Gtk.Label (_("Fun &")) { - halign = Gtk.Align.START - }; - fun_label.add_css_class (Granite.STYLE_CLASS_ACCENT); - fun_label.add_css_class ("pink"); - - var games_label = new Gtk.Label (_("Games")); - games_label.add_css_class (Granite.STYLE_CLASS_ACCENT); - games_label.add_css_class ("blue"); - - 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); - content_area.add_css_class ("games"); - } - } } diff --git a/src/meson.build b/src/meson.build index 78fec03f71..6fab1e0190 100644 --- a/src/meson.build +++ b/src/meson.build @@ -5,6 +5,7 @@ appcenter_files = files( 'SuspendControl.vala', 'Utils.vala', 'Core/CardUtils.vala', + 'Core' / 'CategoryManager.vala', 'Core/ChangeInformation.vala', 'Core/FlatpakBackend.vala', 'Core/HttpClient.vala', From 8df6338679144bf9cf29e5a7ff85b703859ee803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 6 Mar 2025 12:33:29 -0800 Subject: [PATCH 2/3] Revert styles --- data/styles/Category.scss | 34 ++++---- src/Core/CategoryManager.vala | 21 +++-- src/Views/Homepage.vala | 148 +++++++--------------------------- 3 files changed, 54 insertions(+), 149 deletions(-) diff --git a/data/styles/Category.scss b/data/styles/Category.scss index 5a6908ef20..6bad927642 100644 --- a/data/styles/Category.scss +++ b/data/styles/Category.scss @@ -13,19 +13,12 @@ inset 0 -1px 0 0 rgba(white, 0.15), 0 3px 2px -1px rgba(black, 0.15), 0 3px 5px rgba(black, 0.1); - font-size: 1.5em; + font-size: 2em; font-weight: 600; margin: rem(12px); - padding: rem(6px); - -gtk-icon-size: 32px; - -gtk-icon-style: symbolic; - - &.communication, - &.media-production, - &.writing-language, - &.internet { - -gtk-icon-style: regular; - } + padding: rem(12px); + min-height: 3em; + -gtk-icon-size: 48px; &.accessibility { background-image: @@ -266,20 +259,24 @@ 0 0 0 1px rgba(black, 0.15), 0 3px 2px -1px rgba(black, 0.15), 0 3px 5px rgba(black, 0.1); - - image { - color: #{'@SLATE_500'}; - -gtk-icon-shadow: - 0 1px 2px #{'alpha(@SLATE_900, 0.2)'}, - 0 2px 6px #{'alpha(@SLATE_900, 0.1)'}; - } + font-weight: 900; + letter-spacing: -1px; + -gtk-icon-shadow: + 0 1px 2px #{'alpha(@SLATE_900, 0.2)'}, + 0 2px 6px #{'alpha(@SLATE_900, 0.1)'}; label { color: #{'@BLUEBERRY_500'}; + font-size: 1.5em; text-shadow: 0 1px 2px #{'alpha(@BLUEBERRY_900, 0.2)'}, 0 2px 6px #{'alpha(@BLUEBERRY_900, 0.1)'}; } + + image { + color: #{'@SLATE_500'}; + -gtk-icon-size: rem(64px); + } } &.graphics { @@ -486,6 +483,7 @@ 0 3px 5px rgba(black, 0.1); color: #{'@BANANA_300'}; text-shadow: 0 1px 2px #{'alpha(@SLATE_900, 0.75)'}; + -gtk-icon-shadow: 0 1px 2px #{'alpha(@SLATE_900, 0.75)'}; } &.office { diff --git a/src/Core/CategoryManager.vala b/src/Core/CategoryManager.vala index 965657f6b9..c7aea211f3 100644 --- a/src/Core/CategoryManager.vala +++ b/src/Core/CategoryManager.vala @@ -20,8 +20,7 @@ public class AppCenter.CategoryManager : Object { append ("accessories", _("Accessories"), "applications-accessories", {"Utility"}); append ("audio", _("Audio"), "appcenter-audio", {"Audio", "Music"}); - // FIXME: This is an app icon, not a category icon - append ("communication", _("Communication"), "internet-chat", { + append ("communication", _("Communication"), "", { "Chat", "ContactManagement", "Email", @@ -31,7 +30,7 @@ public class AppCenter.CategoryManager : Object { "VideoConference" }); - append ("development", _("Development"), "applications-development", { + append ("development", _("Development"), "", { "Database", "Debugger", "Development", @@ -42,7 +41,6 @@ public class AppCenter.CategoryManager : Object { "WebDevelopment" }); - // FIXME: Icon missing append ("education", _("Education"), "", {"Education"}); append ("finance", _("Finance"), "appcenter-finance", { @@ -50,7 +48,7 @@ public class AppCenter.CategoryManager : Object { "Finance" }); - append ("games", _("Fun & Games"), "applications-games", { + append ("games", _("Fun & Games"), "appcenter-games-symbolic", { "ActionGame", "AdventureGame", "Amusement", @@ -68,7 +66,7 @@ public class AppCenter.CategoryManager : Object { "StrategyGame" }); - append ("graphics", _("Graphics"), "applications-graphics", { + append ("graphics", _("Graphics"), "", { "2DGraphics", "3DGraphics", "Graphics", @@ -83,7 +81,7 @@ public class AppCenter.CategoryManager : Object { "P2P" }); - append ("science", _("Math, Science, & Engineering"), "applications-science", { + append ("science", _("Math, Science, & Engineering"), "", { "ArtificialIntelligence", "Astronomy", "Biology", @@ -103,7 +101,7 @@ public class AppCenter.CategoryManager : Object { "Science" }); - append ("media-production", _("Media Production"), "applications-multimedia", { + append ("media-production", _("Media Production"), "appcenter-multimedia-symbolic", { "AudioVideoEditing", "Midi", "Mixer", @@ -111,7 +109,7 @@ public class AppCenter.CategoryManager : Object { "Sequencer" }); - append ("office", _("Office"), "applications-office", { + append ("office", _("Office"), "appcenter-office-symbolic", { "Office", "Presentation", "Publishing", @@ -124,9 +122,9 @@ public class AppCenter.CategoryManager : Object { "System" }); - append ("accessibility", _("Universal Access"), "preferences-desktop-accessibility", {"Accessibility"}); + append ("accessibility", _("Universal Access"), "appcenter-accessibility-symbolic", {"Accessibility"}); - append ("video", _("Video"), "appcenter-video", { + append ("video", _("Video"), "appcenter-video-symbolic", { "Tuner", "TV", "Video" @@ -143,7 +141,6 @@ public class AppCenter.CategoryManager : Object { "WordProcessor" }); - // FIXME: MISSING ICON append ("privacy-security", _("Privacy & Security"), "preferences-system-privacy", { "Security" }); diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index c26d16c4ff..b5dfaf2cbd 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -106,108 +106,9 @@ public class AppCenter.Homepage : Adw.NavigationPage { }); foreach (unowned var category in CategoryManager.get_default ().categories) { - category_flow.append (new CategoryCard (category.name, category.icon, {}, category.id)); + category_flow.append (new CategoryCard (category)); } - // var games_card = new GamesCard (); - - // category_flow.append (new CategoryCard (_("Accessories"), "applications-accessories", {"Utility"}, "accessories")); - // category_flow.append (new CategoryCard (_("Audio"), "appcenter-audio-symbolic", {"Audio", "Music"}, "audio")); - // category_flow.append (new CategoryCard (_("Communication"), "", { - // "Chat", - // "ContactManagement", - // "Email", - // "InstantMessaging", - // "IRCClient", - // "Telephony", - // "VideoConference" - // }, "communication")); - // category_flow.append (new CategoryCard (_("Development"), "", { - // "Database", - // "Debugger", - // "Development", - // "GUIDesigner", - // "IDE", - // "RevisionControl", - // "TerminalEmulator", - // "WebDevelopment" - // }, "development")); - // category_flow.append (new CategoryCard (_("Education"), "", {"Education"}, "education")); - // category_flow.append (new CategoryCard (_("Finance"), "appcenter-finance-symbolic", { - // "Economy", - // "Finance" - // }, "finance")); - // category_flow.append (games_card); - // category_flow.append (new CategoryCard (_("Graphics"), "", { - // "2DGraphics", - // "3DGraphics", - // "Graphics", - // "ImageProcessing", - // "Photography", - // "RasterGraphics", - // "VectorGraphics" - // }, "graphics")); - // category_flow.append (new CategoryCard (_("Internet"), "applications-internet", { - // "Network", - // "P2P" - // }, "internet")); - // category_flow.append (new CategoryCard (_("Math, Science, & Engineering"), "", { - // "ArtificialIntelligence", - // "Astronomy", - // "Biology", - // "Calculator", - // "Chemistry", - // "ComputerScience", - // "DataVisualization", - // "Electricity", - // "Electronics", - // "Engineering", - // "Geology", - // "Geoscience", - // "Math", - // "NumericalAnalysis", - // "Physics", - // "Robotics", - // "Science" - // }, "science")); - // category_flow.append (new CategoryCard (_("Media Production"), "appcenter-multimedia-symbolic", { - // "AudioVideoEditing", - // "Midi", - // "Mixer", - // "Recorder", - // "Sequencer" - // }, "media-production")); - // category_flow.append (new CategoryCard (_("Office"), "appcenter-office-symbolic", { - // "Office", - // "Presentation", - // "Publishing", - // "Spreadsheet", - // "WordProcessor" - // }, "office")); - // category_flow.append (new CategoryCard (_("System"), "applications-system-symbolic", { - // "Monitor", - // "System" - // }, "system")); - // category_flow.append (new CategoryCard (_("Universal Access"), "appcenter-accessibility-symbolic", {"Accessibility"}, "accessibility")); - // category_flow.append (new CategoryCard (_("Video"), "appcenter-video-symbolic", { - // "Tuner", - // "TV", - // "Video" - // }, "video")); - // category_flow.append (new CategoryCard (_("Writing & Language"), "preferences-desktop-locale", { - // "Dictionary", - // "Languages", - // "Literature", - // "OCR", - // "TextEditor", - // "TextTools", - // "Translation", - // "WordProcessor" - // }, "writing-language")); - // category_flow.append (new CategoryCard (_("Privacy & Security"), "preferences-system-privacy", { - // "Security", - // }, "privacy-security")); - var box = new Gtk.Box (VERTICAL, 0); box.append (banner_carousel); box.append (banner_dots); @@ -434,38 +335,37 @@ public class AppCenter.Homepage : Adw.NavigationPage { private class CategoryCard : Gtk.FlowBoxChild { public AppStream.Category category { get; construct; } - public CategoryCard (string name, string icon, string[] groups, string style) { - var category = new AppStream.Category () { - id = style - }; - category.set_name (name); - category.set_icon (icon); - - foreach (var group in groups) { - category.add_desktop_group (group); - } - + public CategoryCard (AppStream.Category category) { Object (category: category); } construct { - var display_image = new Gtk.Image.from_icon_name (category.icon) { - halign = END, - valign = CENTER, - }; + var name_label = new Gtk.Label (category.name) { - halign = START, wrap = true, - max_width_chars = 15, - xalign = 0 + max_width_chars = 15 }; var box = new Gtk.Box (HORIZONTAL, 6) { halign = CENTER, valign = CENTER }; - box.append (display_image); + + if (category.icon != "") { + var display_image = new Gtk.Image.from_icon_name (category.icon) { + halign = END, + valign = CENTER, + }; + + box.append (display_image); + + name_label.xalign = 0; + name_label.halign = START; + } else { + name_label.justify = CENTER; + } + box.append (name_label); var expanded_grid = new Gtk.Grid () { @@ -483,6 +383,16 @@ public class AppCenter.Homepage : Adw.NavigationPage { child = content_area; + if (category.id == "accessibility") { + name_label.label = category.name.up (); + } else { + name_label.label = category.name; + } + + if (category.id == "science") { + name_label.justify = CENTER; + } + AppCenterCore.UpdateManager.get_default ().installed_apps_changed.connect (() => { Idle.add (() => { // Clear the cached categories when the AppStream pool is updated From 66a83e8a8db91e3a8c3263b3e3a9a7877376c39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 6 Mar 2025 12:34:36 -0800 Subject: [PATCH 3/3] Fix extra newlines --- src/Views/Homepage.vala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index b5dfaf2cbd..9f05e58f5e 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -340,8 +340,6 @@ public class AppCenter.Homepage : Adw.NavigationPage { } construct { - - var name_label = new Gtk.Label (category.name) { wrap = true, max_width_chars = 15