static void popup_menu_launch_capplet () { GAppInfo *info; GdkAppLaunchContext *ctx; GError *error = NULL; info = g_app_info_create_from_commandline ("sagarmatha-settings region", NULL, 0, &error); if (info != NULL) { ctx = gdk_display_get_app_launch_context (gdk_display_get_default ()); if (g_app_info_launch (info, NULL, G_APP_LAUNCH_CONTEXT (ctx), &error) == FALSE) { g_warning ("Could not execute keyboard properties capplet: [%s]\n", error->message); g_error_free (error); } g_object_unref (info); g_object_unref (ctx); } }
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); } } }
static gboolean panel_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GdkScreen *screen, guint32 timestamp, GError **error) { GdkAppLaunchContext *context; GError *local_error; GdkDisplay *display; g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE); g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); display = gdk_screen_get_display (screen); context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, timestamp); local_error = NULL; g_app_info_launch_uris (appinfo, uris, (GAppLaunchContext *) context, &local_error); g_object_unref (context); return _panel_launch_handle_error (g_app_info_get_name (appinfo), screen, local_error, error); }
gboolean exec_app_info (const char *executable, GAppInfoCreateFlags flags) { GAppInfo *appinfo = NULL; GError *error = NULL; gboolean is_ok __attribute__((unused)) = FALSE; appinfo = gen_app_info (executable, flags); if ( appinfo == NULL ) { g_debug ("gen app info failed!"); return FALSE; } GdkAppLaunchContext* ctx = gdk_display_get_app_launch_context(gdk_display_get_default()); gdk_app_launch_context_set_screen(ctx, gdk_screen_get_default()); //must set this otherwise termiator will not work properly is_ok = g_app_info_launch (appinfo, NULL, (GAppLaunchContext*)ctx, &error); g_object_unref(ctx); if (error!=NULL) { g_debug("exec app info error: %s", error->message); g_error_free(error); g_object_unref (appinfo); return FALSE; } g_object_unref (appinfo); return TRUE; }
gboolean panel_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GdkScreen *screen, guint32 timestamp, GError **error) { GdkAppLaunchContext *context; GError *local_error; gboolean retval; g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (appinfo), FALSE); g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); GdkDisplay *display = gdk_display_get_default (); context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, timestamp); local_error = NULL; retval = g_desktop_app_info_launch_uris_as_manager ((GDesktopAppInfo*)appinfo, uris, (GAppLaunchContext *) context, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, gather_pid_callback, appinfo, &local_error); g_object_unref (context); if ((local_error == NULL) && (retval == TRUE)) return TRUE; return _panel_launch_handle_error (g_app_info_get_name ((GAppInfo*) appinfo), screen, local_error, error); }
/** * xfdashboard_create_app_context: * @inWorkspace: The workspace where to place application windows on or %NULL * * Returns a #GAppLaunchContext suitable for launching applications on the * given display and workspace by GIO. * * If @inWorkspace is specified it sets workspace on which applications will * be launched when using this context when running under a window manager * that supports multiple workspaces. * * When the workspace is not specified it is up to the window manager to pick * one, typically it will be the current workspace. * * Return value: (transfer full): the newly created #GAppLaunchContext or %NULL * in case of an error. Use g_object_unref() to free return value. */ GAppLaunchContext* xfdashboard_create_app_context(XfdashboardWindowTrackerWorkspace *inWorkspace) { GdkAppLaunchContext *context; const ClutterEvent *event; XfdashboardWindowTracker *tracker; g_return_val_if_fail(inWorkspace==NULL || XFDASHBOARD_IS_WINDOW_TRACKER_WORKSPACE(inWorkspace), NULL); /* Get last event for timestamp */ event=clutter_get_current_event(); /* Get active workspace if not specified */ if(!inWorkspace) { tracker=xfdashboard_window_tracker_get_default(); inWorkspace=xfdashboard_window_tracker_get_active_workspace(tracker); g_object_unref(tracker); } /* Create and set up application context to use either the workspace specified * or otherwise current active workspace. We will even set the current active * explicitly to launch the application on current workspace even if user changes * workspace in the time between launching application and showing first window. */ context=gdk_display_get_app_launch_context(gdk_display_get_default()); if(event) gdk_app_launch_context_set_timestamp(context, clutter_event_get_time(event)); gdk_app_launch_context_set_desktop(context, xfdashboard_window_tracker_workspace_get_number(inWorkspace)); /* Return application context */ return(G_APP_LAUNCH_CONTEXT(context)); }
void invoke(const gchar *cmd, const gchar *desktop, gboolean with_pkexec) { GdkAppLaunchContext *context; GAppInfo *appinfo; GError *error = NULL; static GtkWidget *w = NULL; // pkexec if(with_pkexec || FORCE_PKEXEC) { invoke_with_pkexec(cmd); return; } // fake window to get the current server time *urgh* if (!w) { w = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize (w); } // normal launch context = gdk_display_get_app_launch_context (gdk_display_get_default ()); guint32 timestamp = gdk_x11_get_server_time (gtk_widget_get_window (w)); appinfo = g_app_info_create_from_commandline(cmd, cmd, G_APP_INFO_CREATE_NONE, &error); gdk_app_launch_context_set_timestamp (context, timestamp); if (!g_app_info_launch (appinfo, NULL, (GAppLaunchContext*)context, &error)) g_warning ("Launching failed: %s", error->message); g_object_unref (context); g_object_unref (appinfo); }
static void on_open_with_easytag (NautilusMenuItem *item, gpointer data) { GList *files; GDesktopAppInfo *appinfo; files = g_object_get_data (G_OBJECT (item), "files"); appinfo = g_desktop_app_info_new ("easytag.desktop"); if (appinfo) { GdkAppLaunchContext *context; GList *l; GList *uris = NULL; for (l = files; l != NULL; l = g_list_next (l)) { uris = g_list_append (uris, nautilus_file_info_get_uri (l->data)); } context = gdk_display_get_app_launch_context (gdk_display_get_default ()); g_app_info_launch_uris (G_APP_INFO (appinfo), uris, G_APP_LAUNCH_CONTEXT (context), NULL); } }
gboolean libre_impuesto_file_launch_application (GAppInfo *app, GList *files, guint32 user_time, GtkWidget *widget) { GdkAppLaunchContext *context; GdkDisplay *display; GdkScreen *screen; gboolean res; if (widget) { display = gtk_widget_get_display (widget); screen = gtk_widget_get_screen (widget); } else { display = gdk_display_get_default (); screen = gdk_screen_get_default (); } context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, user_time); res = g_app_info_launch (app, files, G_APP_LAUNCH_CONTEXT (context), NULL); g_object_unref (context); return res; }
static void panel_menu_item_activate_switch_user (GtkWidget *menuitem, gpointer user_data) { GdkScreen *screen; GAppInfo *app_info; if (panel_lockdown_get_disable_switch_user_s ()) return; screen = gtk_widget_get_screen (GTK_WIDGET (menuitem)); app_info = g_app_info_create_from_commandline (GDM_FLEXISERVER_COMMAND " " GDM_FLEXISERVER_ARGS, GDM_FLEXISERVER_COMMAND, G_APP_INFO_CREATE_NONE, NULL); if (app_info) { GdkAppLaunchContext *launch_context; GdkDisplay *display; display = gdk_screen_get_display (screen); launch_context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (launch_context, screen); g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), NULL); g_object_unref (launch_context); g_object_unref (app_info); } }
void eel_gnome_open_terminal_on_screen (const char *command, GdkScreen *screen) { GAppInfo *app; GdkAppLaunchContext *ctx; GError *error = NULL; GdkDisplay *display; app = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NEEDS_TERMINAL, &error); if (app != NULL && screen != 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), &error); g_object_unref (app); g_object_unref (ctx); } if (error != NULL) { g_message ("Could not start application on terminal: %s", error->message); g_error_free (error); } }
/** * cinnamon_app_launch: * @timestamp: Event timestamp, or 0 for current event timestamp * @uris: (element-type utf8): List of uris to pass to application * @workspace: Start on this workspace, or -1 for default * @startup_id: (out): Returned startup notification ID, or %NULL if none * @error: A #GError */ gboolean cinnamon_app_launch (CinnamonApp *app, guint timestamp, GList *uris, int workspace, char **startup_id, GError **error) { GDesktopAppInfo *gapp; GdkAppLaunchContext *context; gboolean ret; CinnamonGlobal *global; MetaScreen *screen; GdkDisplay *gdisplay; if (startup_id) *startup_id = NULL; if (app->entry == NULL) { MetaWindow *window = window_backed_app_get_window (app); /* We can't pass URIs into a window; shouldn't hit this * code path. If we do, fix the caller to disallow it. */ g_return_val_if_fail (uris == NULL, TRUE); meta_window_activate (window, timestamp); return TRUE; } global = cinnamon_global_get (); screen = cinnamon_global_get_screen (global); gdisplay = gdk_screen_get_display (cinnamon_global_get_gdk_screen (global)); if (timestamp == 0) timestamp = cinnamon_global_get_current_time (global); if (workspace < 0) workspace = meta_screen_get_active_workspace_index (screen); context = gdk_display_get_app_launch_context (gdisplay); gdk_app_launch_context_set_timestamp (context, timestamp); gdk_app_launch_context_set_desktop (context, workspace); gapp = gmenu_tree_entry_get_app_info (app->entry); ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris, G_APP_LAUNCH_CONTEXT (context), G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, _gather_pid_callback, app, error); g_object_unref (context); return ret; }
/** * caja_launch_application_from_command: * * Fork off a process to launch an application with a given uri as * a parameter. * * @command_string: The application to be launched, with any desired * command-line options. * @...: Passed as parameters to the application after quoting each of them. */ void caja_launch_application_from_command (GdkScreen *screen, const char *name, const char *command_string, gboolean use_terminal, ...) { char *full_command, *tmp; char *quoted_parameter; char *parameter; va_list ap; full_command = g_strdup (command_string); va_start (ap, use_terminal); while ((parameter = va_arg (ap, char *)) != NULL) { quoted_parameter = g_shell_quote (parameter); tmp = g_strconcat (full_command, " ", quoted_parameter, NULL); g_free (quoted_parameter); g_free (full_command); full_command = tmp; } va_end (ap); if (use_terminal) { eel_mate_open_terminal_on_screen (full_command, screen); } else { GdkAppLaunchContext *launch_context; GdkDisplay *display; GAppInfo *app_info = NULL; app_info = g_app_info_create_from_commandline (full_command, NULL, G_APP_INFO_CREATE_NONE, NULL); if (app_info != NULL) { display = gdk_screen_get_display (screen); launch_context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (launch_context, screen); g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), NULL); g_object_unref (launch_context); g_object_unref (app_info); } } g_free (full_command); }
void empathy_launch_program (const gchar *dir, const gchar *name, const gchar *args) { GdkDisplay *display; GError *error = NULL; gchar *path, *cmd; GAppInfo *app_info; GdkAppLaunchContext *context = NULL; /* Try to run from source directory if possible */ path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src", name, NULL); if (!g_file_test (path, G_FILE_TEST_EXISTS)) { g_free (path); path = g_build_filename (dir, name, NULL); } if (args != NULL) cmd = g_strconcat (path, " ", args, NULL); else cmd = g_strdup (path); app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &error); if (app_info == NULL) { DEBUG ("Failed to create app info: %s", error->message); g_error_free (error); goto out; } display = gdk_display_get_default (); context = gdk_display_get_app_launch_context (display); if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context, &error)) { g_warning ("Failed to launch %s: %s", name, error->message); g_error_free (error); goto out; } out: tp_clear_object (&app_info); tp_clear_object (&context); g_free (path); g_free (cmd); }
static gboolean photos_empty_results_box_activate_link (PhotosEmptyResultsBox *self, const gchar *uri) { GAppInfo *app = NULL; GError *error; GdkAppLaunchContext *ctx = NULL; GdkDisplay *display; GdkScreen *screen; gboolean ret_val = FALSE; if (g_strcmp0 (uri, "system-settings") != 0) goto out; error = NULL; app = g_app_info_create_from_commandline ("gnome-control-center online-accounts", NULL, G_APP_INFO_CREATE_NONE, &error); if (error != NULL) { g_warning ("Unable to launch gnome-control-center: %s", error->message); g_error_free (error); goto out; } screen = gtk_widget_get_screen (GTK_WIDGET (self)); if (screen != NULL) display = gdk_screen_get_display (screen); else display = gdk_display_get_default (); ctx = gdk_display_get_app_launch_context (display); if (screen != NULL) gdk_app_launch_context_set_screen (ctx, screen); error = NULL; g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), &error); if (error != NULL) { g_warning ("Unable to launch gnome-control-center: %s", error->message); g_error_free (error); goto out; } ret_val = TRUE; out: g_clear_object (&ctx); g_clear_object (&app); return ret_val; }
static void fsearch_window_action_open_with (GSimpleAction *action, GVariant *variant, gpointer user_data) { FsearchApplicationWindow *self = user_data; GtkTreeSelection *selection = fsearch_application_window_get_listview_selection (self); GList *file_list = NULL; if (selection) { guint selected_rows = gtk_tree_selection_count_selected_rows (selection); if (selected_rows <= 10) { gtk_tree_selection_selected_foreach (selection, open_with_cb, &file_list); } } GDesktopAppInfo *app_info = NULL; GdkAppLaunchContext *launch_context = NULL; const char *app_id = g_variant_get_string (variant, NULL); if (!app_id) { goto out; } app_info = g_desktop_app_info_new (app_id); if (!app_info) { goto out; } GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (self)); launch_context = gdk_display_get_app_launch_context (display); if (!launch_context) { goto out; } g_app_info_launch (G_APP_INFO (app_info), file_list, G_APP_LAUNCH_CONTEXT (launch_context), NULL); out: if (launch_context) { g_object_unref (launch_context); launch_context = NULL; } if (app_info) { g_object_unref (app_info); app_info = NULL; } if (file_list) { g_list_free_full (file_list, g_object_unref); file_list = NULL; } }
static void dialog_cb(GtkAction* action, AccessxStatusApplet* sapplet) { GError* error = NULL; GdkScreen *screen; GdkAppLaunchContext *launch_context; GAppInfo *appinfo; if (sapplet->error_type != ACCESSX_STATUS_ERROR_NONE) { popup_error_dialog(sapplet); return; } screen = gtk_widget_get_screen (GTK_WIDGET (sapplet->applet)); appinfo = g_app_info_create_from_commandline ("mate-keyboard-properties --a11y", _("Open the keyboard preferences dialog"), G_APP_INFO_CREATE_NONE, &error); if (!error) { #if GTK_CHECK_VERSION (3, 0, 0) launch_context = gdk_display_get_app_launch_context ( gtk_widget_get_display (GTK_WIDGET (screen))); #else launch_context = gdk_app_launch_context_new (); #endif gdk_app_launch_context_set_screen (launch_context, screen); g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error); g_object_unref (launch_context); } if (error != NULL) { GtkWidget* dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("There was an error launching the keyboard preferences dialog: %s"), error->message); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL); gtk_window_set_screen(GTK_WINDOW(dialog), screen); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_widget_show(dialog); g_error_free(error); } g_object_unref (appinfo); }
static gboolean ev_attachment_launch_app (EvAttachment *attachment, GdkScreen *screen, guint32 timestamp, GError **error) { gboolean result; GList *files = NULL; GdkAppLaunchContext *context; GdkDisplay *display; GError *ioerror = NULL; g_assert (G_IS_FILE (attachment->priv->tmp_file)); g_assert (G_IS_APP_INFO (attachment->priv->app)); files = g_list_prepend (files, attachment->priv->tmp_file); display = screen ? gdk_screen_get_display (screen) : gdk_display_get_default (); context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, timestamp); result = g_app_info_launch (attachment->priv->app, files, G_APP_LAUNCH_CONTEXT (context), &ioerror); g_object_unref (context); if (!result) { g_set_error (error, EV_ATTACHMENT_ERROR, (gint) result, _("Couldn't open attachment “%s”: %s"), attachment->priv->name, ioerror->message); g_list_free (files); g_error_free (ioerror); return FALSE; } g_list_free (files); return TRUE; }
void nemo_connect_server_dialog_display_location_async (NemoConnectServerDialog *self, GFile *location, GAsyncReadyCallback callback, gpointer user_data) { GError *error; GdkAppLaunchContext *launch_context; gchar *uri; display_location_res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, nemo_connect_server_dialog_display_location_async); error = NULL; uri = g_file_get_uri (location); if (just_print_uri) { g_print ("%s\n", uri); } else { 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))); g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (launch_context), &error); g_object_unref (launch_context); } if (error != NULL) { g_simple_async_result_set_from_error (display_location_res, error); g_error_free (error); } g_simple_async_result_complete_in_idle (display_location_res); g_free (uri); g_object_unref (display_location_res); display_location_res = NULL; }
static void notification_action_cb (NotifyNotification *notification, const char *action, DrWright *dr) { GAppInfo *app_info; GdkAppLaunchContext *launch_context; g_assert (action != NULL); if (g_strcmp0 (action, "take-break") == 0) { if (dr->enabled) { dr->state = STATE_BREAK_SETUP; maybe_change_state (dr); } } else if (g_strcmp0 (action, "settings") == 0) { GError *error = NULL; launch_context = gdk_display_get_app_launch_context (gdk_display_get_default ()); app_info = g_app_info_create_from_commandline (BINDIR "/gnome-control-center typing-break", NULL, G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION, &error); if (error) { g_warning ("%s", error->message); goto out; } g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error); if (error) { g_warning ("%s", error->message); } out: g_clear_error (&error); g_object_unref (launch_context); } else { g_warning ("Unknown action: %s", action); } }
void _not_eel_gnome_open_terminal_on_screen (const char *command, GdkScreen *screen) { char *command_line; GAppInfo *app; GdkAppLaunchContext *ctx; GError *error = NULL; GdkDisplay *display; if (screen == NULL) { screen = gdk_screen_get_default (); } command_line = _not_eel_gnome_make_terminal_command (command); if (command_line == NULL) { g_message ("Could not start a terminal"); return; } app = g_app_info_create_from_commandline (command_line, NULL, 0, &error); 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), &error); g_object_unref (app); g_object_unref (ctx); } if (error != NULL) { g_message ("Could not start application on terminal: %s", error->message); g_error_free (error); } g_free (command_line); }
static void activate_open_with_application_item (GtkMenuItem *menuitem, gpointer data) { GthBrowser *browser = data; GList *items; GList *file_list; GList *uris; GList *scan; GAppInfo *appinfo; GdkAppLaunchContext *context; GError *error = NULL; items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser))); file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items); uris = NULL; for (scan = file_list; scan; scan = scan->next) { GthFileData *file_data = scan->data; uris = g_list_prepend (uris, g_file_get_uri (file_data->file)); } uris = g_list_reverse (uris); appinfo = g_object_get_data (G_OBJECT (menuitem), "appinfo"); g_return_if_fail (G_IS_APP_INFO (appinfo)); context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (browser))); gdk_app_launch_context_set_timestamp (context, 0); gdk_app_launch_context_set_icon (context, g_app_info_get_icon (appinfo)); if (! g_app_info_launch_uris (appinfo, uris, G_APP_LAUNCH_CONTEXT (context), &error)) { _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not perform the operation"), error); g_clear_error (&error); } g_object_unref (context); g_list_free (uris); _g_object_list_unref (file_list); _gtk_tree_path_list_free (items); }
bool LauncherApplication::launch() { if (m_appInfo == NULL) { return false; } GError* error = NULL; GdkWindow* root; guint32 timestamp; GdkDisplay* display = gdk_display_get_default(); GObjectScopedPointer<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display)); /* We need to take the timestamp from the X server for the window manager to work properly https://bugs.launchpad.net/unity-2d/+bug/735205 */ /* FIXME: ultimately we should forward the timestamps from events that triggered the launch */ root = gdk_x11_window_lookup_for_display(display, GDK_ROOT_WINDOW()); timestamp = gdk_x11_get_server_time(root); gdk_app_launch_context_set_timestamp(context.data(), timestamp); g_app_info_launch(m_appInfo.data(), NULL, (GAppLaunchContext*)context.data(), &error); if (error != NULL) { UQ_WARNING << "Failed to launch application:" << error->message; g_error_free(error); return false; } /* 'launching' property becomes true for a few seconds and becomes false as soon as the application is launched */ m_launching_timer.start(); launchingChanged(true); return true; }
gboolean panel_show_uri_force_mime_type (GdkScreen *screen, const gchar *uri, const gchar *mime_type, guint32 timestamp, GError **error) { GFile *file; GAppInfo *appinfo; gboolean ret; GdkDisplay *display; GdkAppLaunchContext *context; GList *uris; g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (mime_type != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); file = g_file_new_for_uri (uri); appinfo = g_app_info_get_default_for_type (mime_type, !g_file_is_native (file)); g_object_unref (file); if (appinfo == NULL) { /* no application for the mime type, so let's fallback on * automatic detection */ return panel_show_uri (screen, uri, timestamp, error); } uris = g_list_append (NULL, (gpointer)uri); display = gdk_screen_get_display (screen); context = gdk_display_get_app_launch_context (display); ret = g_app_info_launch_uris (appinfo, uris, G_APP_LAUNCH_CONTEXT(context), error); g_object_unref (context); g_list_free (uris); g_object_unref (appinfo); return ret; }
static void show_selected_settings (GtkButton *button, gpointer data) { GtkBuilder *builder = data; GtkTreeModel *model; GtkTreeIter iter; GdkAppLaunchContext *ctx; GDesktopAppInfo *app_info; gchar *id; GError *error = NULL; g_debug ("show selected layout"); if (!get_selected_iter (builder, &model, &iter)) return; gtk_tree_model_get (model, &iter, SETUP_COLUMN, &app_info, -1); if (!app_info) return; ctx = gdk_display_get_app_launch_context (gdk_display_get_default ()); gdk_app_launch_context_set_timestamp (ctx, gtk_get_current_event_time ()); gtk_tree_model_get (model, &iter, ID_COLUMN, &id, -1); g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (ctx), "IBUS_ENGINE_NAME", id); g_free (id); if (!g_app_info_launch (G_APP_INFO (app_info), NULL, G_APP_LAUNCH_CONTEXT (ctx), &error)) { g_warning ("Failed to launch input source setup: %s", error->message); g_error_free (error); } g_object_unref (ctx); g_object_unref (app_info); }
/* Connect Server */ static void panel_action_connect_server (GtkWidget *widget) { GdkScreen *screen; GAppInfo *app_info; GError *error; screen = gtk_widget_get_screen (GTK_WIDGET (widget)); error = NULL; app_info = g_app_info_create_from_commandline ("nautilus-connect-server", _("Connect to server"), G_APP_INFO_CREATE_NONE, &error); if (!error) { GdkAppLaunchContext *launch_context; GdkDisplay *display; display = gdk_screen_get_display (screen); launch_context = gdk_display_get_app_launch_context (display); 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); g_object_unref (app_info); } if (error) { panel_error_dialog (NULL, screen, "cannot_connect_server", TRUE, _("Could not connect to server"), error->message); g_clear_error (&error); } }
static void on_open_in_easytag (NautilusMenuItem *item, gpointer data) { NautilusFileInfo *dir; GDesktopAppInfo *appinfo; dir = g_object_get_data (G_OBJECT (item), "dir"); appinfo = g_desktop_app_info_new ("easytag.desktop"); if (appinfo) { GdkAppLaunchContext *context; GList *uris = NULL; uris = g_list_append (uris, nautilus_file_info_get_uri (dir)); context = gdk_display_get_app_launch_context (gdk_display_get_default ()); g_app_info_launch_uris (G_APP_INFO (appinfo), uris, G_APP_LAUNCH_CONTEXT (context), NULL); } }
static gboolean launch_app_info (GAppInfo *app_info, GError **error) { GdkAppLaunchContext *context = NULL; GdkDisplay *display; GError *err = NULL; display = gdk_display_get_default (); context = gdk_display_get_app_launch_context (display); if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context, &err)) { DEBUG ("Failed to launch %s: %s", g_app_info_get_display_name (app_info), err->message); g_propagate_error (error, err); return FALSE; } tp_clear_object (&context); return TRUE; }
static void gb_project_tree_actions_open_with (GSimpleAction *action, GVariant *variant, gpointer user_data) { g_autoptr(GDesktopAppInfo) app_info = NULL; g_autoptr(GdkAppLaunchContext) launch_context = NULL; GbProjectTree *self = user_data; GbTreeNode *selected; GbWorkbench *workbench; GdkDisplay *display; GFileInfo *file_info; GFile *file; const gchar *app_id; GObject *item; GList *files; g_assert (GB_IS_PROJECT_TREE (self)); g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)); if (!(workbench = gb_widget_get_workbench (GTK_WIDGET (self))) || !(selected = gb_tree_get_selected (GB_TREE (self))) || !(item = gb_tree_node_get_item (selected)) || !IDE_IS_PROJECT_FILE (item) || !(app_id = g_variant_get_string (variant, NULL)) || !(file_info = ide_project_file_get_file_info (IDE_PROJECT_FILE (item))) || !(file = ide_project_file_get_file (IDE_PROJECT_FILE (item))) || !(app_info = g_desktop_app_info_new (app_id))) return; display = gtk_widget_get_display (GTK_WIDGET (self)); launch_context = gdk_display_get_app_launch_context (display); files = g_list_append (NULL, file); g_app_info_launch (G_APP_INFO (app_info), files, G_APP_LAUNCH_CONTEXT (launch_context), NULL); g_list_free (files); }
GAppLaunchContext * photos_utils_new_app_launch_context_from_widget (GtkWidget *widget) { GAppLaunchContext *ret_val = NULL; g_autoptr (GdkAppLaunchContext) ctx = NULL; GdkDisplay *display = NULL; GdkScreen *screen = NULL; if (widget != NULL) { screen = gtk_widget_get_screen (widget); display = gdk_screen_get_display (screen); } if (display == NULL) display = gdk_display_get_default (); ctx = gdk_display_get_app_launch_context (display); if (screen != NULL) gdk_app_launch_context_set_screen (ctx, screen); ret_val = G_APP_LAUNCH_CONTEXT (g_steal_pointer (&ctx)); return ret_val; }