summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2010-12-26 16:20:00 +0100
committerCosimo Cecchi <cosimoc@gnome.org>2010-12-26 16:20:00 +0100
commitbd151c8174796c1c5b0b6466ef8a0e3a0e214054 (patch)
treebd921186a4eca7a07028fdd84fe38dedddd42eb3
parent2ff006dd583f58ff2dd687f538e59757a8bd70c4 (diff)
downloadnautilus-bd151c8174796c1c5b0b6466ef8a0e3a0e214054.tar.gz
general: don't use deprecated gdk_app_launch_context_new()
-rw-r--r--eel/eel-gnome-extensions.c12
-rw-r--r--eel/eel-gnome-extensions.h4
-rw-r--r--libnautilus-private/nautilus-program-choosing.c88
-rw-r--r--src/nautilus-connect-server-dialog-main.c2
4 files changed, 51 insertions, 55 deletions
diff --git a/eel/eel-gnome-extensions.c b/eel/eel-gnome-extensions.c
index fbe74378e..73e9378f2 100644
--- a/eel/eel-gnome-extensions.c
+++ b/eel/eel-gnome-extensions.c
@@ -144,7 +144,7 @@ get_terminal_command_prefix (gboolean for_command)
return command;
}
-char *
+static char *
eel_gnome_make_terminal_command (const char *command)
{
char *prefix, *quoted, *terminal_command;
@@ -168,6 +168,7 @@ eel_gnome_open_terminal_on_screen (const char *command,
GAppInfo *app;
GdkAppLaunchContext *ctx;
GError *error = NULL;
+ GdkDisplay *display;
command_line = eel_gnome_make_terminal_command (command);
if (command_line == NULL) {
@@ -178,7 +179,8 @@ eel_gnome_open_terminal_on_screen (const char *command,
app = g_app_info_create_from_commandline (command_line, NULL, 0, &error);
if (app != NULL && screen != NULL) {
- ctx = gdk_app_launch_context_new ();
+ display = gdk_screen_get_display (screen);
+ ctx = gdk_display_get_app_launch_context (display);
gdk_app_launch_context_set_screen (ctx, screen);
g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), &error);
@@ -195,9 +197,3 @@ eel_gnome_open_terminal_on_screen (const char *command,
g_free (command_line);
}
-
-void
-eel_gnome_open_terminal (const char *command)
-{
- eel_gnome_open_terminal_on_screen (command, NULL);
-}
diff --git a/eel/eel-gnome-extensions.h b/eel/eel-gnome-extensions.h
index 82c137407..8a00d5e0a 100644
--- a/eel/eel-gnome-extensions.h
+++ b/eel/eel-gnome-extensions.h
@@ -29,11 +29,7 @@
#include <gtk/gtk.h>
-/* Return a command string containing the path to a terminal on this system. */
-char * eel_gnome_make_terminal_command (const char *command);
-
/* Open up a new terminal, optionally passing in a command to execute */
-void eel_gnome_open_terminal (const char *command);
void eel_gnome_open_terminal_on_screen (const char *command,
GdkScreen *screen);
diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c
index a003b840a..e2e791e44 100644
--- a/libnautilus-private/nautilus-program-choosing.c
+++ b/libnautilus-private/nautilus-program-choosing.c
@@ -95,12 +95,13 @@ nautilus_launch_application_by_uri (GAppInfo *application,
GList *uris,
GtkWindow *parent_window)
{
- char *uri;
- GList *locations, *l;
+ char *uri;
+ GList *locations, *l;
GFile *location;
- NautilusFile *file;
- gboolean result;
+ NautilusFile *file;
+ gboolean result;
GError *error;
+ GdkDisplay *display;
GdkAppLaunchContext *launch_context;
NautilusIconInfo *icon;
int count, total;
@@ -122,10 +123,18 @@ nautilus_launch_application_by_uri (GAppInfo *application,
}
locations = g_list_reverse (locations);
- launch_context = gdk_app_launch_context_new ();
- if (parent_window)
+ if (parent_window != NULL) {
+ display = gtk_widget_get_display (GTK_WIDGET (parent_window));
+ } else {
+ display = gdk_display_get_default ();
+ }
+
+ launch_context = gdk_display_get_app_launch_context (display);
+
+ if (parent_window != NULL) {
gdk_app_launch_context_set_screen (launch_context,
gtk_window_get_screen (parent_window));
+ }
file = nautilus_file_get_by_uri (uris->data);
icon = nautilus_file_get_icon (file, 48, 0);
@@ -168,6 +177,33 @@ nautilus_launch_application_by_uri (GAppInfo *application,
g_list_free_full (locations, g_object_unref);
}
+static void
+launch_application_from_command_internal (const gchar *full_command,
+ GdkScreen *screen,
+ gboolean use_terminal)
+{
+ GAppInfo *app;
+ GdkAppLaunchContext *ctx;
+ GdkDisplay *display;
+
+ if (use_terminal) {
+ eel_gnome_open_terminal_on_screen (full_command, screen);
+ } else {
+ app = g_app_info_create_from_commandline (full_command, NULL, 0, NULL);
+
+ if (app != NULL) {
+ display = gdk_screen_get_display (screen);
+ ctx = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (ctx, screen);
+
+ g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), NULL);
+
+ g_object_unref (app);
+ g_object_unref (ctx);
+ }
+ }
+}
+
/**
* nautilus_launch_application_from_command:
*
@@ -188,8 +224,6 @@ nautilus_launch_application_from_command (GdkScreen *screen,
char *quoted_parameter;
char *parameter;
va_list ap;
- GAppInfo *app;
- GdkAppLaunchContext *ctx;
full_command = g_strdup (command_string);
@@ -207,22 +241,8 @@ nautilus_launch_application_from_command (GdkScreen *screen,
va_end (ap);
- if (use_terminal) {
- eel_gnome_open_terminal_on_screen (full_command, screen);
- } else {
- app = g_app_info_create_from_commandline (full_command, NULL, 0, NULL);
-
- if (app != NULL) {
- ctx = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_screen (ctx, screen);
-
- g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), NULL);
-
- g_object_unref (app);
- g_object_unref (ctx);
- }
- }
-
+ launch_application_from_command_internal (full_command, screen, use_terminal);
+
g_free (full_command);
}
@@ -245,8 +265,6 @@ nautilus_launch_application_from_command_array (GdkScreen *screen,
char *full_command, *tmp;
char *quoted_parameter;
const char * const *p;
- GAppInfo *app;
- GdkAppLaunchContext *ctx;
full_command = g_strdup (command_string);
@@ -261,21 +279,7 @@ nautilus_launch_application_from_command_array (GdkScreen *screen,
}
}
- if (use_terminal) {
- eel_gnome_open_terminal_on_screen (full_command, screen);
- } else {
- app = g_app_info_create_from_commandline (full_command, NULL, 0, NULL);
-
- if (app != NULL) {
- ctx = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_screen (ctx, screen);
-
- g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), NULL);
-
- g_object_unref (app);
- g_object_unref (ctx);
- }
- }
+ launch_application_from_command_internal (full_command, screen, use_terminal);
g_free (full_command);
}
@@ -362,7 +366,7 @@ nautilus_launch_desktop_file (GdkScreen *screen,
}
error = NULL;
- context = gdk_app_launch_context_new ();
+ context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (parent_window)));
/* TODO: Ideally we should accept a timestamp here instead of using GDK_CURRENT_TIME */
gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME);
gdk_app_launch_context_set_screen (context,
diff --git a/src/nautilus-connect-server-dialog-main.c b/src/nautilus-connect-server-dialog-main.c
index d25eaf3aa..8b518fe08 100644
--- a/src/nautilus-connect-server-dialog-main.c
+++ b/src/nautilus-connect-server-dialog-main.c
@@ -88,7 +88,7 @@ nautilus_connect_server_dialog_display_location_async (NautilusConnectServerDial
g_print ("%s\n", uri);
}
else {
- launch_context = gdk_app_launch_context_new ();
+ launch_context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (self)));
gdk_app_launch_context_set_screen (launch_context,
gtk_widget_get_screen (GTK_WIDGET (self)));