[file-roller: 1/3] dlg-package-installer.c: Remove X11 dependency



commit cee5c88b9b18d4663161a67c2e5c01d36ee39ed4
Author: Romeo Calota <kicsyromy gmail com>
Date:   Fri May 1 12:54:43 2020 +0300

    dlg-package-installer.c: Remove X11 dependency
    
    When a user opens an archive of a type that no installed package can open
    a dialog pops up with the option to search for a suitable application
    in GNOME Software.
    
    This functionality was provided by org.freedesktop.PackageKit.Modify's
    InstallPackageNames method that required an X11 window id.
    
    The fix consists of migrating to the new org.freedesktop.PackageKit.Modify2
    D-Bus API that handles this use-case without needing an X11 window id and
    instead using a reverse domain name application id.
    
    Closes #78

 src/dlg-package-installer.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/src/dlg-package-installer.c b/src/dlg-package-installer.c
index bb521bb4..55216dd4 100644
--- a/src/dlg-package-installer.c
+++ b/src/dlg-package-installer.c
@@ -22,9 +22,6 @@
 #include <config.h>
 #include <string.h>
 #include <glib/gi18n.h>
-#ifdef ENABLE_PACKAGEKIT
-#include <gdk/gdkx.h>
-#endif
 #include <gtk/gtk.h>
 #include "dlg-package-installer.h"
 #include "gio-utils.h"
@@ -103,7 +100,7 @@ packagekit_install_package_names_ready_cb (GObject      *source_object,
                if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)
                    || (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR)
                        && (error->message != NULL)
-                       && (strstr (error->message, "org.freedesktop.Packagekit.Modify.Cancelled") != NULL)))
+                       && (strstr (error->message, "org.freedesktop.Packagekit.Modify2.Cancelled") != NULL)))
                {
                        error_type = FR_ERROR_STOPPED;
                        error_message = NULL;
@@ -186,29 +183,28 @@ install_packages (InstallerData *idata)
                                               NULL,
                                               "org.freedesktop.PackageKit",
                                               "/org/freedesktop/PackageKit",
-                                              "org.freedesktop.PackageKit.Modify",
+                                              "org.freedesktop.PackageKit.Modify2",
                                               idata->cancellable,
                                               &error);
 
                if (proxy != NULL) {
-                       guint   xid;
-                       char  **names;
-                       char  **real_names;
-
-                       if (window != NULL)
-                               xid = GDK_WINDOW_XID (window);
-                       else
-                               xid = 0;
+                       char    **names;
+                       char    **real_names;
+                       char     *desktop_startup_id;
+                       GVariant *platform_data;
 
                        names = g_strsplit (idata->packages, ",", -1);
                        real_names = get_packages_real_names (names);
+                       desktop_startup_id = g_strdup_printf ("_TIME%i", gtk_get_current_event_time ());
+                       platform_data = g_variant_new_parsed ("{'desktop-startup-id': %v}", 
g_variant_new_take_string (desktop_startup_id));
 
                        g_dbus_proxy_call (proxy,
                                           "InstallPackageNames",
-                                          g_variant_new ("(u^ass)",
-                                                         xid,
-                                                         real_names,
-                                                         "hide-confirm-search,hide-finished,hide-warning"),
+                                          g_variant_new ("(^asss@a{sv})",
+                                          real_names,
+                                          "hide-confirm-search,hide-finished,hide-warning",
+                                          "org.gnome.FileRoller",
+                                          platform_data),
                                           G_DBUS_CALL_FLAGS_NONE,
                                           G_MAXINT,
                                           idata->cancellable,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]