summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2011-07-12 12:46:09 +0200
committerMurray Cumming <murrayc@murrayc.com>2011-07-19 11:00:29 +0200
commit7a6f7eef1c58d51e870aabada452ce2cb84a8ea5 (patch)
tree16c62dbec13d510a758d73ed714ec7c3e723f072 /gio
parent5dc68d4c46c4f786e5df6595c4481e6e27d8f135 (diff)
downloadglibmm-7a6f7eef1c58d51e870aabada452ce2cb84a8ea5.tar.gz
AppInfo: Add launch() taking one file, and launch_uri() taking one URI.
* gio/src/appinfo.[hg|ccg]: Add launch() overloads that take a single Gio::File, for convenience. Also add launch_uri() to take a single URI.
Diffstat (limited to 'gio')
-rw-r--r--gio/src/appinfo.ccg51
-rw-r--r--gio/src/appinfo.hg82
2 files changed, 132 insertions, 1 deletions
diff --git a/gio/src/appinfo.ccg b/gio/src/appinfo.ccg
index e5146da0..f237a633 100644
--- a/gio/src/appinfo.ccg
+++ b/gio/src/appinfo.ccg
@@ -53,5 +53,56 @@ bool AppInfo::launch_default_for_uri(const std::string& uri)
return retvalue;
}
+bool AppInfo::launch(const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<AppLaunchContext>& launch_context)
+{
+ std::vector< Glib::RefPtr<Gio::File> > vec;
+ vec.push_back(file);
+
+ GError* gerror = 0;
+ bool retvalue = g_app_info_launch(gobj(), Glib::ListHandler<Glib::RefPtr<Gio::File> >::vector_to_list(vec).data (), Glib::unwrap(launch_context), &(gerror));
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+
+ return retvalue;
+}
+
+bool AppInfo::launch(const Glib::RefPtr<Gio::File>& file)
+{
+ std::vector< Glib::RefPtr<Gio::File> > vec;
+ vec.push_back(file);
+
+ GError* gerror = 0;
+ bool retvalue = g_app_info_launch(gobj(), Glib::ListHandler<Glib::RefPtr<Gio::File> >::vector_to_list(vec).data (), 0, &(gerror));
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+
+ return retvalue;
+}
+
+bool AppInfo::launch_uri(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& launch_context)
+{
+ std::vector<std::string> vec;
+ vec.push_back(uri);
+
+ GError* gerror = 0;
+ bool retvalue = g_app_info_launch_uris(gobj(), Glib::ListHandler<std::string>::vector_to_list(vec).data (), Glib::unwrap(launch_context), &(gerror));
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+
+ return retvalue;
+}
+
+bool AppInfo::launch_uri(const std::string& uri)
+{
+ std::vector<std::string> vec;
+ vec.push_back(uri);
+
+ GError* gerror = 0;
+ bool retvalue = g_app_info_launch_uris(gobj(), Glib::ListHandler<std::string>::vector_to_list(vec).data (), 0, &(gerror));
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+
+ return retvalue;
+}
} // namespace Gio
diff --git a/gio/src/appinfo.hg b/gio/src/appinfo.hg
index b248d5e7..20689a61 100644
--- a/gio/src/appinfo.hg
+++ b/gio/src/appinfo.hg
@@ -101,6 +101,64 @@ public:
#m4 _CONVERSION(`const std::vector< Glib::RefPtr<Gio::File> >&',`GList*',`Glib::ListHandler<Glib::RefPtr<Gio::File> >::vector_to_list($3).data ()')
+ /** Launches the application. This passes the @a file to the launched application
+ * as an argument, using the optional @a launch_context to get information
+ * about the details of the launcher (like what screen it is on).
+ * On error, an exception will be thrown accordingly.
+ *
+ * Note that even if the launch is successful the application launched
+ * can fail to start if it runs into problems during startup. There is
+ * no way to detect this.
+ *
+ * Some URIs can be changed when passed through a GFile (for instance
+ * unsupported uris with strange formats like mailto:), so if you have
+ * a textual uri you want to pass in as argument, consider using
+ * launch_uris() instead.
+ *
+ * On UNIX, this function sets the <envar>GIO_LAUNCHED_DESKTOP_FILE</envar>
+ * environment variable with the path of the launched desktop file and
+ * <envar>GIO_LAUNCHED_DESKTOP_FILE_PID</envar> to the process
+ * id of the launched process. This can be used to ignore
+ * <envar>GIO_LAUNCHED_DESKTOP_FILE</envar>, should it be inherited
+ * by further processes. The <envar>DISPLAY</envar> and
+ * <envar>DESKTOP_STARTUP_ID</envar> environment variables are also
+ * set, based on information provided in @a launch_context.
+ * @param files A List of File objects.
+ * @param launch_context An AppLaunchContext.
+ * @return <tt>true</tt> on successful launch, <tt>false</tt> otherwise.
+ *
+ * @newin{3,2}
+ */
+ bool launch(const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<AppLaunchContext>& launch_context);
+
+ /** Launches the application. This passes the @a file to the launched application
+ * as an arguments.
+ * On error, an exception will be thrown accordingly.
+ *
+ * Note that even if the launch is successful the application launched
+ * can fail to start if it runs into problems during startup. There is
+ * no way to detect this.
+ *
+ * Some URIs can be changed when passed through a GFile (for instance
+ * unsupported uris with strange formats like mailto:), so if you have
+ * a textual uri you want to pass in as argument, consider using
+ * launch_uris() instead.
+ *
+ * On UNIX, this function sets the <envar>GIO_LAUNCHED_DESKTOP_FILE</envar>
+ * environment variable with the path of the launched desktop file and
+ * <envar>GIO_LAUNCHED_DESKTOP_FILE_PID</envar> to the process
+ * id of the launched process. This can be used to ignore
+ * <envar>GIO_LAUNCHED_DESKTOP_FILE</envar>, should it be inherited
+ * by further processes. The <envar>DISPLAY</envar> and
+ * <envar>DESKTOP_STARTUP_ID</envar> environment variables are also
+ * set, based on information provided in @a launch_context.
+ * @param files A File object.
+ * @return <tt>true</tt> on successful launch, <tt>false</tt> otherwise.
+ *
+ * @newin{3,2}
+ */
+ bool launch(const Glib::RefPtr<Gio::File>& file);
+
_WRAP_METHOD(bool launch(const std::vector< Glib::RefPtr<Gio::File> >& files,
const Glib::RefPtr<AppLaunchContext>& launch_context{?}),
g_app_info_launch,
@@ -119,7 +177,29 @@ public:
const Glib::RefPtr<AppLaunchContext>& launch_context{?}),
g_app_info_launch_uris,
errthrow)
-
+
+ /** Launches the application. This passes the @a uri to the launched application
+ * as an arguments, using the optional @a launch_context to get information
+ * about the details of the launcher (like what screen it is on).
+ * On error, an exception will be thrown accordingly.
+ *
+ * Note that even if the launch is successful the application launched
+ * can fail to start if it runs into problems during startup. There is
+ * no way to detect this.
+ * @param uris A URIs to launch.
+ * @param launch_context An AppLaunchContext.
+ * @return <tt>true</tt> on successful launch, <tt>false</tt> otherwise.
+ *
+ * @newin{3,2}
+ */
+ bool launch_uri(const std::string& uris, const Glib::RefPtr<AppLaunchContext>& launch_context);
+
+ /** A launch_uri() convenience overload.
+ *
+ * @newin{3,2}
+ */
+ bool launch_uri(const std::string& uris);
+
_WRAP_METHOD(bool should_show() const, g_app_info_should_show)
// FIXME: use better terminology than delete/do_delete
_WRAP_METHOD(bool can_delete() const, g_app_info_can_delete)