Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XdpAppInfo cleanups #1619

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

GeorgesStavracas
Copy link
Member

See commits. This is the first part of #1614

* Add space before '('
* gchar → char
* Remove stray newline
Makes it slightly easier to read.
We'll start shuffling things around, so that XdpAppInfo & subclasses
operate with the mechanics proposed by GInitable.
@@ -67,7 +67,6 @@ typedef struct _XdpAppInfoPrivate
GAppInfo *gappinfo;
gboolean supports_opath;
gboolean has_network;
gboolean requires_pid_mapping;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I screwed something up when refactoring XdpAppInfo? Might be worth double checking what this was used for...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was never used:

And pass it during object construction (i.e. g_initable_new())
And pass it during object construction (i.e. g_initable_new())
And pass it during object construction (i.e. g_initable_new()).
And pass it during object construction (i.e. g_initable_new())
Generate flag type from the private enum, and make it a construct-only
property.
And pass it during object construction (i.e. g_initable_new()).

This was the last value passed to xdp_app_info_initialize() so
remove this function as well.
Now that the constructor is a simple g_initable_new(), the
xdp_app_info_host_new_full() constructor seems unnecessary. Next
commits will introduce different flags for each path so just
separate them now.
Right now it's somewhat useless, and just serves as a safeguard,
but it will be useful for sharing the GAppInfo creation code a
little more.
Instead of making each constructor create a GAppInfo in almost exactly
equal ways, add an overridable vfunc, and implement the common path
in XdpAppInfo.

XdpAppInfoSnap needs a little bit of handholding, since the desktop
file does not match the app id, so add a construct-only property to
XdpAppInfoSnap and use it for a Snap-specific GAppInfo construction.
No functional changes (hopefully).
@GeorgesStavracas GeorgesStavracas force-pushed the gbsneto/xdp-app-info-followups branch from 35f2e5a to c8b31e4 Compare February 7, 2025 13:12
@@ -175,6 +180,11 @@ xdp_app_info_set_property (GObject *object,
priv->instance = g_value_dup_string (value);
break;

case PROP_PIDFD:
g_assert (priv->pidfd == -1);
priv->pidfd = dup (g_value_get_int (value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedef enum _XdpAppInfoFlags

tbh, I'm unsure why this even is a pattern in e.g. mutter but at least it makes it easy to grep for the declaration...

@@ -23,6 +23,12 @@

#include "xdp-app-info.h"

typedef enum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedef enum _XdpAppInfoFlags

tbh, I'm unsure why this even is a pattern in e.g. mutter but at least it makes it easy to grep for the declaration...

@swick
Copy link
Contributor

swick commented Feb 7, 2025

I'm a bit on the fence about the approach. Wouldn't it be better to move the code we currently have in xdp_app_info_foo_new to xdp_app_info_foo_initable_init and only have the pid and pidfd as props?

@GeorgesStavracas
Copy link
Member Author

Wouldn't it be better to move the code we currently have in xdp_app_info_foo_new to xdp_app_info_foo_initable_init and only have the pid and pidfd as props?

That was my original approach, but it got pretty spectacularly messy and I just settled for these construct-only properties.

@swick
Copy link
Contributor

swick commented Feb 7, 2025

That was my original approach, but it got pretty spectacularly messy and I just settled for these construct-only properties.

Mh, I couldn't resist and tried it as well. The result is pretty nice, but I need to untangle the changes into smaller commits: https://github.com/swick/xdg-desktop-portal/commits/wip/app-info-initable/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants