예제 #1
0
bool ImageIcon::showSvgDocument(const SPDocument *docArg)
{

    if (document)
        sp_document_unref(document);

    SPDocument *doc = (SPDocument *)docArg;

    sp_document_ref(doc);
    document = doc;

    //This should remove it from the box, and free resources
    //if (viewerGtkmm)
    //    viewerGtkmm->destroy();

    GtkWidget *viewerGtk  = sp_svg_view_widget_new(doc);
    viewerGtkmm = Glib::wrap(viewerGtk);

    viewerGtkmm->show();
    pack_start(*viewerGtkmm, TRUE, TRUE, 0);

    //GtkWidget *vbox = (GtkWidget *)gobj();
    //gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0);

    return true;
}
예제 #2
0
SPDesktop* 
Editor::createDesktop (SPDocument* doc)
{
    g_assert (doc != 0);
    (_funCreateEditWidget(doc))->present();
    sp_document_unref (doc);
    SPDesktop *dt = getActiveDesktop();
    reactivateDesktop (dt);
    return dt;
}
예제 #3
0
bool ImageIcon::showSvgFromMemory(const char *xmlBuffer)
{
    if (!xmlBuffer)
        return false;

    gint len = (gint)strlen(xmlBuffer);
    SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0);
    if (!doc) {
        g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer);
        return false;
    }

    showSvgDocument(doc);

    sp_document_unref(doc);

    return true;
}
예제 #4
0
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;
}
예제 #5
0
파일: help.c 프로젝트: benjohnson2001/base
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);
}
예제 #6
0
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;
}
// TODO: When the switchover to the new GUI is complete, this function should go away
// and be replaced with a call to Inkscape::NSApplication::Editor::createDesktop.  
// It currently only exists to correctly mimic the desktop creation functionality
// in file.cpp.
//
// \see sp_file_new
SPDesktop*
makeInkboardDesktop(SPDocument* doc)
{
    SPDesktop* dt;

    if (NSApplication::Application::getNewGui()) 
        dt = NSApplication::Editor::createDesktop(doc);

    else 
    {
        SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL));
        g_return_val_if_fail(dtw != NULL, NULL);
        sp_document_unref(doc);

        sp_create_window(dtw, TRUE);
        dt = static_cast<SPDesktop*>(dtw->view);
        sp_namedview_window_from_document(dt);
        sp_namedview_update_layers_from_document(dt);
    }

    return dt;
}
예제 #8
0
/**
 * Destructor
 */
ImageIcon::~ImageIcon()
{
    if (document)
        sp_document_unref(document);
}