diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index d664ef729a5cf963c93882693f47425919f18fcf..835003e5e621737df23b2c948820b879216611b9 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
-#define __SP_EXPORT_C__
-
-/** \file
- * \brief PNG export dialog
+/** @file
+ * @brief PNG export dialog
*/
*/
-
-/*
- * Authors:
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
# include "config.h"
#endif
# include "config.h"
#endif
+// This has to be included prior to anything that includes setjmp.h, it croaks otherwise
+#include <png.h>
+
#include <gtk/gtk.h>
#include <gtkmm/box.h>
#include <gtkmm/buttonbox.h>
#include <gtk/gtk.h>
#include <gtkmm/box.h>
#include <gtkmm/buttonbox.h>
#include "selection-chemistry.h"
#include "dialog-events.h"
#include "selection-chemistry.h"
#include "dialog-events.h"
-#include "../prefs-utils.h"
-#include "../verbs.h"
-#include "../interface.h"
+#include "preferences.h"
+#include "verbs.h"
+#include "interface.h"
#include "extension/output.h"
#include "extension/db.h"
#include "extension/output.h"
#include "extension/db.h"
#include "io/sys.h"
#include "helper/png-write.h"
#include "io/sys.h"
#include "helper/png-write.h"
-#include <png.h>
+#ifdef WIN32
+#include <windows.h>
+#include <COMMDLG.h>
+#include <gdk/gdkwin32.h>
+#endif
#define SP_EXPORT_MIN_SIZE 1.0
#define SP_EXPORT_MIN_SIZE 1.0
static inline void sp_export_find_default_selection(GtkWidget * dlg);
static void sp_export_detect_size(GtkObject * base);
static inline void sp_export_find_default_selection(GtkWidget * dlg);
static void sp_export_detect_size(GtkObject * base);
-static const gchar *prefs_path = "dialogs.export";
+static Glib::ustring const prefs_path = "/dialogs/export/";
// these all need to be reinitialized to their defaults during dialog_destroy
static GtkWidget *dlg = NULL;
// these all need to be reinitialized to their defaults during dialog_destroy
static GtkWidget *dlg = NULL;
@@ -170,10 +173,11 @@ sp_export_dialog_delete ( GtkObject */*object*/, GdkEvent */*event*/, gpointer /
if (x<0) x=0;
if (y<0) y=0;
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
return FALSE; // which means, go ahead and destroy it
@@ -200,20 +204,20 @@ sp_export_dialog_delete ( GtkObject */*object*/, GdkEvent */*event*/, gpointer /
*/
static void
*/
static void
-sp_export_spinbutton_new ( gchar *key, float val, float min, float max,
+sp_export_spinbutton_new ( gchar const *key, float val, float min, float max,
float step, float page, GtkWidget *us,
GtkWidget *t, int x, int y,
const gchar *ll, const gchar *lr,
int digits, unsigned int sensitive,
GCallback cb, GtkWidget *dlg )
{
float step, float page, GtkWidget *us,
GtkWidget *t, int x, int y,
const gchar *ll, const gchar *lr,
int digits, unsigned int sensitive,
GCallback cb, GtkWidget *dlg )
{
- GtkObject *a = gtk_adjustment_new (val, min, max, step, page, page);
- gtk_object_set_data (a, "key", key);
- gtk_object_set_data (GTK_OBJECT (dlg), (const gchar *)key, a);
+ GtkObject *adj = gtk_adjustment_new( val, min, max, step, page, 0 );
+ gtk_object_set_data( adj, "key", const_cast<gchar *>(key) );
+ gtk_object_set_data( GTK_OBJECT (dlg), (const gchar *)key, adj );
if (us) {
sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us),
if (us) {
sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us),
- GTK_ADJUSTMENT (a) );
+ GTK_ADJUSTMENT (adj) );
}
int pos = 0;
}
int pos = 0;
}
}
- GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, digits);
+ GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1.0, digits);
gtk_table_attach ( GTK_TABLE (t), sb, x + pos, x + pos + 1, y, y + 1,
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0 );
gtk_widget_set_size_request (sb, 80, -1);
gtk_table_attach ( GTK_TABLE (t), sb, x + pos, x + pos + 1, y, y + 1,
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0 );
gtk_widget_set_size_request (sb, 80, -1);
}
if (cb)
}
if (cb)
- gtk_signal_connect (a, "value_changed", cb, dlg);
+ gtk_signal_connect (adj, "value_changed", cb, dlg);
return;
} // end of sp_export_spinbutton_new()
return;
} // end of sp_export_spinbutton_new()
dlg );
sp_export_spinbutton_new ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
dlg );
sp_export_spinbutton_new ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
- us->gobj(), GTK_WIDGET(t->gobj()), 4, 0, _("Width:"), NULL, EXPORT_COORD_PRECISION, 1,
+ us->gobj(), GTK_WIDGET(t->gobj()), 4, 0, _("Wid_th:"), NULL, EXPORT_COORD_PRECISION, 1,
G_CALLBACK
(sp_export_area_width_value_changed),
dlg );
G_CALLBACK
(sp_export_area_width_value_changed),
dlg );
dlg );
sp_export_spinbutton_new ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
dlg );
sp_export_spinbutton_new ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
- us->gobj(), GTK_WIDGET(t->gobj()), 4, 1, _("Height:"), NULL, EXPORT_COORD_PRECISION, 1,
+ us->gobj(), GTK_WIDGET(t->gobj()), 4, 1, _("Hei_ght:"), NULL, EXPORT_COORD_PRECISION, 1,
G_CALLBACK (sp_export_area_height_value_changed),
dlg );
G_CALLBACK (sp_export_area_height_value_changed),
dlg );
void
sp_export_dialog (void)
{
void
sp_export_dialog (void)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (!dlg) {
gchar title[500];
if (!dlg) {
gchar title[500];
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
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);
+ x = prefs->getInt(prefs_path + "x", 0);
+ y = prefs->getInt(prefs_path + "y", 0);
}
if (w ==0 || h == 0) {
}
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
}
// if (x<0) x=0;
dlg );
sp_export_spinbutton_new ( "xdpi",
dlg );
sp_export_spinbutton_new ( "xdpi",
- prefs_get_double_attribute
- ( "dialogs.export.defaultxdpi",
- "value", DPI_BASE),
+ prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 0,
NULL, _("dp_i"), 2, 1,
G_CALLBACK (sp_export_xdpi_value_changed),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 0,
NULL, _("dp_i"), 2, 1,
G_CALLBACK (sp_export_xdpi_value_changed),
sp_export_spinbutton_new ( "bmheight", 16.0, 1.0, 1000000.0, 1.0, 10.0,
NULL, GTK_WIDGET(t->gobj()), 0, 1,
sp_export_spinbutton_new ( "bmheight", 16.0, 1.0, 1000000.0, 1.0, 10.0,
NULL, GTK_WIDGET(t->gobj()), 0, 1,
- _("Height:"), _("pixels at"), 0, 1,
+ _("_Height:"), _("pixels at"), 0, 1,
G_CALLBACK
(sp_export_bitmap_height_value_changed),
dlg );
G_CALLBACK
(sp_export_bitmap_height_value_changed),
dlg );
* Needs fixing: there's no way to set ydpi currently, so we use
* the defaultxdpi value here, too...
*/
* Needs 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),
+ sp_export_spinbutton_new ( "ydpi", prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 1,
NULL, _("dpi"), 2, 0, NULL, dlg );
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 1,
NULL, _("dpi"), 2, 0, NULL, dlg );
gchar *name;
SPDocument * doc = SP_ACTIVE_DOCUMENT;
const gchar *uri = SP_DOCUMENT_URI (doc);
gchar *name;
SPDocument * doc = SP_ACTIVE_DOCUMENT;
const gchar *uri = SP_DOCUMENT_URI (doc);
- Inkscape::XML::Node * repr = sp_document_repr_root(doc);
- const gchar * text_extension = repr->attribute("inkscape:output_extension");
+ const gchar *text_extension = Inkscape::Preferences::get()->getString("/dialogs/save_as/default").c_str();
Inkscape::Extension::Output * oextension = NULL;
if (text_extension != NULL) {
Inkscape::Extension::Output * oextension = NULL;
if (text_extension != NULL) {
GtkWidget *he = (GtkWidget *)gtk_object_get_data(base, "hide_checkbox");
if (num >= 2) {
gtk_widget_set_sensitive (be, true);
GtkWidget *he = (GtkWidget *)gtk_object_get_data(base, "hide_checkbox");
if (num >= 2) {
gtk_widget_set_sensitive (be, true);
- gtk_button_set_label (GTK_BUTTON(be), g_strdup_printf (_("Batch export %d selected objects"), num));
+ gtk_button_set_label (GTK_BUTTON(be), g_strdup_printf (ngettext("Batch export %d selected object","Batch export %d selected objects",num), num));
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(be), FALSE);
gtk_widget_set_sensitive (be, FALSE);
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(be), FALSE);
gtk_widget_set_sensitive (be, FALSE);
/* Try using the preferences */
if (key == SELECTION_NUMBER_OF) {
/* Try using the preferences */
if (key == SELECTION_NUMBER_OF) {
- const gchar *what = NULL;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int i = SELECTION_NUMBER_OF;
int i = SELECTION_NUMBER_OF;
- what = prefs_get_string_attribute ("dialogs.export.exportarea", "value");
+ Glib::ustring what = prefs->getString("/dialogs/export/exportarea/value");
- if (what != NULL) {
+ if (!what.empty()) {
for (i = 0; i < SELECTION_NUMBER_OF; i++) {
for (i = 0; i < SELECTION_NUMBER_OF; i++) {
- if (!strcmp (what, selection_names[i])) {
+ if (what == selection_names[i]) {
break;
}
}
break;
}
}
if ( SP_ACTIVE_DESKTOP ) {
SPDocument *doc;
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
if ( SP_ACTIVE_DESKTOP ) {
SPDocument *doc;
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- NR::Maybe<NR::Rect> bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
+ Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
if (bbox) {
if (bbox) {
- sp_export_set_area (base, bbox->min()[NR::X],
- bbox->min()[NR::Y],
- bbox->max()[NR::X],
- bbox->max()[NR::Y]);
+ sp_export_set_area (base, bbox->min()[Geom::X],
+ bbox->min()[Geom::Y],
+ bbox->max()[Geom::X],
+ bbox->max()[Geom::Y]);
}
}
break;
}
}
break;
if ( SP_ACTIVE_DESKTOP )
{
SPDocument *doc;
if ( SP_ACTIVE_DESKTOP )
{
SPDocument *doc;
- NR::Maybe<NR::Rect> bbox;
+ Geom::OptRect bbox;
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
/* Notice how the switch is used to 'fall through' here to get
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
/* Notice how the switch is used to 'fall through' here to get
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
{
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
{
- bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds();
+ bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->bounds();
/* Only if there is a selection that we can set
do we break, otherwise we fall through to the
drawing */
/* Only if there is a selection that we can set
do we break, otherwise we fall through to the
drawing */
break;
}
case SELECTION_PAGE:
break;
}
case SELECTION_PAGE:
- bbox = NR::Rect(NR::Point(0.0, 0.0),
- NR::Point(sp_document_width(doc), sp_document_height(doc))
- );
+ bbox = Geom::Rect(Geom::Point(0.0, 0.0),
+ Geom::Point(sp_document_width(doc), sp_document_height(doc)));
// std::cout << "Using selection: PAGE" << std::endl;
key = SELECTION_PAGE;
// std::cout << "Using selection: PAGE" << std::endl;
key = SELECTION_PAGE;
} // switch
// remember area setting
} // switch
// remember area setting
- prefs_set_string_attribute ( "dialogs.export.exportarea",
- "value", selection_names[key]);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("/dialogs/export/exportarea/value", selection_names[key]);
if ( key != SELECTION_CUSTOM && bbox ) {
if ( key != SELECTION_CUSTOM && bbox ) {
- sp_export_set_area (base, bbox->min()[NR::X],
- bbox->min()[NR::Y],
- bbox->max()[NR::X],
- bbox->max()[NR::Y]);
+ sp_export_set_area (base, bbox->min()[Geom::X],
+ bbox->min()[Geom::Y],
+ bbox->max()[Geom::X],
+ bbox->max()[Geom::Y]);
}
} // end of if ( SP_ACTIVE_DESKTOP )
}
} // end of if ( SP_ACTIVE_DESKTOP )
static gchar *
filename_add_extension (const gchar *filename, const gchar *extension)
{
static gchar *
filename_add_extension (const gchar *filename, const gchar *extension)
{
- gchar *dot;
+ const gchar *dot;
dot = strrchr (filename, '.');
if ( !dot )
dot = strrchr (filename, '.');
if ( !dot )
dpi = DPI_BASE;
}
dpi = DPI_BASE;
}
- NRRect area;
- sp_item_invoke_bbox(item, &area, sp_item_i2r_affine((SPItem *) item), TRUE);
-
- gint width = (gint) ((area.x1 - area.x0) * dpi / PX_PER_IN + 0.5);
- gint height = (gint) ((area.y1 - area.y0) * dpi / PX_PER_IN + 0.5);
-
- if (width > 1 && height > 1) {
- /* Do export */
- if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), fn,
- area.x0, area.y0, area.x1, area.y1, width, height, dpi, dpi,
- nv->pagecolor,
- NULL, NULL, TRUE, // overwrite without asking
- hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL
- )) {
- gchar * error;
- gchar * safeFile = Inkscape::IO::sanitizeString(fn);
- error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
- sp_ui_error_dialog(error);
- g_free(safeFile);
- g_free(error);
+ Geom::OptRect area;
+ sp_item_invoke_bbox(item, area, sp_item_i2d_affine((SPItem *) item), TRUE);
+ if (area) {
+ gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5);
+ gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5);
+
+ if (width > 1 && height > 1) {
+ /* Do export */
+ if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), fn,
+ *area, width, height, dpi, dpi,
+ nv->pagecolor,
+ NULL, NULL, TRUE, // overwrite without asking
+ hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL
+ )) {
+ gchar * error;
+ gchar * safeFile = Inkscape::IO::sanitizeString(fn);
+ error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
+ sp_ui_error_dialog(error);
+ g_free(safeFile);
+ g_free(error);
+ }
}
}
n++;
}
}
n++;
/* Do export */
if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), filename_ext,
/* Do export */
if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), filename_ext,
- x0, y0, x1, y1, width, height, xdpi, ydpi,
+ Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
nv->pagecolor,
sp_export_progress_callback, base, FALSE,
hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL
nv->pagecolor,
sp_export_progress_callback, base, FALSE,
hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL
sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
modified = true;
}
sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
modified = true;
}
-
- if (modified)
- doc->setModified();
sp_document_set_undo_sensitive(doc, saved);
sp_document_set_undo_sensitive(doc, saved);
+
+ if (modified) {
+ doc->setModifiedSinceSave();
+ }
break;
}
case SELECTION_SELECTION: {
break;
}
case SELECTION_SELECTION: {
modified = true;
}
}
modified = true;
}
}
+ sp_document_set_undo_sensitive(doc, saved);
if (modified) {
if (modified) {
- doc->setModified();
+ doc->setModifiedSinceSave();
}
}
-
- sp_document_set_undo_sensitive(doc, saved);
break;
}
default:
break;
}
default:
} // end of sp_export_export_clicked()
/// Called when Browse button is clicked
} // end of sp_export_export_clicked()
/// Called when Browse button is clicked
+/// @todo refactor this code to use ui/dialogs/filedialog.cpp
static void
sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/)
{
static void
sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/)
{
const gchar *filename;
fs = gtk_file_chooser_dialog_new (_("Select a filename for exporting"),
const gchar *filename;
fs = gtk_file_chooser_dialog_new (_("Select a filename for exporting"),
- NULL,
+ (GtkWindow*)dlg,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
filename = gtk_entry_get_text (GTK_ENTRY (fe));
if (*filename == '\0') {
filename = gtk_entry_get_text (GTK_ENTRY (fe));
if (*filename == '\0') {
- filename = homedir_path(NULL);
+ filename = create_filepath_from_id(NULL, NULL);
}
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs), filename);
}
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs), filename);
+#ifdef WIN32
+ // code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp
+ OPENFILENAMEW opf;
+ WCHAR* filter_string = (WCHAR*)g_utf8_to_utf16("PNG\0*.png\0\0", 12, NULL, NULL, NULL);
+ WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL);
+ WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL);
+ // Copy the selected file name, converting from UTF-8 to UTF-16
+ WCHAR _filename[_MAX_PATH + 1];
+ memset(_filename, 0, sizeof(_filename));
+ gunichar2* utf16_path_string = g_utf8_to_utf16(filename, -1, NULL, NULL, NULL);
+ wcsncpy(_filename, (wchar_t*)utf16_path_string, _MAX_PATH);
+ g_free(utf16_path_string);
+
+ opf.hwndOwner = (HWND)(GDK_WINDOW_HWND(GTK_WIDGET(dlg)->window));
+ opf.lpstrFilter = filter_string;
+ opf.lpstrCustomFilter = 0;
+ opf.nMaxCustFilter = 0L;
+ opf.nFilterIndex = 1L;
+ opf.lpstrFile = _filename;
+ opf.nMaxFile = _MAX_PATH;
+ opf.lpstrFileTitle = NULL;
+ opf.nMaxFileTitle=0;
+ opf.lpstrInitialDir = 0;
+ opf.lpstrTitle = title_string;
+ opf.nFileOffset = 0;
+ opf.nFileExtension = 2;
+ opf.lpstrDefExt = extension_string;
+ opf.lpfnHook = NULL;
+ opf.lCustData = 0;
+ opf.Flags = OFN_PATHMUSTEXIST;
+ opf.lStructSize = sizeof(OPENFILENAMEW);
+ if (GetSaveFileNameW(&opf) != 0)
+ {
+ // Copy the selected file name, converting from UTF-16 to UTF-8
+ gchar *utf8string = g_utf16_to_utf8((const gunichar2*)opf.lpstrFile, _MAX_PATH, NULL, NULL, NULL);
+ gtk_entry_set_text (GTK_ENTRY (fe), utf8string);
+ g_object_set_data (G_OBJECT (dlg), "filename", fe);
+ g_free(utf8string);
+
+ }
+ g_free(extension_string);
+ g_free(title_string);
+ g_free(filter_string);
+#else
if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT)
{
gchar *file;
if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT)
{
gchar *file;
g_free(utf8file);
g_free(file);
}
g_free(utf8file);
g_free(file);
}
+#endif
gtk_widget_destroy (fs);
gtk_widget_destroy (fs);
// TODO: Move this to nr-rect-fns.h.
static bool
// TODO: Move this to nr-rect-fns.h.
static bool
-sp_export_bbox_equal(NR::Rect const &one, NR::Rect const &two)
+sp_export_bbox_equal(Geom::Rect const &one, Geom::Rect const &two)
{
double const epsilon = pow(10.0, -EXPORT_COORD_PRECISION);
return (
{
double const epsilon = pow(10.0, -EXPORT_COORD_PRECISION);
return (
- (fabs(one.min()[NR::X] - two.min()[NR::X]) < epsilon) &&
- (fabs(one.min()[NR::Y] - two.min()[NR::Y]) < epsilon) &&
- (fabs(one.max()[NR::X] - two.max()[NR::X]) < epsilon) &&
- (fabs(one.max()[NR::Y] - two.max()[NR::Y]) < epsilon)
+ (fabs(one.min()[Geom::X] - two.min()[Geom::X]) < epsilon) &&
+ (fabs(one.min()[Geom::Y] - two.min()[Geom::Y]) < epsilon) &&
+ (fabs(one.max()[Geom::X] - two.max()[Geom::X]) < epsilon) &&
+ (fabs(one.max()[Geom::Y] - two.max()[Geom::Y]) < epsilon)
);
}
);
}
selection_type this_test[SELECTION_NUMBER_OF + 1];
selection_type key = SELECTION_NUMBER_OF;
selection_type this_test[SELECTION_NUMBER_OF + 1];
selection_type key = SELECTION_NUMBER_OF;
- NR::Point x(sp_export_value_get_px (base, "x0"),
- sp_export_value_get_px (base, "y0"));
- NR::Point y(sp_export_value_get_px (base, "x1"),
- sp_export_value_get_px (base, "y1"));
- NR::Rect current_bbox(x, y);
+ Geom::Point x(sp_export_value_get_px (base, "x0"),
+ sp_export_value_get_px (base, "y0"));
+ Geom::Point y(sp_export_value_get_px (base, "x1"),
+ sp_export_value_get_px (base, "y1"));
+ Geom::Rect current_bbox(x, y);
//std::cout << "Current " << current_bbox;
this_test[0] = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type")));
//std::cout << "Current " << current_bbox;
this_test[0] = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type")));
switch (this_test[i]) {
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
switch (this_test[i]) {
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- NR::Maybe<NR::Rect> bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds();
+ Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds();
//std::cout << "Selection " << bbox;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox)) {
//std::cout << "Selection " << bbox;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox)) {
case SELECTION_DRAWING: {
SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
case SELECTION_DRAWING: {
SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- NR::Maybe<NR::Rect> bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
+ Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
// std::cout << "Drawing " << bbox2;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) {
// std::cout << "Drawing " << bbox2;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) {
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- NR::Point x(0.0, 0.0);
- NR::Point y(sp_document_width(doc),
- sp_document_height(doc));
- NR::Rect bbox(x, y);
+ Geom::Point x(0.0, 0.0);
+ Geom::Point y(sp_document_width(doc),
+ sp_document_height(doc));
+ Geom::Rect bbox(x, y);
// std::cout << "Page " << bbox;
if (sp_export_bbox_equal(bbox,current_bbox)) {
// std::cout << "Page " << bbox;
if (sp_export_bbox_equal(bbox,current_bbox)) {
xdpi = sp_export_value_get (base, "xdpi");
// remember xdpi setting
xdpi = sp_export_value_get (base, "xdpi");
// remember xdpi setting
- prefs_set_double_attribute ("dialogs.export.defaultxdpi", "value", xdpi);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/export/defaultxdpi/value", xdpi);
bmwidth = (x1 - x0) * xdpi / DPI_BASE;
bmwidth = (x1 - x0) * xdpi / DPI_BASE;
Local Variables:
mode:c++
c-file-style:"stroustrup"
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
indent-tabs-mode:nil
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :