[xdg-desktop-portal-gnome/mwleeds/implement-dynamic-launcher] fixup! Implement dynamic launcher portal (gtk4)
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xdg-desktop-portal-gnome/mwleeds/implement-dynamic-launcher] fixup! Implement dynamic launcher portal (gtk4)
- Date: Tue, 15 Mar 2022 02:05:37 +0000 (UTC)
commit 46af6c84cfe1f3eb4bc8007c746ca0b7b42c1445
Author: Phaedrus Leeds <mwleeds protonmail com>
Date: Mon Mar 14 18:34:26 2022 -0700
fixup! Implement dynamic launcher portal (gtk4)
src/dynamic-launcher.c | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/src/dynamic-launcher.c b/src/dynamic-launcher.c
index 6565f9e..0d90738 100644
--- a/src/dynamic-launcher.c
+++ b/src/dynamic-launcher.c
@@ -41,12 +41,14 @@
#define DEFAULT_ICON_SIZE 192
-typedef enum {
+typedef enum
+{
DYNAMIC_LAUNCHER_TYPE_APPLICATION = 1,
DYNAMIC_LAUNCHER_TYPE_WEBAPP = 2,
} DynamicLauncherType;
-typedef struct {
+typedef struct
+{
XdpImplDynamicLauncher *impl;
GDBusMethodInvocation *invocation;
Request *request;
@@ -64,11 +66,11 @@ install_dialog_handle_free (gpointer data)
InstallDialogHandle *handle = data;
g_clear_object (&handle->external_parent);
- g_object_unref (handle->request);
+ g_clear_object (&handle->request);
if (handle->dialog)
- g_object_unref (handle->dialog);
+ g_clear_object (&handle->dialog);
- g_variant_unref (handle->icon_v);
+ g_clear_pointer (&handle->icon_v, g_variant_unref);
g_free (handle);
}
@@ -84,7 +86,7 @@ install_dialog_handle_close (InstallDialogHandle *handle)
static gboolean
handle_close (XdpImplRequest *object,
GDBusMethodInvocation *invocation,
- InstallDialogHandle *handle)
+ InstallDialogHandle *handle)
{
GVariantBuilder opt_builder;
@@ -298,13 +300,12 @@ handle_prepare_install (XdpImplDynamicLauncher *object,
gtk_entry_set_text (GTK_ENTRY (entry), arg_name);
gtk_widget_set_sensitive (entry, editable_name);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- gtk_box_pack_start (GTK_BOX (box), entry, FALSE, TRUE, 0);
+ gtk_box_append (GTK_BOX (box), entry);
if (launcher_type == DYNAMIC_LAUNCHER_TYPE_WEBAPP)
{
g_autofree char *escaped_address = NULL;
g_autofree char *markup = NULL;
- GtkStyleContext *context;
escaped_address = g_markup_escape_text (url, -1);
markup = g_strdup_printf ("<small>%s</small>", escaped_address);
@@ -314,9 +315,8 @@ handle_prepare_install (XdpImplDynamicLauncher *object,
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
- context = gtk_widget_get_style_context (label);
- gtk_style_context_add_class (context, "dim-label");
+ gtk_box_append (GTK_BOX (box), label);
+ gtk_widget_add_css_class (label, "dim-label");
}
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
@@ -325,7 +325,6 @@ handle_prepare_install (XdpImplDynamicLauncher *object,
handle->entry = entry;
g_signal_connect (request, "handle-close", G_CALLBACK (handle_close), handle);
-
g_signal_connect (dialog, "response", G_CALLBACK (handle_prepare_install_response), handle);
gtk_widget_realize (dialog);
@@ -336,7 +335,7 @@ handle_prepare_install (XdpImplDynamicLauncher *object,
request_export (request, g_dbus_method_invocation_get_connection (invocation));
- gtk_widget_show_all (dialog);
+ gtk_window_present (GTK_WINDOW (dialog));
return TRUE;
@@ -352,15 +351,21 @@ handle_request_install_token (XdpImplDynamicLauncher *object,
const char *arg_app_id,
GVariant *arg_options)
{
- static const char *allowlist[] = {"org.gnome.Software",
- "org.gnome.SoftwareDevel",
- NULL };
+ static const char *allowlist[] = {
+ "org.gnome.Software",
+ "org.gnome.SoftwareDevel",
+ NULL
+ };
guint response;
+ enum {
+ RESPONSE_ALLOW_REQUEST = 0,
+ RESPONSE_REJECT_REQUEST = 2
+ };
if (arg_app_id != NULL && g_strv_contains (allowlist, arg_app_id))
- response = 0;
+ response = RESPONSE_ALLOW_REQUEST;
else
- response = 2;
+ response = RESPONSE_REJECT_REQUEST;
xdp_impl_dynamic_launcher_complete_request_install_token (object,
invocation,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]