summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/2geom/svg-path.h11
-rw-r--r--src/color-profile.cpp15
-rw-r--r--src/desktop-events.cpp5
-rw-r--r--src/draw-anchor.cpp20
-rw-r--r--src/extension/internal/emf-win32-inout.cpp8
-rw-r--r--src/extension/internal/emf-win32-print.cpp25
-rw-r--r--src/extension/internal/emf-win32-print.h8
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp6
-rw-r--r--src/extension/internal/latex-pstricks-out.cpp26
-rw-r--r--src/extension/internal/latex-pstricks.cpp25
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp42
-rw-r--r--src/extension/internal/pdf-input-cairo.h9
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp46
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h9
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp63
-rw-r--r--src/extension/internal/svg.cpp12
-rw-r--r--src/extension/internal/svgz.cpp12
-rw-r--r--src/extension/internal/wpg-input.cpp7
-rw-r--r--src/extension/param/string.cpp1
-rw-r--r--src/extension/prefdialog.h1
-rw-r--r--src/gradient-drag.cpp2
-rw-r--r--src/interface.cpp63
-rw-r--r--src/interface.h1
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp21
-rw-r--r--src/livarot/ShapeMisc.cpp28
-rw-r--r--src/live_effects/lpe-knot.cpp3
-rw-r--r--src/live_effects/lpe-powerstroke.cpp104
-rw-r--r--src/live_effects/lpe-rough-hatches.cpp8
-rw-r--r--src/main.cpp29
-rw-r--r--src/selection-chemistry.cpp36
-rw-r--r--src/selection-chemistry.h4
-rw-r--r--src/svg-view-widget.cpp31
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/align-and-distribute.h3
-rw-r--r--src/ui/dialog/export.cpp569
-rw-r--r--src/ui/dialog/export.h67
-rw-r--r--src/ui/dialog/find.cpp6
-rw-r--r--src/ui/dialog/find.h73
-rw-r--r--src/ui/dialog/icon-preview.cpp5
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp9
-rw-r--r--src/ui/dialog/input.cpp25
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp1
-rw-r--r--src/ui/dialog/livepatheffect-editor.h4
-rw-r--r--src/ui/dialog/object-properties.cpp3
-rw-r--r--src/ui/dialog/object-properties.h5
-rw-r--r--src/ui/dialog/ocaldialogs.cpp6
-rw-r--r--src/ui/dialog/text-edit.cpp3
-rw-r--r--src/ui/dialog/text-edit.h3
-rw-r--r--src/ui/dialog/tracedialog.cpp13
-rw-r--r--src/ui/previewholder.cpp28
-rw-r--r--src/ui/widget/Makefile_insert2
-rw-r--r--src/ui/widget/frame.cpp83
-rw-r--r--src/ui/widget/frame.h79
-rw-r--r--src/ui/widget/selected-style.cpp2
-rw-r--r--src/ui/widget/toolbox.cpp11
-rw-r--r--src/widgets/button.cpp32
-rw-r--r--src/widgets/desktop-widget.cpp2
-rw-r--r--src/widgets/eek-preview.cpp21
-rw-r--r--src/widgets/gradient-image.cpp32
-rw-r--r--src/widgets/gradient-toolbar.cpp30
-rw-r--r--src/widgets/icon.cpp28
-rw-r--r--src/widgets/paint-selector.cpp251
-rw-r--r--src/widgets/paint-selector.h6
-rw-r--r--src/widgets/ruler.cpp77
-rw-r--r--src/widgets/ruler.h4
-rw-r--r--src/widgets/sp-color-slider.cpp90
-rw-r--r--src/widgets/sp-widget.cpp32
-rw-r--r--src/widgets/sp-xmlview-tree.cpp70
-rw-r--r--src/widgets/spinbutton-events.cpp6
-rw-r--r--src/widgets/spinbutton-events.h2
-rw-r--r--src/widgets/toolbox.cpp83
-rw-r--r--src/xml/repr-io.cpp22
72 files changed, 1481 insertions, 990 deletions
diff --git a/src/2geom/svg-path.h b/src/2geom/svg-path.h
index 591eb3aa2..c22f65d11 100644
--- a/src/2geom/svg-path.h
+++ b/src/2geom/svg-path.h
@@ -48,6 +48,10 @@ public:
virtual void quadTo(Point c, Point p) = 0;
virtual void arcTo(double rx, double ry, double angle,
bool large_arc, bool sweep, Point p) = 0;
+
+ /** Undo the last lineTo, curveTo, etc. call. */
+ virtual void backspace() = 0;
+
virtual void closePath() = 0;
virtual void finish() = 0;
virtual ~SVGPathSink() {}
@@ -120,6 +124,13 @@ public:
large_arc, sweep, p);
}
+ void backspace()
+ {
+ if (_in_path && _path.size() > 0) {
+ _path.erase_last();
+ }
+ }
+
void append(Path const &other, Path::Stitching stitching = Path::NO_STITCHING)
{
if (!_in_path) {
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index c4855543c..0ee3ed787 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -774,19 +774,10 @@ std::vector<Glib::ustring> ColorProfile::getBaseProfileDirs() {
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
std::vector<Glib::ustring> sources;
- gchar* base = profile_path("XXX");
- {
- gchar* base2 = g_path_get_dirname(base);
- g_free(base);
- base = base2;
- base2 = g_path_get_dirname(base);
- g_free(base);
- base = base2;
- }
-
// first try user's local dir
- sources.push_back( g_build_filename(g_get_user_data_dir(), "color", "icc", NULL) );
-
+ gchar* path = g_build_filename(g_get_user_data_dir(), "color", "icc", NULL);
+ sources.push_back(path);
+ g_free(path);
const gchar* const * dataDirs = g_get_system_data_dirs();
for ( int i = 0; dataDirs[i]; i++ ) {
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 68b372d99..15c04fa1f 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -152,12 +152,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
SPDesktop *desktop = dtw->desktop;
GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(dtw->canvas));
-#if GTK_CHECK_VERSION(3,0,0)
- GdkDisplay *display = gdk_window_get_display(window);
- gdk_window_get_device_position(window, display->core_pointer, &wx, &wy, NULL);
-#else
gdk_window_get_pointer(window, &wx, &wy, NULL);
-#endif
Geom::Point const event_win(wx, wy);
gint width, height;
diff --git a/src/draw-anchor.cpp b/src/draw-anchor.cpp
index f3a42ca4e..d11ac462f 100644
--- a/src/draw-anchor.cpp
+++ b/src/draw-anchor.cpp
@@ -21,11 +21,13 @@
#include "display/sodipodi-ctrl.h"
#include "display/curve.h"
+#define FILL_COLOR_NORMAL 0xffffff7f
+#define FILL_COLOR_MOUSEOVER 0xff0000ff
+
/**
* Creates an anchor object and initializes it.
*/
-SPDrawAnchor *
-sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, Geom::Point delta)
+SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, Geom::Point delta)
{
if (SP_IS_LPETOOL_CONTEXT(dc)) {
// suppress all kinds of anchors in LPEToolContext
@@ -44,8 +46,8 @@ sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, Geom::Poin
a->dp = delta;
a->ctrl = sp_canvas_item_new(sp_desktop_controls(dt), SP_TYPE_CTRL,
"size", 6.0,
- "filled", 0,
- "fill_color", 0xff00007f,
+ "filled", 1,
+ "fill_color", FILL_COLOR_NORMAL,
"stroked", 1,
"stroke_color", 0x000000ff,
NULL);
@@ -58,8 +60,7 @@ sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, Geom::Poin
/**
* Destroys the anchor's canvas item and frees the anchor object.
*/
-SPDrawAnchor *
-sp_draw_anchor_destroy(SPDrawAnchor *anchor)
+SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor)
{
if (anchor->curve) {
anchor->curve->unref();
@@ -77,21 +78,20 @@ sp_draw_anchor_destroy(SPDrawAnchor *anchor)
* Test if point is near anchor, if so fill anchor on canvas and return
* pointer to it or NULL.
*/
-SPDrawAnchor *
-sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate)
+SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate)
{
SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(anchor->dc);
if ( activate && ( Geom::LInfty( w - dt->d2w(anchor->dp) ) <= A_SNAP ) ) {
if (!anchor->active) {
- sp_canvas_item_set((GtkObject *) anchor->ctrl, "filled", TRUE, NULL);
+ sp_canvas_item_set((GtkObject *) anchor->ctrl, "fill_color", FILL_COLOR_MOUSEOVER, NULL);
anchor->active = TRUE;
}
return anchor;
}
if (anchor->active) {
- sp_canvas_item_set((GtkObject *) anchor->ctrl, "filled", FALSE, NULL);
+ sp_canvas_item_set((GtkObject *) anchor->ctrl, "fill_color", FILL_COLOR_NORMAL, NULL);
anchor->active = FALSE;
}
return NULL;
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index e321f67f1..bb7f22a70 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -2457,10 +2457,8 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
void
EmfWin32::init (void)
{
- Inkscape::Extension::Extension * ext;
-
/* EMF in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("EMF Input") "</name>\n"
"<id>org.inkscape.input.emf.win32</id>\n"
@@ -2474,7 +2472,7 @@ EmfWin32::init (void)
"</inkscape-extension>", new EmfWin32());
/* WMF in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("WMF Input") "</name>\n"
"<id>org.inkscape.input.wmf.win32</id>\n"
@@ -2488,7 +2486,7 @@ EmfWin32::init (void)
"</inkscape-extension>", new EmfWin32());
/* EMF out */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("EMF Output") "</name>\n"
"<id>org.inkscape.output.emf.win32</id>\n"
diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp
index d5e44e702..ef76c2c14 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -543,7 +543,7 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom
/**
* For all Subpaths in the <path>
- */
+ */
for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
{
using Geom::X;
@@ -553,7 +553,7 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom
p0[X] = (p0[X] * IN_PER_PX * dwDPI);
p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
-
+
LONG const x0 = (LONG) round(p0[X]);
LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -715,7 +715,7 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo
/**
* For all Subpaths in the <path>
- */
+ */
for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
{
using Geom::X;
@@ -725,7 +725,7 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo
p0[X] = (p0[X] * IN_PER_PX * dwDPI);
p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
-
+
LONG const x0 = (LONG) round(p0[X]);
LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -818,7 +818,7 @@ unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char cons
HFONT hfont = NULL;
Geom::Affine tf = m_tr_stack.top();
- double rot = 1800.0*std::atan2(tf[1], tf[0])/M_PI; // 0.1 degree rotation
+ double rot = 1800.0*std::atan2(tf[1], tf[0])/M_PI; // 0.1 degree rotation
#ifdef USE_PANGO_WIN32
/*
@@ -904,10 +904,8 @@ unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char cons
void PrintEmfWin32::init (void)
{
- Inkscape::Extension::Extension * ext;
-
/* EMF print */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>Enhanced Metafile Print</name>\n"
"<id>org.inkscape.print.emf.win32</id>\n"
@@ -920,6 +918,17 @@ void PrintEmfWin32::init (void)
return;
}
+unsigned int PrintEmfWin32::image(Inkscape::Extension::Print * /* module */, /** not used */
+ unsigned char *px, /** array of pixel values, Gdk::Pixbuf bitmap format */
+ unsigned int /*w*/, /** width of bitmap */
+ unsigned int /*h*/, /** height of bitmap */
+ unsigned int /*rs*/, /** row stride (normally w*4) */
+ Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */
+ SPStyle const * /*style*/) /** provides indirect link to image object */
+{
+ free(px);
+ return 0;
+}
} /* namespace Internal */
} /* namespace Extension */
diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h
index 71ce5d6d0..e7bd08477 100644
--- a/src/extension/internal/emf-win32-print.h
+++ b/src/extension/internal/emf-win32-print.h
@@ -50,6 +50,13 @@ class PrintEmfWin32 : public Inkscape::Extension::Implementation::Implementation
unsigned int print_pathv (Geom::PathVector const &pathv, const Geom::Affine &transform);
bool print_simple_shape (Geom::PathVector const &pathv, const Geom::Affine &transform);
+ unsigned int image(Inkscape::Extension::Print * /* module */, /** not used */
+ unsigned char *px, /** array of pixel values, Gdk::Pixbuf bitmap format */
+ unsigned int w, /** width of bitmap */
+ unsigned int h, /** height of bitmap */
+ unsigned int rs, /** row stride (normally w*4) */
+ Geom::Affine const &tf_ignore, /** WRONG affine transform, use the one from m_tr_stack */
+ SPStyle const *style); /** provides indirect link to image object */
public:
PrintEmfWin32 (void);
@@ -80,7 +87,6 @@ public:
bool textToPath (Inkscape::Extension::Print * ext);
static void init (void);
-
protected:
int create_brush(SPStyle const *style);
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index 4519befcf..80be2ecc2 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -54,7 +54,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
static std::set<Glib::ustring> lossy = create_lossy_set();
if (pb) { /* We are readable */
- bool is_lossy;
+ // TODO revisit: bool is_lossy;
Glib::ustring mime_type, ext;
Glib::ustring u = uri;
std::size_t dotpos = u.rfind('.');
@@ -64,10 +64,10 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
// HACK: replace with something better based on GIO
if (!ext.empty() && lossy.find(ext) != lossy.end()) {
- is_lossy = true;
+ // TODO revisit: is_lossy = true;
mime_type = "image/jpeg";
} else {
- is_lossy = false;
+ // TODO revisit: is_lossy = false;
mime_type = "image/png";
}
diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp
index decc42d94..3ce2c5531 100644
--- a/src/extension/internal/latex-pstricks-out.cpp
+++ b/src/extension/internal/latex-pstricks-out.cpp
@@ -49,8 +49,6 @@ bool LatexOutput::check(Inkscape::Extension::Extension * /*module*/)
void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename)
{
SPPrintContext context;
- unsigned int ret = 0;
-
doc->ensureUpToDate();
Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX);
@@ -58,28 +56,26 @@ void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc,
gchar * oldoutput = g_strdup(oldconst);
mod->set_param_string("destination", filename);
- /* Start */
+ // Start
context.module = mod;
- /* fixme: This has to go into module constructor somehow */
+ // fixme: This has to go into module constructor somehow
mod->base = doc->getRoot();
Inkscape::Drawing drawing;
- mod->dkey = SPItem::display_key_new (1);
- mod->root = (mod->base)->invoke_show (drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ mod->dkey = SPItem::display_key_new(1);
+ mod->root = (mod->base)->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
drawing.setRoot(mod->root);
- /* Print document */
- ret = mod->begin (doc);
- (mod->base)->invoke_print (&context);
- ret = mod->finish ();
- /* Release things */
- (mod->base)->invoke_hide (mod->dkey);
+ // Print document
+ mod->begin(doc);
+ (mod->base)->invoke_print(&context);
+ mod->finish();
+ // Release things
+ (mod->base)->invoke_hide(mod->dkey);
mod->base = NULL;
mod->root = NULL; // should have been deleted by invoke_hide
- /* end */
+ // end
mod->set_param_string("destination", oldoutput);
g_free(oldoutput);
-
- return;
}
#include "clear-n_.h"
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index bdf95f941..c1eddf539 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -326,22 +326,17 @@ PrintLatex::textToPath(Inkscape::Extension::Print * ext)
#include "clear-n_.h"
-void
-PrintLatex::init (void)
+void PrintLatex::init(void)
{
- Inkscape::Extension::Extension * ext;
-
- /* SVG in */
- ext = Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("LaTeX Print") "</name>\n"
- "<id>" SP_MODULE_KEY_PRINT_LATEX "</id>\n"
- "<param name=\"destination\" type=\"string\"></param>\n"
- "<param name=\"textToPath\" type=\"boolean\">true</param>\n"
- "<print/>\n"
- "</inkscape-extension>", new PrintLatex());
-
- return;
+ /* SVG in */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("LaTeX Print") "</name>\n"
+ "<id>" SP_MODULE_KEY_PRINT_LATEX "</id>\n"
+ "<param name=\"destination\" type=\"string\"></param>\n"
+ "<param name=\"textToPath\" type=\"boolean\">true</param>\n"
+ "<print/>\n"
+ "</inkscape-extension>", new PrintLatex());
}
} /* namespace Internal */
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index 36ef66713..0a89c6661 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -32,6 +32,8 @@
#include <poppler/glib/poppler-page.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
+
#include <gdkmm/general.h>
namespace Inkscape {
@@ -99,9 +101,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
hbox3 = Gtk::manage(new class Gtk::HBox(false, 4));
vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- alignment3 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
- _labelPageSettings = Gtk::manage(new class Gtk::Label(_("Page settings")));
- _pageSettingsFrame = Gtk::manage(new class Gtk::Frame());
+ _pageSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Page settings")));
_labelPrecision = Gtk::manage(new class Gtk::Label(_("Precision of approximating gradient meshes:")));
_labelPrecisionWarning = Gtk::manage(new class Gtk::Label(_("<b>Note</b>: setting the precision too high may result in a large SVG file and slow performance.")));
@@ -125,9 +125,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
hbox5 = Gtk::manage(new class Gtk::HBox(false, 4));
_embedImagesCheck = Gtk::manage(new class Gtk::CheckButton(_("Embed images")));
vbox3 = Gtk::manage(new class Gtk::VBox(false, 4));
- alignment4 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
- _labelImportSettings = Gtk::manage(new class Gtk::Label(_("Import settings")));
- _importSettingsFrame = Gtk::manage(new class Gtk::Frame());
+ _importSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Import settings")));
vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
_previewArea = Gtk::manage(new class Gtk::DrawingArea());
hbox1 = Gtk::manage(new class Gtk::HBox(false, 4));
@@ -167,18 +165,8 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
hbox3->pack_start(*_cropTypeCombo, Gtk::PACK_SHRINK, 0);
vbox2->pack_start(*hbox2);
vbox2->pack_start(*hbox3);
- alignment3->add(*vbox2);
- _labelPageSettings->set_alignment(0.5,0.5);
- _labelPageSettings->set_padding(4,0);
- _labelPageSettings->set_justify(Gtk::JUSTIFY_LEFT);
- _labelPageSettings->set_line_wrap(false);
- _labelPageSettings->set_use_markup(true);
- _labelPageSettings->set_selectable(false);
+ _pageSettingsFrame->add(*vbox2);
_pageSettingsFrame->set_border_width(4);
- _pageSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
- _pageSettingsFrame->set_label_align(0,0.5);
- _pageSettingsFrame->add(*alignment3);
- _pageSettingsFrame->set_label_widget(*_labelPageSettings);
_labelPrecision->set_alignment(0,0.5);
_labelPrecision->set_padding(4,0);
_labelPrecision->set_justify(Gtk::JUSTIFY_LEFT);
@@ -228,18 +216,8 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4);
vbox3->pack_start(*_localFontsCheck, Gtk::PACK_SHRINK, 0);
vbox3->pack_start(*_embedImagesCheck, Gtk::PACK_SHRINK, 0);
- alignment4->add(*vbox3);
- _labelImportSettings->set_alignment(0.5,0.5);
- _labelImportSettings->set_padding(4,0);
- _labelImportSettings->set_justify(Gtk::JUSTIFY_LEFT);
- _labelImportSettings->set_line_wrap(false);
- _labelImportSettings->set_use_markup(true);
- _labelImportSettings->set_selectable(false);
+ _importSettingsFrame->add(*vbox3);
_importSettingsFrame->set_border_width(4);
- _importSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
- _importSettingsFrame->set_label_align(0,0.5);
- _importSettingsFrame->add(*alignment4);
- _importSettingsFrame->set_label_widget(*_labelImportSettings);
vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0);
vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0);
hbox1->pack_start(*vbox1);
@@ -266,8 +244,6 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
_cropTypeCombo->show();
hbox3->show();
vbox2->show();
- alignment3->show();
- _labelPageSettings->show();
_pageSettingsFrame->show();
_labelPrecision->show();
_labelPrecisionWarning->show();
@@ -280,8 +256,6 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
_localFontsCheck->show();
_embedImagesCheck->show();
vbox3->show();
- alignment4->show();
- _labelImportSettings->show();
_importSettingsFrame->show();
vbox1->show();
_previewArea->show();
@@ -657,9 +631,7 @@ static cairo_status_t
void
PdfInputCairo::init(void) {
- Inkscape::Extension::Extension * ext;
-
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>PDF Input</name>\n"
"<id>org.inkscape.input.cairo-pdf</id>\n"
diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h
index 7581cb0a5..cc3ed975e 100644
--- a/src/extension/internal/pdf-input-cairo.h
+++ b/src/extension/internal/pdf-input-cairo.h
@@ -42,6 +42,7 @@ namespace Inkscape {
namespace UI {
namespace Widget {
class SpinButton;
+ class Frame;
}
}
@@ -77,9 +78,7 @@ private:
class Gtk::ComboBoxText * _cropTypeCombo;
class Gtk::HBox * hbox3;
class Gtk::VBox * vbox2;
- class Gtk::Alignment * alignment3;
- class Gtk::Label * _labelPageSettings;
- class Gtk::Frame * _pageSettingsFrame;
+ class Inkscape::UI::Widget::Frame * _pageSettingsFrame;
class Gtk::Label * _labelPrecision;
class Gtk::Label * _labelPrecisionWarning;
class Gtk::HScale * _fallbackPrecisionSlider;
@@ -92,9 +91,7 @@ private:
class Gtk::CheckButton * _localFontsCheck;
class Gtk::CheckButton * _embedImagesCheck;
class Gtk::VBox * vbox3;
- class Gtk::Alignment * alignment4;
- class Gtk::Label * _labelImportSettings;
- class Gtk::Frame * _importSettingsFrame;
+ class Inkscape::UI::Widget::Frame * _importSettingsFrame;
class Gtk::VBox * vbox1;
class Gtk::DrawingArea * _previewArea;
class Gtk::HBox * hbox1;
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index eff488c9d..8802ce2ba 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -49,6 +49,7 @@
#include "dialogs/dialog-events.h"
#include <gtk/gtk.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
#include <gdkmm/general.h>
@@ -116,9 +117,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
hbox3 = Gtk::manage(new class Gtk::HBox(false, 4));
vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- alignment3 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
- _labelPageSettings = Gtk::manage(new class Gtk::Label(_("Page settings")));
- _pageSettingsFrame = Gtk::manage(new class Gtk::Frame());
+ _pageSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Page settings")));
_labelPrecision = Gtk::manage(new class Gtk::Label(_("Precision of approximating gradient meshes:")));
_labelPrecisionWarning = Gtk::manage(new class Gtk::Label(_("<b>Note</b>: setting the precision too high may result in a large SVG file and slow performance.")));
@@ -142,9 +141,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
hbox5 = Gtk::manage(new class Gtk::HBox(false, 4));
_embedImagesCheck = Gtk::manage(new class Gtk::CheckButton(_("Embed images")));
vbox3 = Gtk::manage(new class Gtk::VBox(false, 4));
- alignment4 = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
- _labelImportSettings = Gtk::manage(new class Gtk::Label(_("Import settings")));
- _importSettingsFrame = Gtk::manage(new class Gtk::Frame());
+ _importSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame(_("Import settings")));
vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
_previewArea = Gtk::manage(new class Gtk::DrawingArea());
hbox1 = Gtk::manage(new class Gtk::HBox(false, 4));
@@ -184,18 +181,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
hbox3->pack_start(*_cropTypeCombo, Gtk::PACK_SHRINK, 0);
vbox2->pack_start(*hbox2);
vbox2->pack_start(*hbox3);
- alignment3->add(*vbox2);
- _labelPageSettings->set_alignment(0.5,0.5);
- _labelPageSettings->set_padding(4,0);
- _labelPageSettings->set_justify(Gtk::JUSTIFY_LEFT);
- _labelPageSettings->set_line_wrap(false);
- _labelPageSettings->set_use_markup(true);
- _labelPageSettings->set_selectable(false);
+ _pageSettingsFrame->add(*vbox2);
_pageSettingsFrame->set_border_width(4);
- _pageSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
- _pageSettingsFrame->set_label_align(0,0.5);
- _pageSettingsFrame->add(*alignment3);
- _pageSettingsFrame->set_label_widget(*_labelPageSettings);
_labelPrecision->set_alignment(0,0.5);
_labelPrecision->set_padding(4,0);
_labelPrecision->set_justify(Gtk::JUSTIFY_LEFT);
@@ -245,18 +232,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4);
vbox3->pack_start(*_localFontsCheck, Gtk::PACK_SHRINK, 0);
vbox3->pack_start(*_embedImagesCheck, Gtk::PACK_SHRINK, 0);
- alignment4->add(*vbox3);
- _labelImportSettings->set_alignment(0.5,0.5);
- _labelImportSettings->set_padding(4,0);
- _labelImportSettings->set_justify(Gtk::JUSTIFY_LEFT);
- _labelImportSettings->set_line_wrap(false);
- _labelImportSettings->set_use_markup(true);
- _labelImportSettings->set_selectable(false);
+ _importSettingsFrame->add(*vbox3);
_importSettingsFrame->set_border_width(4);
- _importSettingsFrame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
- _importSettingsFrame->set_label_align(0,0.5);
- _importSettingsFrame->add(*alignment4);
- _importSettingsFrame->set_label_widget(*_labelImportSettings);
vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0);
vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0);
hbox1->pack_start(*vbox1);
@@ -283,8 +260,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
_cropTypeCombo->show();
hbox3->show();
vbox2->show();
- alignment3->show();
- _labelPageSettings->show();
_pageSettingsFrame->show();
_labelPrecision->show();
_labelPrecisionWarning->show();
@@ -297,8 +272,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
_localFontsCheck->show();
_embedImagesCheck->show();
vbox3->show();
- alignment4->show();
- _labelImportSettings->show();
_importSettingsFrame->show();
vbox1->show();
_previewArea->show();
@@ -762,12 +735,9 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
#include "../clear-n_.h"
-void
-PdfInput::init(void) {
- Inkscape::Extension::Extension * ext;
-
+void PdfInput::init(void) {
/* PDF in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("PDF Input") "</name>\n"
"<id>org.inkscape.input.pdf</id>\n"
@@ -780,7 +750,7 @@ PdfInput::init(void) {
"</inkscape-extension>", new PdfInput());
/* AI in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("AI Input") "</name>\n"
"<id>org.inkscape.input.ai</id>\n"
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 7282de322..8334fd2f3 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -49,6 +49,7 @@ namespace Inkscape {
namespace UI {
namespace Widget {
class SpinButton;
+ class Frame;
}
}
@@ -87,9 +88,7 @@ private:
class Gtk::ComboBoxText * _cropTypeCombo;
class Gtk::HBox * hbox3;
class Gtk::VBox * vbox2;
- class Gtk::Alignment * alignment3;
- class Gtk::Label * _labelPageSettings;
- class Gtk::Frame * _pageSettingsFrame;
+ class Inkscape::UI::Widget::Frame * _pageSettingsFrame;
class Gtk::Label * _labelPrecision;
class Gtk::Label * _labelPrecisionWarning;
class Gtk::HScale * _fallbackPrecisionSlider;
@@ -102,9 +101,7 @@ private:
class Gtk::CheckButton * _localFontsCheck;
class Gtk::CheckButton * _embedImagesCheck;
class Gtk::VBox * vbox3;
- class Gtk::Alignment * alignment4;
- class Gtk::Label * _labelImportSettings;
- class Gtk::Frame * _importSettingsFrame;
+ class Inkscape::UI::Widget::Frame * _importSettingsFrame;
class Gtk::VBox * vbox1;
class Gtk::DrawingArea * _previewArea;
class Gtk::HBox * hbox1;
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 885bed3c9..2f36e19a4 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -57,6 +57,7 @@ namespace Internal {
#define TRACE(_args) IFTRACE(g_print _args)
static double ttm[6] = {1, 0, 0, 1, 0, 0}; // temporary transform matrix
+static bool ttm_is_set = false; // flag to forbid setting ttm
/**
* \struct SvgTransparencyGroup
@@ -214,7 +215,11 @@ Inkscape::XML::Node *SvgBuilder::pushGroup() {
setAsLayer(_docname);
}
}
-
+ if (_container->parent()->attribute("inkscape:groupmode") != NULL) {
+ ttm[0] = ttm[3] = 1.0; // clear ttm if parent is a layer
+ ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0;
+ ttm_is_set = false;
+ }
return _container;
}
@@ -567,17 +572,14 @@ bool SvgBuilder::getTransform(double *transform) {
void SvgBuilder::setTransform(double c0, double c1, double c2, double c3,
double c4, double c5) {
// do not remember the group which is a layer
- if (_container->attribute("inkscape:groupmode") != NULL) {
- ttm[0] = ttm[3] = 1.0;
- ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0;
- }
- else {
+ if ((_container->attribute("inkscape:groupmode") == NULL) && !ttm_is_set) {
ttm[0] = c0;
ttm[1] = c1;
ttm[2] = c2;
ttm[3] = c3;
ttm[4] = c4;
ttm[5] = c5;
+ ttm_is_set = true;
}
// Avoid transforming a group with an already set clip-path
@@ -862,30 +864,29 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
} else if ( type == 3 ) { // Stitching
StitchingFunction *stitchingFunc = static_cast<StitchingFunction*>(func);
double *bounds = stitchingFunc->getBounds();
+ double *encode = stitchingFunc->getEncode();
int num_funcs = stitchingFunc->getNumFuncs();
+
// Add stops from all the stitched functions
+ GfxRGB prev_color, color;
+ svgGetShadingColorRGB(shading, bounds[0], &prev_color);
+ _addStopToGradient(gradient, bounds[0], &prev_color, 1.0);
for ( int i = 0 ; i < num_funcs ; i++ ) {
- GfxRGB color;
- svgGetShadingColorRGB(shading, bounds[i], &color);
- bool is_continuation = false;
- if ( i > 0 ) { // Compare to previous stop
- GfxRGB prev_color;
- svgGetShadingColorRGB(shading, bounds[i-1], &prev_color);
- if ( abs(color.r - prev_color.r) < INT_EPSILON &&
- abs(color.g - prev_color.g) < INT_EPSILON &&
- abs(color.b - prev_color.b) < INT_EPSILON ) {
- is_continuation = true;
- }
- }
+ svgGetShadingColorRGB(shading, bounds[i + 1], &color);
// Add stops
- if ( !is_continuation ) {
- _addStopToGradient(gradient, bounds[i], &color, 1.0);
- }
- if ( is_continuation || ( i == num_funcs - 1 ) ) {
- GfxRGB next_color;
- svgGetShadingColorRGB(shading, bounds[i+1], &next_color);
- _addStopToGradient(gradient, bounds[i+1], &next_color, 1.0);
+ if (stitchingFunc->getFunc(i)->getType() == 2) { // process exponential fxn
+ double expE = (static_cast<ExponentialFunction*>(stitchingFunc->getFunc(i)))->getE();
+ if (expE > 1.0) {
+ expE = (bounds[i + 1] - bounds[i])/expE; // approximate exponential as a single straight line at x=1
+ if (encode[2*i] == 0) { // normal sequence
+ _addStopToGradient(gradient, bounds[i + 1] - expE, &prev_color, 1.0);
+ } else { // reflected sequence
+ _addStopToGradient(gradient, bounds[i] + expE, &color, 1.0);
+ }
+ }
}
+ _addStopToGradient(gradient, bounds[i + 1], &color, 1.0);
+ prev_color = color;
}
} else { // Unsupported function type
return false;
@@ -911,10 +912,10 @@ void SvgBuilder::updateStyle(GfxState *state) {
that a space in sp may be removed or replaced by some other tokens
specified in the code. (Bug LP #179589)
*/
-static int MatchingChars(std::string s1, std::string sp)
+static size_t MatchingChars(std::string s1, std::string sp)
{
- unsigned int is = 0;
- unsigned int ip = 0;
+ size_t is = 0;
+ size_t ip = 0;
while(is < s1.length() && ip < sp.length()) {
if (s1[is] == sp[ip]) {
@@ -928,7 +929,7 @@ static int MatchingChars(std::string s1, std::string sp)
break;
}
}
- return(ip);
+ return ip;
}
/*
@@ -945,12 +946,12 @@ std::string SvgBuilder::_BestMatchingFont(std::string PDFname)
std::string fontname = _availableFontNames[i];
// At least the first word of the font name should match.
- guint minMatch = fontname.find(" ");
+ size_t minMatch = fontname.find(" ");
if (minMatch == std::string::npos) {
minMatch = fontname.length();
}
- int Match = MatchingChars(PDFname, fontname);
+ size_t Match = MatchingChars(PDFname, fontname);
if (Match >= minMatch) {
double relMatch = (float)Match / (fontname.length() + PDFname.length());
if (relMatch > bestMatch) {
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index d054e4427..9b1098afd 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -83,10 +83,8 @@ void pruneExtendedAttributes( Inkscape::XML::Node *repr )
void
Svg::init(void)
{
- Inkscape::Extension::Extension * ext;
-
/* SVG in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("SVG Input") "</name>\n"
"<id>" SP_MODULE_KEY_INPUT_SVG "</id>\n"
@@ -100,7 +98,7 @@ Svg::init(void)
"</inkscape-extension>", new Svg());
/* SVG out Inkscape */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("SVG Output Inkscape") "</name>\n"
"<id>" SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "</id>\n"
@@ -114,7 +112,7 @@ Svg::init(void)
"</inkscape-extension>", new Svg());
/* SVG out */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("SVG Output") "</name>\n"
"<id>" SP_MODULE_KEY_OUTPUT_SVG "</id>\n"
@@ -232,8 +230,6 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena
g_return_if_fail(doc != NULL);
g_return_if_fail(filename != NULL);
- gchar *save_path = g_path_get_dirname(filename);
-
bool const exportExtensions = ( !mod->get_id()
|| !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE)
|| !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE));
@@ -259,8 +255,6 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena
Inkscape::GC::release(rdoc);
}
- g_free(save_path);
-
return;
}
diff --git a/src/extension/internal/svgz.cpp b/src/extension/internal/svgz.cpp
index fceafd3ee..be9440980 100644
--- a/src/extension/internal/svgz.cpp
+++ b/src/extension/internal/svgz.cpp
@@ -40,10 +40,8 @@ namespace Internal {
void
Svgz::init(void)
{
- Inkscape::Extension::Extension * ext;
-
/* SVGZ in */
- ext = Inkscape::Extension::build_from_mem(
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("SVGZ Input") "</name>\n"
"<id>" SP_MODULE_KEY_INPUT_SVGZ "</id>\n"
@@ -57,8 +55,8 @@ Svgz::init(void)
"</input>\n"
"</inkscape-extension>", new Svgz());
- /* SVGZ out Inkscape */
- ext = Inkscape::Extension::build_from_mem(
+ /* SVGZ out Inkscape */
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("SVGZ Output") "</name>\n"
"<id>" SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE "</id>\n"
@@ -71,8 +69,8 @@ Svgz::init(void)
"</output>\n"
"</inkscape-extension>", new Svgz());
- /* SVGZ out */
- ext = Inkscape::Extension::build_from_mem(
+ /* SVGZ out */
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("SVGZ Output") "</name>\n"
"<id>" SP_MODULE_KEY_OUTPUT_SVGZ "</id>\n"
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index 8862c1d4a..cb1677547 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -115,11 +115,8 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
#include "clear-n_.h"
-void
-WpgInput::init(void) {
- Inkscape::Extension::Extension * ext;
-
- ext = Inkscape::Extension::build_from_mem(
+void WpgInput::init(void) {
+ Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("WPG Input") "</name>\n"
"<id>org.inkscape.input.wpg</id>\n"
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index f15d56f0d..cf2b0f5d5 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -10,6 +10,7 @@
# include "config.h"
#endif
+#include <glibmm/value.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h
index ff857272a..943273623 100644
--- a/src/extension/prefdialog.h
+++ b/src/extension/prefdialog.h
@@ -10,6 +10,7 @@
#ifndef INKSCAPE_EXTENSION_DIALOG_H__
#define INKSCAPE_EXTENSION_DIALOG_H__
+#include <glibmm/value.h>
#include <gtkmm/dialog.h>
#include <glibmm/ustring.h>
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index ad66b258a..c1f9251df 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -1615,6 +1615,7 @@ void GrDrag::addDragger(GrDraggable *draggable)
*/
void GrDrag::addDraggersRadial(SPRadialGradient *rg, SPItem *item, bool fill_or_stroke)
{
+ rg->ensureVector();
addDragger (new GrDraggable (item, POINT_RG_CENTER, 0, fill_or_stroke));
guint num = rg->vector.stops.size();
if (num > 2) {
@@ -1637,6 +1638,7 @@ void GrDrag::addDraggersRadial(SPRadialGradient *rg, SPItem *item, bool fill_or_
*/
void GrDrag::addDraggersLinear(SPLinearGradient *lg, SPItem *item, bool fill_or_stroke)
{
+ lg->ensureVector();
addDragger (new GrDraggable (item, POINT_LG_BEGIN, 0, fill_or_stroke));
guint num = lg->vector.stops.size();
if (num > 2) {
diff --git a/src/interface.cpp b/src/interface.cpp
index 762a1692d..d43662317 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -540,7 +540,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb
gchar* c = sp_shortcut_get_label(shortcut);
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *const hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
+ gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
#else
GtkWidget *const hb = gtk_hbox_new(FALSE, 16);
#endif
@@ -728,8 +728,8 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *
gchar* c = sp_shortcut_get_label(shortcut);
#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
+ GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16);
+ gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
#else
GtkWidget *hb = gtk_hbox_new(FALSE, 16);
#endif
@@ -885,7 +885,7 @@ void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view)
{
gchar const* data[] = {
C_("Interface setup", "Default"), _("Default interface setup"),
- C_("Interface setup", "Custom"), _("Set the custom task"),
+ C_("Interface setup", "Custom"), _("Setup for custom task"),
C_("Interface setup", "Wide"), _("Setup for widescreen work"),
0, 0
};
@@ -1589,7 +1589,6 @@ void injectRenamedIcons()
ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) :
_item(item),
- separators(),
MIGroup(),
MIParent(_("Go to parent"))
{
@@ -1650,15 +1649,13 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) :
ContextMenu::~ContextMenu(void)
{
-// g_message("~ContextMenu");
}
Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void)
{
- Gtk::SeparatorMenuItem* sep = new Gtk::SeparatorMenuItem();
+ Gtk::SeparatorMenuItem* sep = manage(new Gtk::SeparatorMenuItem());
sep->show();
append(*sep);
- separators.push_back(sep);
return sep;
}
@@ -1693,11 +1690,11 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//
unsigned int shortcut = sp_shortcut_get_primary(verb);
if (shortcut!=GDK_KEY_VoidSymbol) {
gchar* c = sp_shortcut_get_label(shortcut);
- Gtk::HBox *const hb = new Gtk::HBox (FALSE, 16);
- Gtk::Label *const name_lbl = new Gtk::Label(action->name, true);
+ Gtk::HBox *const hb = manage(new Gtk::HBox (FALSE, 16));
+ Gtk::Label *const name_lbl = manage(new Gtk::Label(action->name, true));
name_lbl->set_alignment(0.0, 0.5);
hb->pack_start(*name_lbl, TRUE, TRUE, 0);
- Gtk::Label *const accel_lbl = new Gtk::Label(c);
+ Gtk::Label *const accel_lbl = manage(new Gtk::Label(c));
accel_lbl->set_alignment(1.0, 0.5);
hb->pack_end(*accel_lbl, FALSE, FALSE, 0);
hb->show_all();
@@ -1712,9 +1709,9 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//
// if (radio) {
// item = gtk_radio_menu_item_new (group);
// } else {
- item = new Gtk::ImageMenuItem();
+ item = manage(new Gtk::ImageMenuItem());
// }
- Gtk::Label *const name_lbl = new Gtk::Label(action->name, true);
+ Gtk::Label *const name_lbl = manage(new Gtk::Label(action->name, true));
name_lbl->set_alignment(0.0, 0.5);
item->add(*name_lbl);
}
@@ -1773,7 +1770,7 @@ void ContextMenu::MakeItemMenu (void)
Gtk::MenuItem* mi;
/* Item dialog */
- mi = new Gtk::MenuItem(_("_Object Properties..."),1);
+ mi = manage(new Gtk::MenuItem(_("_Object Properties..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties));
mi->show();
append(*mi);//insert(*mi,positionOfLastDialog++);
@@ -1781,7 +1778,7 @@ void ContextMenu::MakeItemMenu (void)
AddSeparator();
/* Select item */
- mi = new Gtk::MenuItem(_("_Select This"),1);
+ mi = manage(new Gtk::MenuItem(_("_Select This"),1));
if (_desktop->selection->includes(_item)) {
mi->set_sensitive(FALSE);
} else {
@@ -1791,7 +1788,7 @@ void ContextMenu::MakeItemMenu (void)
append(*mi);
/* Select same fill and stroke */
- mi = new Gtk::MenuItem(_("_Select Same Fill and Stroke"),1);
+ mi = manage(new Gtk::MenuItem(_("_Select Same Fill and Stroke"),1));
if (_desktop->selection->isEmpty()) {
mi->set_sensitive(FALSE);
} else {
@@ -1802,7 +1799,7 @@ void ContextMenu::MakeItemMenu (void)
append(*mi);
/* Create link */
- mi = new Gtk::MenuItem(_("_Create Link"),1);
+ mi = manage(new Gtk::MenuItem(_("_Create Link"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink));
mi->set_sensitive(!SP_IS_ANCHOR(_item));
mi->show();
@@ -1825,7 +1822,7 @@ void ContextMenu::MakeItemMenu (void)
}
}
/* Set mask */
- mi = new Gtk::MenuItem(_("Set Mask"),1);
+ mi = manage(new Gtk::MenuItem(_("Set Mask"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask));
if (ClipRefOK || MaskRefOK) {
mi->set_sensitive(FALSE);
@@ -1836,7 +1833,7 @@ void ContextMenu::MakeItemMenu (void)
append(*mi);
/* Release mask */
- mi = new Gtk::MenuItem(_("Release Mask"),1);
+ mi = manage(new Gtk::MenuItem(_("Release Mask"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask));
if (MaskRefOK) {
mi->set_sensitive(TRUE);
@@ -1847,7 +1844,7 @@ void ContextMenu::MakeItemMenu (void)
append(*mi);
/* Set Clip */
- mi = new Gtk::MenuItem(_("Set _Clip"),1);
+ mi = manage(new Gtk::MenuItem(_("Set _Clip"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip));
if (ClipRefOK || MaskRefOK) {
mi->set_sensitive(FALSE);
@@ -1858,7 +1855,7 @@ void ContextMenu::MakeItemMenu (void)
append(*mi);
/* Release Clip */
- mi = new Gtk::MenuItem(_("Release C_lip"),1);
+ mi = manage(new Gtk::MenuItem(_("Release C_lip"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip));
if (ClipRefOK) {
mi->set_sensitive(TRUE);
@@ -1933,7 +1930,7 @@ void ContextMenu::ReleaseClip(void)
void ContextMenu::MakeGroupMenu(void)
{
/* Ungroup */
- Gtk::MenuItem* mi = new Gtk::MenuItem(_("_Ungroup"),1);
+ Gtk::MenuItem* mi = manage(new Gtk::MenuItem(_("_Ungroup"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup));
mi->show();
append(*mi);
@@ -1953,19 +1950,19 @@ void ContextMenu::MakeAnchorMenu(void)
Gtk::MenuItem* mi;
/* Link dialog */
- mi = new Gtk::MenuItem(_("Link _Properties..."),1);
+ mi = manage(new Gtk::MenuItem(_("Link _Properties..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties));
mi->show();
insert(*mi,positionOfLastDialog++);
/* Select item */
- mi = new Gtk::MenuItem(_("_Follow Link"),1);
+ mi = manage(new Gtk::MenuItem(_("_Follow Link"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow));
mi->show();
append(*mi);
/* Reset transformations */
- mi = new Gtk::MenuItem(_("_Remove Link"),1);
+ mi = manage(new Gtk::MenuItem(_("_Remove Link"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove));
mi->show();
append(*mi);
@@ -1995,13 +1992,13 @@ void ContextMenu::MakeImageMenu (void)
const gchar *href = ir->attribute("xlink:href");
/* Image properties */
- mi = new Gtk::MenuItem(_("Image _Properties..."),1);
+ mi = manage(new Gtk::MenuItem(_("Image _Properties..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties));
mi->show();
insert(*mi,positionOfLastDialog++);
/* Edit externally */
- mi = new Gtk::MenuItem(_("Edit Externally..."),1);
+ mi = manage(new Gtk::MenuItem(_("Edit Externally..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit));
mi->show();
insert(*mi,positionOfLastDialog++);
@@ -2011,7 +2008,7 @@ void ContextMenu::MakeImageMenu (void)
/* Embed image */
if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) {
- mi = new Gtk::MenuItem(C_("Context menu", "Embed Image"));
+ mi = manage(new Gtk::MenuItem(C_("Context menu", "Embed Image")));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed));
mi->show();
insert(*mi,positionOfLastDialog++);
@@ -2022,7 +2019,7 @@ void ContextMenu::MakeImageMenu (void)
/* Extract image */
if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) {
- mi = new Gtk::MenuItem(C_("Context menu", "Extract Image..."));
+ mi = manage(new Gtk::MenuItem(C_("Context menu", "Extract Image...")));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract));
mi->show();
insert(*mi,positionOfLastDialog++);
@@ -2155,7 +2152,7 @@ void ContextMenu::MakeShapeMenu (void)
Gtk::MenuItem* mi;
/* Item dialog */
- mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1);
+ mi = manage(new Gtk::MenuItem(_("_Fill and Stroke..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings));
mi->show();
insert(*mi,positionOfLastDialog++);
@@ -2175,19 +2172,19 @@ void ContextMenu::MakeTextMenu (void)
Gtk::MenuItem* mi;
/* Fill and Stroke dialog */
- mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1);
+ mi = manage(new Gtk::MenuItem(_("_Fill and Stroke..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings));
mi->show();
insert(*mi,positionOfLastDialog++);
/* Edit Text dialog */
- mi = new Gtk::MenuItem(_("_Text and Font..."),1);
+ mi = manage(new Gtk::MenuItem(_("_Text and Font..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings));
mi->show();
insert(*mi,positionOfLastDialog++);
/* Spellcheck dialog */
- mi = new Gtk::MenuItem(_("Check Spellin_g..."),1);
+ mi = manage(new Gtk::MenuItem(_("Check Spellin_g..."),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings));
mi->show();
insert(*mi,positionOfLastDialog++);
diff --git a/src/interface.h b/src/interface.h
index 1ea13f639..029bb4154 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -120,7 +120,6 @@ class ContextMenu : public Gtk::Menu
int positionOfLastDialog;
- std::vector<Gtk::SeparatorMenuItem*> separators; //contains pointers to separators
Gtk::MenuItem MIGroup; //menu entry to enter a group
Gtk::MenuItem MIParent; //menu entry to leave a group
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index 2830a8026..0ce00e43b 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -435,17 +435,17 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
}
for (unsigned char_index = 0 ; char_index < _characters.size() ; ) {
- unsigned current_cluster_glyph_index, next_cluster_glyph_index;
- unsigned next_cluster_char_index;
Span const &span = _characters[char_index].span(this);
- current_cluster_glyph_index = _characters[char_index].in_glyph;
-
+ size_t next_cluster_char_index = 0; // TODO refactor to not bump via for loops
for (next_cluster_char_index = char_index + 1 ; next_cluster_char_index < _characters.size() ; next_cluster_char_index++) {
if (_characters[next_cluster_char_index].in_glyph != -1 && _characters[next_cluster_char_index].char_attributes.is_cursor_position)
+ {
break;
+ }
}
+ size_t next_cluster_glyph_index = 0;
if (next_cluster_char_index == _characters.size()) {
next_cluster_glyph_index = _glyphs.size();
} else {
@@ -454,11 +454,16 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
double start_offset = offset + span.x_start + _characters[char_index].x;
double cluster_width = 0.0;
- for (int glyph_index = current_cluster_glyph_index ; glyph_index < next_cluster_glyph_index ; glyph_index++)
+ size_t const current_cluster_glyph_index = _characters[char_index].in_glyph;
+ for (size_t glyph_index = current_cluster_glyph_index ; glyph_index < next_cluster_glyph_index ; glyph_index++)
+ {
cluster_width += _glyphs[glyph_index].width;
+ }
// TODO block progression?
if (span.direction == RIGHT_TO_LEFT)
+ {
start_offset -= cluster_width;
+ }
double end_offset = start_offset + cluster_width;
int unused = 0;
@@ -504,17 +509,19 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
if (_directions_are_orthogonal(_blockProgression(), TOP_TO_BOTTOM)) {
double rotation = atan2(-tangent[Geom::X], tangent[Geom::Y]);
- for (int glyph_index = current_cluster_glyph_index; glyph_index < next_cluster_glyph_index ; glyph_index++) {
+ for (size_t glyph_index = current_cluster_glyph_index; glyph_index < next_cluster_glyph_index ; glyph_index++) {
_glyphs[glyph_index].x = midpoint[Geom::Y] - tangent[Geom::X] * _glyphs[glyph_index].y - span.chunk(this).left_x;
_glyphs[glyph_index].y = midpoint[Geom::X] + tangent[Geom::Y] * _glyphs[glyph_index].y - _lines.front().baseline_y;
_glyphs[glyph_index].rotation += rotation;
}
} else {
double rotation = atan2(tangent[Geom::Y], tangent[Geom::X]);
- for (int glyph_index = current_cluster_glyph_index; glyph_index < next_cluster_glyph_index ; glyph_index++) {
+ for (size_t glyph_index = current_cluster_glyph_index; glyph_index < next_cluster_glyph_index ; glyph_index++) {
double tangent_shift = -cluster_width * 0.5 + _glyphs[glyph_index].x - (_characters[char_index].x + span.x_start);
if (span.direction == RIGHT_TO_LEFT)
+ {
tangent_shift += cluster_width;
+ }
_glyphs[glyph_index].x = midpoint[Geom::X] + tangent[Geom::X] * tangent_shift - tangent[Geom::Y] * _glyphs[glyph_index].y - span.chunk(this).left_x;
_glyphs[glyph_index].y = midpoint[Geom::Y] + tangent[Geom::Y] * tangent_shift + tangent[Geom::X] * _glyphs[glyph_index].y - _lines.front().baseline_y;
_glyphs[glyph_index].rotation += rotation;
diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp
index da268910f..7b170e8a0 100644
--- a/src/livarot/ShapeMisc.cpp
+++ b/src/livarot/ShapeMisc.cpp
@@ -584,15 +584,13 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
enB = a->CyclePrevAt (a->getEdge(i).en, i);
}
- Geom::Point stD, seD, enD;
- double stL, seL, enL;
- stD = a->getEdge(stB).dx;
- seD = a->getEdge(i).dx;
- enD = a->getEdge(enB).dx;
+ Geom::Point stD = a->getEdge(stB).dx;
+ Geom::Point seD = a->getEdge(i).dx;
+ Geom::Point enD = a->getEdge(enB).dx;
- stL = sqrt (dot(stD,stD));
- seL = sqrt (dot(seD,seD));
- enL = sqrt (dot(enD,enD));
+ double stL = sqrt (dot(stD,stD));
+ double seL = sqrt (dot(seD,seD));
+ //double enL = sqrt (dot(enD,enD));
MiscNormalize (stD);
MiscNormalize (enD);
MiscNormalize (seD);
@@ -778,15 +776,13 @@ Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_p
enB = a->CycleNextAt (a->getEdge(i).en, i);
}
- Geom::Point stD, seD, enD;
- double stL, seL, enL;
- stD = a->getEdge(stB).dx;
- seD = a->getEdge(i).dx;
- enD = a->getEdge(enB).dx;
+ Geom::Point stD = a->getEdge(stB).dx;
+ Geom::Point seD = a->getEdge(i).dx;
+ Geom::Point enD = a->getEdge(enB).dx;
- stL = sqrt (dot(stD,stD));
- seL = sqrt (dot(seD,seD));
- enL = sqrt (dot(enD,enD));
+ double stL = sqrt (dot(stD,stD));
+ double seL = sqrt (dot(seD,seD));
+ //double enL = sqrt (dot(enD,enD));
MiscNormalize (stD);
MiscNormalize (enD);
MiscNormalize (seD);
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index 7a66b80c9..7ec103a85 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -94,7 +94,8 @@ findShadowedTime(Geom::Path const &patha, std::vector<Geom::Point> const &pt_and
using namespace Geom;
Point T = unit_vector(pt_and_dir[1]);
Point N = T.cw();
- Point A = pt_and_dir[0]-3*width*T, B = A+6*width*T;
+ //Point A = pt_and_dir[0] - 3 * width * T;
+ //Point B = A+6*width*T;
Affine mat = from_basis( T, N, pt_and_dir[0] );
mat = mat.inverse();
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index a9cf22f6a..44f9b9eb0 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -209,7 +209,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
Geom::Piecewise<Geom::SBasis> const & y, // width path
LineJoinType jointype,
double miter_limit,
- bool forward_direction,
+ bool /*forward_direction*/,
double tol=Geom::EPSILON)
{
/* per definition, each discontinuity should be fixed with a join-ending, as defined by linejoin_type
@@ -238,10 +238,10 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
Geom::Point discontinuity_vec = B[i].at0() - B[prev_i].at1();
bool on_outside = ( dot(tang1, discontinuity_vec) >= 0. );
- switch (jointype) {
- case LINEJOIN_ROUND: {
- if (on_outside) {
- // we are on the outside: round corner
+ if (on_outside) {
+ // we are on the outside: add some type of join!
+ switch (jointype) {
+ case LINEJOIN_ROUND: {
/* for constant width paths, the rounding is a circular arc (rx == ry),
for non-constant width paths, the rounding can be done with an ellipse but is hard and ambiguous.
The elliptical arc should go through the discontinuity's start and end points (of course!)
@@ -258,30 +258,23 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
break;
}
- Geom::Ellipse ellipse = find_ellipse(B[prev_i].at1(), B[i].at0(), *O);
+ Geom::Ellipse ellipse;
+ try {
+ ellipse = find_ellipse(B[prev_i].at1(), B[i].at0(), *O);
+ }
+ catch (Geom::LogicalError &e) {
+ // 2geom did not find a fitting ellipse, this happens for weird thick paths :)
+ // do bevel, and break
+ pb.lineTo(B[i].at0());
+ break;
+ }
+
pb.arcTo( ellipse.ray(Geom::X), ellipse.ray(Geom::Y), ellipse.rot_angle(),
false, width < 0, B[i].at0() );
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
- }
- break;
- }
-/* case LINEJOIN_NONE: {
- if ( on_outside ) {
- // we are on the outside
- Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width;
- pb.lineTo(point_on_path);
- pb.lineTo(B[i].at0());
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
- }
- } */
- case LINEJOIN_EXTRP_MITER: {
- if (on_outside) {
- // we are on the outside, do something complicated to make it look good ;)
+ break;
+ }
+ case LINEJOIN_EXTRP_MITER: {
Geom::D2<Geom::SBasis> newcurve1 = B[prev_i] * Geom::reflection(rot90(tang1), B[prev_i].at1());
Geom::CubicBezier bzr1 = sbasis_to_cubicbezier( reverse(newcurve1) );
@@ -306,17 +299,9 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
pb.curveTo(sub2.second[1], sub2.second[2], sub2.second[3]);
}
}
-
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
+ break;
}
- break;
- }
- case LINEJOIN_MITER: {
- if (on_outside) {
- // we are on the outside, do something complicated to make it look good ;)
-
+ case LINEJOIN_MITER: {
boost::optional<Geom::Point> p = intersection_point( B[prev_i].at1(), tang1,
B[i].at0(), tang2 );
if (p) {
@@ -329,14 +314,9 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
}
}
pb.lineTo(B[i].at0());
- } else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
+ break;
}
- break;
- }
- case LINEJOIN_SPIRO: {
- if (on_outside) {
+ case LINEJOIN_SPIRO: {
Geom::Point direction = B[i].at0() - B[prev_i].at1();
double tang1_sign = dot(direction,tang1);
double tang2_sign = dot(direction,tang2);
@@ -358,19 +338,39 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
Geom::Path spiro;
Spiro::spiro_run(controlpoints, 4, spiro);
pb.append(spiro.portion(1,spiro.size_open()-1), Geom::Path::STITCH_DISCONTINUOUS);
+ break;
+ }
+ case LINEJOIN_BEVEL:
+ default:
+ pb.lineTo(B[i].at0());
+ break;
+ }
+
+ build_from_sbasis(pb, B[i], tol, false);
+
+ } else {
+ // we are on inside of corner!
+ Geom::Path bzr1 = path_from_sbasis( B[prev_i], tol );
+ Geom::Path bzr2 = path_from_sbasis( B[i], tol );
+ Geom::Crossings cross = crossings(bzr1, bzr2);
+ if (cross.size() != 1) {
+ // empty crossing or too many crossings: default to bevel
+ pb.lineTo(B[i].at0());
+ pb.append(bzr2, Geom::Path::STITCH_DISCONTINUOUS);
} else {
- // we are on the inside, do a simple bevel to connect the paths
- pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles
+ // :-) quick hack:
+ for (unsigned i=0; i < bzr1.size_open(); ++i) {
+ pb.backspace();
+ }
+
+ pb.append( bzr1.portion(0, cross[0].ta), Geom::Path::STITCH_DISCONTINUOUS );
+ pb.append( bzr2.portion(cross[0].tb, bzr2.size_open()), Geom::Path::STITCH_DISCONTINUOUS );
}
- break;
- }
- case LINEJOIN_BEVEL:
- default:
- pb.lineTo(B[i].at0());
- break;
}
+ } else {
+ build_from_sbasis(pb, B[i], tol, false);
}
- build_from_sbasis(pb, B[i], tol, false);
+
prev_i = i;
}
pb.finish();
diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp
index f9ab72373..fb3d143aa 100644
--- a/src/live_effects/lpe-rough-hatches.cpp
+++ b/src/live_effects/lpe-rough-hatches.cpp
@@ -440,8 +440,8 @@ LPERoughHatches::smoothSnake(std::vector<std::vector<Point> > const &linearSnake
for (unsigned comp=0; comp<linearSnake.size(); comp++){
if (linearSnake[comp].size()>=2){
Point last_pt = linearSnake[comp][0];
- Point last_top = linearSnake[comp][0];
- Point last_bot = linearSnake[comp][0];
+ //Point last_top = linearSnake[comp][0];
+ //Point last_bot = linearSnake[comp][0];
Point last_hdle = linearSnake[comp][0];
Point last_top_hdle = linearSnake[comp][0];
Point last_bot_hdle = linearSnake[comp][0];
@@ -482,8 +482,8 @@ LPERoughHatches::smoothSnake(std::vector<std::vector<Point> > const &linearSnake
if ( fat_output.get_value() ){
//double scaled_width = double((is_top ? stroke_width_top : stroke_width_bot))/(pt1[X]-pt0[X]);
- double scaled_width = 1./(pt1[X]-pt0[X]);
- Point hdle_offset = (pt1-pt0)*scaled_width;
+ //double scaled_width = 1./(pt1[X]-pt0[X]);
+ //Point hdle_offset = (pt1-pt0)*scaled_width;
Point inside = new_pt;
Point inside_hdle_in;
Point inside_hdle_out;
diff --git a/src/main.cpp b/src/main.cpp
index 7a5d15cb7..a22295424 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1253,10 +1253,9 @@ do_query_all_recurse (SPObject *o)
}
-static void
-sp_do_export_png(SPDocument *doc)
+static void sp_do_export_png(SPDocument *doc)
{
- const gchar *filename = NULL;
+ Glib::ustring filename;
bool filename_from_hint = false;
gdouble dpi = 0.0;
@@ -1356,7 +1355,7 @@ sp_do_export_png(SPDocument *doc)
}
// set filename and dpi from options, if not yet set from the hints
- if (!filename) {
+ if (filename.empty()) {
if (!sp_export_png) {
g_warning ("No export filename given and no filename hint. Nothing exported.");
return;
@@ -1447,36 +1446,34 @@ sp_do_export_png(SPDocument *doc)
}
}
- gchar *path = 0;
+ Glib::ustring path;
if (filename_from_hint) {
//Make relative paths go from the document location, if possible:
- if (!g_path_is_absolute(filename) && doc->getURI()) {
- gchar *dirname = g_path_get_dirname(doc->getURI());
- if (dirname) {
- path = g_build_filename(dirname, filename, NULL);
- g_free(dirname);
+ if (!Glib::path_is_absolute(filename) && doc->getURI()) {
+ Glib::ustring dirname = Glib::path_get_dirname(doc->getURI());
+ if (!dirname.empty()) {
+ path = Glib::build_filename(dirname, filename);
}
}
- if (!path) {
- path = g_strdup(filename);
+ if (path.empty()) {
+ path = filename;
}
} else {
- path = g_strdup(filename);
+ path = filename;
}
g_print("Background RRGGBBAA: %08x\n", bgcolor);
g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi);
- g_print("Bitmap saved as: %s\n", filename);
+ g_print("Bitmap saved as: %s\n", filename.c_str());
if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
- sp_export_png_file(doc, path, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
+ sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
} else {
g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX);
}
- g_free (path);
g_slist_free (items);
}
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index e9257d3af..953e7c8d9 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -10,8 +10,9 @@
* Jon A. Cruz <jon@joncruz.org>
* Martin Sucha <martin.sucha-inkscape@jts-sro.sk>
* Abhishek Sharma
+ * Kris De Gussem <Kris.DeGussem@gmail.com>
*
- * Copyright (C) 1999-2010 authors
+ * Copyright (C) 1999-2010,2012 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -2924,8 +2925,7 @@ void sp_selection_untile(SPDesktop *desktop)
}
}
-void
-sp_selection_get_export_hints(Inkscape::Selection *selection, char const **filename, float *xdpi, float *ydpi)
+void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring &filename, float *xdpi, float *ydpi)
{
if (selection->isEmpty()) {
return;
@@ -2945,13 +2945,17 @@ sp_selection_get_export_hints(Inkscape::Selection *selection, char const **filen
Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data;
if (filename_search) {
- *filename = repr->attribute("inkscape:export-filename");
- if (*filename != NULL)
+ const gchar* tmp = repr->attribute("inkscape:export-filename");
+ if (tmp){
+ filename = tmp;
filename_search = FALSE;
+ }
+ else{
+ filename.clear();
+ }
}
if (xdpi_search) {
- dpi_string = NULL;
dpi_string = repr->attribute("inkscape:export-xdpi");
if (dpi_string != NULL) {
*xdpi = atof(dpi_string);
@@ -2960,7 +2964,6 @@ sp_selection_get_export_hints(Inkscape::Selection *selection, char const **filen
}
if (ydpi_search) {
- dpi_string = NULL;
dpi_string = repr->attribute("inkscape:export-ydpi");
if (dpi_string != NULL) {
*ydpi = atof(dpi_string);
@@ -2970,12 +2973,19 @@ sp_selection_get_export_hints(Inkscape::Selection *selection, char const **filen
}
}
-void sp_document_get_export_hints(SPDocument *doc, char const **filename, float *xdpi, float *ydpi)
+void sp_document_get_export_hints(SPDocument *doc, Glib::ustring &filename, float *xdpi, float *ydpi)
{
Inkscape::XML::Node * repr = doc->getReprRoot();
- *filename = repr->attribute("inkscape:export-filename");
-
+ const gchar* tmp = repr->attribute("inkscape:export-filename");
+ if(tmp)
+ {
+ filename = tmp;
+ }
+ else
+ {
+ filename.clear();
+ }
gchar const *dpi_string = repr->attribute("inkscape:export-xdpi");
if (dpi_string != NULL) {
*xdpi = atof(dpi_string);
@@ -3069,14 +3079,14 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
res = PX_PER_IN * prefs_min / MIN(bbox->width(), bbox->height());
} else {
float hint_xdpi = 0, hint_ydpi = 0;
- char const *hint_filename;
+ Glib::ustring hint_filename;
// take resolution hint from the selected objects
- sp_selection_get_export_hints(selection, &hint_filename, &hint_xdpi, &hint_ydpi);
+ sp_selection_get_export_hints(selection, hint_filename, &hint_xdpi, &hint_ydpi);
if (hint_xdpi != 0) {
res = hint_xdpi;
} else {
// take resolution hint from the document
- sp_document_get_export_hints(document, &hint_filename, &hint_xdpi, &hint_ydpi);
+ sp_document_get_export_hints(document, hint_filename, &hint_xdpi, &hint_ydpi);
if (hint_xdpi != 0) {
res = hint_xdpi;
} else {
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index ccb152602..0e69fdac8 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -142,8 +142,8 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item);
void sp_undo (SPDesktop *desktop, SPDocument *doc);
void sp_redo (SPDesktop *desktop, SPDocument *doc);
-void sp_selection_get_export_hints (Inkscape::Selection *selection, const char **filename, float *xdpi, float *ydpi);
-void sp_document_get_export_hints (SPDocument * doc, const char **filename, float *xdpi, float *ydpi);
+void sp_selection_get_export_hints (Inkscape::Selection *selection, Glib::ustring &filename, float *xdpi, float *ydpi);
+void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, float *xdpi, float *ydpi);
void sp_selection_create_bitmap_copy (SPDesktop *desktop);
diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp
index 0e962a711..ac74f893f 100644
--- a/src/svg-view-widget.cpp
+++ b/src/svg-view-widget.cpp
@@ -29,6 +29,16 @@ static void sp_svg_view_widget_destroy (GtkObject *object);
static void sp_svg_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static void sp_svg_view_widget_size_request (GtkWidget *widget, GtkRequisition *req);
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_svg_view_widget_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sp_svg_view_widget_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static void sp_svg_view_widget_view_resized (SPViewWidget *vw, Inkscape::UI::View::View *view, gdouble width, gdouble height);
static SPViewWidgetClass *widget_parent_class;
@@ -68,7 +78,12 @@ static void sp_svg_view_widget_class_init(SPSVGSPViewWidgetClass *klass)
object_class->destroy = sp_svg_view_widget_destroy;
widget_class->size_allocate = sp_svg_view_widget_size_allocate;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = sp_svg_view_widget_get_preferred_width;
+ widget_class->get_preferred_height = sp_svg_view_widget_get_preferred_height;
+#else
widget_class->size_request = sp_svg_view_widget_size_request;
+#endif
vw_class->view_resized = sp_svg_view_widget_view_resized;
}
@@ -164,6 +179,22 @@ static void sp_svg_view_widget_size_request(GtkWidget *widget, GtkRequisition *r
}
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_svg_view_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sp_svg_view_widget_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void sp_svg_view_widget_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sp_svg_view_widget_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
/**
* Callback connected with size_allocate signal.
*/
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index c00590ae1..2c6a68569 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -80,6 +80,7 @@ set(ui_SRC
widget/dock.cpp
widget/entity-entry.cpp
widget/entry.cpp
+ widget/frame.cpp
widget/filter-effect-chooser.cpp
widget/handlebox.cpp
widget/icon-widget.cpp
@@ -211,6 +212,7 @@ set(ui_SRC
widget/dock.h
widget/entity-entry.h
widget/entry.h
+ widget/frame.h
widget/filter-effect-chooser.h
widget/handlebox.h
widget/icon-widget.h
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index 7edf9c30c..59cc0dba4 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -17,6 +17,7 @@
#include <list>
#include "ui/widget/panel.h"
+#include "ui/widget/frame.h"
#include <gtkmm/frame.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/label.h>
@@ -107,7 +108,7 @@ protected:
#endif
std::list<Action *> _actionList;
- Gtk::Frame _alignFrame, _distributeFrame, _rearrangeFrame, _removeOverlapFrame, _nodesFrame;
+ UI::Widget::Frame _alignFrame, _distributeFrame, _rearrangeFrame, _removeOverlapFrame, _nodesFrame;
#if WITH_GTKMM_3_0
Gtk::Grid _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable;
#else
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 060a10f63..af5788ac6 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -94,8 +94,8 @@ namespace Dialog {
Export::Export (void) :
UI::Widget::Panel ("", "/dialogs/export/", SP_VERB_DIALOG_EXPORT),
current_key(SELECTION_PAGE),
- original_name(NULL),
- doc_export_name(NULL),
+ original_name(),
+ doc_export_name(),
filename_modified(false),
was_empty(true),
update(false),
@@ -116,6 +116,8 @@ Export::Export (void) :
button_box(Gtk::BUTTONBOX_END),
export_label(_("_Export"), 1),
export_image(Gtk::StockID(Gtk::Stock::APPLY), Gtk::ICON_SIZE_BUTTON),
+ prog_dlg(NULL),
+ interrupted(false),
prefs(NULL),
desktop(NULL),
deskTrack(),
@@ -164,27 +166,27 @@ Export::Export (void) :
t->set_col_spacings (4);
x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
- GTK_WIDGET(t->gobj()), 0, 0, _("_x0:"), NULL, EXPORT_COORD_PRECISION, 1,
+ t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1,
&Export::onAreaX0Change);
x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
- GTK_WIDGET(t->gobj()), 2, 0, _("x_1:"), NULL, EXPORT_COORD_PRECISION, 1,
+ t, 2, 0, _("x_1:"), "", EXPORT_COORD_PRECISION, 1,
&Export::onAreaX1Change);
width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
- unit_selector->gobj(), GTK_WIDGET(t->gobj()), 4, 0, _("Wid_th:"), NULL, EXPORT_COORD_PRECISION, 1,
+ unit_selector->gobj(), t, 4, 0, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1,
&Export::onAreaWidthChange);
y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
- GTK_WIDGET(t->gobj()), 0, 1, _("_y0:"), NULL, EXPORT_COORD_PRECISION, 1,
+ t, 0, 1, _("_y0:"), "", EXPORT_COORD_PRECISION, 1,
&Export::onAreaY0Change);
y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
- GTK_WIDGET(t->gobj()), 2, 1, _("y_1:"), NULL, EXPORT_COORD_PRECISION, 1,
+ t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1,
&Export::onAreaY1Change);
height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
- unit_selector->gobj(), GTK_WIDGET(t->gobj()), 4, 1, _("Hei_ght:"), NULL, EXPORT_COORD_PRECISION, 1,
+ unit_selector->gobj(), t, 4, 1, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1,
&Export::onAreaHeightChange);
area_box.pack_start(togglebox, false, false, 3);
@@ -213,18 +215,18 @@ Export::Export (void) :
size_box.pack_start(*t);
bmwidth_adj = createSpinbutton ( "bmwidth", 16.0, 1.0, 1000000.0, 1.0, 10.0,
- NULL, GTK_WIDGET(t->gobj()), 0, 0,
+ NULL, t, 0, 0,
_("_Width:"), _("pixels at"), 0, 1,
&Export::onBitmapWidthChange);
xdpi_adj = createSpinbutton ( "xdpi",
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,
+ 0.01, 100000.0, 0.1, 1.0, NULL, t, 3, 0,
+ "", _("dp_i"), 2, 1,
&Export::onExportXdpiChange);
bmheight_adj = createSpinbutton ( "bmheight", 16.0, 1.0, 1000000.0, 1.0, 10.0,
- NULL, GTK_WIDGET(t->gobj()), 0, 1,
+ NULL, t, 0, 1,
_("_Height:"), _("pixels at"), 0, 1,
&Export::onBitmapHeightChange);
@@ -232,8 +234,8 @@ Export::Export (void) :
* There's no way to set ydpi currently, so we use the defaultxdpi value here, too...
*/
ydpi_adj = createSpinbutton ( "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 );
+ 0.01, 100000.0, 0.1, 1.0, NULL, t, 3, 1,
+ "", _("dpi"), 2, 0, NULL );
singleexport_box.pack_start(size_box);
}
@@ -262,7 +264,7 @@ Export::Export (void) :
file_box.add(filename_box);
- original_name = g_strdup(filename_entry.get_text().c_str());
+ original_name = filename_entry.get_text();
// focus is in the filename initially:
filename_entry.grab_focus();
@@ -317,10 +319,6 @@ Export::Export (void) :
Export::~Export (void)
{
- g_free(original_name);
- original_name = NULL;
- g_free(doc_export_name);
- doc_export_name = NULL;
was_empty = TRUE;
selectModifiedConn.disconnect();
@@ -353,7 +351,6 @@ void Export::setTargetDesktop(SPDesktop *desktop)
//// Must check flags, so can't call widget_setup() directly.
selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &Export::onSelectionModified)));
}
- //widget_setup();
}
}
@@ -406,77 +403,49 @@ void Export::set_default_filename () {
g_free(name);
}
- doc_export_name = g_strdup(filename_entry.get_text().c_str());
+ doc_export_name = filename_entry.get_text();
}
}
-/**
- * Creates a new spin button for the export dialog.
- * @param key The name of the spin button
- * @param val A default value for the spin button
- * @param min Minimum value for the spin button
- * @param max Maximum value for the spin button
- * @param step The step size for the spin button
- * @param page Size of the page increment
- * @param us Unit selector that effects this spin button
- * @param t Table to put the spin button in
- * @param x X location in the table \c t to start with
- * @param y Y location in the table \c t to start with
- * @param ll Text to put on the left side of the spin button (optional)
- * @param lr Text to put on the right side of the spin button (optional)
- * @param digits Number of digits to display after the decimal
- * @param sensitive Whether the spin button is sensitive or not
- * @param cb Callback for when this spin button is changed (optional)
- */
Gtk::Adjustment * Export::createSpinbutton( 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,
+ Gtk::Table *t, int x, int y,
+ const Glib::ustring ll, const Glib::ustring lr,
int digits, unsigned int sensitive,
void (Export::*cb)() )
{
Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 );
-
if (us) {
- sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us),
- GTK_ADJUSTMENT (adj->gobj()) );
+ sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us), GTK_ADJUSTMENT (adj->gobj()) );
}
int pos = 0;
+ Gtk::Label *l = NULL;
- GtkWidget *l = NULL;
-
- if (ll) {
-
- l = gtk_label_new_with_mnemonic ((const gchar *)ll);
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
- gtk_table_attach ( GTK_TABLE (t), l, x + pos, x + pos + 1, y, y + 1,
- (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0 );
- gtk_widget_set_sensitive (l, sensitive);
- pos += 1;
-
+ if (!ll.empty()) {
+ l = new Gtk::Label(ll,true);
+ l->set_alignment (1.0, 0.5);
+ t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
+ l->set_sensitive(sensitive);
+ pos++;
}
- GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (adj->gobj()), 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_widget_set_sensitive (sb, sensitive);
- pos += 1;
+ Gtk::SpinButton *sb = new Gtk::SpinButton(*adj, 1.0, digits);
+ t->attach (*sb, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
+ sb->set_size_request (80, -1);
+ sb->set_sensitive (sensitive);
+ pos++;
- if (ll) { gtk_label_set_mnemonic_widget (GTK_LABEL(l), sb); }
+ if (!ll.empty()) { l->set_mnemonic_widget(*sb);}
- if (lr) {
-
- l = gtk_label_new_with_mnemonic ((const gchar *)lr);
- gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
- gtk_table_attach ( GTK_TABLE (t), l, x + pos, x + pos + 1, y, y + 1,
- (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0 );
- gtk_widget_set_sensitive (l, sensitive);
- pos += 1;
-
- gtk_label_set_mnemonic_widget (GTK_LABEL(l), sb);
+ if (!lr.empty()) {
+ l = new Gtk::Label(lr,true);
+ l->set_alignment (0.0, 0.5);
+ t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
+ l->set_sensitive (sensitive);
+ pos++;
+ l->set_mnemonic_widget (*sb);
}
if (cb) {
@@ -487,40 +456,36 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl
} // end of createSpinbutton()
-gchar* Export::create_filepath_from_id (const gchar *id, const gchar *file_entry_text) {
-
- if (id == NULL) /* This should never happen */
+Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ustring &file_entry_text)
+{
+ if (id.empty())
+ { /* This should never happen */
id = "bitmap";
+ }
- gchar *directory = NULL;
+ Glib::ustring directory;
- if (directory == NULL && file_entry_text != NULL && file_entry_text[0] != '\0') {
- // std::cout << "Directory from dialog" << std::endl;
- directory = g_path_get_dirname(file_entry_text);
+ if (!file_entry_text.empty()) {
+ directory = Glib::path_get_dirname(file_entry_text);
}
- if (directory == NULL) {
+ if (directory.empty()) {
/* Grab document directory */
- if ( SP_ACTIVE_DOCUMENT->getURI() ) {
- // std::cout << "Directory from document" << std::endl;
- directory = g_path_get_dirname( SP_ACTIVE_DOCUMENT->getURI() );
+ const gchar* docURI = SP_ACTIVE_DOCUMENT->getURI();
+ if (docURI) {
+ directory = Glib::path_get_dirname(docURI);
}
}
- if (directory == NULL) {
- // std::cout << "Home Directory" << std::endl;
+ if (directory.empty()) {
directory = homedir_path(NULL);
}
- gchar * id_ext = g_strconcat(id, ".png", NULL);
- gchar *filename = g_build_filename(directory, id_ext, NULL);
- g_free(directory);
- g_free(id_ext);
+ Glib::ustring filename = Glib::build_filename(directory, id+".png");
return filename;
}
-void
-Export::onBatchClicked ()
+void Export::onBatchClicked ()
{
if (batch_export.get_active()) {
singleexport_box.set_sensitive(false);
@@ -546,8 +511,7 @@ void Export::updateCheckbuttons ()
}
}
-inline void
-Export::findDefaultSelection()
+inline void Export::findDefaultSelection()
{
selection_type key = SELECTION_NUMBER_OF;
@@ -609,6 +573,7 @@ void Export::onSelectionChanged()
void Export::onSelectionModified ( guint /*flags*/ )
{
+ Inkscape::Selection * Sel;
switch (current_key) {
case SELECTION_DRAWING:
if ( SP_ACTIVE_DESKTOP ) {
@@ -624,12 +589,16 @@ void Export::onSelectionModified ( guint /*flags*/ )
}
break;
case SELECTION_SELECTION:
- if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->visualBounds();
- setArea ( bbox->left(),
+ Sel = sp_desktop_selection(SP_ACTIVE_DESKTOP);
+ if (Sel->isEmpty() == false) {
+ Geom::OptRect bbox = Sel->visualBounds();
+ if (bbox)
+ {
+ setArea ( bbox->left(),
bbox->top(),
bbox->right(),
bbox->bottom());
+ }
}
break;
default:
@@ -717,20 +686,18 @@ void Export::onAreaToggled ()
if (SP_ACTIVE_DESKTOP && !filename_modified) {
- const gchar * filename = NULL;
+ Glib::ustring filename;
float xdpi = 0.0, ydpi = 0.0;
switch (key) {
case SELECTION_PAGE:
case SELECTION_DRAWING: {
SPDocument * doc = SP_ACTIVE_DOCUMENT;
- sp_document_get_export_hints (doc, &filename, &xdpi, &ydpi);
+ sp_document_get_export_hints (doc, filename, &xdpi, &ydpi);
- if (filename == NULL) {
- if (doc_export_name != NULL) {
- filename = g_strdup(doc_export_name);
- } else {
- filename = g_strdup("");
+ if (filename.empty()) {
+ if (!doc_export_name.empty()) {
+ filename = doc_export_name;
}
}
break;
@@ -738,11 +705,11 @@ void Export::onAreaToggled ()
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- sp_selection_get_export_hints (sp_desktop_selection(SP_ACTIVE_DESKTOP), &filename, &xdpi, &ydpi);
+ sp_selection_get_export_hints (sp_desktop_selection(SP_ACTIVE_DESKTOP), filename, &xdpi, &ydpi);
/* If we still don't have a filename -- let's build
one that's nice */
- if (filename == NULL) {
+ if (filename.empty()) {
const gchar * id = NULL;
const GSList * reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList();
for(; reprlst != NULL; reprlst = reprlst->next) {
@@ -753,7 +720,7 @@ void Export::onAreaToggled ()
}
}
- filename = create_filepath_from_id (id, filename_entry.get_text().c_str());
+ filename = create_filepath_from_id (id, filename_entry.get_text());
}
}
break;
@@ -762,9 +729,8 @@ void Export::onAreaToggled ()
break;
}
- if (filename != NULL) {
- g_free(original_name);
- original_name = g_strdup(filename);
+ if (!filename.empty()) {
+ original_name = filename;
filename_entry.set_text(filename);
}
@@ -784,75 +750,61 @@ void Export::onAreaToggled ()
} // end of sp_export_area_toggled()
/// Called when dialog is deleted
-
-gint Export::onProgressDelete ( GtkWidget * /*widget*/, GdkEvent * /*event*/, GObject *base )
+bool Export::onProgressDelete (GdkEventAny * /*event*/)
{
- g_object_set_data (base, "cancel", (gpointer) 1);
+ interrupted = true;
return TRUE;
} // end of sp_export_progress_delete()
/// Called when progress is cancelled
-void Export::onProgressCancel ( GtkWidget * /*widget*/, GObject *base )
+void Export::onProgressCancel ()
{
- g_object_set_data (base, "cancel", (gpointer) 1);
+ interrupted = true;
} // end of sp_export_progress_cancel()
/// Called for every progress iteration
-unsigned int Export::onProgressCallback (float value, void *data)
+unsigned int Export::onProgressCallback (float value, void *dlg)
{
- GtkWidget *prg;
- int evtcount;
-
- if (g_object_get_data ((GObject *) data, "cancel"))
+ Gtk::Dialog *dlg2 = reinterpret_cast<Gtk::Dialog*>(dlg);
+ if (dlg2->get_data("cancel")){
return FALSE;
+ }
- prg = (GtkWidget *) g_object_get_data ((GObject *) data, "progress");
- gtk_progress_bar_set_fraction ((GtkProgressBar *) prg, value);
+ Gtk::ProgressBar *prg = (Gtk::ProgressBar *) dlg2->get_data ("progress");
+ prg->set_fraction(value);
- evtcount = 0;
+ int evtcount = 0;
while ((evtcount < 16) && gdk_events_pending ()) {
gtk_main_iteration_do (FALSE);
evtcount += 1;
}
gtk_main_iteration_do (FALSE);
-
return TRUE;
-
} // end of sp_export_progress_callback()
-GtkWidget * Export::create_progress_dialog (Glib::ustring progress_text) {
- GtkWidget *dlg, *prg, *btn; /* progressbar dlg widgets */
-
- dlg = gtk_dialog_new ();
-
- GtkObject *base = GTK_OBJECT(dlg);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Export in progress"));
- prg = gtk_progress_bar_new ();
- //sp_transientize (dlg);
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- g_object_set_data ((GObject *) base, "progress", prg);
-
- gtk_progress_bar_set_text ((GtkProgressBar *) prg, progress_text.c_str());
+Gtk::Dialog * Export::create_progress_dialog (Glib::ustring progress_text) {
+ Gtk::Dialog *dlg = new Gtk::Dialog(_("Export in progress"), TRUE);
+
+ Gtk::ProgressBar *prg = new Gtk::ProgressBar ();
+ prg->set_text(progress_text);
+ prg->set_orientation(Gtk::PROGRESS_LEFT_TO_RIGHT);
+ dlg->set_data ("progress", prg);
+#if GTK_CHECK_VERSION(3,0,0)
+ Gtk::Box* CA = dlg->get_content_area();
+#else
+ Gtk::Box* CA = dlg->get_vbox();
+#endif
+ CA->pack_start(*prg, FALSE, FALSE, 4);
- gtk_progress_bar_set_orientation ( (GtkProgressBar *) prg,
- GTK_PROGRESS_LEFT_TO_RIGHT);
- gtk_box_pack_start ((GtkBox *) gtk_dialog_get_content_area((GtkDialog *) dlg),
- prg, FALSE, FALSE, 4 );
- btn = gtk_dialog_add_button ( GTK_DIALOG (dlg),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL );
+ Gtk::Button* btn = dlg->add_button (Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
- g_signal_connect ( (GObject *) dlg, "delete_event",
- (GCallback) onProgressDelete, base);
- g_signal_connect ( (GObject *) btn, "clicked",
- (GCallback) onProgressCancel, base);
- gtk_window_set_modal ((GtkWindow *) dlg, TRUE);
- gtk_widget_show_all (dlg);
+ btn->signal_clicked().connect( sigc::mem_fun(*this, &Export::onProgressCancel) );
+ dlg->signal_delete_event().connect( sigc::mem_fun(*this, &Export::onProgressDelete) );
+ dlg->show_all ();
return dlg;
}
@@ -879,19 +831,18 @@ Glib::ustring Export::filename_add_extension (Glib::ustring filename, Glib::ustr
}
}
-gchar *Export::absolutize_path_from_document_location (SPDocument *doc, const gchar *filename)
+Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, const Glib::ustring &filename)
{
- gchar *path = 0;
+ Glib::ustring path;
//Make relative paths go from the document location, if possible:
- if (!g_path_is_absolute(filename) && doc->getURI()) {
- gchar *dirname = g_path_get_dirname(doc->getURI());
- if (dirname) {
- path = g_build_filename(dirname, filename, NULL);
- g_free(dirname);
+ if (!Glib::path_is_absolute(filename) && doc->getURI()) {
+ Glib::ustring dirname = Glib::path_get_dirname(doc->getURI());
+ if (!dirname.empty()) {
+ path = Glib::build_filename(dirname, filename);
}
}
- if (!path) {
- path = g_strdup(filename);
+ if (path.empty()) {
+ path = filename;
}
return path;
}
@@ -914,18 +865,22 @@ void Export::onExport ()
if (num < 1)
return;
- GtkWidget *prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 files"),num));
+ prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 files"),num));
for (GSList *i = const_cast<GSList *>(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList());
- i != NULL;
- i = i->next) {
+ i != NULL;
+ i = i->next) {
+ if (interrupted){
+ break;
+ }
SPItem *item = reinterpret_cast<SPItem *>(i->data);
// retrieve export filename hint
const gchar *filename = item->getRepr()->attribute("inkscape:export-filename");
- gchar *path = NULL;
+ Glib::ustring path;
if (!filename) {
- path = create_filepath_from_id(item->getId(), NULL);
+ Glib::ustring tmp;
+ path = create_filepath_from_id(item->getId(), tmp);
} else {
path = absolutize_path_from_document_location(doc, filename);
}
@@ -947,14 +902,14 @@ void Export::onExport ()
if (width > 1 && height > 1) {
/* Do export */
- if (!sp_export_png_file (doc, path,
+ if (!sp_export_png_file (doc, path.c_str(),
*area, width, height, dpi, dpi,
nv->pagecolor,
NULL, NULL, TRUE, // overwrite without asking
hide ? const_cast<GSList *>(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()) : NULL
)) {
gchar * error;
- gchar * safeFile = Inkscape::IO::sanitizeString(path);
+ gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str());
error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
sp_ui_error_dialog(error);
g_free(safeFile);
@@ -963,148 +918,96 @@ void Export::onExport ()
}
}
n++;
- g_free(path);
onProgressCallback((float)n/num, prog_dlg);
}
- gtk_widget_destroy (prog_dlg);
- //g_object_set_data (G_OBJECT (base), "cancel", (gpointer) 0);
+ delete prog_dlg;
+ prog_dlg = NULL;
+ interrupted = false;
} else {
+ Glib::ustring filename = filename_entry.get_text();
- Glib::ustring filename = filename_entry.get_text();
+ if (filename.empty()){
+ sp_ui_error_dialog(_("You have to enter a filename"));
+ return;
+ }
+
+ float const x0 = getValuePx(x0_adj);
+ float const y0 = getValuePx(y0_adj);
+ float const x1 = getValuePx(x1_adj);
+ float const y1 = getValuePx(y1_adj);
+ float const xdpi = getValue(xdpi_adj);
+ float const ydpi = getValue(ydpi_adj);
+ unsigned long int const width = int(getValue(bmwidth_adj) + 0.5);
+ unsigned long int const height = int(getValue(bmheight_adj) + 0.5);
+
+ if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) {
+ sp_ui_error_dialog (_("The chosen area to be exported is invalid"));
+ return;
+ }
- if (filename.empty()){
- sp_ui_error_dialog(_("You have to enter a filename"));
- return;
- }
-
- float const x0 = getValuePx(x0_adj);
- float const y0 = getValuePx(y0_adj);
- float const x1 = getValuePx(x1_adj);
- float const y1 = getValuePx(y1_adj);
- float const xdpi = getValue(xdpi_adj);
- float const ydpi = getValue(ydpi_adj);
- unsigned long int const width = int(getValue(bmwidth_adj) + 0.5);
- unsigned long int const height = int(getValue(bmheight_adj) + 0.5);
-
- if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) {
- sp_ui_error_dialog (_("The chosen area to be exported is invalid"));
- return;
- }
+ // make sure that .png is the extension of the file:
+ Glib::ustring const filename_ext = filename_add_extension(filename, "png");
+ filename_entry.set_text(filename_ext);
+ Glib::ustring path = absolutize_path_from_document_location(doc, filename_ext);
- // make sure that .png is the extension of the file:
- Glib::ustring const filename_ext = filename_add_extension(filename, "png");
- filename_entry.set_text(filename_ext);
- gchar *path = absolutize_path_from_document_location(doc, filename_ext.c_str());
+ Glib::ustring dirname = Glib::path_get_dirname(path);
+ if ( dirname.empty()
+ || !Inkscape::IO::file_test(dirname.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) )
+ {
+ gchar *safeDir = Inkscape::IO::sanitizeString(dirname.c_str());
+ gchar *error = g_strdup_printf(_("Directory %s does not exist or is not a directory.\n"),
+ safeDir);
+ sp_ui_error_dialog(error);
+ g_free(safeDir);
+ g_free(error);
+ return;
+ }
- gchar *dirname = g_path_get_dirname(path);
- if ( dirname == NULL
- || !Inkscape::IO::file_test(dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) )
- {
- gchar *safeDir = Inkscape::IO::sanitizeString(dirname);
- gchar *error = g_strdup_printf(_("Directory %s does not exist or is not a directory.\n"),
- safeDir);
- sp_ui_error_dialog(error);
- g_free(safeDir);
- g_free(error);
- g_free(dirname);
- g_free(path);
- return;
- }
- g_free(dirname);
-
- gchar *fn = g_path_get_basename (path);
- GtkWidget *prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 (%2 x %3)"), fn, width, height));
- g_free (fn);
-
-
- /* Do export */
- if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), path,
- Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
- nv->pagecolor,
- onProgressCallback, prog_dlg, FALSE,
- hide ? const_cast<GSList *>(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()) : NULL
- )) {
- gchar * error;
- gchar * safeFile = Inkscape::IO::sanitizeString(path);
- error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
- sp_ui_error_dialog(error);
- g_free(safeFile);
- g_free(error);
- }
+ Glib::ustring fn = path_get_basename (path);
+
+ prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 (%2 x %3)"), fn, width, height));
+
+ /* Do export */
+ if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), path.c_str(),
+ Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
+ nv->pagecolor,
+ onProgressCallback, (void*)prog_dlg, FALSE,
+ hide ? const_cast<GSList *>(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()) : NULL
+ )) {
+ gchar * error;
+ gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str());
+ error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
+ sp_ui_error_dialog(error);
+ g_free(safeFile);
+ g_free(error);
+ }
- /* Reset the filename so that it can be changed again by changing
- selections and all that */
- g_free(original_name);
- original_name = const_cast<gchar*>(filename_ext.c_str());
- filename_modified = false;
+ /* Reset the filename so that it can be changed again by changing
+ selections and all that */
+ original_name = filename_ext;
+ filename_modified = false;
- gtk_widget_destroy (prog_dlg);
- //g_object_set_data (G_OBJECT (base), "cancel", (gpointer) 0);
+ delete prog_dlg;
+ prog_dlg = NULL;
+ interrupted = false;
+ /* Setup the values in the document */
+ switch (current_key) {
+ case SELECTION_PAGE:
+ case SELECTION_DRAWING: {
+ SPDocument * doc = SP_ACTIVE_DOCUMENT;
+ Inkscape::XML::Node * repr = doc->getReprRoot();
+ bool modified = false;
- /* Setup the values in the document */
- switch (current_key) {
- case SELECTION_PAGE:
- case SELECTION_DRAWING: {
- SPDocument * doc = SP_ACTIVE_DOCUMENT;
- Inkscape::XML::Node * repr = doc->getReprRoot();
- bool modified = false;
-
- bool saved = DocumentUndo::getUndoSensitive(doc);
- DocumentUndo::setUndoSensitive(doc, false);
-
- gchar const *temp_string = repr->attribute("inkscape:export-filename");
- if (temp_string == NULL || (filename_ext != temp_string)) {
- repr->setAttribute("inkscape:export-filename", filename_ext.c_str());
- modified = true;
- }
- temp_string = repr->attribute("inkscape:export-xdpi");
- if (temp_string == NULL || xdpi != atof(temp_string)) {
- sp_repr_set_svg_double(repr, "inkscape:export-xdpi", xdpi);
- modified = true;
- }
- temp_string = repr->attribute("inkscape:export-ydpi");
- if (temp_string == NULL || ydpi != atof(temp_string)) {
- sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
- modified = true;
- }
- DocumentUndo::setUndoSensitive(doc, saved);
+ bool saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
- if (modified) {
- doc->setModifiedSinceSave();
- }
- break;
- }
- case SELECTION_SELECTION: {
- const GSList * reprlst;
- SPDocument * doc = SP_ACTIVE_DOCUMENT;
- bool modified = false;
-
- bool saved = DocumentUndo::getUndoSensitive(doc);
- DocumentUndo::setUndoSensitive(doc, false);
- reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList();
-
- for(; reprlst != NULL; reprlst = reprlst->next) {
- Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data);
- const gchar * temp_string;
- Glib::ustring dir = Glib::path_get_dirname(filename.c_str());
- const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI();
- Glib::ustring docdir;
- if (docURI)
- {
- docdir = Glib::path_get_dirname(docURI);
- }
- if (repr->attribute("id") == NULL ||
- !(filename_ext.find_last_of(repr->attribute("id")) &&
- ( !docURI ||
- (dir == docdir)))) {
- temp_string = repr->attribute("inkscape:export-filename");
- if (temp_string == NULL || (filename_ext != temp_string)) {
- repr->setAttribute("inkscape:export-filename", filename_ext.c_str());
- modified = true;
- }
+ gchar const *temp_string = repr->attribute("inkscape:export-filename");
+ if (temp_string == NULL || (filename_ext != temp_string)) {
+ repr->setAttribute("inkscape:export-filename", filename_ext.c_str());
+ modified = true;
}
temp_string = repr->attribute("inkscape:export-xdpi");
if (temp_string == NULL || xdpi != atof(temp_string)) {
@@ -1116,18 +1019,63 @@ void Export::onExport ()
sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
modified = true;
}
+ DocumentUndo::setUndoSensitive(doc, saved);
+
+ if (modified) {
+ doc->setModifiedSinceSave();
+ }
+ break;
}
- DocumentUndo::setUndoSensitive(doc, saved);
+ case SELECTION_SELECTION: {
+ const GSList * reprlst;
+ SPDocument * doc = SP_ACTIVE_DOCUMENT;
+ bool modified = false;
+
+ bool saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
+ reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList();
+
+ for(; reprlst != NULL; reprlst = reprlst->next) {
+ Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data);
+ const gchar * temp_string;
+ Glib::ustring dir = Glib::path_get_dirname(filename.c_str());
+ const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI();
+ Glib::ustring docdir;
+ if (docURI)
+ {
+ docdir = Glib::path_get_dirname(docURI);
+ }
+ if (repr->attribute("id") == NULL ||
+ !(filename_ext.find_last_of(repr->attribute("id")) &&
+ ( !docURI ||
+ (dir == docdir)))) {
+ temp_string = repr->attribute("inkscape:export-filename");
+ if (temp_string == NULL || (filename_ext != temp_string)) {
+ repr->setAttribute("inkscape:export-filename", filename_ext.c_str());
+ modified = true;
+ }
+ }
+ temp_string = repr->attribute("inkscape:export-xdpi");
+ if (temp_string == NULL || xdpi != atof(temp_string)) {
+ sp_repr_set_svg_double(repr, "inkscape:export-xdpi", xdpi);
+ modified = true;
+ }
+ temp_string = repr->attribute("inkscape:export-ydpi");
+ if (temp_string == NULL || ydpi != atof(temp_string)) {
+ sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
+ modified = true;
+ }
+ }
+ DocumentUndo::setUndoSensitive(doc, saved);
- if (modified) {
- doc->setModifiedSinceSave();
+ if (modified) {
+ doc->setModifiedSinceSave();
+ }
+ break;
}
- break;
+ default:
+ break;
}
- default:
- break;
- }
- g_free (path);
}
} // end of sp_export_export_clicked()
@@ -1137,7 +1085,7 @@ void Export::onExport ()
void Export::onBrowse ()
{
GtkWidget *fs;
- const gchar *filename;
+ Glib::ustring filename;
fs = gtk_file_chooser_dialog_new (_("Select a filename for exporting"),
(GtkWindow*)desktop->getToplevel(),
@@ -1156,13 +1104,14 @@ void Export::onBrowse ()
gtk_window_set_modal(GTK_WINDOW (fs), true);
- filename = filename_entry.get_text().c_str();
+ filename = filename_entry.get_text();
- if (*filename == '\0') {
- filename = create_filepath_from_id(NULL, NULL);
+ if (filename.empty()) {
+ Glib::ustring tmp;
+ filename = create_filepath_from_id(tmp, tmp);
}
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs), filename);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs), filename.c_str());
#ifdef WIN32
// code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp
@@ -1177,7 +1126,7 @@ void Export::onBrowse ()
// 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);
+ gunichar2* utf16_path_string = g_utf8_to_utf16(filename.c_str(), -1, NULL, NULL, NULL);
wcsncpy(_filename, (wchar_t*)utf16_path_string, _MAX_PATH);
g_free(utf16_path_string);
@@ -1792,7 +1741,7 @@ float Export::getValuePx( Gtk::Adjustment *adj )
*/
void Export::onFilenameModified()
{
- if (strcmp(original_name, filename_entry.get_text().c_str())==0) {
+ if (original_name == filename_entry.get_text()) {
filename_modified = false;
} else {
filename_modified = true;
diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h
index 51b969b5e..eaab04762 100644
--- a/src/ui/dialog/export.h
+++ b/src/ui/dialog/export.h
@@ -96,15 +96,33 @@ private:
*/
void setValue (Gtk::Adjustment *adj, double val);
void setValuePx (Gtk::Adjustment *adj, double val);
- float getValue ( Gtk::Adjustment *adj );
- float getValuePx ( Gtk::Adjustment *adj );
- /*
- * Helper function to create, style and pack spinbuttons
+ float getValue (Gtk::Adjustment *adj);
+ float getValuePx (Gtk::Adjustment *adj);
+
+ /**
+ * Helper function to create, style and pack spinbuttons for the export dialog.
+ *
+ * Creates a new spin button for the export dialog.
+ * @param key The name of the spin button
+ * @param val A default value for the spin button
+ * @param min Minimum value for the spin button
+ * @param max Maximum value for the spin button
+ * @param step The step size for the spin button
+ * @param page Size of the page increment
+ * @param us Unit selector that effects this spin button
+ * @param t Table to put the spin button in
+ * @param x X location in the table \c t to start with
+ * @param y Y location in the table \c t to start with
+ * @param ll Text to put on the left side of the spin button (optional)
+ * @param lr Text to put on the right side of the spin button (optional)
+ * @param digits Number of digits to display after the decimal
+ * @param sensitive Whether the spin button is sensitive or not
+ * @param cb Callback for when this spin button is changed (optional)
*/
Gtk::Adjustment * createSpinbutton( 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,
+ Gtk::Table *t, int x, int y,
+ const Glib::ustring ll, const Glib::ustring lr,
int digits, unsigned int sensitive,
void (Export::*cb)() );
/**
@@ -188,20 +206,34 @@ private:
void setTargetDesktop(SPDesktop *desktop);
/**
- * Progress dialog callbacks
+ * Creates progress dialog for batch exporting.
+ *
+ * @param progress_text Text to be shown in the progress bar
+ */
+ Gtk::Dialog * create_progress_dialog (Glib::ustring progress_text);
+ /**
+ * Callback to be used in for loop to update the progress bar.
+ *
+ * @param value number between 0 and 1 indicating the fraction of progress (0.17 = 17 % progress)
+ * @param dlg void pointer to the Gtk::Dialog progress dialog
*/
- GtkWidget * create_progress_dialog (Glib::ustring progress_text);
- static unsigned int onProgressCallback (float value, void *data);
- static void onProgressCancel ( GtkWidget *widget, GObject *base );
- static gint onProgressDelete ( GtkWidget *widget, GdkEvent *event, GObject *base );
+ static unsigned int onProgressCallback (float value, void *dlg);
+ /**
+ * Callback for pressing the cancel button.
+ */
+ void onProgressCancel ();
+ /**
+ * Callback invoked on closing the progress dialog.
+ */
+ bool onProgressDelete (GdkEventAny *event);
/*
- * Utlitiy filename and path functions
+ * Utility filename and path functions
*/
void set_default_filename ();
- gchar* create_filepath_from_id (const gchar *id, const gchar *file_entry_text);
+ Glib::ustring create_filepath_from_id (Glib::ustring id, const Glib::ustring &file_entry_text);
Glib::ustring filename_add_extension (Glib::ustring filename, Glib::ustring extension);
- gchar *absolutize_path_from_document_location (SPDocument *doc, const gchar *filename);
+ Glib::ustring absolutize_path_from_document_location (SPDocument *doc, const Glib::ustring &filename);
/*
* Currently selected export area type
@@ -210,8 +242,8 @@ private:
/*
* Original name for the export object
*/
- gchar * original_name;
- gchar * doc_export_name;
+ Glib::ustring original_name;
+ Glib::ustring doc_export_name;
/*
* Was the Original name modified
*/
@@ -273,6 +305,9 @@ private:
Gtk::Label export_label;
Gtk::Image export_image;
+ Gtk::Dialog *prog_dlg;
+ bool interrupted; // indicates whether export needs to be interrupted (read: user pressed cancel in the progress dialog)
+
Inkscape::Preferences *prefs;
SPDesktop *desktop;
DesktopTracker deskTrack;
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 5fd6e18d8..641acd3f3 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -72,10 +72,10 @@ Find::Find()
check_scope_selection(_("S_election"), _("Limit search to the current selection")),
check_searchin_text(_("Te_xt"), _("Search in text objects")),
check_searchin_property(_("_Properties"), _("Search in object properties, styles, attributes and IDs")),
+ vbox_searchin(0, false),
frame_searchin(_("Search in")),
frame_scope(_("Scope")),
-
check_case_sensitive(_("Case sensiti_ve"), _("Match upper/lower case"), false),
check_exact_match(_("E_xact match"), _("Match whole objects only"), false),
check_include_hidden(_("Include _hidden"), _("Include hidden objects in search"), false),
@@ -120,8 +120,8 @@ Find::Find()
Gtk::RadioButtonGroup grp_searchin = check_searchin_text.get_group();
check_searchin_property.set_group(grp_searchin);
- vbox_searchin.pack_start(check_searchin_text, true, true);
- vbox_searchin.pack_start(check_searchin_property, true, true);
+ vbox_searchin.pack_start(check_searchin_text, false, false);
+ vbox_searchin.pack_start(check_searchin_property, false, false);
frame_searchin.add(vbox_searchin);
Gtk::RadioButtonGroup grp_scope = check_scope_all.get_group();
diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h
index 62ecd1763..64fb4cc3d 100644
--- a/src/ui/dialog/find.h
+++ b/src/ui/dialog/find.h
@@ -15,6 +15,7 @@
#include "ui/widget/panel.h"
#include "ui/widget/button.h"
#include "ui/widget/entry.h"
+#include "ui/widget/frame.h"
#include <glib.h>
#include <gtkmm.h>
@@ -198,78 +199,78 @@ private:
/*
* Find and replace combo box widgets
*/
- Inkscape::UI::Widget::Entry entry_find;
- Inkscape::UI::Widget::Entry entry_replace;
+ UI::Widget::Entry entry_find;
+ UI::Widget::Entry entry_replace;
/**
* Scope and search in widgets
*/
- Inkscape::UI::Widget::RadioButton check_scope_all;
- Inkscape::UI::Widget::RadioButton check_scope_layer;
- Inkscape::UI::Widget::RadioButton check_scope_selection;
- Inkscape::UI::Widget::RadioButton check_searchin_text;
- Inkscape::UI::Widget::RadioButton check_searchin_property;
+ UI::Widget::RadioButton check_scope_all;
+ UI::Widget::RadioButton check_scope_layer;
+ UI::Widget::RadioButton check_scope_selection;
+ UI::Widget::RadioButton check_searchin_text;
+ UI::Widget::RadioButton check_searchin_property;
Gtk::HBox hbox_searchin;
Gtk::VBox vbox_scope;
Gtk::VBox vbox_searchin;
- Gtk::Frame frame_searchin;
- Gtk::Frame frame_scope;
+ UI::Widget::Frame frame_searchin;
+ UI::Widget::Frame frame_scope;
/**
* General option widgets
*/
- Inkscape::UI::Widget::CheckButton check_case_sensitive;
- Inkscape::UI::Widget::CheckButton check_exact_match;
- Inkscape::UI::Widget::CheckButton check_include_hidden;
- Inkscape::UI::Widget::CheckButton check_include_locked;
+ UI::Widget::CheckButton check_case_sensitive;
+ UI::Widget::CheckButton check_exact_match;
+ UI::Widget::CheckButton check_include_hidden;
+ UI::Widget::CheckButton check_include_locked;
Gtk::VBox vbox_options1;
Gtk::VBox vbox_options2;
Gtk::HBox hbox_options;
Gtk::VBox vbox_expander;
Gtk::Expander expander_options;
- Gtk::Frame frame_options;
+ UI::Widget::Frame frame_options;
/**
* Property type widgets
*/
- Inkscape::UI::Widget::CheckButton check_ids;
- Inkscape::UI::Widget::CheckButton check_attributename;
- Inkscape::UI::Widget::CheckButton check_attributevalue;
- Inkscape::UI::Widget::CheckButton check_style;
- Inkscape::UI::Widget::CheckButton check_font;
+ UI::Widget::CheckButton check_ids;
+ UI::Widget::CheckButton check_attributename;
+ UI::Widget::CheckButton check_attributevalue;
+ UI::Widget::CheckButton check_style;
+ UI::Widget::CheckButton check_font;
Gtk::VBox vbox_properties;
Gtk::HBox hbox_properties1;
Gtk::HBox hbox_properties2;
- Gtk::Frame frame_properties;
+ UI::Widget::Frame frame_properties;
/**
* A vector of all the properties widgets for easy processing
*/
- std::vector<Inkscape::UI::Widget::CheckButton *> checkProperties;
+ std::vector<UI::Widget::CheckButton *> checkProperties;
/**
* Object type widgets
*/
- Inkscape::UI::Widget::CheckButton check_alltypes;
- Inkscape::UI::Widget::CheckButton check_rects;
- Inkscape::UI::Widget::CheckButton check_ellipses;
- Inkscape::UI::Widget::CheckButton check_stars;
- Inkscape::UI::Widget::CheckButton check_spirals;
- Inkscape::UI::Widget::CheckButton check_paths;
- Inkscape::UI::Widget::CheckButton check_texts;
- Inkscape::UI::Widget::CheckButton check_groups;
- Inkscape::UI::Widget::CheckButton check_clones;
- Inkscape::UI::Widget::CheckButton check_images;
- Inkscape::UI::Widget::CheckButton check_offsets;
+ UI::Widget::CheckButton check_alltypes;
+ UI::Widget::CheckButton check_rects;
+ UI::Widget::CheckButton check_ellipses;
+ UI::Widget::CheckButton check_stars;
+ UI::Widget::CheckButton check_spirals;
+ UI::Widget::CheckButton check_paths;
+ UI::Widget::CheckButton check_texts;
+ UI::Widget::CheckButton check_groups;
+ UI::Widget::CheckButton check_clones;
+ UI::Widget::CheckButton check_images;
+ UI::Widget::CheckButton check_offsets;
Gtk::VBox vbox_types1;
Gtk::VBox vbox_types2;
Gtk::HBox hbox_types;
- Gtk::Frame frame_types;
+ UI::Widget::Frame frame_types;
/**
* A vector of all the check option widgets for easy processing
*/
- std::vector<Inkscape::UI::Widget::CheckButton *> checkTypes;
+ std::vector<UI::Widget::CheckButton *> checkTypes;
//Gtk::HBox hbox_text;
@@ -277,8 +278,8 @@ private:
* Action Buttons and status
*/
Gtk::Label status;
- Inkscape::UI::Widget::Button button_find;
- Inkscape::UI::Widget::Button button_replace;
+ UI::Widget::Button button_find;
+ UI::Widget::Button button_replace;
Gtk::HButtonBox box_buttons;
Gtk::HBox hboxbutton_row;
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index 19cdea9bc..de213ca85 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -25,6 +25,7 @@
#include <gtkmm/checkbutton.h>
#include <gtkmm/frame.h>
#include <gtkmm/stock.h>
+#include "ui/widget/frame.h"
#include "desktop.h"
#include "desktop-handles.h"
@@ -160,7 +161,7 @@ IconPreviewPanel::IconPreviewPanel() :
Gtk::VBox* magBox = new Gtk::VBox();
- Gtk::Frame *magFrame = Gtk::manage(new Gtk::Frame(_("Magnified:")));
+ UI::Widget::Frame *magFrame = Gtk::manage(new UI::Widget::Frame(_("Magnified:")));
magFrame->add( magnified );
magBox->pack_start( *magFrame, Gtk::PACK_EXPAND_WIDGET );
@@ -229,7 +230,7 @@ IconPreviewPanel::IconPreviewPanel() :
iconBox.pack_start(splitter);
splitter.pack1( *magBox, true, true );
- Gtk::Frame *actuals = Gtk::manage(new Gtk::Frame(_("Actual Size:")));
+ UI::Widget::Frame *actuals = Gtk::manage(new UI::Widget::Frame (_("Actual Size:")));
actuals->add(*verts);
splitter.pack2( *actuals, false, false );
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index b038ae60d..719e42f16 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -851,10 +851,10 @@ void InkscapePreferences::initPageIO()
Glib::ustring intentLabels[numIntents] = {_("Perceptual"), _("Relative Colorimetric"), _("Saturation"), _("Absolute Colorimetric")};
int intentValues[numIntents] = {0, 1, 2, 3};
-#if !defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+#if !defined(HAVE_LIBLCMS1) && !defined(HAVE_LIBLCMS2)
Gtk::Label* lbl = new Gtk::Label(_("(Note: Color management has been disabled in this build)"));
_page_cms.add_line( false, "", *lbl, "", "", true);
-#endif // !defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+#endif // !defined(HAVE_LIBLCMS1) && !defined(HAVE_LIBLCMS2)
_page_cms.add_group_header( _("Display adjustment"));
@@ -913,6 +913,8 @@ void InkscapePreferences::initPageIO()
_("Enables black point compensation"), false);
_cms_proof_preserveblack.init( _("Preserve black"), "/options/softproof/preserveblack", false);
+
+#if !defined(HAVE_LIBLCMS2)
_page_cms.add_line( true, "", _cms_proof_preserveblack,
#if defined(cmsFLAGS_PRESERVEBLACK)
"",
@@ -920,6 +922,7 @@ void InkscapePreferences::initPageIO()
_("(LittleCMS 1.15 or later required)"),
#endif // defined(cmsFLAGS_PRESERVEBLACK)
_("Preserve K channel in CMYK -> CMYK transforms"), false);
+#endif // !defined(HAVE_LIBLCMS2)
#if !defined(cmsFLAGS_PRESERVEBLACK)
_cms_proof_preserveblack.set_sensitive( false );
@@ -1495,7 +1498,7 @@ void InkscapePreferences::initPageSystem()
_sys_icon_scroll.add(_sys_icon);
_sys_icon_scroll.set_size_request(0, 80);
_sys_icon_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- _page_system.add_line(true, _("Icon theme: "), _sys_icon_scroll, "", _("Location of icon themes"), true);
+ _page_system.add_line(true, _("Icon theme: "), _sys_icon_scroll, "", _("Locations of icon themes"), true);
this->AddPage(_page_system, _("System"), PREFS_PAGE_SYSTEM);
}
diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp
index 1e60d7f8a..eb2ddb88f 100644
--- a/src/ui/dialog/input.cpp
+++ b/src/ui/dialog/input.cpp
@@ -13,6 +13,8 @@
#include <set>
#include <list>
#include "ui/widget/panel.h"
+#include "ui/widget/frame.h"
+
#include <glib/gprintf.h>
#include <glibmm/i18n.h>
#include <gtkmm/alignment.h>
@@ -426,8 +428,8 @@ private:
Glib::RefPtr<Gtk::TreeStore> store;
Gtk::TreeIter tabletIter;
Gtk::TreeView tree;
- Gtk::Frame frame2;
- Gtk::Frame testFrame;
+ Inkscape::UI::Widget::Frame detailFrame;
+ Inkscape::UI::Widget::Frame testFrame;
Gtk::ScrolledWindow treeScroller;
Gtk::ScrolledWindow detailScroller;
Gtk::HPaned splitter;
@@ -527,7 +529,7 @@ InputDialogImpl::InputDialogImpl() :
store(Gtk::TreeStore::create(getCols())),
tabletIter(),
tree(store),
- frame2(),
+ detailFrame(),
testFrame(_("Test Area")),
treeScroller(),
detailScroller(),
@@ -544,10 +546,11 @@ InputDialogImpl::InputDialogImpl() :
treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ treeScroller.set_shadow_type(Gtk::SHADOW_IN);
treeScroller.add(tree);
treeScroller.set_size_request(50, 0);
split2.pack1(testFrame, false, false);
- split2.pack2(frame2, true, true);
+ split2.pack2(detailFrame, true, true);
splitter.pack1(treeScroller);
splitter.pack2(split2);
@@ -591,7 +594,7 @@ InputDialogImpl::InputDialogImpl() :
int rowNum = 0;
- Gtk::Label* lbl = Gtk::manage(new Gtk::Label(_("Name:")));
+/* Gtk::Label* lbl = Gtk::manage(new Gtk::Label(_("Name:")));
devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
@@ -599,9 +602,9 @@ InputDialogImpl::InputDialogImpl() :
::Gtk::SHRINK,
::Gtk::SHRINK);
- rowNum++;
+ rowNum++;*/
- lbl = Gtk::manage(new Gtk::Label(_("Link:")));
+ Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:")));
devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
@@ -700,9 +703,11 @@ InputDialogImpl::InputDialogImpl() :
devDetails.set_sensitive(false);
detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ detailScroller.set_shadow_type(Gtk::SHADOW_NONE);
+ detailScroller.set_border_width (0);
detailScroller.add(devDetails);
- frame2.add(detailScroller);
- frame2.set_size_request(0, 60);
+ detailFrame.add(detailScroller);
+ detailFrame.set_size_request(0, 60);
//- 16x16/devices
// gnome-dev-mouse-optical
@@ -1307,6 +1312,7 @@ void InputDialogImpl::resyncToSelection() {
clear = false;
devName.set_label(row[getCols().description]);
+ detailFrame.set_label(row[getCols().description]);
setupValueAndCombo( dev->getNumAxes(), dev->getNumAxes(), devAxesCount, axesCombo);
setupValueAndCombo( dev->getNumKeys(), dev->getNumKeys(), devKeyCount, buttonCombo);
}
@@ -1314,6 +1320,7 @@ void InputDialogImpl::resyncToSelection() {
devDetails.set_sensitive(!clear);
if (clear) {
+ detailFrame.set_label("");
devName.set_label("");
devAxesCount.set_label("");
devKeyCount.set_label("");
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 1f252c089..5b9f72453 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -84,7 +84,6 @@ LivePathEffectEditor::LivePathEffectEditor()
effectwidget(NULL),
status_label("", Gtk::ALIGN_CENTER),
effectcontrol_frame(""),
- effectlist_frame(_("Effect list")),
button_add(),
button_remove(),
button_up(),
diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h
index beebbc698..20b0a673d 100644
--- a/src/ui/dialog/livepatheffect-editor.h
+++ b/src/ui/dialog/livepatheffect-editor.h
@@ -16,6 +16,7 @@
#include <gtkmm/label.h>
#include <gtkmm/frame.h>
#include "ui/widget/combo-enums.h"
+#include "ui/widget/frame.h"
#include "live_effects/effect-enum.h"
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>
@@ -89,8 +90,7 @@ private:
Gtk::Widget * effectwidget;
Gtk::Label status_label;
- Gtk::Frame effectcontrol_frame;
- Gtk::Frame effectlist_frame;
+ UI::Widget::Frame effectcontrol_frame;
Gtk::HBox effectapplication_hbox;
Gtk::VBox effectcontrol_vbox;
Gtk::VBox effectlist_vbox;
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 13d80e301..23c0f72ee 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -43,6 +43,7 @@ ObjectProperties::ObjectProperties (void) :
LabelLabel(_("_Label:"), 1),
LabelTitle(_("_Title:"),1),
LabelDescription(_("_Description"),1),
+ FrameDescription("", FALSE),
HBoxCheck(FALSE, 0),
CheckTable(1, 2, TRUE),
CBHide(_("_Hide"), 1),
@@ -145,6 +146,8 @@ void ObjectProperties::MakeWidget(void)
/* Create the frame for the object description */
FrameDescription.set_label_widget (LabelDescription);
+ FrameDescription.set_padding (4,0,0,0);
+
TopTable.attach (FrameDescription, 0, 3, 3, 4,
Gtk::EXPAND | Gtk::FILL,
Gtk::EXPAND | Gtk::FILL, 0, 0 );
diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h
index d8d74cdb3..d9d1a3fdd 100644
--- a/src/ui/dialog/object-properties.h
+++ b/src/ui/dialog/object-properties.h
@@ -14,6 +14,7 @@
#define SEEN_DIALOGS_ITEM_PROPERTIES_H
#include "ui/widget/panel.h"
+#include "ui/widget/frame.h"
#include <gtkmm/entry.h>
#include <gtkmm/expander.h>
#include <gtkmm/frame.h>
@@ -61,8 +62,8 @@ private:
Gtk::Entry EntryTitle; //the entry for the object title
Gtk::Label LabelDescription; //the label for the object description
- Gtk::Frame FrameDescription; //the frame for the object description
- Gtk::Frame FrameTextDescription; //the frame for the text of the object description
+ UI::Widget::Frame FrameDescription; //the frame for the object description
+ Gtk::Frame FrameTextDescription; //the frame for the text of the object description
Gtk::TextView TextViewDescription; //the text view object showing the object description
Gtk::HBox HBoxCheck; // the HBox for the check boxes
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index 4c9245f5c..9dccb9c85 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -879,9 +879,11 @@ void SearchResultList::populate_from_xml(xmlNode * a_node)
guint row_num = 0;
for (xmlNode *cur_node = a_node; cur_node; cur_node = cur_node->next) {
+
// Get items information
if (strcmp((const char*)cur_node->name, "rss")) // Avoid the root
- if (cur_node->type == XML_ELEMENT_NODE && !strcmp((const char*)cur_node->parent->name, "item"))
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ (cur_node->parent->name && !strcmp((const char*)cur_node->parent->name, "item")))
{
if (!strcmp((const char*)cur_node->name, "title"))
{
@@ -1055,7 +1057,7 @@ void ImportDialog::on_xml_file_read(const Glib::RefPtr<Gio::AsyncResult>& result
list_results->populate_from_xml(root_element);
// Populate the MARKUP column with the title & description of the clipart
- for (guint i = 0; i <= list_results->size() - 1; i++) {
+ for (guint i = 0; i < list_results->size(); i++) {
Glib::ustring title = list_results->get_text(i, RESULTS_COLUMN_TITLE);
Glib::ustring description = list_results->get_text(i, RESULTS_COLUMN_DESCRIPTION);
char* markup = g_markup_printf_escaped("<b>%s</b>\n<span size=\"small\">%s</span>",
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index b09096e63..791b49af9 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -64,7 +64,7 @@ namespace Dialog {
TextEdit::TextEdit()
: UI::Widget::Panel("", "/dialogs/textandfont", SP_VERB_DIALOG_TEXT),
font_label(_("_Font"), true),
- layout_frame(_("Layout")),
+ layout_frame(),
text_label(_("_Text"), true),
setasdefault_button(_("Set as _default")),
close_button(Gtk::Stock::CLOSE),
@@ -134,6 +134,7 @@ This conditional and its #else block can be deleted in the future.
gtk_widget_set_tooltip_text (px, _("Spacing between lines (percent of font size)"));
gtk_widget_set_tooltip_text (spacing_combo, _("Spacing between lines (percent of font size)"));
layout_hbox.pack_start(*Gtk::manage(Glib::wrap(spacing_combo)), false, false);
+ layout_frame.set_padding(4,4,4,4);
layout_frame.add(layout_hbox);
/* Font preview */
diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h
index e750677c8..9fd9baa30 100644
--- a/src/ui/dialog/text-edit.h
+++ b/src/ui/dialog/text-edit.h
@@ -25,6 +25,7 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/separator.h>
#include "ui/widget/panel.h"
+#include "ui/widget/frame.h"
#include "ui/dialog/desktop-tracker.h"
class SPItem;
@@ -165,7 +166,7 @@ private:
Gtk::HBox fontsel_hbox;
SPFontSelector *fsel;
- Gtk::Frame layout_frame;
+ Gtk::Alignment layout_frame;
Gtk::HBox layout_hbox;
Gtk::RadioButton align_left;
Gtk::RadioButton align_center;
diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp
index 2751a9953..a6495c205 100644
--- a/src/ui/dialog/tracedialog.cpp
+++ b/src/ui/dialog/tracedialog.cpp
@@ -19,6 +19,7 @@
#include <gtkmm/notebook.h>
#include <gtkmm/frame.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
#include <gtkmm/stock.h>
#include <gtk/gtk.h> //for GTK_RESPONSE* types
@@ -105,14 +106,14 @@ class TraceDialogImpl : public TraceDialog
//# Single scan mode
//brightness
- Gtk::Frame modeBrightnessFrame;
+ UI::Widget::Frame modeBrightnessFrame;
Gtk::VBox modeBrightnessVBox;
Gtk::HBox modeBrightnessBox;
Gtk::RadioButton modeBrightnessRadioButton;
Gtk::Label modeBrightnessSpinnerLabel;
Inkscape::UI::Widget::SpinButton modeBrightnessSpinner;
//edge detection
- Gtk::Frame modeCannyFrame;
+ UI::Widget::Frame modeCannyFrame;
Gtk::HBox modeCannyBox;
Gtk::VBox modeCannyVBox;
Gtk::RadioButton modeCannyRadioButton;
@@ -122,7 +123,7 @@ class TraceDialogImpl : public TraceDialog
Gtk::Label modeCannyHiSpinnerLabel;
Inkscape::UI::Widget::SpinButton modeCannyHiSpinner;
//quantization
- Gtk::Frame modeQuantFrame;
+ UI::Widget::Frame modeQuantFrame;
Gtk::HBox modeQuantBox;
Gtk::VBox modeQuantVBox;
Gtk::RadioButton modeQuantRadioButton;
@@ -133,7 +134,7 @@ class TraceDialogImpl : public TraceDialog
Gtk::HBox modeInvertBox;
//# Multiple path scanning mode
- Gtk::Frame modeMultiScanFrame;
+ UI::Widget::Frame modeMultiScanFrame;
Gtk::VBox modeMultiScanVBox;
//brightness
Gtk::HBox modeMultiScanHBox1;
@@ -158,7 +159,7 @@ class TraceDialogImpl : public TraceDialog
// potrace parameters
- Gtk::Frame optionsFrame;
+ UI::Widget::Frame optionsFrame;
Gtk::VBox optionsVBox;
Gtk::HBox optionsSpecklesBox;
Gtk::CheckButton optionsSpecklesButton;
@@ -190,7 +191,7 @@ class TraceDialogImpl : public TraceDialog
//#### Preview
- Gtk::Frame previewFrame;
+ UI::Widget::Frame previewFrame;
Gtk::VBox previewVBox;
Gtk::Button previewButton;
Gtk::Image previewImage;
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index d8f1a21a9..cce7da103 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -207,7 +207,12 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation )
Gtk::VBox::on_size_allocate( allocation );
if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
- Gtk::Requisition req = _insides->size_request();
+ Gtk::Requisition req;
+#if WITH_GTKMM_3_0
+ _insides->get_preferred_size(&req, NULL);
+#else
+ req = _insides->size_request();
+#endif
gint delta = allocation.get_width() - req.width;
if ( (delta > 4) && req.height < allocation.get_height() ) {
@@ -233,7 +238,12 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
height = 1;
if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) {
- Gtk::Requisition req = _scroller->size_request();
+ Gtk::Requisition req;
+#if WITH_GTKMM_3_0
+ _scroller->get_preferred_size(&req, NULL);
+#else
+ req = _scroller->size_request();
+#endif
int currW = _scroller->get_width();
if ( currW > req.width ) {
req.width = currW;
@@ -241,13 +251,23 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
Gtk::HScrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
if ( hs ) {
- Gtk::Requisition scrollReq = hs->size_request();
+ Gtk::Requisition scrollReq;
+#if WITH_GTKMM_3_0
+ hs->get_preferred_size(&req, NULL);
+#else
+ req = hs->size_request();
+#endif
// the +8 is a temporary hack
req.height -= scrollReq.height + 8;
}
- Gtk::Requisition req2 = const_cast<Gtk::Widget*>(thing)->size_request();
+ Gtk::Requisition req2;
+#if WITH_GTKMM_3_0
+ const_cast<Gtk::Widget*>(thing)->get_preferred_size(&req2, NULL);
+#else
+ req2 = const_cast<Gtk::Widget*>(thing)->size_request();
+#endif
int h2 = ((req2.height > 0) && (req.height > req2.height)) ? (req.height / req2.height) : 1;
int w2 = ((req2.width > 0) && (req.width > req2.width)) ? (req.width / req2.width) : 1;
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert
index 718d95979..f36ffbf56 100644
--- a/src/ui/widget/Makefile_insert
+++ b/src/ui/widget/Makefile_insert
@@ -21,6 +21,8 @@ ink_common_sources += \
ui/widget/entry.h \
ui/widget/filter-effect-chooser.h \
ui/widget/filter-effect-chooser.cpp \
+ ui/widget/frame.cpp \
+ ui/widget/frame.h \
ui/widget/handlebox.cpp \
ui/widget/handlebox.h \
ui/widget/icon-widget.cpp \
diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp
new file mode 100644
index 000000000..b2968f806
--- /dev/null
+++ b/src/ui/widget/frame.cpp
@@ -0,0 +1,83 @@
+/*
+ * Authors:
+ * Murray C
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "frame.h"
+
+
+// Inkscape::UI::Widget::Frame
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+Frame::Frame(Glib::ustring const &label_text /*= ""*/, gboolean label_bold /*= TRUE*/ )
+ : _label(label_text, 1.0, 0.5, TRUE),
+ _alignment()
+{
+ set_shadow_type(Gtk::SHADOW_NONE);
+
+ //Put an indented GtkAlignment inside the frame.
+ //Further children should be children of this GtkAlignment:
+ Gtk::Frame::add(_alignment);
+ set_padding(4, 0, 8, 0);
+
+ set_label_widget(_label);
+ set_label(label_text, label_bold);
+
+ show_all_children();
+}
+
+void
+Frame::add(Widget& widget)
+{
+ _alignment.add(widget);
+}
+
+void
+Frame::set_label(const Glib::ustring &label_text, gboolean label_bold /*= TRUE*/)
+{
+ if (label_bold) {
+ _label.set_markup(Glib::ustring("<b>") + label_text + "</b>");
+ } else {
+ _label.set_text(label_text);
+ }
+}
+
+void
+Frame::set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right)
+{
+#if WITH_GTKMM_2_24
+ _alignment.set_padding(padding_top, padding_bottom, padding_left, padding_right);
+#endif
+}
+
+Gtk::Label const *
+Frame::get_label_widget() const
+{
+ return &_label;
+}
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/frame.h b/src/ui/widget/frame.h
new file mode 100644
index 000000000..cf736d8a1
--- /dev/null
+++ b/src/ui/widget/frame.h
@@ -0,0 +1,79 @@
+/*
+ * Authors:
+ * Murray C
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_FRAME_H
+#define INKSCAPE_UI_WIDGET_FRAME_H
+
+#include <gtkmm.h>
+
+namespace Gtk {
+class Frame;
+}
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * Creates a Gnome HIG style indented frame with bold label
+ * See http://developer.gnome.org/hig-book/stable/controls-frames.html.en
+ */
+class Frame : public Gtk::Frame
+{
+public:
+
+ /**
+ * Construct a Frame Widget.
+ *
+ * @param label The frame text.
+ */
+ Frame(Glib::ustring const &label = "", gboolean label_bold = TRUE);
+
+ /**
+ * Return the label widget
+ */
+ Gtk::Label const *get_label_widget() const;
+
+ /**
+ * Add a widget to this frame
+ */
+ virtual void add(Widget& widget);
+
+ /**
+ * Set the frame label text and if bold or not
+ */
+ void set_label(const Glib::ustring &label, gboolean label_bold = TRUE);
+
+ /**
+ * Set the frame padding
+ */
+ void set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right);
+
+protected:
+ Gtk::Label _label;
+ Gtk::Alignment _alignment;
+
+};
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_FRAME_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index c81385dd7..d26005317 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -1157,7 +1157,7 @@ void SelectedStyle::on_opacity_changed () {
_("Change opacity"));
// resume interruptibility
sp_desktop_canvas(_desktop)->endForcedFullRedraws();
- spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj()));
+ spinbutton_defocus(GTK_WIDGET(_opacity_sb.gobj()));
_opacity_blocked = false;
}
diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp
index 99891fc44..a11bd2d74 100644
--- a/src/ui/widget/toolbox.cpp
+++ b/src/ui/widget/toolbox.cpp
@@ -12,6 +12,7 @@
#endif
#include <gtkmm/radioaction.h>
+#include <gtkmm/orientable.h>
#include <gtk/gtk.h>
#include "ui/widget/toolbox.h"
#include "path-prefix.h"
@@ -97,7 +98,9 @@ Toolbox::init_actions()
void
Toolbox::init_orientation(Gtk::Orientation const &orientation)
{
- static_cast<Gtk::Toolbar*>(_widget)->set_orientation(orientation);
+ gtk_orientable_set_orientation(GTK_ORIENTABLE(static_cast<Gtk::Toolbar*>(_widget)->gobj()),
+ GtkOrientation(orientation));
+
if (orientation == Gtk::ORIENTATION_VERTICAL) {
set_handle_position(Gtk::POS_TOP);
}
@@ -226,7 +229,8 @@ Toolbox::on_change_orient_horiz()
{
Glib::RefPtr<Gtk::RadioAction> action = Glib::RefPtr<Gtk::RadioAction>::cast_static(_detach_grp->get_action("OrientHoriz"));
if (action->get_active()) {
- static_cast<Gtk::Toolbar*>(_widget)->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
+ gtk_orientable_set_orientation(GTK_ORIENTABLE(static_cast<Gtk::Toolbar*>(_widget)->gobj()),
+ GTK_ORIENTATION_HORIZONTAL);
}
}
@@ -235,7 +239,8 @@ Toolbox::on_change_orient_vert()
{
Glib::RefPtr<Gtk::RadioAction> action = Glib::RefPtr<Gtk::RadioAction>::cast_static(_detach_grp->get_action("OrientVert"));
if (action->get_active()) {
- static_cast<Gtk::Toolbar*>(_widget)->set_orientation(Gtk::ORIENTATION_VERTICAL);
+ gtk_orientable_set_orientation(GTK_ORIENTABLE(static_cast<Gtk::Toolbar*>(_widget)->gobj()),
+ GTK_ORIENTATION_VERTICAL);
}
}
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index 676cb9b59..0071fc56e 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -30,6 +30,17 @@ static void sp_button_init (SPButton *button);
static void sp_button_destroy (GtkObject *object);
static void sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition);
+
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_button_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sp_button_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static void sp_button_clicked (GtkButton *button);
static void sp_button_perform_action (SPButton *button, gpointer data);
static gint sp_button_process_event (SPButton *button, GdkEvent *event);
@@ -72,7 +83,12 @@ sp_button_class_init (SPButtonClass *klass)
parent_class = (GtkToggleButtonClass *)g_type_class_peek_parent (klass);
object_class->destroy = sp_button_destroy;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = sp_button_get_preferred_width;
+ widget_class->get_preferred_height = sp_button_get_preferred_height;
+#else
widget_class->size_request = sp_button_size_request;
+#endif
button_class->clicked = sp_button_clicked;
}
@@ -129,6 +145,22 @@ sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition)
requisition->height += 2 + 2 * MAX (2, style->ythickness);
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sp_button_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sp_button_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
static void
sp_button_clicked (GtkButton *button)
{
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 44d3c2f9a..996f116e2 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -1741,7 +1741,7 @@ sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data)
desktop->zoom_absolute (d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor);
g_signal_handler_unblock (spin, dtw->zoom_update);
- spinbutton_defocus (GTK_OBJECT (spin));
+ spinbutton_defocus (GTK_WIDGET(spin));
}
static void
diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp
index 134cf9342..db9cb96bd 100644
--- a/src/widgets/eek-preview.cpp
+++ b/src/widgets/eek-preview.cpp
@@ -177,6 +177,22 @@ static void eek_preview_size_request( GtkWidget* widget, GtkRequisition* req )
req->height = height;
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void eek_preview_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ eek_preview_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void eek_preview_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ eek_preview_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
enum {
CLICKED_SIGNAL,
ALTCLICKED_SIGNAL,
@@ -578,7 +594,12 @@ static void eek_preview_class_init( EekPreviewClass *klass )
/*widgetClass->unmap = ;*/
/*widgetClass->realize = ;*/
/*widgetClass->unrealize = ;*/
+#if GTK_CHECK_VERSION(3,0,0)
+ widgetClass->get_preferred_width = eek_preview_get_preferred_width;
+ widgetClass->get_preferred_height = eek_preview_get_preferred_height;
+#else
widgetClass->size_request = eek_preview_size_request;
+#endif
/*widgetClass->size_allocate = ;*/
/*widgetClass->state_changed = ;*/
/*widgetClass->style_set = ;*/
diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp
index b835dc36b..114d76293 100644
--- a/src/widgets/gradient-image.cpp
+++ b/src/widgets/gradient-image.cpp
@@ -28,6 +28,17 @@ static void sp_gradient_image_init (SPGradientImage *image);
static void sp_gradient_image_destroy (GtkObject *object);
static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition);
+
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_gradient_image_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sp_gradient_image_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static gint sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event);
static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im);
@@ -69,7 +80,12 @@ sp_gradient_image_class_init (SPGradientImageClass *klass)
object_class->destroy = sp_gradient_image_destroy;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = sp_gradient_image_get_preferred_width;
+ widget_class->get_preferred_height = sp_gradient_image_get_preferred_height;
+#else
widget_class->size_request = sp_gradient_image_size_request;
+#endif
widget_class->expose_event = sp_gradient_image_expose;
}
@@ -110,6 +126,22 @@ static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisitio
requisition->height = 12;
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_gradient_image_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sp_gradient_image_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void sp_gradient_image_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sp_gradient_image_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
static gint
sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event)
{
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index e239457fd..a7b97c21a 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -636,6 +636,20 @@ gr_remove_stop (GtkWidget */*button*/, GtkWidget *vb)
}
static void
+gr_linked_changed (GtkToggleAction *act, gpointer data)
+{
+ gboolean active = gtk_toggle_action_get_active( act );
+ if ( active ) {
+ g_object_set( G_OBJECT(act), "iconId", INKSCAPE_ICON("object-locked"), NULL );
+ } else {
+ g_object_set( G_OBJECT(act), "iconId", INKSCAPE_ICON("object-unlocked"), NULL );
+ }
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/options/forkgradientvectors/value", !active);
+}
+
+static void
gr_reverse (GtkWidget */*button*/, gpointer data)
{
SPDesktop *desktop = static_cast<SPDesktop *>(data);
@@ -1264,6 +1278,22 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
}
+ // Gradients Linked toggle
+ {
+ InkToggleAction* itact = ink_toggle_action_new( "GradientEditLinkAction",
+ _("Link gradients"),
+ _("Link gradients to change all related gradients"),
+ INKSCAPE_ICON("object-unlocked"),
+ secondarySize );
+ g_object_set( itact, "short_label", "Lock", NULL );
+ g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(gr_linked_changed), desktop) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool linkedmode = prefs->getBool("/options/forkgradientvectors/value", true);
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), !linkedmode );
+ }
+
Inkscape::Selection *selection = sp_desktop_selection (desktop);
SPDocument *document = sp_desktop_document (desktop);
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 7f027870d..a58645015 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -61,6 +61,15 @@ struct IconImpl {
static void clear(SPIcon *icon);
static void sizeRequest(GtkWidget *widget, GtkRequisition *requisition);
+
+ static void getPreferredWidth(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+ static void getPreferredHeight(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+
static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
static int expose(GtkWidget *widget, GdkEventExpose *event);
@@ -172,7 +181,12 @@ void IconImpl::classInit(SPIconClass *klass)
object_class->dispose = IconImpl::dispose;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = IconImpl::getPreferredWidth;
+ widget_class->get_preferred_height = IconImpl::getPreferredHeight;
+#else
widget_class->size_request = IconImpl::sizeRequest;
+#endif
widget_class->size_allocate = IconImpl::sizeAllocate;
widget_class->expose_event = IconImpl::expose;
widget_class->screen_changed = IconImpl::screenChanged;
@@ -225,6 +239,20 @@ void IconImpl::sizeRequest(GtkWidget *widget, GtkRequisition *requisition)
requisition->height = size;
}
+void IconImpl::getPreferredWidth(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sizeRequest(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+void IconImpl::getPreferredHeight(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sizeRequest(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+
void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
{
gtk_widget_set_allocation(widget, allocation);
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 3f34c8ad1..075308321 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -445,9 +445,9 @@ void SPPaintSelector::setColorAlpha(SPColor const &color, float alpha)
{
g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) );
SPColorSelector *csel = 0;
+/*
guint32 rgba = 0;
-/*
if ( sp_color_get_colorspace_type(color) == SP_COLORSPACE_TYPE_CMYK )
{
#ifdef SP_PS_VERBOSE
@@ -465,7 +465,7 @@ void SPPaintSelector::setColorAlpha(SPColor const &color, float alpha)
}
csel = reinterpret_cast<SPColorSelector*>(g_object_get_data(G_OBJECT(selector), "color-selector"));
- rgba = color.toRGBA32( alpha );
+ //rgba = color.toRGBA32( alpha );
csel->base->setColorAlpha( color, alpha );
}
@@ -572,21 +572,6 @@ sp_paint_selector_clear_frame(SPPaintSelector *psel)
if (psel->selector) {
- /* before we destroy the frame contents, we must detach
- * the patternmenu so that Gtk doesn't gtk_widget_destroy
- * all the children of the menu. (We also have a g_object_ref
- * count set on it too so that the gtk_container_remove doesn't
- * end up destroying it.
- */
- GtkWidget *patterns = (GtkWidget *)g_object_get_data(G_OBJECT(psel), "patternmenu");
- if (patterns != NULL) {
- GtkWidget * parent = gtk_widget_get_parent( GTK_WIDGET(patterns));
- if ( parent != NULL ) {
- g_assert( GTK_IS_CONTAINER(parent) );
- gtk_container_remove( GTK_CONTAINER(parent), patterns );
- }
- }
-
gtk_widget_destroy(psel->selector);
psel->selector = NULL;
}
@@ -829,53 +814,42 @@ ink_pattern_list_get (SPDocument *source)
* Adds menu items for pattern list - derived from marker code, left hb etc in to make addition of previews easier at some point.
*/
static void
-sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source*/)
+sp_pattern_menu_build (GtkWidget *combo, GSList *pattern_list, SPDocument */*source*/)
{
+ GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo)));
+ GtkTreeIter iter;
for (; pattern_list != NULL; pattern_list = pattern_list->next) {
+
Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(pattern_list->data)->getRepr();
- GtkWidget *i = gtk_menu_item_new();
- gtk_widget_show(i);
- if (repr->attribute("inkscape:stockid"))
- g_object_set_data (G_OBJECT(i), "stockid", (void *) "true");
- else
- g_object_set_data (G_OBJECT(i), "stockid", (void *) "false");
+ // label for combobox
+ gchar const *label;
+ if (repr->attribute("inkscape:stockid")) {
+ label = _(repr->attribute("inkscape:stockid"));
+ } else {
+ label = _(repr->attribute("id"));
+ }
gchar const *patid = repr->attribute("id");
- g_object_set_data (G_OBJECT(i), "pattern", (void *) patid);
-
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, 4);
-#endif
- gtk_widget_show(hb);
-
- // create label
- GtkWidget *l;
- if (repr->attribute("inkscape:stockid"))
- l = gtk_label_new(_(repr->attribute("inkscape:stockid")));
- else
- l = gtk_label_new(_(repr->attribute("id")));
- gtk_widget_show(l);
- gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.5);
- gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, 0);
+ gboolean stockid = false;
+ if (repr->attribute("inkscape:stockid")) {
+ stockid = true;
+ }
- gtk_widget_show(hb);
- gtk_container_add(GTK_CONTAINER(i), hb);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ COMBO_COL_LABEL, label, COMBO_COL_STOCK, stockid, COMBO_COL_PATTERN, patid, COMBO_COL_SEP, FALSE, -1);
- gtk_menu_shell_append(GTK_MENU_SHELL(m), i);
- }
- }
+ }
+}
/**
* Pick up all patterns from source, except those that are in
* current_doc (if non-NULL), and add items to the pattern menu.
*/
-static void sp_pattern_list_from_doc(GtkWidget *m, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*pattern_doc*/)
+static void sp_pattern_list_from_doc(GtkWidget *combo, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*pattern_doc*/)
{
GSList *pl = ink_pattern_list_get(source);
GSList *clean_pl = NULL;
@@ -889,17 +863,15 @@ static void sp_pattern_list_from_doc(GtkWidget *m, SPDocument * /*current_doc*/,
clean_pl = g_slist_prepend (clean_pl, pl->data);
}
- sp_pattern_menu_build (m, clean_pl, source);
+ sp_pattern_menu_build (combo, clean_pl, source);
g_slist_free (pl);
g_slist_free (clean_pl);
}
-
-
static void
-ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
+ink_pattern_menu_populate_menu(GtkWidget *combo, SPDocument *doc)
{
static SPDocument *patterns_doc = NULL;
@@ -913,51 +885,59 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
}
// suck in from current doc
- sp_pattern_list_from_doc ( m, NULL, doc, patterns_doc );
+ sp_pattern_list_from_doc ( combo, NULL, doc, patterns_doc );
// add separator
{
- GtkWidget *i = gtk_separator_menu_item_new();
- gchar const *patid = "";
- g_object_set_data (G_OBJECT(i), "pattern", (void *) patid);
- gtk_widget_show(i);
- gtk_menu_shell_append(GTK_MENU_SHELL(m), i);
+ GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo)));
+ GtkTreeIter iter;
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set(store, &iter,
+ COMBO_COL_LABEL, "", COMBO_COL_STOCK, false, COMBO_COL_PATTERN, "", COMBO_COL_SEP, true, -1);
}
// suck in from patterns.svg
if (patterns_doc) {
doc->ensureUpToDate();
- sp_pattern_list_from_doc ( m, doc, patterns_doc, NULL );
+ sp_pattern_list_from_doc ( combo, doc, patterns_doc, NULL );
}
}
static GtkWidget*
-ink_pattern_menu(GtkWidget *mnu)
+ink_pattern_menu(GtkWidget *combo)
{
- /* Create new menu widget */
- GtkWidget *m = gtk_menu_new();
- gtk_widget_show(m);
SPDocument *doc = SP_ACTIVE_DOCUMENT;
+ GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo)));
+ GtkTreeIter iter;
+
if (!doc) {
- GtkWidget *i;
- i = gtk_menu_item_new_with_label(_("No document selected"));
- gtk_widget_show(i);
- gtk_menu_shell_append(GTK_MENU_SHELL(m), i);
- gtk_widget_set_sensitive(mnu, FALSE);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COMBO_COL_LABEL, _("No document selected"), COMBO_COL_STOCK, false, COMBO_COL_PATTERN, "", COMBO_COL_SEP, false, -1);
+ gtk_widget_set_sensitive(combo, FALSE);
+
} else {
- ink_pattern_menu_populate_menu(m, doc);
- gtk_widget_set_sensitive(mnu, TRUE);
+ ink_pattern_menu_populate_menu(combo, doc);
+ gtk_widget_set_sensitive(combo, TRUE);
}
- gtk_option_menu_set_menu(GTK_OPTION_MENU(mnu), m);
- /* Set history */
- gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), 0);
- return mnu;
+ // Select the first item that is not a seperator
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), &iter)) {
+ gboolean sep = false;
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, COMBO_COL_SEP, &sep, -1);
+ if (sep) {
+ gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
+ }
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
+ }
+
+ return combo;
}
@@ -967,43 +947,41 @@ void SPPaintSelector::updatePatternList( SPPattern *pattern )
if (update) {
return;
}
- GtkWidget *mnu = GTK_WIDGET(g_object_get_data(G_OBJECT(this), "patternmenu"));
- g_assert( mnu != NULL );
+ GtkWidget *combo = GTK_WIDGET(g_object_get_data(G_OBJECT(this), "patternmenu"));
+ g_assert( combo != NULL );
/* Clear existing menu if any */
- gtk_option_menu_remove_menu(GTK_OPTION_MENU(mnu));
+ GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+ gtk_list_store_clear(GTK_LIST_STORE(store));
- ink_pattern_menu(mnu);
+ ink_pattern_menu(combo);
/* Set history */
- if (pattern && !g_object_get_data(G_OBJECT(mnu), "update")) {
-
- g_object_set_data(G_OBJECT(mnu), "update", GINT_TO_POINTER(TRUE));
+ if (pattern && !g_object_get_data(G_OBJECT(combo), "update")) {
+ g_object_set_data(G_OBJECT(combo), "update", GINT_TO_POINTER(TRUE));
gchar const *patname = pattern->getRepr()->attribute("id");
- GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(mnu)));
-
- GList *kids = gtk_container_get_children(GTK_CONTAINER(m));
-
- int patpos = 0;
- int i = 0;
-
- for (; kids != NULL; kids = kids->next) {
-
- gchar *men_pat = (gchar *) g_object_get_data(G_OBJECT(kids->data), "pattern");
- if ( strcmp(men_pat, patname) == 0 ) {
- patpos = i;
- }
- i++;
+ // Find this pattern and set it active in the combo_box
+ GtkTreeIter iter ;
+ gchar *patid = NULL;
+ bool valid = gtk_tree_model_get_iter_first (store, &iter);
+ if (!valid) {
+ return;
+ }
+ gtk_tree_model_get (store, &iter, COMBO_COL_PATTERN, &patid, -1);
+ while (valid && strcmp(patid, patname) != 0) {
+ valid = gtk_tree_model_iter_next (store, &iter);
+ gtk_tree_model_get (store, &iter, COMBO_COL_PATTERN, &patid, -1);
}
+ if (valid) {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
+ }
- gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), patpos);
- g_object_set_data(G_OBJECT(mnu), "update", GINT_TO_POINTER(FALSE));
+ g_object_set_data(G_OBJECT(combo), "update", GINT_TO_POINTER(FALSE));
}
- //gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), 0);
}
static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSelector::Mode mode)
@@ -1039,15 +1017,29 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel
GtkWidget *hb = gtk_hbox_new(FALSE, 1);
#endif
- GtkWidget *mnu = gtk_option_menu_new();
- ink_pattern_menu(mnu);
- g_signal_connect(G_OBJECT(mnu), "changed", G_CALLBACK(sp_psel_pattern_change), psel);
- g_signal_connect(G_OBJECT(mnu), "destroy", G_CALLBACK(sp_psel_pattern_destroy), psel);
- g_object_set_data(G_OBJECT(psel), "patternmenu", mnu);
- g_object_ref( G_OBJECT(mnu));
-
- gtk_container_add(GTK_CONTAINER(hb), mnu);
+ /**
+ * Create a combo_box and store with 4 columns,
+ * The label, a pointer to the pattern, is stockid or not, is a separator or not.
+ */
+ GtkListStore *store = gtk_list_store_new (COMBO_N_COLS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+ gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo), SPPaintSelector::isSeparator, NULL, NULL);
+
+ GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_renderer_set_padding (renderer, 2, 0);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", COMBO_COL_LABEL, NULL);
+
+ ink_pattern_menu(combo);
+ g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(sp_psel_pattern_change), psel);
+ g_signal_connect(G_OBJECT(combo), "destroy", G_CALLBACK(sp_psel_pattern_destroy), psel);
+ g_object_set_data(G_OBJECT(psel), "patternmenu", combo);
+ g_object_ref( G_OBJECT(combo));
+
+ gtk_container_add(GTK_CONTAINER(hb), combo);
gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
+
+ g_object_unref( G_OBJECT(store));
}
{
@@ -1078,37 +1070,54 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel
#endif
}
+gboolean SPPaintSelector::isSeparator (GtkTreeModel *model, GtkTreeIter *iter, gpointer /*data*/) {
+
+ gboolean sep = FALSE;
+ gtk_tree_model_get(model, iter, COMBO_COL_SEP, &sep, -1);
+ return sep;
+}
+
SPPattern *SPPaintSelector::getPattern()
{
SPPattern *pat = 0;
g_return_val_if_fail((mode == MODE_PATTERN) , NULL);
- GtkWidget *patmnu = (GtkWidget *) g_object_get_data(G_OBJECT(this), "patternmenu");
+ GtkWidget *combo = (GtkWidget *) g_object_get_data(G_OBJECT(this), "patternmenu");
+
/* no pattern menu if we were just selected */
- if ( patmnu == NULL ) return NULL;
+ if ( combo == NULL ) {
+ return NULL;
+ }
- GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(patmnu)));
+ GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
- /* Get Pattern */
- if (!g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "pattern"))
- {
+ /* Get the selected pattern */
+ GtkTreeIter iter;
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX(combo), &iter) ||
+ !gtk_list_store_iter_is_valid(GTK_LIST_STORE(store), &iter)) {
return NULL;
}
- gchar *patid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)),
- "pattern");
- //gchar *pattern = "";
+
+ gchar *patid = NULL;
+ gboolean stockid = FALSE;
+ gchar *label = NULL;
+ gtk_tree_model_get (store, &iter, COMBO_COL_LABEL, &label, COMBO_COL_STOCK, &stockid, COMBO_COL_PATTERN, &patid, -1);
+ if (patid == NULL) {
+ return NULL;
+ }
+
if (strcmp(patid, "none")){
- gchar *stockid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)),
- "stockid");
- gchar *paturn = patid;
- if (!strcmp(stockid,"true")) paturn = g_strconcat("urn:inkscape:pattern:",patid,NULL);
+ gchar *paturn = g_strdup(patid);
+ if (stockid) {
+ paturn = g_strconcat("urn:inkscape:pattern:",patid,NULL);
+ }
SPObject *pat_obj = get_stock_item(paturn);
if (pat_obj) {
pat = SP_PATTERN(pat_obj);
}
} else {
- pat = pattern_getroot(SP_PATTERN(g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "pattern")));
+ pat = pattern_getroot(SP_PATTERN(patid));
}
if (pat && !SP_IS_PATTERN(pat)) {
diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h
index 7400987ee..d6ad3f50c 100644
--- a/src/widgets/paint-selector.h
+++ b/src/widgets/paint-selector.h
@@ -77,6 +77,7 @@ struct SPPaintSelector {
SPColor color;
float alpha;
+
static Mode getModeForStyle(SPStyle const & style, FillOrStroke kind);
void setMode( Mode mode );
@@ -97,10 +98,15 @@ struct SPPaintSelector {
SPPattern * getPattern();
void updatePatternList( SPPattern *pat );
+ static gboolean isSeparator (GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
+
// TODO move this elsewhere:
void setFlatColor( SPDesktop *desktop, const gchar *color_property, const gchar *opacity_property );
};
+enum {COMBO_COL_LABEL=0, COMBO_COL_STOCK=1, COMBO_COL_PATTERN=2, COMBO_COL_SEP=3, COMBO_N_COLS=4};
+
+
/// The SPPaintSelector vtable
struct SPPaintSelectorClass {
GtkVBoxClass parent_class;
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index a76bf3081..b4fbb13c5 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -61,6 +61,17 @@ static void gtk_deprecated_ruler_realize (GtkWidget *widget);
static void gtk_deprecated_ruler_unrealize (GtkWidget *widget);
static void gtk_deprecated_ruler_size_request (GtkWidget *widget,
GtkRequisition *requisition);
+
+#if GTK_CHECK_VERSION(3,0,0)
+static void gtk_deprecated_ruler_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void gtk_deprecated_ruler_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static void gtk_deprecated_ruler_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_deprecated_ruler_motion_notify (GtkWidget *widget,
@@ -96,7 +107,12 @@ gtk_deprecated_ruler_class_init (GtkDeprecatedRulerClass *klass)
widget_class->realize = gtk_deprecated_ruler_realize;
widget_class->unrealize = gtk_deprecated_ruler_unrealize;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = gtk_deprecated_ruler_get_preferred_width;
+ widget_class->get_preferred_height = gtk_deprecated_ruler_get_preferred_height;
+#else
widget_class->size_request = gtk_deprecated_ruler_size_request;
+#endif
widget_class->size_allocate = gtk_deprecated_ruler_size_allocate;
widget_class->motion_notify_event = gtk_deprecated_ruler_motion_notify;
widget_class->expose_event = gtk_deprecated_ruler_expose;
@@ -359,16 +375,15 @@ gtk_deprecated_ruler_set_metric (GtkDeprecatedRuler *ruler,
*
* Return value: the units currently used for @ruler
**/
-GtkMetricType
-gtk_deprecated_ruler_get_metric (GtkDeprecatedRuler *ruler)
+GtkMetricType gtk_deprecated_ruler_get_metric (GtkDeprecatedRuler *ruler)
{
- gint i;
+ g_return_val_if_fail(GTK_DEPRECATED_IS_RULER(ruler), static_cast<GtkMetricType>(0));
- g_return_val_if_fail (GTK_DEPRECATED_IS_RULER (ruler), static_cast<GtkMetricType>(0));
-
- for (i = 0; i < G_N_ELEMENTS (ruler_metrics); i++)
- if (ruler->metric == &ruler_metrics[i])
+ for (size_t i = 0; i < G_N_ELEMENTS(ruler_metrics); i++) {
+ if (ruler->metric == &ruler_metrics[i]) {
return static_cast<GtkMetricType>(i);
+ }
+ }
g_assert_not_reached ();
@@ -470,6 +485,22 @@ gtk_deprecated_ruler_size_request (GtkWidget *widget,
}
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void gtk_deprecated_ruler_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ gtk_deprecated_ruler_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void gtk_deprecated_ruler_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ gtk_deprecated_ruler_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
static void
gtk_deprecated_ruler_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -995,6 +1026,16 @@ static gint sp_vruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static void sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisition);
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_vruler_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sp_vruler_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static GtkWidgetClass *vruler_parent_class;
GType
@@ -1033,7 +1074,13 @@ sp_vruler_class_init (SPVRulerClass *klass)
ruler_class = (GtkDeprecatedRulerClass*) klass;
widget_class->motion_notify_event = sp_vruler_motion_notify;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = sp_vruler_get_preferred_width;
+ widget_class->get_preferred_height = sp_vruler_get_preferred_height;
+#else
widget_class->size_request = sp_vruler_size_request;
+#endif
ruler_class->draw_ticks = sp_ruler_common_draw_ticks;
}
@@ -1091,6 +1138,22 @@ sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisition)
requisition->width = style->xthickness * 2 + RULER_WIDTH;
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_vruler_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sp_vruler_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void sp_vruler_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sp_vruler_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
static void
sp_ruler_common_draw_ticks(GtkDeprecatedRuler *ruler)
{
diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h
index 03eace0cb..0e7d32b2a 100644
--- a/src/widgets/ruler.h
+++ b/src/widgets/ruler.h
@@ -70,8 +70,8 @@ struct _GtkDeprecatedRulerClass
struct _GtkDeprecatedRulerMetric
{
- gchar *metric_name;
- gchar *abbrev;
+ gchar const *metric_name;
+ gchar const *abbrev;
/* This should be points_per_unit. This is the size of the unit
* in 1/72nd's of an inch and has nothing to do with screen pixels */
gdouble pixels_per_unit;
diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp
index b74be502b..3b690afc9 100644
--- a/src/widgets/sp-color-slider.cpp
+++ b/src/widgets/sp-color-slider.cpp
@@ -32,6 +32,17 @@ static void sp_color_slider_destroy (GtkObject *object);
static void sp_color_slider_realize (GtkWidget *widget);
static void sp_color_slider_size_request (GtkWidget *widget, GtkRequisition *requisition);
+
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_color_slider_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sp_color_slider_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static void sp_color_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
/* static void sp_color_slider_draw (GtkWidget *widget, GdkRectangle *area); */
/* static void sp_color_slider_draw_focus (GtkWidget *widget); */
@@ -117,7 +128,12 @@ sp_color_slider_class_init (SPColorSliderClass *klass)
object_class->destroy = sp_color_slider_destroy;
widget_class->realize = sp_color_slider_realize;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = sp_color_slider_get_preferred_width;
+ widget_class->get_preferred_height = sp_color_slider_get_preferred_height;
+#else
widget_class->size_request = sp_color_slider_size_request;
+#endif
widget_class->size_allocate = sp_color_slider_size_allocate;
/* widget_class->draw = sp_color_slider_draw; */
/* widget_class->draw_focus = sp_color_slider_draw_focus; */
@@ -225,6 +241,22 @@ sp_color_slider_size_request (GtkWidget *widget, GtkRequisition *requisition)
requisition->height = SLIDER_HEIGHT + style->ythickness * 2;
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_color_slider_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sp_color_slider_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void sp_color_slider_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sp_color_slider_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
static void
sp_color_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
@@ -512,12 +544,18 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area)
b = sp_color_slider_render_map (cpaint.x - carea.x, cpaint.y - carea.y, cpaint.width, cpaint.height,
slider->map, s, d,
slider->b0, slider->b1, slider->bmask);
- if (b != NULL) {
- gdk_draw_rgb_image(window, style->black_gc,
- cpaint.x, cpaint.y,
- cpaint.width, cpaint.height,
- GDK_RGB_DITHER_MAX,
- (guchar *) b, cpaint.width * 3);
+ if (b != NULL && cpaint.width > 0) {
+
+ GdkPixbuf *pb = gdk_pixbuf_new_from_data (b, GDK_COLORSPACE_RGB,
+ 0, 8, cpaint.width, cpaint.height, cpaint.width * 3, NULL, NULL);
+
+ cairo_t *ct = gdk_cairo_create(window);
+ gdk_cairo_set_source_pixbuf (ct, pb, cpaint.x, cpaint.y);
+ cairo_paint(ct);
+ cairo_destroy(ct);
+
+ g_object_unref(pb);
+
}
} else {
@@ -537,13 +575,18 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area)
c, dc,
slider->b0, slider->b1, slider->bmask);
- /* Draw pixelstore */
- if (b != NULL) {
- gdk_draw_rgb_image(window, style->black_gc,
- cpaint.x, cpaint.y,
- wi, cpaint.height,
- GDK_RGB_DITHER_MAX,
- (guchar *) b, wi * 3);
+ /* Draw pixelstore 1 */
+ if (b != NULL && wi > 0) {
+
+ GdkPixbuf *pb = gdk_pixbuf_new_from_data (b, GDK_COLORSPACE_RGB,
+ 0, 8, wi, cpaint.height, wi * 3, NULL, NULL);
+
+ cairo_t *ct = gdk_cairo_create(window);
+ gdk_cairo_set_source_pixbuf (ct, pb, cpaint.x, cpaint.y);
+ cairo_paint(ct);
+ cairo_destroy(ct);
+
+ g_object_unref(pb);
}
}
@@ -560,19 +603,24 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area)
c, dc,
slider->b0, slider->b1, slider->bmask);
- /* Draw pixelstore */
- if (b != NULL) {
- gdk_draw_rgb_image(window, style->black_gc,
- MAX(cpaint.x, carea.width/2 + carea.x), cpaint.y,
- wi, cpaint.height,
- GDK_RGB_DITHER_MAX,
- (guchar *) b, wi * 3);
+ /* Draw pixelstore 2 */
+ if (b != NULL && wi > 0) {
+
+ GdkPixbuf *pb = gdk_pixbuf_new_from_data (b, GDK_COLORSPACE_RGB,
+ 0, 8, wi, cpaint.height, wi * 3, NULL, NULL);
+
+ cairo_t *ct = gdk_cairo_create(window);
+ gdk_cairo_set_source_pixbuf (ct, pb, MAX(cpaint.x, carea.width/2 + carea.x), cpaint.y);
+ cairo_paint(ct);
+ cairo_destroy(ct);
+
+ g_object_unref(pb);
}
}
}
}
- /* Draw shadow */
+ /* Draw shadow */
if (!colorsOnTop) {
gtk_paint_shadow( style, window,
gtk_widget_get_state(widget), GTK_SHADOW_IN,
diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp
index 8645d90f7..c0ee44f83 100644
--- a/src/widgets/sp-widget.cpp
+++ b/src/widgets/sp-widget.cpp
@@ -35,6 +35,17 @@ static void sp_widget_show (GtkWidget *widget);
static void sp_widget_hide (GtkWidget *widget);
static gint sp_widget_expose (GtkWidget *widget, GdkEventExpose *event);
static void sp_widget_size_request (GtkWidget *widget, GtkRequisition *requisition);
+
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_widget_get_preferred_width(GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+
+static void sp_widget_get_preferred_height(GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#endif
+
static void sp_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static void sp_widget_modify_selection (Inkscape::Application *inkscape, Inkscape::Selection *selection, guint flags, SPWidget *spw);
@@ -115,7 +126,12 @@ sp_widget_class_init (SPWidgetClass *klass)
widget_class->show = sp_widget_show;
widget_class->hide = sp_widget_hide;
widget_class->expose_event = sp_widget_expose;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->get_preferred_width = sp_widget_get_preferred_width;
+ widget_class->get_preferred_height = sp_widget_get_preferred_height;
+#else
widget_class->size_request = sp_widget_size_request;
+#endif
widget_class->size_allocate = sp_widget_size_allocate;
}
@@ -212,6 +228,22 @@ sp_widget_size_request (GtkWidget *widget, GtkRequisition *requisition)
gtk_widget_size_request (child, requisition);
}
+#if GTK_CHECK_VERSION(3,0,0)
+static void sp_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ GtkRequisition requisition;
+ sp_widget_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void sp_widget_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ GtkRequisition requisition;
+ sp_widget_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
+}
+#endif
+
static void
sp_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp
index ade5bec39..aafd4ab79 100644
--- a/src/widgets/sp-xmlview-tree.cpp
+++ b/src/widgets/sp-xmlview-tree.cpp
@@ -43,12 +43,12 @@ static void text_content_changed (Inkscape::XML::Node * repr, const gchar * old_
static void comment_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data);
static void pi_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data);
-static void ref_to_sibling (NodeData *node, Inkscape::XML::Node * ref, GtkTreeIter *);
-static void repr_to_child (NodeData *node, Inkscape::XML::Node * repr, GtkTreeIter *);
+static gboolean ref_to_sibling (NodeData *node, Inkscape::XML::Node * ref, GtkTreeIter *);
+static gboolean repr_to_child (NodeData *node, Inkscape::XML::Node * repr, GtkTreeIter *);
static Inkscape::XML::Node * sibling_to_ref (GtkTreeView * tree, GtkTreeIter * parent, GtkTreeIter * sibling);
static gboolean tree_model_iter_compare(GtkTreeModel* store, GtkTreeIter * iter1, GtkTreeIter * iter2);
GtkTreeRowReference *tree_iter_to_ref (SPXMLViewTree * tree, GtkTreeIter* iter);
-static void tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref);
+static gboolean tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref);
gboolean search_equal_func (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data);
gboolean foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
@@ -204,6 +204,10 @@ add_node (SPXMLViewTree * tree, GtkTreeIter *parent, GtkTreeIter *before, Inksca
GtkTreeIter iter;
gtk_tree_store_insert_before (tree->store, &iter, parent, before);
+ if (!gtk_tree_store_iter_is_valid(tree->store, &iter)) {
+ return NULL;
+ }
+
GtkTreeRowReference *rowref = tree_iter_to_ref (tree, &iter);
data = node_data_new (tree, &iter, rowref, repr);
g_assert (data != NULL);
@@ -264,7 +268,9 @@ element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child
if (data->tree->blocked) return;
- ref_to_sibling (data, ref, &before);
+ if (!ref_to_sibling (data, ref, &before)) {
+ return;
+ }
GtkTreeIter data_iter;
tree_ref_to_iter(data->tree, &data_iter, data->rowref);
@@ -297,8 +303,9 @@ element_attr_changed (Inkscape::XML::Node * repr, const gchar * key, const gchar
}
GtkTreeIter iter;
- tree_ref_to_iter(data->tree, &iter, data->rowref);
- gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
+ gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ }
g_free (label);
}
@@ -311,8 +318,9 @@ element_child_removed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * chi
if (data->tree->blocked) return;
GtkTreeIter iter;
- repr_to_child (data, child, &iter);
- gtk_tree_store_remove (GTK_TREE_STORE(data->tree->store), &iter);
+ if (repr_to_child (data, child, &iter)) {
+ gtk_tree_store_remove (GTK_TREE_STORE(data->tree->store), &iter);
+ }
}
@@ -348,8 +356,9 @@ text_content_changed (Inkscape::XML::Node * /*repr*/, const gchar * /*old_conten
label = g_strdup_printf ("\"%s\"", new_content);
GtkTreeIter iter;
- tree_ref_to_iter(data->tree, &iter, data->rowref);
- gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
+ gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ }
g_free (label);
}
@@ -366,9 +375,9 @@ comment_content_changed (Inkscape::XML::Node */*repr*/, const gchar * /*old_cont
label = g_strdup_printf ("<!--%s-->", new_content);
GtkTreeIter iter;
- tree_ref_to_iter(data->tree, &iter, data->rowref);
- gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
-
+ if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
+ gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ }
g_free (label);
}
@@ -384,9 +393,9 @@ pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, con
label = g_strdup_printf ("<?%s %s?>", repr->name(), new_content);
GtkTreeIter iter;
- tree_ref_to_iter(data->tree, &iter, data->rowref);
- gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
-
+ if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
+ gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ }
g_free (label);
}
@@ -452,8 +461,7 @@ void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *it
}
GtkTreeIter old_parent;
- tree_ref_to_iter(tree, &old_parent, old_parent_ref);
- if (!gtk_tree_store_iter_is_valid(GTK_TREE_STORE(tree_model), &old_parent)){
+ if (!tree_ref_to_iter(tree, &old_parent, old_parent_ref)) {
//Drag source parent is not valid
g_signal_emit_by_name(G_OBJECT (tree), "tree_move", GUINT_TO_POINTER(0) );
return;
@@ -501,30 +509,41 @@ void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *it
/*
* Set iter to ref or node data's child with the same repr or first child
*/
-void ref_to_sibling (NodeData *data, Inkscape::XML::Node *repr, GtkTreeIter *iter)
+gboolean ref_to_sibling (NodeData *data, Inkscape::XML::Node *repr, GtkTreeIter *iter)
{
if (repr) {
- repr_to_child (data, repr, iter);
+ if (!repr_to_child (data, repr, iter)) {
+ return false;
+ }
gtk_tree_model_iter_next (GTK_TREE_MODEL(data->tree->store), iter);
} else {
GtkTreeIter data_iter;
- tree_ref_to_iter(data->tree, &data_iter, data->rowref);
+ if (!tree_ref_to_iter(data->tree, &data_iter, data->rowref)) {
+ return false;
+ }
gtk_tree_model_iter_children(GTK_TREE_MODEL(data->tree->store), iter, &data_iter);
}
+ return true;
}
/*
* Set iter to the node data's child with the same repr
*/
-void repr_to_child (NodeData *data, Inkscape::XML::Node * repr, GtkTreeIter *iter)
+gboolean repr_to_child (NodeData *data, Inkscape::XML::Node * repr, GtkTreeIter *iter)
{
GtkTreeIter data_iter;
tree_ref_to_iter(data->tree, &data_iter, data->rowref);
+ if (!gtk_tree_store_iter_is_valid(GTK_TREE_STORE(data->tree->store), &data_iter)) {
+ return false;
+ }
+
gboolean valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(data->tree->store), iter, &data_iter);
while (valid && sp_xmlview_tree_node_get_repr (GTK_TREE_VIEW(data->tree), iter) != repr) {
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(data->tree->store), iter);
}
+
+ return valid;
}
/*
@@ -542,10 +561,15 @@ GtkTreeRowReference *tree_iter_to_ref (SPXMLViewTree * tree, GtkTreeIter* iter)
/*
* Get a matching GtkTreeIter for a GtkTreeRowReference
*/
-void tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref)
+gboolean tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref)
{
GtkTreePath* path = gtk_tree_row_reference_get_path(ref);
+ if (!path) {
+ return false;
+ }
gtk_tree_model_get_iter(GTK_TREE_MODEL(tree->store), iter, path);
+
+ return gtk_tree_store_iter_is_valid(GTK_TREE_STORE(tree->store), iter);
}
/*
diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp
index 994d954cc..565c89ece 100644
--- a/src/widgets/spinbutton-events.cpp
+++ b/src/widgets/spinbutton-events.cpp
@@ -48,7 +48,7 @@ spinbutton_undo (GtkWidget *w)
}
void
-spinbutton_defocus (GtkObject *container)
+spinbutton_defocus (GtkWidget *container)
{
// defocus spinbuttons by moving focus to the canvas, unless "stay" is on
gboolean stay = GPOINTER_TO_INT(g_object_get_data(G_OBJECT (container), "stay"));
@@ -71,12 +71,12 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data)
switch (get_group0_keyval (event)) {
case GDK_Escape: // defocus
spinbutton_undo (w);
- spinbutton_defocus (GTK_OBJECT (spw));
+ spinbutton_defocus(GTK_WIDGET(spw));
return TRUE; // I consumed the event
break;
case GDK_Return: // defocus
case GDK_KP_Enter:
- spinbutton_defocus (GTK_OBJECT (spw));
+ spinbutton_defocus (GTK_WIDGET(spw));
return TRUE; // I consumed the event
break;
case GDK_Tab:
diff --git a/src/widgets/spinbutton-events.h b/src/widgets/spinbutton-events.h
index cf8c7b44b..c1df88c8a 100644
--- a/src/widgets/spinbutton-events.h
+++ b/src/widgets/spinbutton-events.h
@@ -15,7 +15,7 @@
gboolean spinbutton_focus_in (GtkWidget *w, GdkEventKey *event, gpointer data);
void spinbutton_undo (GtkWidget *w);
gboolean spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data);
-void spinbutton_defocus (GtkObject *container);
+void spinbutton_defocus (GtkWidget *container);
/*
Local Variables:
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 58c7958ba..7d73c042b 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -538,6 +538,7 @@ static gchar const * ui_descr =
" <toolitem action='GradientNewFillStrokeAction' />"
" <separator />"
" <toolitem action='GradientSelectGradientAction' />"
+ " <toolitem action='GradientEditLinkAction' />"
" <toolitem action='GradientEditReverseAction' />"
" <toolitem action='GradientSelectRepeatAction' />"
" <separator />"
@@ -584,7 +585,7 @@ static void update_aux_toolbox(SPDesktop *desktop, SPEventContext *eventcontext,
static void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
static void update_commands_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
-static GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
+static GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view);
@@ -656,18 +657,19 @@ Gtk::Widget* VerbAction::create_tool_item_vfunc()
// Gtk::Widget* widg = Gtk::Action::create_tool_item_vfunc();
Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/tools/small");
GtkWidget* toolbox = 0;
- GtkWidget *button = sp_toolbox_button_new_from_verb_with_doubleclick( toolbox, toolboxSize,
- SP_BUTTON_TYPE_TOGGLE,
- verb,
- verb2,
- view );
+ GtkToolItem *button_toolitem = sp_toolbox_button_item_new_from_verb_with_doubleclick( toolbox, toolboxSize,
+ SP_BUTTON_TYPE_TOGGLE,
+ verb,
+ verb2,
+ view );
+
+ GtkWidget* button_widget = gtk_bin_get_child(GTK_BIN(button_toolitem));
+
if ( active ) {
- sp_button_toggle_set_down( SP_BUTTON(button), active);
+ sp_button_toggle_set_down( SP_BUTTON(button_widget), active);
}
- gtk_widget_show_all( button );
- Gtk::Widget* wrapped = Glib::wrap(button);
- Gtk::ToolItem* holder = Gtk::manage(new Gtk::ToolItem());
- holder->add(*wrapped);
+ gtk_widget_show_all( button_widget );
+ Gtk::ToolItem* holder = Glib::wrap(button_toolitem);
// g_message("create_tool_item_vfunc() = %p for '%s'", holder, verb->get_id());
return holder;
@@ -833,7 +835,7 @@ void PrefPusher::notify(Inkscape::Preferences::Entry const &newVal)
}
}
-static void delete_prefspusher(GtkObject * /*obj*/, PrefPusher *watcher )
+static void delete_prefspusher(GObject * /*obj*/, PrefPusher *watcher )
{
delete watcher;
}
@@ -841,7 +843,7 @@ static void delete_prefspusher(GtkObject * /*obj*/, PrefPusher *watcher )
// ------------------------------------------------------
-GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
+GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view)
{
@@ -861,24 +863,27 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc
/* fixme: Implement sp_button_new_from_action */
GtkWidget *b = sp_button_new(size, type, action, doubleclick_action);
gtk_widget_show(b);
-
+ GtkToolItem *b_toolitem = gtk_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(b_toolitem), b);
unsigned int shortcut = sp_shortcut_get_primary(verb);
if (shortcut != GDK_KEY_VoidSymbol) {
gchar *key = sp_shortcut_get_label(shortcut);
gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key);
if ( t ) {
- gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, tip, 0 );
+ gtk_toolbar_insert(GTK_TOOLBAR(t), b_toolitem, -1);
+ gtk_widget_set_tooltip_text(b, tip);
}
g_free(tip);
g_free(key);
} else {
if ( t ) {
- gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, action->tip, 0 );
+ gtk_toolbar_insert(GTK_TOOLBAR(t), b_toolitem, -1);
+ gtk_widget_set_tooltip_text(b, action->tip);
}
}
- return b;
+ return b_toolitem;
}
@@ -1063,8 +1068,8 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType han
GtkWidget *ToolboxFactory::createToolToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *tb = gtk_box_new(GTK_ORIENTATION, 0);
- gtk_box_new(GTK_BOX(tb), FALSE);
+ GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
#endif
@@ -1076,7 +1081,7 @@ GtkWidget *ToolboxFactory::createAuxToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_new(GTK_BOX(tb), FALSE);
+ gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
#endif
@@ -1092,7 +1097,7 @@ GtkWidget *ToolboxFactory::createCommandsToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_new(GTK_BOX(tb), FALSE);
+ gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
#endif
@@ -1104,7 +1109,7 @@ GtkWidget *ToolboxFactory::createSnapToolbox()
{
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_new(GTK_BOX(tb), FALSE);
+ gtk_box_set_homogeneous(GTK_BOX(tb), FALSE);
#else
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
#endif
@@ -2075,7 +2080,7 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
void update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget * /*toolbox*/ )
{
gchar const *const tname = ( eventcontext
- ? gtk_type_name(GTK_OBJECT_TYPE(eventcontext))
+ ? g_type_name(G_OBJECT_TYPE(eventcontext))
: NULL );
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
@@ -2178,7 +2183,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
void update_aux_toolbox(SPDesktop * /*desktop*/, SPEventContext *eventcontext, GtkWidget *toolbox)
{
gchar const *tname = ( eventcontext
- ? gtk_type_name(GTK_OBJECT_TYPE(eventcontext))
+ ? g_type_name(G_OBJECT_TYPE(eventcontext))
: NULL );
for (int i = 0 ; aux_toolboxes[i].type_name ; i++ ) {
GtkWidget *sub_toolbox = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbox), aux_toolboxes[i].data_name));
@@ -4041,7 +4046,7 @@ static void sp_spl_tb_t0_value_changed(GtkAdjustment *adj, GObject *tbl)
sp_spl_tb_value_changed(adj, tbl, "t0");
}
-static void sp_spl_tb_defaults(GtkWidget * /*widget*/, GtkObject *obj)
+static void sp_spl_tb_defaults(GtkWidget * /*widget*/, GObject *obj)
{
GtkWidget *tbl = GTK_WIDGET(obj);
@@ -4052,19 +4057,19 @@ static void sp_spl_tb_defaults(GtkWidget * /*widget*/, GtkObject *obj)
gdouble exp = 1.0;
gdouble t0 = 0.0;
- adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "revolution");
+ adj = (GtkAdjustment*)g_object_get_data(obj, "revolution");
gtk_adjustment_set_value(adj, rev);
gtk_adjustment_value_changed(adj);
- adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "expansion");
+ adj = (GtkAdjustment*)g_object_get_data(obj, "expansion");
gtk_adjustment_set_value(adj, exp);
gtk_adjustment_value_changed(adj);
- adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "t0");
+ adj = (GtkAdjustment*)g_object_get_data(obj, "t0");
gtk_adjustment_set_value(adj, t0);
gtk_adjustment_value_changed(adj);
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(tbl);
}
@@ -4374,7 +4379,7 @@ static void sp_pen_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* mainAct
}
-static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GtkObject *obj)
+static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj)
{
GtkWidget *tbl = GTK_WIDGET(obj);
@@ -4383,11 +4388,11 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GtkObject *obj)
// fixme: make settable
gdouble tolerance = 4;
- adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "tolerance");
+ adj = (GtkAdjustment*)g_object_get_data(obj, "tolerance");
gtk_adjustment_set_value(adj, tolerance);
gtk_adjustment_value_changed(adj);
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(tbl);
}
static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl)
@@ -5720,7 +5725,7 @@ static void sp_arctb_defaults(GtkWidget *, GObject *obj)
gtk_adjustment_set_value(adj, 0.0);
gtk_adjustment_value_changed(adj);
- spinbutton_defocus( GTK_OBJECT(obj) );
+ spinbutton_defocus(GTK_WIDGET(obj));
}
static void arc_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const * /*name*/,
@@ -5941,14 +5946,14 @@ static void toggle_dropper_pick_alpha( GtkToggleAction* act, gpointer tbl )
}
}
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(GTK_WIDGET(tbl));
}
static void toggle_dropper_set_alpha( GtkToggleAction* act, gpointer tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/dropper/setalpha", gtk_toggle_action_get_active( act ) );
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(GTK_WIDGET(tbl));
}
@@ -8172,7 +8177,7 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
//## Connector ##
//#########################
-static void sp_connector_mode_toggled( GtkToggleAction* act, GtkObject * /*tbl*/ )
+static void sp_connector_mode_toggled( GtkToggleAction* act, GObject * /*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/connector/mode",
@@ -8357,14 +8362,14 @@ static void sp_connector_graph_layout(void)
DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
}
-static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GtkObject * /*tbl*/ )
+static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GObject * /*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/connector/directedlayout",
gtk_toggle_action_get_active( act ));
}
-static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GtkObject * /*tbl*/ )
+static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GObject * /*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/connector/avoidoverlaplayout",
@@ -8393,7 +8398,7 @@ static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
gtk_adjustment_set_value(adj, spacing);
gtk_adjustment_value_changed(adj);
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(tbl);
}
}
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 355f3e2b3..b85e58899 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -625,7 +625,7 @@ void sp_repr_save_stream(Document *doc, FILE *fp, gchar const *default_ns, bool
/**
- * Returns true iff file successfully saved.
+ * Returns true if file successfully saved.
*
* \param filename The actual file to do I/O to, which might be a temp file.
*
@@ -652,27 +652,23 @@ bool sp_repr_save_rebased_file(Document *doc, gchar const *const filename, gchar
return false;
}
- std::string old_href_abs_base;
- gchar *new_href_abs_base = NULL;
+ Glib::ustring old_href_abs_base;
+ Glib::ustring new_href_abs_base;
if (for_filename) {
old_href_abs_base = calc_abs_doc_base(old_base);
- if (g_path_is_absolute(for_filename)) {
- new_href_abs_base = g_path_get_dirname(for_filename);
+ if (Glib::path_is_absolute(for_filename)) {
+ new_href_abs_base = Glib::path_get_dirname(for_filename);
} else {
- gchar *const cwd = g_get_current_dir();
- gchar *const for_abs_filename = g_build_filename(cwd, for_filename, NULL);
- g_free(cwd);
- new_href_abs_base = g_path_get_dirname(for_abs_filename);
- g_free(for_abs_filename);
+ Glib::ustring const cwd = Glib::get_current_dir();
+ Glib::ustring const for_abs_filename = Glib::build_filename(cwd, for_filename);
+ new_href_abs_base = Glib::path_get_dirname(for_abs_filename);
}
/* effic: Once we're confident that we never need (or never want) to resort
* to using sodipodi:absref instead of the xlink:href value,
* then we should do `if streq() { free them and set both to NULL; }'. */
}
- sp_repr_save_stream(doc, file, default_ns, compress, old_href_abs_base.c_str(), new_href_abs_base);
-
- g_free(new_href_abs_base);
+ sp_repr_save_stream(doc, file, default_ns, compress, old_href_abs_base.c_str(), new_href_abs_base.c_str());
if (fclose (file) != 0) {
return false;