[gnome-launch-box] migrate the app launching to GDesktopAppFile



commit f5439342b699bf83fafc471f476ccf166ce6e3a5
Author: Sven Herzberg <herzi gnome-de org>
Date:   Tue Feb 9 14:10:49 2010 +0100

    migrate the app launching to GDesktopAppFile
    
    * configure.ac: depend on gio-unix-2.0 unconditionally
    * src/lb-item-application.c: replace the GnomeDesktopFile code with the
      newer one

 configure.ac              |    3 +-
 src/lb-item-application.c |   52 ++++++++++++++++++++++----------------------
 2 files changed, 28 insertions(+), 27 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b6a6e28..62673d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,7 @@ AC_MSG_CHECKING([whether to use tracker for application search])
 AC_ARG_ENABLE([tracker], AS_HELP_STRING([--disable-tracker],[disable tracker (default: enable if available]))
 if test -z "$enable_tracker" || test "$enable_tracker" != "no"; then
 	PKG_CHECK_EXISTS(tracker-client-0.7,
-			 [tracker_client="tracker-client-0.7 gio-unix-2.0"
+			 [tracker_client=tracker-client-0.7
 			  AC_MSG_RESULT([yes (0.7 found)])
 			  AC_DEFINE_UNQUOTED([HAVE_TRACKER],[1],[specify whether we can use tracker])],
 			 [AC_MSG_RESULT([no])])
@@ -56,6 +56,7 @@ AM_CONDITIONAL([HAVE_TRACKER],[test -n "$tracker_client"])
 
 PKG_CHECK_MODULES(LB,[
 	glib-2.0 >= 2.14
+	gio-unix-2.0
 	gtk+-2.0 >= 2.10
 	gnome-vfs-2.0 >= 2.10
 	libgnomeui-2.0
diff --git a/src/lb-item-application.c b/src/lb-item-application.c
index 2d4aa0a..7d70a73 100644
--- a/src/lb-item-application.c
+++ b/src/lb-item-application.c
@@ -26,7 +26,8 @@
 
 #include "lb-item-application.h"
 
-#include <libgnome/gnome-desktop-item.h>
+#include <gio/gdesktopappinfo.h>
+#include <gdk/gdk.h>
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LB_TYPE_ITEM_APPLICATION, LbItemApplicationPriv))
 
@@ -153,31 +154,30 @@ item_application_get_property (GObject    *object,
 static void
 module_applications_activate_action (LbAction *action)
 {
-	GError           *error = NULL;
-	GnomeDesktopItem *item;
-	const gchar      *item_path;
-
-	item_path = lb_action_get_data (action);
-
-	item = gnome_desktop_item_new_from_file (
-		item_path, 
-		GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS |
-		GNOME_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS,
-		&error);
-	
-	if (!item) {
-		g_printerr ("Unable to open desktop file %s for launcher: %s\n",
-			    item_path, 
-			    error->message);
-		g_error_free (error);
-
-		return;
-	}
-
-	if (gnome_desktop_item_launch (item, NULL, 0, &error) < 0) {
-		g_printerr ("Unable to launch: '%s'\n", error->message);
-		g_error_free (error);
-	}
+  GError              *error = NULL;
+  GDesktopAppInfo     *info;
+  const gchar         *item_path;
+  GdkAppLaunchContext *context;
+
+  item_path = lb_action_get_data (action);
+
+  info = g_desktop_app_info_new_from_filename (item_path);
+
+  if (!info)
+  {
+    g_printerr ("Unable to open desktop file %s for launcher\n",
+        item_path);
+
+    return;
+  }
+
+  context = gdk_app_launch_context_new ();
+  if (!g_app_info_launch (G_APP_INFO (info), NULL, G_APP_LAUNCH_CONTEXT (context), &error))
+  {
+    g_printerr ("Unable to launch: '%s'\n", error->message);
+    g_error_free (error);
+  }
+  g_object_unref (context);
 }
 
 void



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