/* Helper functions */ gint ev_document_links_get_dest_page (EvDocumentLinks *document_links, EvLinkDest *dest) { gint page = -1; switch (ev_link_dest_get_dest_type (dest)) { case EV_LINK_DEST_TYPE_NAMED: { page = ev_document_links_find_link_page (document_links, ev_link_dest_get_named_dest (dest)); } break; case EV_LINK_DEST_TYPE_PAGE_LABEL: ev_document_find_page_by_label (EV_DOCUMENT (document_links), ev_link_dest_get_page_label (dest), &page); break; default: page = ev_link_dest_get_page (dest); } return page; }
static void ev_spawn (const char *uri, GdkScreen *screen, EvLinkDest *dest, EvWindowRunMode mode, const gchar *search_string, guint timestamp) { GString *cmd; gchar *path, *cmdline; GAppInfo *app; GdkAppLaunchContext *ctx; GError *error = NULL; cmd = g_string_new (NULL); #ifdef G_OS_WIN32 { gchar *dir; dir = g_win32_get_package_installation_directory_of_module (NULL); path = g_build_filename (dir, "bin", "atril", NULL); g_free (dir); } #else path = g_build_filename (BINDIR, "atril", NULL); #endif g_string_append_printf (cmd, " %s", path); g_free (path); /* Page label */ if (dest) { const gchar *page_label; page_label = ev_link_dest_get_page_label (dest); if (page_label) g_string_append_printf (cmd, " --page-label=%s", page_label); else g_string_append_printf (cmd, " --page-label=%d", ev_link_dest_get_page (dest)); } /* Find string */ if (search_string) { g_string_append_printf (cmd, " --find=%s", search_string); } /* Mode */ switch (mode) { case EV_WINDOW_MODE_FULLSCREEN: g_string_append (cmd, " -f"); break; case EV_WINDOW_MODE_PRESENTATION: g_string_append (cmd, " -s"); break; default: break; } cmdline = g_string_free (cmd, FALSE); app = g_app_info_create_from_commandline (cmdline, NULL, 0, &error); if (app != NULL) { GList uri_list; GList *uris = NULL; #if GTK_CHECK_VERSION (3, 0, 0) ctx = gdk_display_get_app_launch_context (gdk_screen_get_display (screen)); #else ctx = gdk_app_launch_context_new (); gdk_app_launch_context_set_display (ctx, gdk_screen_get_display (screen)); #endif gdk_app_launch_context_set_screen (ctx, screen); gdk_app_launch_context_set_timestamp (ctx, timestamp); if (uri) { uri_list.data = (gchar *)uri; uri_list.prev = uri_list.next = NULL; uris = &uri_list; } g_app_info_launch_uris (app, uris, G_APP_LAUNCH_CONTEXT (ctx), &error); g_object_unref (app); g_object_unref (ctx); } if (error != NULL) { g_warning ("Error launching atril %s: %s\n", uri, error->message); g_error_free (error); } g_free (cmdline); }