summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomeo Calota <mail@romeocalota.me>2020-04-23 21:30:15 +0300
committerRomeo Calota <mail@romeocalota.me>2020-04-26 13:01:34 +0000
commit2615aeed447e29040b6b76e83ce3e5b652575f60 (patch)
tree7ddae1bdb750225533cbf419e5b1661b955d3d43
parent0733f9df4b7e80dd0cf9dfc8f6b3f271f3d4abc4 (diff)
downloadnautilus-2615aeed447e29040b6b76e83ce3e5b652575f60.tar.gz
nautilus-mime-actions.c: New PackageKit DBus API
When a user opens a file of a type that no installed application can open a dialog pops up with the option to search for a suitable application in GNOME Software. When the user clicks the "Search in Software" button an extra notification pops up asking to confirm searching for the app which is unnecessary and potentialy confusing. The fix consists of migrating to the new org.freedesktop.PackageKit.Modify2 D-Bus API that handles this use-case without a second user prompt. Closes #1299
-rw-r--r--src/nautilus-mime-actions.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index 6be01fd05..26468c597 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -23,9 +23,6 @@
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-#endif
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
@@ -1201,33 +1198,20 @@ static void
search_for_application_mime_type (ActivateParametersInstall *parameters_install,
const gchar *mime_type)
{
- GdkWindow *window;
- guint xid = 0;
- const char *mime_types[2];
+ gchar *desktop_startup_id;
g_assert (parameters_install->proxy != NULL);
-#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
- {
- /* get XID from parent window */
- window = gtk_widget_get_window (GTK_WIDGET (parameters_install->parent_window));
- if (window != NULL)
- {
- xid = GDK_WINDOW_XID (window);
- }
- }
-#endif
-
- mime_types[0] = mime_type;
- mime_types[1] = NULL;
+ desktop_startup_id = g_strdup_printf ("_TIME%i", gtk_get_current_event_time ());
g_dbus_proxy_call (parameters_install->proxy,
"InstallMimeTypes",
- g_variant_new ("(u^ass)",
- xid,
- mime_types,
- "hide-confirm-search"),
+ g_variant_new_parsed ("([%s], %s, %s, [{%s, %v}])",
+ mime_type,
+ "hide-confirm-search",
+ APPLICATION_ID,
+ "desktop-startup-id",
+ g_variant_new_take_string (desktop_startup_id)),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT /* no timeout */,
NULL /* cancellable */,
@@ -1373,7 +1357,7 @@ application_unhandled_uri (ActivateParameters *parameters,
NULL,
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit.Modify",
+ "org.freedesktop.PackageKit.Modify2",
NULL,
pk_proxy_appeared_cb,
parameters_install);