Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_export_dialog ( void   ) 

text-edit

Text editing and font changes

Definition at line 338 of file export.cpp.

References Inkscape::Verb::get(), sp_export_filename_modified(), sp_export_spinbutton_new(), sp_export_xdpi_value_changed(), win_data::stop, and win_data::win.

{
    if (!dlg) {
        GtkWidget *vb, *f, *t, *hb, *fe, *hs, *b;

        gchar title[500];
        sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_FILE_EXPORT), title);

        dlg = sp_window_new (title, TRUE);
        
        if (x == -1000 || y == -1000) {
            x = prefs_get_int_attribute (prefs_path, "x", 0);
            y = prefs_get_int_attribute (prefs_path, "y", 0);
        }
        
        if (w ==0 || h == 0) {
            w = prefs_get_int_attribute (prefs_path, "w", 0);
            h = prefs_get_int_attribute (prefs_path, "h", 0);
        }
        
        if (x != 0 || y != 0) {
            gtk_window_move ((GtkWindow *) dlg, x, y);
        } else {
            gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
        }
        
        if (w && h) 
            gtk_window_resize ((GtkWindow *) dlg, w, h);
        
        sp_transientize (dlg);
        wd.win = dlg;
        wd.stop = 0;
        
        
        g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", 
                             G_CALLBACK (sp_transientize_callback), &wd);
                             
        gtk_signal_connect ( GTK_OBJECT (dlg), "event", 
                             GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
                             
        gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", 
                             G_CALLBACK (sp_export_dialog_destroy), dlg);
                             
        gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", 
                             G_CALLBACK (sp_export_dialog_delete), dlg);
                             
        g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", 
                             G_CALLBACK (sp_export_dialog_delete), dlg);
                             
        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", 
                             G_CALLBACK (sp_dialog_hide), dlg);
                             
        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", 
                             G_CALLBACK (sp_dialog_unhide), dlg);

                             
        vb = gtk_vbox_new (FALSE, 4);
        gtk_widget_show (vb);
        gtk_container_set_border_width (GTK_CONTAINER (vb), 4);
        gtk_container_add (GTK_CONTAINER (dlg), vb);

        /* Export area frame */
        f = sp_export_dialog_area_frame(dlg);
        gtk_box_pack_start (GTK_BOX (vb), f, FALSE, FALSE, 0);

        /* Bitmap size frame */
        f = gtk_frame_new (_("Bitmap size"));
        gtk_box_pack_start (GTK_BOX (vb), f, FALSE, FALSE, 0);
        t = gtk_table_new (2, 5, FALSE);
        gtk_table_set_row_spacings (GTK_TABLE (t), 4);
        gtk_table_set_col_spacings (GTK_TABLE (t), 4);
        gtk_container_set_border_width (GTK_CONTAINER (t), 4);
        gtk_container_add (GTK_CONTAINER (f), t);

        sp_export_spinbutton_new ( "bmwidth", 16.0, 1.0, 1000000.0, 1.0, 10.0, 
                                   NULL, t, 0, 0,
                                   _("Width:"), _("pixels"), 0, 1,
                                   G_CALLBACK 
                                       (sp_export_bitmap_width_value_changed), 
                                   dlg );

        sp_export_spinbutton_new ( "xdpi", 
                                   prefs_get_double_attribute 
                                       ( "dialogs.export.defaultxdpi", 
                                         "value", DPI_BASE), 
                                   1.0, 9600.0, 0.1, 1.0, NULL, t, 3, 0,
                                   NULL, _("dpi"), 2, 1,
                                   G_CALLBACK (sp_export_xdpi_value_changed), 
                                   dlg );

        sp_export_spinbutton_new ( "bmheight", 16.0, 1.0, 1000000.0, 1, 10.0, 
                                   NULL, t, 0, 1, _("Height:"), _("pixels"), 
                                   0, 0, NULL, dlg );

        /*
         * TODO: Nees fixing: there's no way to set ydpi currently, so we use  
         *       the defaultxdpi value here, too...
         */
        sp_export_spinbutton_new ( "ydpi", prefs_get_double_attribute 
                                               ( "dialogs.export.defaultxdpi", 
                                                 "value", DPI_BASE), 
                                   1.0, 9600.0, 0.1, 1.0, NULL, t, 3, 1,
                                   NULL, _("dpi"), 2, 0, NULL, dlg );

        gtk_widget_show_all (f);

        
        /* File entry */
        f = gtk_frame_new (_("Filename"));
        gtk_box_pack_start (GTK_BOX (vb), f, FALSE, FALSE, 0);
        fe = gtk_entry_new ();

        /*
         * set the default filename to be that of the current path + document 
         * with .png extension
         *
         * One thing to notice here is that this filename may get
         * overwritten, but it won't happen here.  The filename gets
         * written into the text field, but then the button to select
         * the area gets set.  In that code the filename can be changed
         * if there are some with presidence in the document.  So, while
         * this code sets the name first, it may not be the one users
         * really see.
         */
        if (SP_ACTIVE_DOCUMENT && SP_DOCUMENT_URI (SP_ACTIVE_DOCUMENT))
        {
            gchar *name;
            SPDocument * doc = SP_ACTIVE_DOCUMENT;
            const gchar *uri = SP_DOCUMENT_URI (doc);
            SPRepr * repr = sp_document_repr_root(doc);
            const gchar * text_extension = sp_repr_attr(repr, "inkscape:output_extension");
            Inkscape::Extension::Output * oextension = NULL;

            if (text_extension != NULL) {
                oextension = dynamic_cast<Inkscape::Extension::Output *>(Inkscape::Extension::db.get(text_extension));
            }

            if (oextension != NULL) {
                gchar * old_extension = oextension->get_extension();
                if (g_str_has_suffix(uri, old_extension)) {
                    gchar * uri_copy;
                    gchar * extension_point;
                    gchar * final_name;

                    uri_copy = g_strdup(uri);
                    extension_point = g_strrstr(uri_copy, old_extension);
                    extension_point[0] = '\0';

                    final_name = g_strconcat(uri_copy, ".png", NULL);
                    gtk_entry_set_text (GTK_ENTRY (fe), final_name);

                    g_free(final_name);
                    g_free(uri_copy);
                }
            } else {
                name = g_strconcat(uri, ".png", NULL);
                gtk_entry_set_text (GTK_ENTRY (fe), name);
                g_free(name);
            } 

            doc_export_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(fe)));
        }
        g_signal_connect ( G_OBJECT (fe), "changed", 
                           G_CALLBACK (sp_export_filename_modified), dlg);

        
        hb = gtk_hbox_new (FALSE, 5);
        gtk_container_add (GTK_CONTAINER (f), hb);
        gtk_container_set_border_width (GTK_CONTAINER (hb), 4);

        b = gtk_button_new_with_label (_("Browse..."));
        gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 4);
        g_signal_connect ( G_OBJECT (b), "clicked", 
                           G_CALLBACK (sp_export_browse_clicked), NULL );

        gtk_box_pack_start (GTK_BOX (hb), fe, TRUE, TRUE, 0);
        gtk_object_set_data (GTK_OBJECT (dlg), "filename", fe);
        gtk_object_set_data (GTK_OBJECT (dlg), "filename-modified", (gpointer)FALSE);
        original_name = g_strdup(gtk_entry_get_text (GTK_ENTRY (fe)));
        gtk_widget_show_all (f);
        // pressing enter in the filename field is the same as clicking export:
        g_signal_connect ( G_OBJECT (fe), "activate", 
                           G_CALLBACK (sp_export_export_clicked), dlg );
        // focus is in the filename initially:
        gtk_widget_grab_focus (GTK_WIDGET (fe));

        /* Buttons */
        hb = gtk_hbox_new (FALSE, 0);
        gtk_widget_show (hb);
        gtk_box_pack_end (GTK_BOX (vb), hb, FALSE, FALSE, 0);

        b = gtk_button_new_with_label (_("Export"));
        gtk_widget_show (b);
        gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0);
        gtk_signal_connect ( GTK_OBJECT (b), "clicked", 
                             GTK_SIGNAL_FUNC (sp_export_export_clicked), dlg );

        hs = gtk_hseparator_new ();
        gtk_widget_show (hs);
        gtk_box_pack_end (GTK_BOX (vb), hs, FALSE, FALSE, 0);
    
    } // end of if (!dlg)

    sp_export_find_default_selection(dlg);

    gtk_window_present ((GtkWindow *) dlg);
    
    return;
} // end of sp_export_dialog()


Generated by  Doxygen 1.6.0   Back to index