summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-08-02 12:51:23 +0200
committerStefano Karapetsas <[email protected]>2013-08-02 12:51:23 +0200
commitd60011687083b1c085c1cacf6febdb8814036335 (patch)
tree25836f4d38b25e02aab73dd10e3709d4ddb2430a
parent5193ccc5428221f9a4cafd275065bacb3af7efbb (diff)
downloadmate-desktop-d60011687083b1c085c1cacf6febdb8814036335.tar.bz2
mate-desktop-d60011687083b1c085c1cacf6febdb8814036335.tar.xz
Add replacement for gdk_spawn_command_line_on_screen
gdk_spawn_command_line_on_screen is removed in GTK3, and require some code to be replaced, so we are going to use a common function to replace it in MATE source code to have GTK3 support
-rw-r--r--libmate-desktop/mate-desktop-utils.c47
-rw-r--r--libmate-desktop/mate-desktop-utils.h5
2 files changed, 52 insertions, 0 deletions
diff --git a/libmate-desktop/mate-desktop-utils.c b/libmate-desktop/mate-desktop-utils.c
index 4d6d170..e434f84 100644
--- a/libmate-desktop/mate-desktop-utils.c
+++ b/libmate-desktop/mate-desktop-utils.c
@@ -163,6 +163,53 @@ mate_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+/**
+ * mate_gdk_spawn_command_line_on_screen:
+ * @screen: a GdkScreen
+ * @command: a command line
+ * @error: return location for errors
+ *
+ * This is a replacement for gdk_spawn_command_line_on_screen, removed
+ * in GTK3.
+ *
+ * gdk_spawn_command_line_on_screen is like g_spawn_command_line_async(),
+ * except the child process is spawned in such an environment that on
+ * calling gdk_display_open() it would be returned a GdkDisplay with
+ * screen as the default screen.
+ *
+ * This is useful for applications which wish to launch an application
+ * on a specific screen.
+ *
+ * Returns: TRUE on success, FALSE if error is set.
+ *
+ * Since: 1.7.1
+ **/
+gboolean
+mate_gdk_spawn_command_line_on_screen (GdkScreen *screen, const gchar *command, GError **error)
+{
+ GAppInfo *appinfo = NULL;
+ GdkAppLaunchContext *context = NULL;
+
+ appinfo = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NONE, &error);
+
+ if (!error) {
+ context = gdk_app_launch_context_new ();
+ gdk_app_launch_context_set_screen (context, screen);
+ g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), &error);
+ g_object_unref (context);
+ }
+
+ if (appinfo != NULL)
+ g_object_unref (appinfo);
+
+ if (!error)
+ return TRUE;
+ else
+ return FALSE;
+}
+#endif
+
void
_mate_desktop_init_i18n (void) {
static gboolean initialized = FALSE;
diff --git a/libmate-desktop/mate-desktop-utils.h b/libmate-desktop/mate-desktop-utils.h
index f2e659f..dd6921b 100644
--- a/libmate-desktop/mate-desktop-utils.h
+++ b/libmate-desktop/mate-desktop-utils.h
@@ -44,6 +44,11 @@ extern "C" {
/* prepend the terminal command to a vector */
void mate_desktop_prepend_terminal_to_vector (int *argc, char ***argv);
+#if GTK_CHECK_VERSION (3, 0, 0)
+/* replace gdk_spawn_command_line_on_screen, not available in GTK3 */
+gboolean mate_gdk_spawn_command_line_on_screen (GdkScreen *screen, const gchar *command, GError **error);
+#endif
+
#ifdef __cplusplus
}
#endif