/** \return A new document just for you! \brief This function takes in a filename of a SVG document and turns it into a SPDocument. \param mod Module to use \param uri The path to the file (UTF-8) This function is really simple, it just calls sp_document_new... */ SPDocument * Svg::open (Inkscape::Extension::Input */*mod*/, const gchar *uri) { #ifdef WITH_GNOME_VFS if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) { // Use built-in loader instead of VFS for this return sp_document_new(uri, TRUE); } gchar * buffer = _load_uri(uri); if (buffer == NULL) { g_warning("Error: Could not open file '%s' with VFS\n", uri); return NULL; } SPDocument * doc = sp_document_new_from_mem(buffer, strlen(buffer), 1); g_free(buffer); return doc; #else return sp_document_new (uri, TRUE); #endif }
bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) { Glib::ustring fileName = theFileName; fileName = Glib::filename_to_utf8(fileName); SPDocument *doc = sp_document_new (fileName.c_str(), 0); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; } showSvgDocument(doc); sp_document_unref(doc); return true; }
void sp_help_about (void) { SPDocument *doc; SPObject *title; GtkWidget *v; gint width, height; if (!w) { doc = sp_document_new (INKSCAPE_PIXMAPDIR "/about.svg", FALSE, TRUE); g_return_if_fail (doc != NULL); title = sp_document_lookup_id (doc, "title"); if (title && SP_IS_TEXT (title)) { gchar *t; t = g_strdup_printf ("Inkscape %s", INKSCAPE_VERSION); sp_text_set_repr_text_multiline (SP_TEXT (title), t); g_free (t); } sp_document_ensure_up_to_date (doc); w = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (w), _("About Inkscape")); width = INK_STATIC_CAST( gint, CLAMP( sp_document_width(doc), WINDOW_MIN, WINDOW_MAX ) ); height = INK_STATIC_CAST( gint, CLAMP( sp_document_height(doc), WINDOW_MIN, WINDOW_MAX ) ); gtk_window_set_default_size (GTK_WINDOW (w), width, height ); gtk_window_set_position(GTK_WINDOW(w), GTK_WIN_POS_CENTER); #if 1 gtk_window_set_policy (GTK_WINDOW (w), TRUE, TRUE, FALSE); #endif gtk_signal_connect (GTK_OBJECT (w), "delete_event", GTK_SIGNAL_FUNC (sp_help_about_delete), NULL); v = sp_svg_view_widget_new (doc); sp_svg_view_widget_set_resize (SP_SVG_VIEW_WIDGET (v), FALSE, sp_document_width (doc), sp_document_height (doc)); sp_document_unref (doc); gtk_widget_show (v); gtk_container_add (GTK_CONTAINER (w), v); } gtk_window_present ((GtkWindow *) w); }
bool Editor::init() { // Load non-local template until we have everything right // This code formerly lived in file.cpp // gchar const *tmpl = g_build_filename ((INKSCAPE_TEMPLATESDIR), "default.svg", NULL); bool have_default = Inkscape::IO::file_test (tmpl, G_FILE_TEST_IS_REGULAR); SPDocument *doc = sp_document_new (have_default? tmpl:0, true, true); g_return_val_if_fail (doc != 0, false); Inkscape::UI::View::EditWidgetInterface *ew = _funCreateEditWidget(doc); sp_document_unref (doc); _window = (void*)(ew->getWindow()); return ew != 0; }