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
76 changes: 55 additions & 21 deletions src/bz-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,17 @@ enumerate_disk_entries_fiber (GWeakRef *wr)
future = g_ptr_array_index (futures, i);
value = dex_future_get_value (future, &local_error);
if (value != NULL)
g_ptr_array_add (entries, g_value_dup_object (value));
{
g_autoptr (BzEntry) entry = NULL;

entry = g_value_dup_object (value);
if (BZ_IS_FLATPAK_ENTRY (entry) &&
bz_flatpak_entry_get_bundle_path (BZ_FLATPAK_ENTRY (entry)))
/* refrain from restoring bundle entries */
continue;

g_ptr_array_add (entries, g_steal_pointer (&entry));
}
else
{
g_warning ("Unable to retrieve cached entry: %s", local_error->message);
Expand Down Expand Up @@ -1363,6 +1373,17 @@ respond_to_flatpak_fiber (RespondToFlatpakData *data)
kind = bz_backend_notification_get_kind (notif);
switch (kind)
{
case BZ_BACKEND_NOTIFICATION_KIND_PRESENT_ID:
{
const char *id = NULL;

id = bz_backend_notification_get_generic_id (notif);
if (id == NULL)
break;

open_generic_id (self, id);
}
break;
case BZ_BACKEND_NOTIFICATION_KIND_ERROR:
{
const char *error = NULL;
Expand Down Expand Up @@ -1414,6 +1435,23 @@ respond_to_flatpak_fiber (RespondToFlatpakData *data)
update_labels = TRUE;
}
break;
case BZ_BACKEND_NOTIFICATION_KIND_INVALIDATE_REMOTES:
{
g_autoptr (GListModel) repos = NULL;

repos = dex_await_object (
bz_backend_list_repositories (BZ_BACKEND (self->flatpak), NULL),
&local_error);

if (repos != NULL)
bz_state_info_set_repositories (self->state, repos);
else
{
g_warning ("Failed to enumerate repositories: %s", local_error->message);
g_clear_error (&local_error);
}
}
break;
case BZ_BACKEND_NOTIFICATION_KIND_REMOTE_SYNC_START:
{
const char *remote_name = NULL;
Expand Down Expand Up @@ -1542,11 +1580,13 @@ respond_to_flatpak_fiber (RespondToFlatpakData *data)
}
break;
case BZ_BACKEND_NOTIFICATION_KIND_ERROR:
case BZ_BACKEND_NOTIFICATION_KIND_TELL_INCOMING:
case BZ_BACKEND_NOTIFICATION_KIND_REPLACE_ENTRY:
case BZ_BACKEND_NOTIFICATION_KIND_REMOTE_SYNC_START:
case BZ_BACKEND_NOTIFICATION_KIND_REMOTE_SYNC_FINISH:
case BZ_BACKEND_NOTIFICATION_KIND_EXTERNAL_CHANGE:
case BZ_BACKEND_NOTIFICATION_KIND_INVALIDATE_REMOTES:
case BZ_BACKEND_NOTIFICATION_KIND_PRESENT_ID:
case BZ_BACKEND_NOTIFICATION_KIND_REMOTE_SYNC_FINISH:
case BZ_BACKEND_NOTIFICATION_KIND_REMOTE_SYNC_START:
case BZ_BACKEND_NOTIFICATION_KIND_REPLACE_ENTRY:
case BZ_BACKEND_NOTIFICATION_KIND_TELL_INCOMING:
default:
g_assert_not_reached ();
};
Expand Down Expand Up @@ -1763,7 +1803,6 @@ open_flatpakref_fiber (OpenFlatpakrefData *data)
GFile *file = data->file;
g_autoptr (GError) local_error = NULL;
g_autoptr (DexFuture) future = NULL;
GtkWindow *window = NULL;
const GValue *value = NULL;

bz_weak_get_or_return_reject (self, data->self);
Expand All @@ -1772,25 +1811,20 @@ open_flatpakref_fiber (OpenFlatpakrefData *data)
future = bz_backend_load_local_package (BZ_BACKEND (self->flatpak), file, NULL);
dex_await (dex_ref (future), NULL);

window = gtk_application_get_active_window (GTK_APPLICATION (self));
if (window == NULL)
window = new_window (self);

value = dex_future_get_value (future, &local_error);
if (value != NULL)
if (value == NULL)
{
if (G_VALUE_HOLDS_OBJECT (value))
{
BzEntry *entry = NULL;
GtkWindow *window = NULL;

entry = g_value_get_object (value);
bz_window_show_entry (BZ_WINDOW (window), entry);
}
else
open_generic_id (self, g_value_get_string (value));
window = gtk_application_get_active_window (GTK_APPLICATION (self));
if (window == NULL)
window = new_window (self);

bz_show_error_for_widget (
GTK_WIDGET (window),
_ ("Failed to open file"),
local_error->message);
}
else
bz_show_error_for_widget (GTK_WIDGET (window), _ ("Failed to open .flatpakref"), local_error->message);

return dex_future_new_true ();
}
Expand Down
3 changes: 2 additions & 1 deletion src/bz-backend-notification.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parent-prefix=g
parent-name=object
author=AUTOGEN

