[gnome-panel/gtk3] Fix gdk_spawn_* by g_spawn_* and GdkApp
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/gtk3] Fix gdk_spawn_* by g_spawn_* and GdkApp
- Date: Thu, 30 Dec 2010 12:34:12 +0000 (UTC)
commit 5585a51bded5b2733dc8a0f7b6f42afec5312669
Author: Germán Póo-Caamaño <gpoo gnome org>
Date: Thu Dec 30 04:32:41 2010 -0800
Fix gdk_spawn_* by g_spawn_* and GdkApp
Use GdkAppLaunchContext instead of gdk_spawn_command_line_on_screen() and use of
g_spawn_async instead of gdk_spawn_on_screen().
https://bugzilla.gnome.org/show_bug.cgi?id=627455
Signed-off-by: Germán Póo-Caamaño <gpoo gnome org>
gnome-panel/panel-run-dialog.c | 46 +++++++++++++++++++++++++--------------
gnome-panel/panel-util.c | 19 +++++++++++++++-
2 files changed, 47 insertions(+), 18 deletions(-)
---
diff --git a/gnome-panel/panel-run-dialog.c b/gnome-panel/panel-run-dialog.c
index 3dc270e..5e66d01 100644
--- a/gnome-panel/panel-run-dialog.c
+++ b/gnome-panel/panel-run-dialog.c
@@ -356,35 +356,46 @@ command_is_executable (const char *command,
return TRUE;
}
+/*
+ * Set the DISPLAY variable, to be use by g_spawn_async.
+ */
+static void
+set_environment (gpointer display)
+{
+ g_setenv ("DISPLAY", display, TRUE);
+}
+
static gboolean
panel_run_dialog_launch_command (PanelRunDialog *dialog,
const char *command,
const char *locale_command)
{
GdkScreen *screen;
- gboolean result;
+ gboolean result;
GError *error = NULL;
char **argv;
int argc;
-
+ char *display;
+
if (!command_is_executable (locale_command, &argc, &argv))
return FALSE;
- screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
-
+ screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
+
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox)))
gnome_desktop_prepend_terminal_to_vector (&argc, &argv);
-
- result = gdk_spawn_on_screen (screen,
- NULL, /* working directory */
- argv,
- NULL, /* envp */
- G_SPAWN_SEARCH_PATH,
- NULL, /* child setup func */
- NULL, /* user data */
- NULL, /* child pid */
- &error);
-
+
+ display = gdk_screen_make_display_name (screen);
+
+ result = g_spawn_async (NULL, /* working directory */
+ argv,
+ NULL, /* envp */
+ G_SPAWN_SEARCH_PATH,
+ set_environment,
+ &display,
+ NULL,
+ &error);
+
if (!result) {
char *primary;
@@ -397,9 +408,10 @@ panel_run_dialog_launch_command (PanelRunDialog *dialog,
g_error_free (error);
}
-
+
+ g_free (display);
g_strfreev (argv);
-
+
return result;
}
diff --git a/gnome-panel/panel-util.c b/gnome-panel/panel-util.c
index 30a235b..fa9aabc 100644
--- a/gnome-panel/panel-util.c
+++ b/gnome-panel/panel-util.c
@@ -399,6 +399,8 @@ panel_lock_screen_action (GdkScreen *screen,
{
GError *error = NULL;
char *command = NULL;
+ GdkAppLaunchContext *launch_context = NULL;
+ GAppInfo *app_info = NULL;
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (action != NULL);
@@ -412,7 +414,21 @@ panel_lock_screen_action (GdkScreen *screen,
if (!command)
return;
- if (!gdk_spawn_command_line_on_screen (screen, command, &error)) {
+ app_info = g_app_info_create_from_commandline (command,
+ NULL,
+ G_APP_INFO_CREATE_NONE,
+ &error);
+
+ if (!error) {
+ launch_context = gdk_app_launch_context_new ();
+ gdk_app_launch_context_set_screen (launch_context, screen);
+ g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error);
+
+ g_object_unref (launch_context);
+ }
+
+ /* error either by create or launch the command */
+ if (error) {
char *primary;
primary = g_strdup_printf (_("Could not execute '%s'"),
@@ -425,6 +441,7 @@ panel_lock_screen_action (GdkScreen *screen,
}
g_free (command);
+ g_object_unref (app_info);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]