From bb174d312ff2a3ad8720e56f860753aa4a30e226 Mon Sep 17 00:00:00 2001
From: Benedikt Meurer <benny@xfce.org>
Date: Sun, 30 Jul 2006 22:49:35 +0000
Subject: [PATCH] 2006-07-31	Benedikt Meurer <benny@xfce.org>

	* thunar/thunar-dbus-service-infos.xml, thunar/thunar-dbus-service.c:
	  Add DisplayChooserDialog() to the org.xfce.FileManager interface,
	  which pops up the "Open With" dialog, optionally allowing the user
	  to open the file with the choosen application. Bug #1811.




(Old svn revision: 22583)
---
 ChangeLog                            |  7 ++++++
 thunar/thunar-dbus-service-infos.xml | 22 +++++++++++++++++++
 thunar/thunar-dbus-service.c         | 32 ++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 9528a8e63..d2760df85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-31	Benedikt Meurer <benny@xfce.org>
+
+	* thunar/thunar-dbus-service-infos.xml, thunar/thunar-dbus-service.c:
+	  Add DisplayChooserDialog() to the org.xfce.FileManager interface,
+	  which pops up the "Open With" dialog, optionally allowing the user
+	  to open the file with the choosen application. Bug #1811.
+
 2006-07-31	Benedikt Meurer <benny@xfce.org>
 
 	* configure.in.in, plugins/thunar-sendto-email/main.c: Check for
diff --git a/thunar/thunar-dbus-service-infos.xml b/thunar/thunar-dbus-service-infos.xml
index 87b59438e..a45211d46 100644
--- a/thunar/thunar-dbus-service-infos.xml
+++ b/thunar/thunar-dbus-service-infos.xml
@@ -30,6 +30,28 @@
   <interface name="org.xfce.FileManager">
     <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="thunar_dbus_service" />
 
+    <!--
+      DisplayChooserDialog (uri : STRING, open : BOOLEAN, display : STRING) : VOID
+
+      uri     : either a file:-URI or an absolute path.
+      open    : TRUE to let the user open the file identified by the
+                uri after choosing an application, FALSE to only update
+                the mime database.
+      display : the screen on which to display the chooser dialog or
+                "" to use the default screen of the file manager.
+
+      Displays the chooser dialog, which lets the user select an application
+      to handle the file identified by the uri (and all other files of the
+      same mime type). If open is TRUE the user will also be able to open
+      the file after choosing an application.
+    -->
+    <method name="DisplayChooserDialog">
+      <arg direction="in" name="uri" type="s" />
+      <arg direction="in" name="open" type="b" />
+      <arg direction="in" name="display" type="s" />
+    </method>
+
+
     <!--
       DisplayFolder (uri : STRING, display : STRING) : VOID
 
diff --git a/thunar/thunar-dbus-service.c b/thunar/thunar-dbus-service.c
index 7dc13ff67..f3ca93f4d 100644
--- a/thunar/thunar-dbus-service.c
+++ b/thunar/thunar-dbus-service.c
@@ -35,6 +35,7 @@
 #include <glib/gstdio.h>
 
 #include <thunar/thunar-application.h>
+#include <thunar/thunar-chooser-dialog.h>
 #include <thunar/thunar-dbus-service.h>
 #include <thunar/thunar-file.h>
 #include <thunar/thunar-gdk-extensions.h>
@@ -56,6 +57,11 @@ static gboolean thunar_dbus_service_parse_uri_and_display       (ThunarDBusServi
                                                                  GError                **error);
 static void     thunar_dbus_service_trash_bin_changed           (ThunarDBusService      *dbus_service,
                                                                  ThunarFile             *trash_bin);
+static gboolean thunar_dbus_service_display_chooser_dialog      (ThunarDBusService      *dbus_service,
+                                                                 const gchar            *uri,
+                                                                 gboolean                open,
+                                                                 const gchar            *display,
+                                                                 GError                **error);
 static gboolean thunar_dbus_service_display_folder              (ThunarDBusService      *dbus_service,
                                                                  const gchar            *uri,
                                                                  const gchar            *display,
@@ -311,6 +317,32 @@ thunar_dbus_service_trash_bin_changed (ThunarDBusService *dbus_service,
 
 
 
+static gboolean
+thunar_dbus_service_display_chooser_dialog (ThunarDBusService *dbus_service,
+                                            const gchar       *uri,
+                                            gboolean           open,
+                                            const gchar       *display,
+                                            GError           **error)
+{
+  ThunarFile *file;
+  GdkScreen  *screen;
+
+  /* parse uri and display parameters */
+  if (!thunar_dbus_service_parse_uri_and_display (dbus_service, uri, display, &file, &screen, error))
+    return FALSE;
+
+  /* popup the chooser dialog */
+  thunar_show_chooser_dialog (screen, file, open);
+
+  /* cleanup */
+  g_object_unref (G_OBJECT (screen));
+  g_object_unref (G_OBJECT (file));
+
+  return TRUE;
+}
+
+
+
 static gboolean
 thunar_dbus_service_display_folder (ThunarDBusService *dbus_service,
                                     const gchar       *uri,
-- 
GitLab