Merge branch 'cosmic-category' into 'main'

Add COSMIC category support

See merge request World/bazaar!1976
This commit is contained in:
Kolunmi 2026-09-15 23:09:03 +00:00
commit 1bf7756aca
5 changed files with 64 additions and 42 deletions

View file

@ -213,6 +213,7 @@
<file preprocess="xml-stripblanks">icons/io.github.kolumni.Bazaar.Updated.svg</file>
<file preprocess="xml-stripblanks">icons/io.github.kolumni.Bazaar.Adwaita.svg</file>
<file preprocess="xml-stripblanks">icons/io.github.kolumni.Bazaar.Kde.svg</file>
<file preprocess="xml-stripblanks">icons/io.github.kolumni.Bazaar.Cosmic.svg</file>
<file preprocess="xml-stripblanks">icons/io.github.kolunmi.Bazaar.login-github.svg</file>
<file preprocess="xml-stripblanks">icons/io.github.kolunmi.Bazaar.login-gitlab.svg</file>

View file

@ -148,6 +148,7 @@ static const CategoryInfo category_info[] = {
{ "mobile", N_ ("Mobile"), N_ ("Mobile"), N_ ("More Mobile"), FALSE, TRUE, "io.github.kolumni.Bazaar.Mobile", "", NULL },
{ "adwaita", N_ ("Adwaita"), N_ ("Adwaita"), N_ ("More Adwaita"), FALSE, TRUE, "io.github.kolumni.Bazaar.Adwaita", "", NULL },
{ "kde", N_ ("KDE Apps"), N_ ("KDE Apps"), N_ ("More KDE Apps"), FALSE, TRUE, "io.github.kolumni.Bazaar.Kde", "", NULL },
{ "cosmic", N_ ("Made for COSMIC™"),N_ ("For COSMIC™"), N_ ("More COSMIC Apps"), FALSE, TRUE, "io.github.kolumni.Bazaar.Cosmic", "", NULL },
{ "game-only", N_ ("Games"), N_ ("Games"), N_ ("More Games"), FALSE, FALSE, "", "", NULL },
{ "emulators", N_ ("Emulators"), N_ ("Emulators"), N_ ("More Emulators"), FALSE, FALSE, "", "", NULL },
{ "launchers", N_ ("Launchers"), N_ ("Launchers"), N_ ("More Game Launchers"), FALSE, FALSE, "", "", NULL },

View file

@ -23,7 +23,6 @@
#define CATEGORY_FETCH_SIZE 48
#define QUALITY_MODERATION_PAGE_SIZE 300
#define KEYWORD_SEARCH_PAGE_SIZE 48
#define ADWAITA_URL "https://arewelibadwaitayet.com"
#include <json-glib/json-glib.h>
#include <libdex.h>
@ -693,15 +692,22 @@ bz_flathub_state_set_map_factory (BzFlathubState *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MAP_FACTORY]);
}
static gboolean
is_kde_plasma (void)
static const char *
get_de (void)
{
const char *desktop = g_getenv ("XDG_CURRENT_DESKTOP");
const char *desktop = NULL;
desktop = g_getenv ("XDG_CURRENT_DESKTOP");
if (desktop == NULL)
return FALSE;
return "adwaita";
return g_str_equal (desktop, "KDE") || g_strstr_len (desktop, -1, "KDE") != NULL;
if (g_strstr_len (desktop, -1, "KDE") != NULL)
return "kde";
if (g_strstr_len (desktop, -1, "COSMIC") != NULL)
return "cosmic";
return "adwaita";
}
static void
@ -709,14 +715,13 @@ add_category (BzFlathubState *self,
const char *name,
JsonNode *node,
GHashTable *quality_set,
gboolean is_json_object,
gboolean is_toplevel_json,
QualityMode quality_mode,
gboolean is_spotlight)
{
JsonObject *object = NULL;
JsonObjectIter iter = { 0 };
JsonArray *hits_array = NULL;
const char *key = NULL;
JsonArray *toplevel_array = NULL;
const char *app = NULL;
g_autoptr (BzFlathubCategory) category = NULL;
g_autoptr (GtkStringList) store = NULL;
@ -736,34 +741,34 @@ add_category (BzFlathubState *self,
bz_flathub_category_set_is_spotlight (category, is_spotlight);
bz_flathub_category_set_applications (category, G_LIST_MODEL (store));
object = json_node_get_object (node);
if (quality_mode == QUALITY_MODE_RANDOM)
quality_apps = g_ptr_array_new_with_free_func (g_free);
if (is_json_object)
if (is_toplevel_json)
{
if (quality_mode == QUALITY_MODE_RANDOM)
quality_apps = g_ptr_array_new_with_free_func (g_free);
toplevel_array = json_node_get_array (node);
app_count = json_array_get_length (toplevel_array);
json_object_iter_init (&iter, object);
while (json_object_iter_next (&iter, &key, NULL))
for (i = 0; i < app_count; i++)
{
gtk_string_list_append (store, key);
const char *app_id = NULL;
if (g_hash_table_contains (quality_set, key))
app_id = json_array_get_string_element (toplevel_array, i);
gtk_string_list_append (store, app_id);
if (g_hash_table_contains (quality_set, app_id))
{
if (quality_mode == QUALITY_MODE_RANDOM)
g_ptr_array_add (quality_apps, g_strdup (key));
g_ptr_array_add (quality_apps, g_strdup (app_id));
else if (quality_mode == QUALITY_MODE_FIRST)
gtk_string_list_append (quality_store, key);
gtk_string_list_append (quality_store, app_id);
}
app_count++;
}
total_entries = json_object_get_size (object);
total_entries = app_count;
}
else
{
if (quality_mode == QUALITY_MODE_RANDOM)
quality_apps = g_ptr_array_new_with_free_func (g_free);
object = json_node_get_object (node);
hits_array = json_object_get_array_member (object, "hits");
app_count = json_array_get_length (hits_array);
@ -843,7 +848,7 @@ initialize_fiber (GWeakRef *wr)
g_autoptr (BzFlathubState) self = NULL;
g_autoptr (GError) local_error = NULL;
gboolean result = FALSE;
gboolean is_kde = is_kde_plasma ();
const char *de = get_de ();
g_autoptr (GHashTable) quality_set = NULL;
g_autoptr (DexFuture) aotd_f = NULL;
@ -856,7 +861,6 @@ initialize_fiber (GWeakRef *wr)
g_autoptr (DexFuture) trending_f = NULL;
g_autoptr (DexFuture) mobile_f = NULL;
g_autoptr (DexFuture) passing_f = NULL;
g_autoptr (DexFuture) adwaita_f = NULL;
g_autoptr (DexFuture) toolkit_f = NULL;
g_autoptr (DexFuture) emulators_f = NULL;
g_autoptr (DexFuture) launchers_f = NULL;
@ -882,18 +886,18 @@ initialize_fiber (GWeakRef *wr)
} \
G_STMT_END
if (is_kde)
ADD_REQUEST (toolkit_f, "/collection/developer/kde?locale=en");
else
{
adwaita_f = bz_https_query_json (ADWAITA_URL "/api/apps");
if (!dex_await (dex_ref (adwaita_f), &local_error))
{
g_warning ("Failed to complete request to arewelibadwaitayet: %s", local_error->message);
g_clear_error (&local_error);
adwaita_f = NULL;
}
}
{
g_autofree char *made_for_route = NULL;
made_for_route = g_strdup_printf ("/made-for/%s", de);
toolkit_f = bz_query_bazaar_json (made_for_route);
if (!dex_await (dex_ref (toolkit_f), &local_error))
{
g_warning ("Failed to complete request to bazaar %s: %s", made_for_route, local_error->message);
g_clear_error (&local_error);
dex_clear (&toolkit_f);
}
}
ADD_REQUEST (passing_f, "/quality-moderation/passing-apps?page=1&page_size=%d", QUALITY_MODERATION_PAGE_SIZE);
ADD_REQUEST (aotd_f, "/app-picks/app-of-the-day/%s", self->for_day);
@ -1019,10 +1023,8 @@ initialize_fiber (GWeakRef *wr)
}
}
if (is_kde)
add_category (self, "kde", GET_BOXED (toolkit_f), quality_set, FALSE, QUALITY_MODE_RANDOM, FALSE);
else if (adwaita_f != NULL)
add_category (self, "adwaita", GET_BOXED (adwaita_f), quality_set, TRUE, QUALITY_MODE_RANDOM, FALSE);
if (toolkit_f != NULL)
add_category (self, de, GET_BOXED (toolkit_f), quality_set, TRUE, QUALITY_MODE_RANDOM, FALSE);
return dex_future_new_true ();
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" fill="none"><mask id="a" width="103" height="14" x="11" y="103" maskUnits="userSpaceOnUse" style="mask-type:luminance"><path fill="#fff" d="M18.7 103.32c-4.22 0-7.67 3.07-7.67 6.84S14.48 117 18.7 117h86.74c4.23 0 7.67-3.07 7.67-6.84s-3.44-6.84-7.67-6.84z"/></mask><g mask="url(#a)"><path fill="url(#b)" d="M18.7 103.32c-4.22 0-7.67 3.07-7.67 6.84S14.48 117 18.7 117h86.74c4.23 0 7.67-3.07 7.67-6.84s-3.44-6.84-7.67-6.84z"/></g><path fill="#fff" d="M124.16 64.07c0 13.5-5.25 22.89-15.6 27.02-4.35 1.73-9.56 2.62-15.5 2.62H74.64a6.96 6.96 0 0 1 0-13.92H86.5c18.2 0 22.33-3.37 22.33-14.65 0-14.04-5.43-17.27-16.96-17.27H32.28c-11.7 0-16.93 3.31-16.93 17.27 0 11.3 4.37 14.65 22.32 14.65h11.9a6.95 6.95 0 1 1 0 13.92H31.1c-5.94 0-11.15-.89-15.49-2.62C5.25 86.96 0 77.56 0 64.07 0 43.74 11.49 33 33.24 33H90.9c21.75 0 33.25 10.74 33.25 31.07M128.2 117h-.98l-.13-2.96c-.03-.75-.03-1.15.01-1.7h-.01l-1.34 4.06h-.88l-1.46-4.05h-.02q.07.8.02 1.7l-.11 2.95h-.94l.22-5.54h1.38l1.35 3.93 1.27-3.93h1.39zm-6.36-4.7h-1.73v4.7h-1v-4.7h-1.83v-.84H122z"/><defs><linearGradient id="b" x1="11.03" x2="113.11" y1="110.16" y2="110.16" gradientUnits="userSpaceOnUse"><stop stop-color="#FFAE02"/><stop offset=".53" stop-color="#FF972A"/><stop offset="1" stop-color="#FE7E57"/><stop offset="1" stop-color="#FE7E57"/></linearGradient></defs></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -855,6 +855,23 @@ window.narrow .category-tile {
background: linear-gradient(135deg, shade(#3584e4, .95) 0%, shade(#704dac, .95) 100%);
}
.category-tile.category-cosmic {
background: #2e2e2e;
}
@media (prefers-color-scheme: light) {
.category-tile.category-cosmic {
background: #232323;
}
}
.category-tile.category-cosmic:hover {
background: shade(#232323, 1.30);
}
.category-tile.category-cosmic:active {
background: shade(#232323, 1.20);
}
.category-tile.category-adwaita image,
.category-tile.category-kde image {
-gtk-icon-shadow: none;