enum=bz backend_notification_kind error tell_incoming replace_entry remote_sync_start remote_sync_finish install_done update_done remove_done external_change
enum=bz backend_notification_kind error tell_incoming replace_entry invalidate_remotes remote_sync_start remote_sync_finish install_done update_done remove_done external_change present_id

include="bz-entry.h"

Expand All @@ -14,4 +14,5 @@ property=n_incoming int G_TYPE_INT int
property=entry BzEntry BZ_TYPE_ENTRY object
property=version char G_TYPE_STRING string
property=remote_name char G_TYPE_STRING string
property=generic_id char G_TYPE_STRING string
property=unique_id char G_TYPE_STRING string
16 changes: 8 additions & 8 deletions src/bz-entry-group.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,11 @@ bz_entry_group_add (BzEntryGroup *self,
}
}

title = bz_entry_get_title (entry);
description = bz_entry_get_description (entry);
installed_size = bz_entry_get_installed_size (entry);
is_flathub = bz_entry_get_is_flathub (entry);
is_floss = bz_entry_get_is_foss (entry);
title = bz_entry_get_title (entry);
description = bz_entry_get_description (entry);
installed_size = bz_entry_get_installed_size (entry);
is_flathub = bz_entry_get_is_flathub (entry);
is_floss = bz_entry_get_is_foss (entry);

if (is_addon) // You would not see any addon when the filter is on without this.
is_verified = TRUE;
Expand Down Expand Up @@ -970,8 +970,8 @@ bz_entry_group_add (BzEntryGroup *self,
gtk_string_list_remove (self->unique_ids, existing);
gtk_string_list_remove (self->installed_versions, existing);
}
gtk_string_list_splice (self->unique_ids, 0, 0, (const char *const[]) { unique_id, NULL });
gtk_string_list_splice (self->installed_versions, 0, 0, (const char *const[]) { installed_version != NULL ? installed_version : "", NULL });
gtk_string_list_splice (self->unique_ids, 0, 0, (const char *const[]){ unique_id, NULL });
gtk_string_list_splice (self->installed_versions, 0, 0, (const char *const[]){ installed_version != NULL ? installed_version : "", NULL });

