[glibmm] AppInfo: Add launch() taking one file, and launch_uri() taking one URI.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] AppInfo: Add launch() taking one file, and launch_uri() taking one URI.
- Date: Tue, 19 Jul 2011 09:01:16 +0000 (UTC)
commit 7a6f7eef1c58d51e870aabada452ce2cb84a8ea5
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Jul 12 12:46:09 2011 +0200
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.
ChangeLog | 8 +++++
gio/src/appinfo.ccg | 51 +++++++++++++++++++++++++++++++
gio/src/appinfo.hg | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 140 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d08309f..2686864 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,14 @@
2011-07-12 Murray Cumming <murrayc murrayc com>
+ 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.
+
+2011-07-12 Murray Cumming <murrayc murrayc com>
+
AppInfo::launch(): Correct the parameter type.
* gio/src/appinfo.hg: g_app_info_launch() takes a GList of GFile, not of
diff --git a/gio/src/appinfo.ccg b/gio/src/appinfo.ccg
index e5146da..f237a63 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 b248d5e..20689a6 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]