Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 53 additions & 28 deletions src/bz-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static DexFuture *
watch_backend_notifs_then_loop_cb (DexFuture *future,
GWeakRef *wr);

static void
static BzEntryGroup *
fiber_replace_entry (BzApplication *self,
BzEntry *entry);

Expand Down Expand Up @@ -1119,10 +1119,11 @@ init_fiber (GWeakRef *wr)
entries, (GCompareDataFunc) cmp_entry, NULL);
for (guint i = 0; i < entries->len; i++)
{
BzEntry *entry = NULL;
BzEntry *entry = NULL;
g_autoptr (BzEntryGroup) group = NULL;

entry = g_ptr_array_index (entries, i);
fiber_replace_entry (self, entry);
group = fiber_replace_entry (self, entry);
}

gtk_filter_changed (GTK_FILTER (self->group_filter), GTK_FILTER_CHANGE_LESS_STRICT);
Expand Down Expand Up @@ -1310,23 +1311,17 @@ respond_to_flatpak_fiber (RespondToFlatpakData *data)
break;
case BZ_BACKEND_NOTIFICATION_KIND_REPLACE_ENTRY:
{
BzEntry *entry = NULL;
BzEntry *entry = NULL;
g_autoptr (BzEntryGroup) group = NULL;

entry = bz_backend_notification_get_entry (notif);
fiber_replace_entry (self, entry);
group = fiber_replace_entry (self, entry);

g_ptr_array_add (build_futures, bz_entry_cache_manager_add (self->cache, entry));
if (bz_entry_is_of_kinds (entry, BZ_ENTRY_KIND_APPLICATION))
if (group != NULL)
{
const char *id = NULL;
BzEntryGroup *group = NULL;

update_filters = TRUE;

id = bz_entry_get_id (entry);
group = g_hash_table_lookup (self->ids_to_groups, id);
if (group != NULL)
g_ptr_array_add (build_notify_groups, g_object_ref (group));
g_ptr_array_add (build_notify_groups, g_object_ref (group));
}

self->n_notifications_incoming--;
Expand Down Expand Up @@ -1626,6 +1621,7 @@ open_flatpakref_fiber (OpenFlatpakrefData *data)
g_autoptr (BzApplication) self = NULL;
GFile *file = data->file;
g_autoptr (GError) local_error = NULL;
gboolean result = FALSE;
g_autoptr (DexFuture) future = NULL;
GtkWindow *window = NULL;
const GValue *value = NULL;
Expand All @@ -1647,14 +1643,36 @@ open_flatpakref_fiber (OpenFlatpakrefData *data)
{
BzEntry *entry = NULL;

entry = g_value_get_object (value);
bz_window_show_entry (BZ_WINDOW (window), entry);
entry = g_value_get_object (value);
result = dex_await (bz_entry_cache_manager_add (self->cache, entry), &local_error);
if (result)
{
g_autoptr (BzEntryGroup) group = NULL;

group = fiber_replace_entry (self, entry);
if (group != NULL)
bz_window_show_group (BZ_WINDOW (window), group);
else
/* TODO: handle standalone addons & runtimes in dedicated UI */
bz_show_error_for_widget (
GTK_WIDGET (window),
"Non-Application Bundle",
"This flatpak ref is a standalone addon/runtime");
}
else
bz_show_error_for_widget (
GTK_WIDGET (window),
_ ("Failed to open package"),
local_error->message);
}
else
open_generic_id (self, g_value_get_string (value));
}
else
bz_show_error_for_widget (GTK_WIDGET (window), _ ("Failed to open .flatpakref"), local_error->message);
bz_show_error_for_widget (
GTK_WIDGET (window),
_ ("Failed to open package"),
local_error->message);

return dex_future_new_true ();
}
Expand Down Expand Up @@ -1845,7 +1863,7 @@ watch_backend_notifs_then_loop_cb (DexFuture *future,
return g_steal_pointer (&ret_future);
}