if (title != NULL)
{
Expand Down Expand Up @@ -1211,7 +1211,7 @@ installed_changed (BzEntryGroup *self,
if (index != G_MAXUINT)
{
gtk_string_list_splice (self->installed_versions, index, 1,
(const char *const[]) {
(const char *const[]){
version != NULL ? version : "",
NULL });
}
Expand Down
41 changes: 38 additions & 3 deletions src/bz-flatpak-entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct _BzFlatpakEntry
char *application_command;
char *runtime_name;
char *addon_extension_of_ref;
char *bundle_path;
BzResult *runtime_result;

FlatpakRef *ref;
Expand All @@ -74,6 +75,7 @@ enum
PROP_USER,
PROP_FLATPAK_NAME,
PROP_IS_BUNDLE,
PROP_BUNDLE_PATH,
PROP_FLATPAK_ID,
PROP_FLATPAK_VERSION,
PROP_APPLICATION_NAME,
Expand Down Expand Up @@ -129,6 +131,9 @@ bz_flatpak_entry_get_property (GObject *object,
case PROP_IS_BUNDLE:
g_value_set_boolean (value, self->is_bundle);
break;
case PROP_BUNDLE_PATH:
g_value_set_string (value, self->bundle_path);
break;
case PROP_APPLICATION_RUNTIME:
g_value_set_string (value, self->application_runtime);
break;
Expand Down Expand Up @@ -169,6 +174,7 @@ bz_flatpak_entry_set_property (GObject *object,
case PROP_APPLICATION_COMMAND:
case PROP_RUNTIME_NAME:
case PROP_ADDON_OF_REF:
case PROP_BUNDLE_PATH:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
Expand Down Expand Up @@ -221,6 +227,12 @@ bz_flatpak_entry_class_init (BzFlatpakEntryClass *klass)
FALSE,
G_PARAM_READABLE);

props[PROP_BUNDLE_PATH] =
g_param_spec_string (
"bundle-path",
NULL, NULL, NULL,
G_PARAM_READABLE);

props[PROP_APPLICATION_RUNTIME] =
g_param_spec_string (
"application-runtime",
Expand Down Expand Up @@ -267,7 +279,10 @@ bz_flatpak_entry_real_serialize (BzSerializable *serializable,
BzFlatpakEntry *self = BZ_FLATPAK_ENTRY (serializable);

g_variant_builder_add (builder, "{sv}", "user", g_variant_new_boolean (self->user));
g_variant_builder_add (builder, "{sv}", "is-bundle", g_variant_new_boolean (self->is_bundle));
g_variant_builder_add (builder, "{sv}", "is-installed-ref", g_variant_new_boolean (self->is_installed_ref));
if (self->bundle_path != NULL)
g_variant_builder_add (builder, "{sv}", "bundle-path", g_variant_new_string (self->bundle_path));
if (self->flatpak_name != NULL)
g_variant_builder_add (builder, "{sv}", "flatpak-name", g_variant_new_string (self->flatpak_name));
if (self->flatpak_id != NULL)
Expand Down Expand Up @@ -309,8 +324,12 @@ bz_flatpak_entry_real_deserialize (BzSerializable *serializable,

if (g_strcmp0 (key, "user") == 0)
self->user = g_variant_get_boolean (value);
else if (g_strcmp0 (key, "is-bundle") == 0)
self->is_bundle = g_variant_get_boolean (value);
else if (g_strcmp0 (key, "is-installed-ref") == 0)
self->is_installed_ref = g_variant_get_boolean (value);
else if (g_strcmp0 (key, "bundle-path") == 0)
self->bundle_path = g_variant_dup_string (value, NULL);
else if (g_strcmp0 (key, "flatpak-name") == 0)
self->flatpak_name = g_variant_dup_string (value, NULL);
else if (g_strcmp0 (key, "flatpak-id") == 0)
Expand Down Expand Up @@ -406,6 +425,15 @@ bz_flatpak_entry_new_for_ref (FlatpakRef *ref,
self->is_installed_ref = FLATPAK_IS_INSTALLED_REF (ref);
self->ref = g_object_ref (ref);

if (FLATPAK_IS_BUNDLE_REF (ref))
{
GFile *file = NULL;

file = flatpak_bundle_ref_get_file (FLATPAK_BUNDLE_REF (ref));
if (file != NULL)
self->bundle_path = g_file_get_path (file);
}

key_file = g_key_file_new ();
if (FLATPAK_IS_REMOTE_REF (ref))
bytes = flatpak_remote_ref_get_metadata (FLATPAK_REMOTE_REF (ref));
Expand Down Expand Up @@ -663,7 +691,8 @@ bz_flatpak_ref_parts_format_unique (const char *origin,
return g_strdup_printf (
"FLATPAK-%s::%s::%s",
user ? "USER" : "SYSTEM",
origin, fmt);
origin != NULL ? origin : "bundle",
fmt);
}

char *
Expand All @@ -677,8 +706,6 @@ bz_flatpak_ref_format_unique (FlatpakRef *ref,

if (FLATPAK_IS_REMOTE_REF (ref))
origin = flatpak_remote_ref_get_remote_name (FLATPAK_REMOTE_REF (ref));
else if (FLATPAK_IS_BUNDLE_REF (ref))
origin = flatpak_bundle_ref_get_origin (FLATPAK_BUNDLE_REF (ref));
else if (FLATPAK_IS_INSTALLED_REF (ref))
origin = flatpak_installed_ref_get_origin (FLATPAK_INSTALLED_REF (ref));

Expand Down Expand Up @@ -780,6 +807,13 @@ bz_flatpak_entry_is_installed_ref (BzFlatpakEntry *self)
return self->is_installed_ref;
}

const char *
bz_flatpak_entry_get_bundle_path (BzFlatpakEntry *self)
{
g_return_val_if_fail (BZ_IS_FLATPAK_ENTRY (self), NULL);
return self->bundle_path;
}

gboolean
bz_flatpak_entry_launch (BzFlatpakEntry *self,
BzFlatpakInstance *flatpak,
Expand Down Expand Up @@ -835,5 +869,6 @@ clear_entry (BzFlatpakEntry *self)
g_clear_pointer (&self->application_command, g_free);
g_clear_pointer (&self->runtime_name, g_free);
g_clear_pointer (&self->addon_extension_of_ref, g_free);
g_clear_pointer (&self->bundle_path, g_free);
g_clear_object (&self->runtime_result);
}
3 changes: 3 additions & 0 deletions src/bz-flatpak-entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ bz_flatpak_entry_is_bundle (BzFlatpakEntry *self);
gboolean
bz_flatpak_entry_is_installed_ref (BzFlatpakEntry *self);

const char *
bz_flatpak_entry_get_bundle_path (BzFlatpakEntry *self);

const char *
bz_flatpak_entry_get_addon_extension_of_ref (BzFlatpakEntry *self);

Expand Down
Loading
Loading