void _g_launch_command (GtkWidget *parent, const char *command, const char *name, GList *files) { GError *error = NULL; GAppInfo *app_info; GdkAppLaunchContext *launch_context; app_info = g_app_info_create_from_commandline (command, name, G_APP_INFO_CREATE_SUPPORTS_URIS, &error); if (app_info == NULL) { _gtk_error_dialog_from_gerror_show(GTK_WINDOW (parent), _("Could not launch the application"), &error); return; } launch_context = gdk_app_launch_context_new (); gdk_app_launch_context_set_screen (launch_context, gtk_widget_get_screen (parent)); if (! g_app_info_launch (app_info, files, G_APP_LAUNCH_CONTEXT (launch_context), &error)) { _gtk_error_dialog_from_gerror_show(GTK_WINDOW (parent), _("Could not launch the application"), &error); return; } g_object_unref (app_info); }
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); } } }
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; }
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 notification_cb (NotifyNotification *notification, gchar *action, gpointer user_data) { GAppLaunchContext *ctx; GDesktopAppInfo *app; GError *error; /* TODO: Hmm, would be nice to set the screen, timestamp etc etc */ ctx = g_app_launch_context_new (); app = g_desktop_app_info_new ("gnome-online-accounts-panel.desktop"); error = NULL; if (!g_app_info_launch (G_APP_INFO (app), NULL, /* files */ ctx, &error)) { goa_warning ("Error launching: %s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); } g_object_unref (app); g_object_unref (ctx); }
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); }
gboolean gs_plugin_launch (GsPlugin *plugin, GsApp *app, GCancellable *cancellable, GError **error) { const gchar *launch_name; g_autofree gchar *binary_name = NULL; GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; g_autoptr(GAppInfo) info = NULL; /* We can only launch apps we know of */ if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) return TRUE; launch_name = gs_app_get_metadata_item (app, "snap::launch-name"); if (!launch_name) return TRUE; if (g_strcmp0 (launch_name, gs_app_get_id (app)) == 0) binary_name = g_strdup_printf ("/snap/bin/%s", launch_name); else binary_name = g_strdup_printf ("/snap/bin/%s.%s", gs_app_get_id (app), launch_name); if (!is_graphical (app, cancellable)) flags |= G_APP_INFO_CREATE_NEEDS_TERMINAL; info = g_app_info_create_from_commandline (binary_name, NULL, flags, error); if (info == NULL) return FALSE; return g_app_info_launch (info, NULL, NULL, error); }
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); } }
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 launch_cmd(const char *cmd, const char *appname) { GAppInfo *appinfo = NULL; gboolean ret = FALSE; appinfo = g_app_info_create_from_commandline(cmd, NULL, G_APP_INFO_CREATE_NONE, NULL); if (appname) { kdesk_hourglass_start((char *) appname); } if (appinfo == NULL) { perror("Command lanuch failed."); if (appname) { kdesk_hourglass_end(); } return; } ret = g_app_info_launch(appinfo, NULL, NULL, NULL); if (!ret) { perror("Command lanuch failed."); if (appname) { kdesk_hourglass_end(); } } }
/* This function launches whatever item is selected in the menu deployed by the function below. */ void menu_launch(GtkMenuItem *unused, gpointer data) { psi const si = (psi)data; GError *err = NULL; g_app_info_launch((GAppInfo*)si->dfile,NULL,NULL,&err); si->uses++; si->lastaccess = make_timestamp(); resolve_item_order(((psi)data)->parent); save_current_list(((psi)data)->parent); }
static void launcher_activated(GtkWidget *widget, gchar *command) { GError *error = NULL; GAppInfo *app = g_app_info_create_from_commandline(command, NULL, 0, &error); if (!g_app_info_launch(app, NULL, NULL, &error)) { exit(1); } }
/* Take a desktop file and execute it */ static void desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data) { GAppInfo * appinfo = G_APP_INFO(data); g_return_if_fail(appinfo != NULL); g_app_info_launch(appinfo, NULL, NULL, NULL); return; }
static gboolean exo_open_launch_desktop_file (const gchar *arg) { #ifdef HAVE_GIO_UNIX GFile *gfile; gchar *contents; gsize length; gboolean result; GKeyFile *key_file; GDesktopAppInfo *appinfo; /* try to open a file from the arguments */ gfile = g_file_new_for_commandline_arg (arg); if (G_UNLIKELY (gfile == NULL)) return FALSE; /* load the contents of the file */ result = g_file_load_contents (gfile, NULL, &contents, &length, NULL, NULL); g_object_unref (G_OBJECT (gfile)); if (G_UNLIKELY (!result || length == 0)) return FALSE; /* create the key file */ key_file = g_key_file_new (); result = g_key_file_load_from_data (key_file, contents, length, G_KEY_FILE_NONE, NULL); g_free (contents); if (G_UNLIKELY (!result)) { g_key_file_free (key_file); return FALSE; } /* create the appinfo */ appinfo = g_desktop_app_info_new_from_keyfile (key_file); g_key_file_free (key_file); if (G_UNLIKELY (appinfo == NULL)) return FALSE; /* try to launch a (non-hidden) desktop file */ if (G_LIKELY (!g_desktop_app_info_get_is_hidden (appinfo))) result = g_app_info_launch (G_APP_INFO (appinfo), NULL, NULL, NULL); else result = FALSE; g_object_unref (G_OBJECT (appinfo)); #ifndef NDEBUG g_debug ("launching desktop file %s", result ? "succeeded" : "failed"); #endif return result; #else /* !HAVE_GIO_UNIX */ g_critical (_("Launching desktop files is not supported when %s is compiled " "without GIO-Unix features."), g_get_prgname ()); return FALSE; #endif }
static void on_examine_action_clicked (NotifyNotification *notification, const gchar *action, gpointer user_data) { GduSdMonitor *monitor = GDU_SD_MONITOR (user_data); const gchar *device_file = NULL; gchar *command_line = NULL; GAppInfo *app_info = NULL; GError *error = NULL; if (g_strcmp0 (action, "examine-smart") == 0) { if (monitor->ata_smart_problems != NULL) { UDisksObject *object = UDISKS_OBJECT (monitor->ata_smart_problems->data); if (object != NULL) { UDisksDrive *drive = udisks_object_peek_drive (object); if (drive != NULL) { UDisksBlock *block = udisks_client_get_block_for_drive (monitor->client, drive, TRUE); /* get_physical */ if (block != NULL) { device_file = udisks_block_get_device (block); g_object_ref (block); } } } } } else { g_assert_not_reached (); } if (device_file != NULL) command_line = g_strdup_printf ("gnome-disks --block-device %s", device_file); else command_line = g_strdup_printf ("gnome-disks"); app_info = g_app_info_create_from_commandline (command_line, NULL, /* application name */ G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION, NULL); if (!g_app_info_launch (app_info, NULL, NULL, &error)) { g_warning ("Error launching gnome-disks: %s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_clear_error (&error); } g_clear_object (&app_info); g_free (command_line); }
gboolean ol_launch_app (const char *cmdline) { ol_assert_ret (cmdline != NULL, FALSE); GAppInfo* app = g_app_info_create_from_commandline (cmdline, "", 0, NULL); gboolean ret = g_app_info_launch (app, NULL, NULL, NULL); g_object_unref (G_OBJECT (app)); 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); }
static gboolean launch_previewer (void) { GString *cmd_str; gchar *cmd; gboolean retval = FALSE; GError *error = NULL; /* Rebuild the command line, ignoring options * not supported by the previewer and taking only * the first path given */ cmd_str = g_string_new ("evince-previewer"); if (print_settings) { gchar *quoted; quoted = g_shell_quote (print_settings); g_string_append_printf (cmd_str, " --print-settings %s", quoted); g_free (quoted); } if (unlink_temp_file) g_string_append (cmd_str, " --unlink-tempfile"); if (file_arguments) { gchar *quoted; quoted = g_shell_quote (file_arguments[0]); g_string_append_printf (cmd_str, " %s", quoted); g_free (quoted); } cmd = g_string_free (cmd_str, FALSE); if (!error) { GAppInfo *app; app = g_app_info_create_from_commandline (cmd, NULL, 0, &error); if (app != NULL) { retval = g_app_info_launch (app, NULL, NULL, &error); g_object_unref (app); } } if (error) { g_warning ("Error launching previewer: %s\n", error->message); g_error_free (error); } g_free (cmd); return retval; }
/* This function launches the first item on our list; the one we're displaying in the panel. */ void menu_launch_first(pqi inst) { GError *err = NULL; if (inst && inst->items) { g_app_info_launch((GAppInfo*)inst->items->dfile,NULL,NULL,&err); inst->items->uses++; inst->items->lastaccess = make_timestamp(); resolve_item_order(inst); save_current_list(inst); } }
static gboolean display_file (GFile* file, const char* content_type) { gboolean res = TRUE; GAppInfo *app = g_app_info_get_default_for_type(content_type, FALSE); GList* list = g_list_append(NULL, file); res = g_app_info_launch(app, list, NULL, NULL); g_list_free(list); g_object_unref(app); return res; }
gboolean fm_app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error) { gboolean supported = FALSE, ret = FALSE; if (G_IS_DESKTOP_APP_INFO (appinfo)) { const char*id = g_app_info_get_id (appinfo); if (id) // this is an installed application { // load the desktop entry file to obtain more info GKeyFile *kf = g_key_file_new (); char *rel_path = g_strconcat ("applications/", id, NULL); char *full_desktop_path; supported = g_key_file_load_from_data_dirs (kf, rel_path, &full_desktop_path, 0, NULL); g_free (rel_path); if (supported) { ret = do_launch (appinfo, full_desktop_path, kf, files, launch_context, error); g_free (full_desktop_path); } g_key_file_free (kf); } else { const char *file = g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (appinfo)); if (file) // this is a desktop entry file { // load the desktop entry file to obtain more info GKeyFile *kf = g_key_file_new (); supported = g_key_file_load_from_file (kf, file, 0, NULL); if (supported) ret = do_launch (appinfo, file, kf, files, launch_context, error); g_key_file_free (kf); } else { // If this is created with fm_app_info_create_from_commandline () if (g_object_get_data (G_OBJECT (appinfo), "flags")) { supported = TRUE; ret = do_launch (appinfo, NULL, NULL, files, launch_context, error); } } } } else supported = FALSE; if (!supported) // fallback to GAppInfo::launch return g_app_info_launch (appinfo, files, launch_context, error); return ret; }
static gboolean _app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error) { OlAppInfo *info = OL_APP_INFO (appinfo); /* TODO: implement launching. */ GAppInfo* app = g_app_info_create_from_commandline (info->cmdline, "", 0, NULL); gboolean ret = g_app_info_launch (app, files, launch_context, error); g_object_unref (G_OBJECT (app)); return ret; }
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; }
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 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 void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data) { AutoRun* data = (AutoRun*)user_data; /* stop the detection */ g_cancellable_cancel(data->cancel); if(res == GTK_RESPONSE_OK) { GtkTreeModel* model; GtkTreeSelection* sel = gtk_tree_view_get_selection(data->view); GtkTreeIter it; if( gtk_tree_selection_get_selected(sel, &model, &it) ) { GAppInfo* app; gtk_tree_model_get(model, &it, 2, &app, -1); if(app) { GFile* gf = g_mount_get_root(data->mount); GList* filelist = g_list_prepend(NULL, gf); g_app_info_launch(app, filelist, NULL, NULL); g_list_free(filelist); g_object_unref(gf); g_object_unref(app); } else { GFile* gf = g_mount_get_root(data->mount); FmPath* path = fm_path_new_for_gfile(gf); fm_main_win_add_win(NULL, path); fm_path_unref(path); g_object_unref(gf); } } } g_signal_handlers_disconnect_by_func(dlg, on_dlg_response, data); g_signal_handlers_disconnect_by_func(data->view, on_row_activated, data); g_signal_handlers_disconnect_by_func(data->mount, on_unmount, data); gtk_widget_destroy(GTK_WIDGET(dlg)); g_object_unref(data->cancel); g_object_unref(data->store); g_object_unref(data->mount); g_slice_free(AutoRun, data); pcmanfm_unref(); }
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; }
static void csd_autorun_launch_for_mount (GMount *mount, GAppInfo *app_info) { GFile *root; GdkAppLaunchContext *launch_context; GError *error; gboolean result; GList *list; gchar *uri_scheme; gchar *uri; root = g_mount_get_root (mount); list = g_list_append (NULL, root); launch_context = gdk_app_launch_context_new (); error = NULL; result = g_app_info_launch (app_info, list, G_APP_LAUNCH_CONTEXT (launch_context), &error); g_object_unref (launch_context); if (!result) { if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_SUPPORTED) { uri = g_file_get_uri (root); uri_scheme = g_uri_parse_scheme (uri); /* FIXME: Present user a dialog to choose another app when the last one failed to handle a file */ g_warning ("Cannot open location: %s\n", error->message); g_free (uri_scheme); g_free (uri); } else { g_warning ("Cannot open app: %s\n", error->message); } g_error_free (error); } g_list_free (list); g_object_unref (root); }