diff --git a/data/io.github.kolunmi.Bazaar.gschema.xml b/data/io.github.kolunmi.Bazaar.gschema.xml index c1d58796..5ed4a108 100644 --- a/data/io.github.kolunmi.Bazaar.gschema.xml +++ b/data/io.github.kolunmi.Bazaar.gschema.xml @@ -21,6 +21,11 @@ Show Only Verified Content Hide applications which are not verified on Flathub + + false + Show Only Mobile apps + Hide applications which do not work well on mobile + true Debounce Search Inputs diff --git a/src/bz-application.c b/src/bz-application.c index 42ef87b8..2b42c98a 100644 --- a/src/bz-application.c +++ b/src/bz-application.c @@ -2139,6 +2139,7 @@ show_hide_app_setting_changed (BzApplication *self, bz_state_info_set_show_only_foss (self->state, g_settings_get_boolean (self->settings, "show-only-foss")); bz_state_info_set_show_only_flathub (self->state, g_settings_get_boolean (self->settings, "show-only-flathub")); bz_state_info_set_show_only_verified (self->state, g_settings_get_boolean (self->settings, "show-only-verified")); + bz_state_info_set_show_only_mobile (self->state, g_settings_get_boolean (self->settings, "show-only-mobile")); gtk_filter_changed (GTK_FILTER (self->group_filter), GTK_FILTER_CHANGE_DIFFERENT); gtk_filter_changed (GTK_FILTER (self->appid_filter), GTK_FILTER_CHANGE_DIFFERENT); @@ -2765,6 +2766,15 @@ init_service_struct (BzApplication *self, G_CALLBACK (show_hide_app_setting_changed), self); + bz_state_info_set_show_only_mobile ( + self->state, + g_settings_get_boolean (self->settings, "show-only-mobile")); + g_signal_connect_swapped ( + self->settings, + "changed::show-only-mobile", + G_CALLBACK (show_hide_app_setting_changed), + self); + self->blocklist_regexes = g_ptr_array_new_with_free_func ( (GDestroyNotify) g_ptr_array_unref); self->blocklists_provider = bz_content_provider_new (); @@ -3119,6 +3129,9 @@ validate_group_for_ui (BzApplication *self, if (bz_state_info_get_show_only_verified (self->state) && !bz_entry_group_get_is_verified (group)) return FALSE; + if (bz_state_info_get_show_only_mobile (self->state) && + !bz_entry_group_get_is_mobile_friendly (group)) + return FALSE; if (self->malcontent != NULL) { diff --git a/src/bz-apps-page.blp b/src/bz-apps-page.blp index 07c4dc9d..de0f16a7 100644 --- a/src/bz-apps-page.blp +++ b/src/bz-apps-page.blp @@ -76,6 +76,7 @@ template $BzAppsPage: Adw.NavigationPage { Box content_box { orientation: vertical; + valign: start; spacing: 10; margin-start: 30; margin-end: 30; diff --git a/src/bz-entry-group.c b/src/bz-entry-group.c index d9df0f21..06005397 100644 --- a/src/bz-entry-group.c +++ b/src/bz-entry-group.c @@ -45,6 +45,7 @@ struct _BzEntryGroup char *dark_accent_color; gboolean is_flathub; gboolean is_verified; + gboolean is_mobile_friendly; char *search_tokens; char *remote_repos_string; char *eol; @@ -93,6 +94,7 @@ enum PROP_DARK_ACCENT_COLOR, PROP_IS_FLATHUB, PROP_IS_VERIFIED, + PROP_IS_MOBILE_FRIENDLY, PROP_SEARCH_TOKENS, PROP_UI_ENTRY, PROP_REMOTE_REPOS_STRING, @@ -209,6 +211,9 @@ bz_entry_group_get_property (GObject *object, case PROP_IS_VERIFIED: g_value_set_boolean (value, bz_entry_group_get_is_verified (self)); break; + case PROP_IS_MOBILE_FRIENDLY: + g_value_set_boolean (value, bz_entry_group_get_is_mobile_friendly (self)); + break; case PROP_SEARCH_TOKENS: g_value_set_boxed (value, bz_entry_group_get_search_tokens (self)); break; @@ -280,6 +285,7 @@ bz_entry_group_set_property (GObject *object, case PROP_DARK_ACCENT_COLOR: case PROP_IS_FLATHUB: case PROP_IS_VERIFIED: + case PROP_IS_MOBILE_FRIENDLY: case PROP_SEARCH_TOKENS: case PROP_EOL: case PROP_UI_ENTRY: @@ -381,6 +387,12 @@ bz_entry_group_class_init (BzEntryGroupClass *klass) NULL, NULL, FALSE, G_PARAM_READABLE); + props[PROP_IS_MOBILE_FRIENDLY] = + g_param_spec_boolean ( + "is-mobile-friendly", + NULL, NULL, FALSE, + G_PARAM_READABLE); + props[PROP_SEARCH_TOKENS] = g_param_spec_string ( "search-tokens", @@ -525,6 +537,7 @@ bz_entry_group_new_for_single_entry (BzEntry *entry) const char *dark_accent_color = NULL; gboolean is_flathub = FALSE; gboolean is_verified = FALSE; + gboolean is_mobile_friendly = FALSE; const char *eol = NULL; guint64 installed_size = 0; const char *donation_url = NULL; @@ -547,6 +560,7 @@ bz_entry_group_new_for_single_entry (BzEntry *entry) dark_accent_color = bz_entry_get_dark_accent_color (entry); is_flathub = bz_entry_get_is_flathub (entry); is_verified = bz_entry_is_verified (entry); + is_mobile_friendly = bz_entry_get_is_mobile_friendly (entry); eol = bz_entry_get_eol (entry); installed_size = bz_entry_get_installed_size (entry); donation_url = bz_entry_get_donation_url (entry); @@ -569,8 +583,9 @@ bz_entry_group_new_for_single_entry (BzEntry *entry) group->light_accent_color = g_strdup (light_accent_color); if (dark_accent_color != NULL) group->dark_accent_color = g_strdup (dark_accent_color); - group->is_flathub = is_flathub; - group->is_verified = is_verified; + group->is_flathub = is_flathub; + group->is_verified = is_verified; + group->is_mobile_friendly = is_mobile_friendly; if (eol != NULL) group->eol = g_strdup (eol); group->installed_size = installed_size; @@ -680,6 +695,13 @@ bz_entry_group_get_is_verified (BzEntryGroup *self) return self->is_verified; } +gboolean +bz_entry_group_get_is_mobile_friendly (BzEntryGroup *self) +{ + g_return_val_if_fail (BZ_IS_ENTRY_GROUP (self), FALSE); + return self->is_mobile_friendly; +} + const char * bz_entry_group_get_search_tokens (BzEntryGroup *self) { @@ -858,6 +880,7 @@ bz_entry_group_add (BzEntryGroup *self, const char *dark_accent_color = NULL; gboolean is_flathub = FALSE; gboolean is_verified = FALSE; + gboolean is_mobile_friendly = FALSE; guint64 installed_size = 0; GListModel *addons = NULL; int n_addons = 0; @@ -907,6 +930,7 @@ bz_entry_group_add (BzEntryGroup *self, dark_accent_color = bz_entry_get_dark_accent_color (entry); is_flathub = bz_entry_get_is_flathub (entry); is_verified = bz_entry_is_verified (entry); + is_mobile_friendly = bz_entry_get_is_mobile_friendly (entry); installed_size = bz_entry_get_installed_size (entry); donation_url = bz_entry_get_donation_url (entry); entry_categories = bz_entry_get_categories (entry); @@ -987,6 +1011,11 @@ bz_entry_group_add (BzEntryGroup *self, self->is_verified = is_verified; g_object_notify_by_pspec (G_OBJECT (self), props[PROP_IS_VERIFIED]); } + if (!!is_mobile_friendly != !!self->is_mobile_friendly) + { + self->is_mobile_friendly = is_mobile_friendly; + g_object_notify_by_pspec (G_OBJECT (self), props[PROP_IS_MOBILE_FRIENDLY]); + } if (installed_size != self->installed_size) { self->installed_size = installed_size; diff --git a/src/bz-entry-group.h b/src/bz-entry-group.h index 88a5133d..96c867e5 100644 --- a/src/bz-entry-group.h +++ b/src/bz-entry-group.h @@ -76,6 +76,9 @@ bz_entry_group_get_is_flathub (BzEntryGroup *self); gboolean bz_entry_group_get_is_verified (BzEntryGroup *self); +gboolean +bz_entry_group_get_is_mobile_friendly (BzEntryGroup *self); + const char * bz_entry_group_get_search_tokens (BzEntryGroup *self); diff --git a/src/bz-preferences-dialog.blp b/src/bz-preferences-dialog.blp index d24c1a63..2a16d0f7 100644 --- a/src/bz-preferences-dialog.blp +++ b/src/bz-preferences-dialog.blp @@ -45,6 +45,11 @@ template $BzPreferencesDialog: Adw.PreferencesDialog { subtitle: _("Hide results that are not verified on Flathub"); } + Adw.SwitchRow only_mobile_switch { + title: _("Mobile Friendly Only"); + subtitle: _("Hide applications that are not optimized for mobile devices"); + } + Adw.SwitchRow hide_eol_switch { title: _("Hide EOL Apps"); subtitle: _("Hide apps which are no longer supported by their developers"); @@ -92,4 +97,4 @@ template $BzPreferencesDialog: Adw.PreferencesDialog { } } } -} +} \ No newline at end of file diff --git a/src/bz-preferences-dialog.c b/src/bz-preferences-dialog.c index 6c985790..63cf9ad8 100644 --- a/src/bz-preferences-dialog.c +++ b/src/bz-preferences-dialog.c @@ -19,6 +19,7 @@ */ #include "bz-preferences-dialog.h" +#include "bz-template-callbacks.h" #include typedef struct @@ -29,28 +30,28 @@ typedef struct } BarTheme; static const BarTheme bar_themes[] = { - { "accent-color", "accent-color-theme", N_ ("Accent Color") }, - { "pride-rainbow-flag", "pride-rainbow-flag-theme", N_ ("Pride Colors") }, - { "lesbian-pride-flag", "lesbian-pride-flag-theme", N_ ("Lesbian Pride Colors") }, - { "gay-pride-flag", "gay-pride-flag-theme", N_ ("Male Homosexual Pride Colors") }, - { "transgender-flag", "transgender-flag-theme", N_ ("Transgender Pride Colors") }, - { "nonbinary-flag", "nonbinary-flag-theme", N_ ("Nonbinary Pride Colors") }, - { "bisexual-flag", "bisexual-flag-theme", N_ ("Bisexual Pride Colors") }, - { "asexual-flag", "asexual-flag-theme", N_ ("Asexual Pride Colors") }, - { "pansexual-flag", "pansexual-flag-theme", N_ ("Pansexual Pride Colors") }, - { "aromantic-flag", "aromantic-flag-theme", N_ ("Aromantic Pride Colors") }, - { "genderfluid-flag", "genderfluid-flag-theme", N_ ("Genderfluid Pride Colors") }, - { "polysexual-flag", "polysexual-flag-theme", N_ ("Polysexual Pride Colors") }, - { "omnisexual-flag", "omnisexual-flag-theme", N_ ("Omnisexual Pride Colors") }, - { "aroace-flag", "aroace-flag-theme", N_ ("Aroace Pride Colors") }, - { "agender-flag", "agender-flag-theme", N_ ("Agender Pride Colors") }, - { "genderqueer-flag", "genderqueer-flag-theme", N_ ("Genderqueer Pride Colors") }, - { "intersex-flag", "intersex-flag-theme", N_ ("Intersex Pride Colors") }, - { "demigender-flag", "demigender-flag-theme", N_ ("Demigender Pride Colors") }, - { "biromantic-flag", "biromantic-flag-theme", N_ ("Biromantic Pride Colors") }, - { "disability-flag", "disability-flag-theme", N_ ("Disability Pride Colors") }, - { "femboy-flag", "femboy-flag-theme", N_ ("Femboy Pride Colors") }, - { "neutrois-flag", "neutrois-flag-theme", N_ ("Neutrois Pride Colors") }, + { "accent-color", "accent-color-theme", N_ ("Accent Color") }, + { "pride-rainbow-flag", "pride-rainbow-flag-theme", N_ ("Pride Colors") }, + { "lesbian-pride-flag", "lesbian-pride-flag-theme", N_ ("Lesbian Pride Colors") }, + { "gay-pride-flag", "gay-pride-flag-theme", N_ ("Male Homosexual Pride Colors") }, + { "transgender-flag", "transgender-flag-theme", N_ ("Transgender Pride Colors") }, + { "nonbinary-flag", "nonbinary-flag-theme", N_ ("Nonbinary Pride Colors") }, + { "bisexual-flag", "bisexual-flag-theme", N_ ("Bisexual Pride Colors") }, + { "asexual-flag", "asexual-flag-theme", N_ ("Asexual Pride Colors") }, + { "pansexual-flag", "pansexual-flag-theme", N_ ("Pansexual Pride Colors") }, + { "aromantic-flag", "aromantic-flag-theme", N_ ("Aromantic Pride Colors") }, + { "genderfluid-flag", "genderfluid-flag-theme", N_ ("Genderfluid Pride Colors") }, + { "polysexual-flag", "polysexual-flag-theme", N_ ("Polysexual Pride Colors") }, + { "omnisexual-flag", "omnisexual-flag-theme", N_ ("Omnisexual Pride Colors") }, + { "aroace-flag", "aroace-flag-theme", N_ ("Aroace Pride Colors") }, + { "agender-flag", "agender-flag-theme", N_ ("Agender Pride Colors") }, + { "genderqueer-flag", "genderqueer-flag-theme", N_ ("Genderqueer Pride Colors") }, + { "intersex-flag", "intersex-flag-theme", N_ ("Intersex Pride Colors") }, + { "demigender-flag", "demigender-flag-theme", N_ ("Demigender Pride Colors") }, + { "biromantic-flag", "biromantic-flag-theme", N_ ("Biromantic Pride Colors") }, + { "disability-flag", "disability-flag-theme", N_ ("Disability Pride Colors") }, + { "femboy-flag", "femboy-flag-theme", N_ ("Femboy Pride Colors") }, + { "neutrois-flag", "neutrois-flag-theme", N_ ("Neutrois Pride Colors") }, }; struct _BzPreferencesDialog @@ -64,6 +65,7 @@ struct _BzPreferencesDialog AdwSwitchRow *only_foss_switch; AdwSwitchRow *only_flathub_switch; AdwSwitchRow *only_verified_switch; + AdwSwitchRow *only_mobile_switch; AdwSwitchRow *search_debounce_switch; GtkFlowBox *flag_buttons_box; AdwSwitchRow *hide_eol_switch; @@ -139,7 +141,7 @@ on_rotate_switch_changed (AdwSwitchRow *row, BzPreferencesDialog *self) { gboolean active = FALSE; - active = adw_switch_row_get_active (row); + active = adw_switch_row_get_active (row); for (guint i = 0; i < G_N_ELEMENTS (bar_themes); i++) { if (active) @@ -205,6 +207,10 @@ bind_settings (BzPreferencesDialog *self) self->only_verified_switch, "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (self->settings, "show-only-mobile", + self->only_mobile_switch, "active", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind (self->settings, "search-debounce", self->search_debounce_switch, "active", G_SETTINGS_BIND_DEFAULT); @@ -214,8 +220,8 @@ bind_settings (BzPreferencesDialog *self) G_SETTINGS_BIND_DEFAULT); g_settings_bind (self->settings, "rotate-flag", - self->rotate_switch, "active", - G_SETTINGS_BIND_DEFAULT); + self->rotate_switch, "active", + G_SETTINGS_BIND_DEFAULT); if (adw_switch_row_get_active (self->rotate_switch)) { @@ -293,9 +299,12 @@ bz_preferences_dialog_class_init (BzPreferencesDialogClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/io/github/kolunmi/Bazaar/bz-preferences-dialog.ui"); + bz_widget_class_bind_all_util_callbacks (widget_class); + gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, only_foss_switch); gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, only_flathub_switch); gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, only_verified_switch); + gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, only_mobile_switch); gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, search_debounce_switch); gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, flag_buttons_box); gtk_widget_class_bind_template_child (widget_class, BzPreferencesDialog, hide_eol_switch); diff --git a/src/bz-state-info.txt b/src/bz-state-info.txt index e8dff14e..d47a6ce8 100644 --- a/src/bz-state-info.txt +++ b/src/bz-state-info.txt @@ -53,6 +53,7 @@ property=settings GSettings G_TYPE_SETTINGS object property=show_only_flathub gboolean G_TYPE_BOOLEAN boolean property=show_only_foss gboolean G_TYPE_BOOLEAN boolean property=show_only_verified gboolean G_TYPE_BOOLEAN boolean +property=show_only_mobile gboolean G_TYPE_BOOLEAN boolean property=syncing gboolean G_TYPE_BOOLEAN boolean property=system_icon_theme GtkIconTheme GTK_TYPE_ICON_THEME object property=transaction_manager BzTransactionManager BZ_TYPE_TRANSACTION_MANAGER object