[gnome-packagekit] Use GIO to launch the desktop file application after it is installed. Fixes rh#531878
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Use GIO to launch the desktop file application after it is installed. Fixes rh#531878
- Date: Wed, 7 Apr 2010 10:10:57 +0000 (UTC)
commit 1f8d2677c7ccaaf383d816d718b64ea283081aed
Author: Richard Hughes <richard hughsie com>
Date: Wed Apr 7 11:10:49 2010 +0100
Use GIO to launch the desktop file application after it is installed. Fixes rh#531878
configure.ac | 7 ++++-
src/gpk-helper-run.c | 53 ++++++++++++++++++++++++++++++-------------------
2 files changed, 37 insertions(+), 23 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 428c0d2..a1112bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,8 +119,11 @@ dnl ---------------------------------------------------------------------------
dnl - Check library dependencies
dnl ---------------------------------------------------------------------------
PKG_CHECK_MODULES(PACKAGEKIT, packagekit-glib2 >= $PACKAGEKIT_REQUIRED)
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0)
-PKG_CHECK_MODULES(GIO, gio-2.0 >= $GIO_REQUIRED)
+PKG_CHECK_MODULES(GLIB, \
+ glib-2.0 >= $GLIB_REQUIRED
+ gobject-2.0
+ gio-2.0 >= $GIO_REQUIRED
+ gio-unix-2.0 >= $GIO_REQUIRED)
PKG_CHECK_MODULES(DBUS, \
dbus-glib-1 >= $DBUS_GLIB_REQUIRED \
dbus-1 >= $DBUS_REQUIRED \
diff --git a/src/gpk-helper-run.c b/src/gpk-helper-run.c
index 446bd37..de24416 100644
--- a/src/gpk-helper-run.c
+++ b/src/gpk-helper-run.c
@@ -24,6 +24,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <packagekit-glib2/packagekit.h>
+#include <gio/gdesktopappinfo.h>
#include "gpk-helper-run.h"
#include "gpk-marshal.h"
@@ -47,7 +48,7 @@ struct GpkHelperRunPrivate
enum {
GPK_CHOOSER_COLUMN_ICON,
GPK_CHOOSER_COLUMN_TEXT,
- GPK_CHOOSER_COLUMN_EXEC,
+ GPK_CHOOSER_COLUMN_FILENAME,
GPK_CHOOSER_COLUMN_LAST
};
@@ -57,23 +58,34 @@ G_DEFINE_TYPE (GpkHelperRun, gpk_helper_run, G_TYPE_OBJECT)
* gpk_helper_run_path:
**/
static gboolean
-gpk_helper_run_path (GpkHelperRun *helper, const gchar *exec)
+gpk_helper_run_path (GpkHelperRun *helper, const gchar *filename)
{
gboolean ret = FALSE;
GError *error = NULL;
+ GAppInfo *app = NULL;
+ GAppLaunchContext *context = NULL;
/* check have value */
- if (exec == NULL) {
+ if (filename == NULL) {
egg_warning ("no full path");
goto out;
}
- ret = g_spawn_command_line_async (exec, &error);
+ /* launch application */
+ app = G_APP_INFO(g_desktop_app_info_new_from_filename (filename));
+ context = G_APP_LAUNCH_CONTEXT(gdk_app_launch_context_new ());
+// app = (GAppInfo*)g_desktop_app_info_new_from_filename (filename);
+// context = (GAppLaunchContext*)gdk_app_launch_context_new ();
+ ret = g_app_info_launch (app, NULL, context, &error);
if (!ret) {
- egg_warning ("failed to run: %s", error->message);
+ egg_warning ("failed to launch: %s", error->message);
g_error_free (error);
}
out:
+ if (app != NULL)
+ g_object_unref (app);
+ if (context != NULL)
+ g_object_unref (context);
return ret;
}
@@ -88,7 +100,7 @@ gpk_helper_run_button_run_cb (GtkWidget *widget, GpkHelperRun *helper)
GtkTreeIter iter;
GtkTreeSelection *selection;
gboolean ret;
- gchar *exec;
+ gchar *filename;
/* get selection */
treeview = GTK_TREE_VIEW (gtk_builder_get_object (helper->priv->builder, "treeview_simple"));
@@ -99,9 +111,9 @@ gpk_helper_run_button_run_cb (GtkWidget *widget, GpkHelperRun *helper)
return;
}
- gtk_tree_model_get (model, &iter, GPK_CHOOSER_COLUMN_EXEC, &exec, -1);
- gpk_helper_run_path (helper, exec);
- g_free (exec);
+ gtk_tree_model_get (model, &iter, GPK_CHOOSER_COLUMN_FILENAME, &filename, -1);
+ gpk_helper_run_path (helper, filename);
+ g_free (filename);
}
/**
@@ -144,19 +156,19 @@ gpk_helper_run_treeview_clicked_cb (GtkTreeSelection *selection, GpkHelperRun *h
{
GtkTreeModel *model;
GtkTreeIter iter;
- gchar *exec = NULL;
+ gchar *filename = NULL;
/* This will only work in single or browse selection mode! */
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- g_free (exec);
- gtk_tree_model_get (model, &iter, GPK_CHOOSER_COLUMN_EXEC, &exec, -1);
+ g_free (filename);
+ gtk_tree_model_get (model, &iter, GPK_CHOOSER_COLUMN_FILENAME, &filename, -1);
/* show full path */
- egg_debug ("selected row is: %s", exec);
+ egg_debug ("selected row is: %s", filename);
} else {
egg_debug ("no row selected");
}
- g_free (exec);
+ g_free (filename);
}
/**
@@ -169,7 +181,7 @@ gpk_helper_run_row_activated_cb (GtkTreeView *treeview, GtkTreePath *path,
GtkTreeModel *model;
GtkTreeIter iter;
gboolean ret;
- gchar *exec;
+ gchar *filename;
/* get selection */
model = gtk_tree_view_get_model (treeview);
@@ -179,10 +191,9 @@ gpk_helper_run_row_activated_cb (GtkTreeView *treeview, GtkTreePath *path,
return;
}
- g_free (exec);
- gtk_tree_model_get (model, &iter, GPK_CHOOSER_COLUMN_EXEC, &exec, -1);
- gpk_helper_run_path (helper, exec);
- g_free (exec);
+ gtk_tree_model_get (model, &iter, GPK_CHOOSER_COLUMN_FILENAME, &filename, -1);
+ gpk_helper_run_path (helper, filename);
+ g_free (filename);
}
/**
@@ -247,7 +258,7 @@ gpk_helper_run_add_desktop_file (GpkHelperRun *helper, const gchar *package_id,
goto out;
}
- /* get exec */
+ /* get hidden */
hidden = g_key_file_get_boolean (file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL);
if (hidden) {
egg_debug ("hidden, so ignoring %s", filename);
@@ -310,7 +321,7 @@ gpk_helper_run_add_desktop_file (GpkHelperRun *helper, const gchar *package_id,
gtk_list_store_set (helper->priv->list_store, &iter,
GPK_CHOOSER_COLUMN_TEXT, fulltext,
- GPK_CHOOSER_COLUMN_EXEC, exec,
+ GPK_CHOOSER_COLUMN_FILENAME, filename,
GPK_CHOOSER_COLUMN_ICON, icon, -1);
out:
if (file != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]