glib r6437 - trunk/gio



Author: alexl
Date: Fri Feb  1 11:21:37 2008
New Revision: 6437
URL: http://svn.gnome.org/viewvc/glib?rev=6437&view=rev

Log:
2008-02-01  Alexander Larsson  <alexl redhat com>

        * gappinfo.[ch]:
        * gio.symbols:
        Add g_app_info_launch_default_for_uri utility
	function. (#513256)



Modified:
   trunk/gio/ChangeLog
   trunk/gio/gappinfo.c
   trunk/gio/gappinfo.h
   trunk/gio/gio.symbols

Modified: trunk/gio/gappinfo.c
==============================================================================
--- trunk/gio/gappinfo.c	(original)
+++ trunk/gio/gappinfo.c	Fri Feb  1 11:21:37 2008
@@ -528,6 +528,47 @@
   return (* iface->should_show) (appinfo);
 }
 
+/**
+ * g_app_info_launch_default_for_uri:
+ * @uri: the uri to show
+ * @context: an optional #GAppLaunchContext.
+ * @error: a #GError.
+ *
+ * Utility function that launches the default application 
+ * registered to handle the specified uri. Synchronous I/O
+ * is done on the uri to detext the type of the file if
+ * required.
+ * 
+ * Returns: %TRUE on success, %FALSE on error.
+ **/
+gboolean
+g_app_info_launch_default_for_uri (const char *uri,
+				   GAppLaunchContext *launch_context,
+				   GError *error)
+{
+  GAppInfo *app_info;
+  GFile *file;
+  GList l;
+  gboolean res;
+
+  file = g_file_new_for_uri (uri);
+  app_info = g_file_query_default_handler (file, NULL, error);
+  g_object_unref (file);
+  if (app_info == NULL)
+    return FALSE;
+
+  /* Use the uri, not the GFile, as the GFile roundtrip may
+   * affect the uri which we don't want (for instance for a
+   * mailto: uri).
+   */
+  l.data = uri;
+  l.next = l.prev = NULL;
+  res = g_app_info_launch_uris (app_info, &l,
+				launch_context, error);
+  return res;
+}
+
+
 G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
 
 /**

Modified: trunk/gio/gappinfo.h
==============================================================================
--- trunk/gio/gappinfo.h	(original)
+++ trunk/gio/gappinfo.h	Fri Feb  1 11:21:37 2008
@@ -186,6 +186,10 @@
 						  gboolean     must_support_uris);
 GAppInfo *g_app_info_get_default_for_uri_scheme  (const char  *uri_scheme);
 
+gboolean g_app_info_launch_default_for_uri (const char *uri,
+					    GAppLaunchContext *launch_context,
+					    GError *error);
+
 /**
  * GAppLaunchContext:
  * @parent_instance: The parent instance.

Modified: trunk/gio/gio.symbols
==============================================================================
--- trunk/gio/gio.symbols	(original)
+++ trunk/gio/gio.symbols	Fri Feb  1 11:21:37 2008
@@ -46,6 +46,7 @@
 g_app_info_add_supports_type
 g_app_info_can_remove_supports_type
 g_app_info_remove_supports_type
+g_app_info_launch_default_for_uri
 g_app_launch_context_new
 g_app_launch_context_get_display
 g_app_launch_context_get_startup_notify_id



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