static void
static BzEntryGroup *
fiber_replace_entry (BzApplication *self,
BzEntry *entry)
{
Expand All @@ -1856,14 +1874,15 @@ fiber_replace_entry (BzApplication *self,
gboolean installed = FALSE;
const char *flatpak_id = NULL;
const char *version = NULL;
g_autoptr (BzEntryGroup) group = NULL;

id = bz_entry_get_id (entry);
unique_id = bz_entry_get_unique_id (entry);
unique_id_checksum = bz_entry_get_unique_id_checksum (entry);
if (id == NULL ||
unique_id == NULL ||
unique_id_checksum == NULL)
return;
return NULL;
user = bz_flatpak_entry_is_user (BZ_FLATPAK_ENTRY (entry));

installed = g_hash_table_contains (self->installed_set, unique_id);
Expand Down Expand Up @@ -1904,26 +1923,28 @@ fiber_replace_entry (BzApplication *self,

if (bz_entry_is_of_kinds (entry, BZ_ENTRY_KIND_APPLICATION))
{
BzEntryGroup *group = NULL;
gboolean ignore_eol = FALSE;
const char *runtime_name = NULL;
BzEntry *eol_runtime = NULL;
BzEntryGroup *existing_group = NULL;
gboolean ignore_eol = FALSE;
const char *runtime_name = NULL;
BzEntry *eol_runtime = NULL;

group = g_hash_table_lookup (self->ids_to_groups, id);
existing_group = g_hash_table_lookup (self->ids_to_groups, id);
if (self->ignore_eol_set != NULL)
ignore_eol = g_hash_table_contains (self->ignore_eol_set, id);

runtime_name = bz_flatpak_entry_get_application_runtime (BZ_FLATPAK_ENTRY (entry));
if (!ignore_eol && runtime_name != NULL)
eol_runtime = g_hash_table_lookup (self->eol_runtimes, runtime_name);

if (group != NULL)
if (existing_group != NULL)
{
bz_entry_group_add (group, entry, eol_runtime, ignore_eol);
if (installed && !g_list_store_find (self->installed_apps, group, NULL))
bz_entry_group_add (existing_group, entry, eol_runtime, ignore_eol);
if (installed && !g_list_store_find (self->installed_apps, existing_group, NULL))
g_list_store_insert_sorted (
self->installed_apps, group,
self->installed_apps, existing_group,
(GCompareDataFunc) cmp_group, NULL);

group = g_object_ref (existing_group);
}
else
{
Expand All @@ -1940,6 +1961,8 @@ fiber_replace_entry (BzApplication *self,
g_list_store_insert_sorted (
self->installed_apps, new_group,
(GCompareDataFunc) cmp_group, NULL);

group = g_object_ref (new_group);
}
}

Expand Down Expand Up @@ -1996,6 +2019,8 @@ fiber_replace_entry (BzApplication *self,
"does not seem to extend anything",
unique_id);
}

return g_steal_pointer (&group);
}

static void
Expand Down
80 changes: 0 additions & 80 deletions src/bz-entry-group.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,86 +509,6 @@ bz_entry_group_new (BzApplicationMapFactory *factory)
return group;
}

BzEntryGroup *
bz_entry_group_new_for_single_entry (BzEntry *entry)
{
BzEntryGroup *group = NULL;
const char *id = NULL;
const char *unique_id = NULL;
const char *title = NULL;
const char *developer = NULL;
const char *description = NULL;
GIcon *mini_icon = NULL;
const char *search_tokens = NULL;
gboolean is_floss = FALSE;
const char *light_accent_color = NULL;
const char *dark_accent_color = NULL;
gboolean is_flathub = FALSE;
gboolean is_verified = FALSE;
const char *eol = NULL;
guint64 installed_size = 0;
const char *donation_url = NULL;
GListModel *entry_categories = NULL;
DexFuture *future = NULL;

g_return_val_if_fail (BZ_IS_ENTRY (entry), NULL);

group = g_object_new (BZ_TYPE_ENTRY_GROUP, NULL);

id = bz_entry_get_id (entry);
unique_id = bz_entry_get_unique_id (entry);
title = bz_entry_get_title (entry);
developer = bz_entry_get_developer (entry);
description = bz_entry_get_description (entry);
mini_icon = bz_entry_get_mini_icon (entry);
search_tokens = bz_entry_get_search_tokens (entry);
is_floss = bz_entry_get_is_foss (entry);
light_accent_color = bz_entry_get_light_accent_color (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);
eol = bz_entry_get_eol (entry);
installed_size = bz_entry_get_installed_size (entry);
donation_url = bz_entry_get_donation_url (entry);
entry_categories = bz_entry_get_categories (entry);

if (id != NULL)
group->id = g_strdup (id);
if (title != NULL)
group->title = g_strdup (title);
if (developer != NULL)
group->developer = g_strdup (developer);
if (description != NULL)
group->description = g_strdup (description);
if (mini_icon != NULL)
group->mini_icon = g_object_ref (mini_icon);
if (search_tokens != NULL)
group->search_tokens = g_strdup (search_tokens);
group->is_floss = is_floss;
if (light_accent_color != NULL)
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;
if (eol != NULL)
group->eol = g_strdup (eol);
group->installed_size = installed_size;
if (donation_url != NULL)
group->donation_url = g_strdup (donation_url);
if (entry_categories != NULL)
group->categories = g_object_ref (entry_categories);

if (unique_id != NULL)
gtk_string_list_append (group->unique_ids, unique_id);

future = dex_future_new_for_object (entry);
group->standalone_ui_entry = bz_result_new (future);
dex_unref (future);

return group;
}

GMutexLocker *
bz_entry_group_lock (BzEntryGroup *self)
{
Expand Down
3 changes: 0 additions & 3 deletions src/bz-entry-group.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ G_DECLARE_FINAL_TYPE (BzEntryGroup, bz_entry_group, BZ, ENTRY_GROUP, GObject)
BzEntryGroup *
bz_entry_group_new (BzApplicationMapFactory *factory);

BzEntryGroup *
bz_entry_group_new_for_single_entry (BzEntry *entry);

/* Only necessary if reading props from another thread, writing is always
prohibited */
GMutexLocker *
Expand Down
Loading