From 03a14fa94b3260fecfbab5848de10751218a3b19 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 30 Mar 2014 13:10:32 +0100 Subject: Fix some mismatched tags (bzr r13230) --- src/gradient-drag.h | 2 +- src/knot-holder-entity.h | 5 ++--- src/knotholder.h | 2 +- src/seltrans.h | 2 +- src/ui/tools/connector-tool.h | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 4ee59bb0f..964ea8093 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -28,7 +28,7 @@ #include "sp-gradient.h" // TODO refactor enums to external .h file #include "sp-mesh-array.h" -struct SPKnot; +class SPKnot; class SPDesktop; class SPCSSAttr; diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index 2737f23e1..a9268d396 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -20,9 +20,8 @@ #include "snapper.h" #include "display/sp-canvas-item.h" -class SPItem; -struct SPKnot; - +class SPItem; +class SPKnot; class SPDesktop; class KnotHolder; diff --git a/src/knotholder.h b/src/knotholder.h index d531ae288..3632635f5 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -34,7 +34,7 @@ class PowerStrokePointArrayParamKnotHolderEntity; class KnotHolderEntity; class SPItem; class SPDesktop; -struct SPKnot; +class SPKnot; /* fixme: Think how to make callbacks most sensitive (Lauris) */ typedef void (* SPKnotHolderReleasedFunc) (SPItem *item); diff --git a/src/seltrans.h b/src/seltrans.h index d97375520..44268ed69 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -27,7 +27,7 @@ #include "sp-item.h" #include "seltrans-handles.h" -struct SPKnot; +class SPKnot; class SPDesktop; struct SPCanvasItem; struct SPCtrlLine; diff --git a/src/ui/tools/connector-tool.h b/src/ui/tools/connector-tool.h index 9a9ae64cf..868b8e77c 100644 --- a/src/ui/tools/connector-tool.h +++ b/src/ui/tools/connector-tool.h @@ -22,7 +22,7 @@ class SPItem; class SPCurve; -struct SPKnot; +class SPKnot; struct SPCanvasItem; namespace Avoid { -- cgit v1.2.3 From c238cf70cf7cd2b3ad6e347076e15d74304294c2 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 30 Mar 2014 13:39:02 +0100 Subject: End support for obsolete GNU hash. Supported either natively, through TR1 or Boost now Fixed bugs: - https://launchpad.net/bugs/1269346 (bzr r13231) --- src/util/unordered-containers.h | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'src') diff --git a/src/util/unordered-containers.h b/src/util/unordered-containers.h index 98c2fa3c9..b92f2e7ea 100644 --- a/src/util/unordered-containers.h +++ b/src/util/unordered-containers.h @@ -69,37 +69,6 @@ struct hash : public std::unary_function -# include -# include -# define INK_UNORDERED_SET __gnu_cxx::hash_set -# define INK_UNORDERED_MAP __gnu_cxx::hash_map -# define INK_HASH __gnu_cxx::hash - -#include - -namespace __gnu_cxx { -// hash function for pointers -// TR1 and Boost have this defined by default, __gnu_cxx doesn't -template -struct hash : public std::unary_function { - std::size_t operator()(T *p) const { - // Taken from Boost - std::size_t x = static_cast(reinterpret_cast(p)); - return x + (x >> 3); - } -}; - -template <> -struct hash : public std::unary_function { - std::size_t operator()(Glib::ustring const &s) const { - return hash()(s.raw()); - } -}; -} // namespace __gnu_cxx #endif #else -- cgit v1.2.3 From 88878512e24f1b2e1c0c1c0177921f8d848033c5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 30 Mar 2014 14:01:28 +0100 Subject: Fix checking for unordered containers on incomplete C++11 implementations (bzr r13232) --- src/ui/tool/node.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index b874949f5..4582d998a 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -12,6 +12,10 @@ #ifndef SEEN_UI_TOOL_NODE_H #define SEEN_UI_TOOL_NODE_H +#if HAVE_CONFIG_H + #include "config.h" +#endif + #include #include #include @@ -37,7 +41,7 @@ template class NodeIterator; } } -#if __cplusplus < 201103L +#if HAVE_TR1_UNORDERED_SET namespace std { namespace tr1 { template struct hash< Inkscape::UI::NodeIterator >; -- cgit v1.2.3 From 93cffb85dbe5e7e522e061fa21e00df9c8270fbc Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 30 Mar 2014 17:34:19 +0100 Subject: Migrate inkjar to cstdio functions to fix build issues on Free BSD (Thanks Markus Engel); see bug #1232474 (bzr r13233) --- src/io/inkjar.cpp | 18 +++++++++--------- src/io/inkjar.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp index 4af140737..b9335c556 100644 --- a/src/io/inkjar.cpp +++ b/src/io/inkjar.cpp @@ -68,7 +68,7 @@ JarFile::JarFile(gchar const*new_filename) { _filename = g_strdup(new_filename); _last_filename = NULL; - fd = -1; + fd = NULL; } //fixme: the following should probably just return a const gchar* and not @@ -104,7 +104,7 @@ bool JarFile::init_inflation() bool JarFile::open() { - if ((fd = ::open(_filename, O_RDONLY)) < 0) { + if ((fd = fopen(_filename, O_RDONLY)) < 0) { fprintf(stderr, "open failed.\n"); return false; } @@ -116,7 +116,7 @@ bool JarFile::open() bool JarFile::close() { - if (fd >= 0 && !::close(fd)) { + if (fd >= 0 && !fclose(fd)) { inflateEnd(&_zs); return true; } @@ -257,7 +257,7 @@ GByteArray *JarFile::get_next_file_contents() if (method == 8 || flags & 0x0008) { unsigned int file_length = 0;//uncompressed file length - lseek(fd, eflen, SEEK_CUR); + fseek(fd, eflen, SEEK_CUR); guint8 *file_data = get_compressed_file(compressed_size, file_length, crc, flags); if (file_data == NULL) { @@ -275,7 +275,7 @@ GByteArray *JarFile::get_next_file_contents() } g_byte_array_append(gba, file_data, compressed_size); } else { - lseek(fd, compressed_size+eflen, SEEK_CUR); + fseek(fd, compressed_size+eflen, SEEK_CUR); g_byte_array_free(gba, FALSE); return NULL; } @@ -314,7 +314,7 @@ guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, std::printf("%u bytes written\n", out_a); #endif } - lseek(fd, eflen, SEEK_CUR); + fseek(fd, eflen, SEEK_CUR); g_free(bytes); if (!check_crc(crc, crc2, flags)) { @@ -329,7 +329,7 @@ guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, int JarFile::read(guint8 *buf, int count) { int nbytes; - if ((nbytes = ::read(fd, buf, count)) != count) { + if ((nbytes = fread(buf, 1, count, fd)) != count) { fprintf(stderr, "read error\n"); exit(1); return 0; @@ -358,8 +358,8 @@ guint8 *JarFile::get_compressed_file(guint32 compressed_size, if (!_zs.avail_in) { - if ((nbytes = ::read(fd, in_buffer, - (leftover_in < RDSZ ? leftover_in : RDSZ))) + if ((nbytes = fread(in_buffer, 1, + (leftover_in < RDSZ ? leftover_in : RDSZ), fd)) < 0) { fprintf(stderr, "jarfile read error"); } diff --git a/src/io/inkjar.h b/src/io/inkjar.h index ea4b0ee32..ee6e33526 100644 --- a/src/io/inkjar.h +++ b/src/io/inkjar.h @@ -27,6 +27,7 @@ #endif #include +#include namespace Inkjar { @@ -87,11 +88,10 @@ typedef uint32_t ub4; * * All memory allocations are done with g_malloc. */ - class JarFile { public: - JarFile() : fd(-1), _filename(NULL), _last_filename(NULL) {} + JarFile() : fd(NULL), _filename(NULL), _last_filename(NULL) {} virtual ~JarFile(); JarFile(gchar const *new_filename); @@ -106,7 +106,7 @@ public: private: - int fd; + FILE *fd; // File descriptor gchar *_filename; z_stream _zs; gchar *_last_filename; -- cgit v1.2.3 From 71d8e96e4874875d7b5ae2707f0a88296ea3b238 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 30 Mar 2014 22:09:32 +0100 Subject: inkjar: Fix access mode string (bzr r13235) --- src/io/inkjar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp index b9335c556..b31b98336 100644 --- a/src/io/inkjar.cpp +++ b/src/io/inkjar.cpp @@ -104,7 +104,7 @@ bool JarFile::init_inflation() bool JarFile::open() { - if ((fd = fopen(_filename, O_RDONLY)) < 0) { + if ((fd = fopen(_filename, "r")) < 0) { fprintf(stderr, "open failed.\n"); return false; } -- cgit v1.2.3 From 1a8f0cfdf29561e9929216e0d9d6db637ab31d54 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 30 Mar 2014 23:43:02 +0200 Subject: Added "Gtk::" scope to "manage" function calls. (bzr r13236) --- src/display/canvas-axonomgrid.cpp | 2 +- src/display/canvas-grid.cpp | 2 +- src/interface.cpp | 64 ++++++++++++++++----------------- src/ui/dialog/document-metadata.cpp | 8 ++--- src/ui/dialog/document-properties.cpp | 48 ++++++++++++------------- src/ui/dialog/fill-and-stroke.cpp | 8 ++--- src/ui/dialog/inkscape-preferences.cpp | 10 +++--- src/ui/dialog/input.cpp | 4 +-- src/ui/dialog/layer-properties.cpp | 6 ++-- src/ui/dialog/layers.cpp | 32 ++++++++--------- src/ui/dialog/livepatheffect-editor.cpp | 2 +- src/ui/dialog/new-from-template.cpp | 2 +- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/template-load-tab.cpp | 6 ++-- src/ui/dialog/template-widget.cpp | 2 +- src/ui/dialog/tracedialog.cpp | 2 +- src/ui/previewholder.cpp | 34 +++++++++--------- src/ui/widget/licensor.cpp | 8 ++--- src/ui/widget/panel.cpp | 30 ++++++++-------- src/ui/widget/registered-widget.cpp | 6 ++-- src/ui/widget/tolerance-slider.cpp | 16 ++++----- src/widgets/stroke-style.cpp | 12 +++---- 22 files changed, 153 insertions(+), 153 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 858312f5b..312a8d655 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -141,7 +141,7 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); #endif } else { - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 space->set_halign(Gtk::ALIGN_CENTER); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 3c4ad9b00..4b1dbd1ed 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -469,7 +469,7 @@ static inline void attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); #endif } else { - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 space->set_halign(Gtk::ALIGN_CENTER); diff --git a/src/interface.cpp b/src/interface.cpp index 6eb1b6a5a..1cbeb44a3 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1524,7 +1524,7 @@ ContextMenu::~ContextMenu(void) Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void) { - Gtk::SeparatorMenuItem* sep = manage(new Gtk::SeparatorMenuItem()); + Gtk::SeparatorMenuItem* sep = Gtk::manage(new Gtk::SeparatorMenuItem()); sep->show(); append(*sep); return sep; @@ -1556,7 +1556,7 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)// return; } - Gtk::ImageMenuItem *item = manage(new Gtk::ImageMenuItem(action->name, true)); + Gtk::ImageMenuItem *item = Gtk::manage(new Gtk::ImageMenuItem(action->name, true)); sp_shortcut_add_accelerator(GTK_WIDGET(item->gobj()), sp_shortcut_get_primary(verb)); @@ -1638,7 +1638,7 @@ void ContextMenu::MakeItemMenu (void) Gtk::MenuItem* mi; /* Item dialog */ - mi = manage(new Gtk::MenuItem(_("_Object Properties..."),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Object Properties..."),1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties)); mi->show(); append(*mi);//insert(*mi,positionOfLastDialog++); @@ -1647,7 +1647,7 @@ void ContextMenu::MakeItemMenu (void) /* Select item */ if (Inkscape::Verb::getbyid( "org.inkscape.followlink" )) { - mi = manage(new Gtk::MenuItem(_("_Select This"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Select This"), 1)); if (_desktop->selection->includes(_item)) { mi->set_sensitive(FALSE); } else { @@ -1658,9 +1658,9 @@ void ContextMenu::MakeItemMenu (void) } - mi = manage(new Gtk::MenuItem(_("Select Same"))); + mi = Gtk::manage(new Gtk::MenuItem(_("Select Same"))); mi->show(); - Gtk::Menu *select_same_submenu = manage(new Gtk::Menu()); + Gtk::Menu *select_same_submenu = Gtk::manage(new Gtk::Menu()); if (_desktop->selection->isEmpty()) { mi->set_sensitive(FALSE); } @@ -1668,42 +1668,42 @@ void ContextMenu::MakeItemMenu (void) append(*mi); /* Select same fill and stroke */ - mi = manage(new Gtk::MenuItem(_("Fill and Stroke"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Fill and Stroke"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke)); mi->set_sensitive(!SP_IS_ANCHOR(_item)); mi->show(); select_same_submenu->append(*mi); /* Select same fill color */ - mi = manage(new Gtk::MenuItem(_("Fill Color"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Fill Color"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillColor)); mi->set_sensitive(!SP_IS_ANCHOR(_item)); mi->show(); select_same_submenu->append(*mi); /* Select same stroke color */ - mi = manage(new Gtk::MenuItem(_("Stroke Color"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Color"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeColor)); mi->set_sensitive(!SP_IS_ANCHOR(_item)); mi->show(); select_same_submenu->append(*mi); /* Select same stroke style */ - mi = manage(new Gtk::MenuItem(_("Stroke Style"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Stroke Style"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameStrokeStyle)); mi->set_sensitive(!SP_IS_ANCHOR(_item)); mi->show(); select_same_submenu->append(*mi); /* Select same stroke style */ - mi = manage(new Gtk::MenuItem(_("Object type"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Object type"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameObjectType)); mi->set_sensitive(!SP_IS_ANCHOR(_item)); mi->show(); select_same_submenu->append(*mi); /* Move to layer */ - mi = manage(new Gtk::MenuItem(_("_Move to layer ..."),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Move to layer ..."), 1)); if (_desktop->selection->isEmpty()) { mi->set_sensitive(FALSE); } else { @@ -1713,7 +1713,7 @@ void ContextMenu::MakeItemMenu (void) append(*mi); /* Create link */ - mi = manage(new Gtk::MenuItem(_("Create _Link"),1)); + mi = Gtk::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(); @@ -1736,7 +1736,7 @@ void ContextMenu::MakeItemMenu (void) } } /* Set mask */ - mi = manage(new Gtk::MenuItem(_("Set Mask"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Set Mask"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask)); if (ClipRefOK || MaskRefOK) { mi->set_sensitive(FALSE); @@ -1747,7 +1747,7 @@ void ContextMenu::MakeItemMenu (void) append(*mi); /* Release mask */ - mi = manage(new Gtk::MenuItem(_("Release Mask"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Release Mask"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask)); if (MaskRefOK) { mi->set_sensitive(TRUE); @@ -1758,7 +1758,7 @@ void ContextMenu::MakeItemMenu (void) append(*mi); /* Set Clip */ - mi = manage(new Gtk::MenuItem(_("Set Cl_ip"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Set Cl_ip"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip)); if (ClipRefOK || MaskRefOK) { mi->set_sensitive(FALSE); @@ -1769,7 +1769,7 @@ void ContextMenu::MakeItemMenu (void) append(*mi); /* Release Clip */ - mi = manage(new Gtk::MenuItem(_("Release C_lip"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Release C_lip"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip)); if (ClipRefOK) { mi->set_sensitive(TRUE); @@ -1780,7 +1780,7 @@ void ContextMenu::MakeItemMenu (void) append(*mi); /* Group */ - mi = manage(new Gtk::MenuItem(_("_Group"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Group"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateGroup)); if (_desktop->selection->isEmpty() || _desktop->selection->single()) { mi->set_sensitive(FALSE); @@ -1882,7 +1882,7 @@ void ContextMenu::ReleaseClip(void) void ContextMenu::MakeGroupMenu(void) { /* Ungroup */ - Gtk::MenuItem* mi = manage(new Gtk::MenuItem(_("_Ungroup"),1)); + Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Ungroup"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup)); mi->show(); append(*mi); @@ -1907,19 +1907,19 @@ void ContextMenu::MakeAnchorMenu(void) Gtk::MenuItem* mi; /* Link dialog */ - mi = manage(new Gtk::MenuItem(_("Link _Properties..."),1)); + mi = Gtk::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 = manage(new Gtk::MenuItem(_("_Follow Link"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Follow Link"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow)); mi->show(); append(*mi); /* Reset transformations */ - mi = manage(new Gtk::MenuItem(_("_Remove Link"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Remove Link"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove)); mi->show(); append(*mi); @@ -1961,13 +1961,13 @@ void ContextMenu::MakeImageMenu (void) const gchar *href = ir->attribute("xlink:href"); /* Image properties */ - mi = manage(new Gtk::MenuItem(_("Image _Properties..."),1)); + mi = Gtk::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 = manage(new Gtk::MenuItem(_("Edit Externally..."),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Edit Externally..."), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit)); mi->show(); insert(*mi,positionOfLastDialog++); @@ -1976,7 +1976,7 @@ void ContextMenu::MakeImageMenu (void) } /* Trace Bitmap */ - mi = manage(new Gtk::MenuItem(_("_Trace Bitmap..."),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Trace Bitmap..."), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap)); mi->show(); insert(*mi,positionOfLastDialog++); @@ -1985,7 +1985,7 @@ void ContextMenu::MakeImageMenu (void) } /* Trace Pixel Art */ - mi = manage(new Gtk::MenuItem(_("Trace Pixel Art"),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("Trace Pixel Art"), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTracePixelArt)); mi->show(); insert(*mi,positionOfLastDialog++); @@ -1995,7 +1995,7 @@ void ContextMenu::MakeImageMenu (void) /* Embed image */ if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { - mi = manage(new Gtk::MenuItem(C_("Context menu", "Embed Image"))); + mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Embed Image"))); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed)); mi->show(); insert(*mi,positionOfLastDialog++); @@ -2006,7 +2006,7 @@ void ContextMenu::MakeImageMenu (void) /* Extract image */ if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) { - mi = manage(new Gtk::MenuItem(C_("Context menu", "Extract Image..."))); + mi = Gtk::manage(new Gtk::MenuItem(C_("Context menu", "Extract Image..."))); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); mi->show(); insert(*mi,positionOfLastDialog++); @@ -2151,7 +2151,7 @@ void ContextMenu::MakeShapeMenu (void) Gtk::MenuItem* mi; /* Item dialog */ - mi = manage(new Gtk::MenuItem(_("_Fill and Stroke..."),1)); + mi = Gtk::manage(new Gtk::MenuItem(_("_Fill and Stroke..."), 1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); mi->show(); insert(*mi,positionOfLastDialog++); @@ -2171,19 +2171,19 @@ void ContextMenu::MakeTextMenu (void) Gtk::MenuItem* mi; /* Fill and Stroke dialog */ - mi = manage(new Gtk::MenuItem(_("_Fill and Stroke..."),1)); + mi = Gtk::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 = manage(new Gtk::MenuItem(_("_Text and Font..."),1)); + mi = Gtk::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 = manage(new Gtk::MenuItem(_("Check Spellin_g..."),1)); + mi = Gtk::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/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index efe25d843..09c505860 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -122,7 +122,7 @@ DocumentMetadata::build_metadata() _page_metadata1.show(); - Gtk::Label *label = manage (new Gtk::Label); + Gtk::Label *label = Gtk::manage (new Gtk::Label); label->set_markup (_("Dublin Core Entities")); label->set_alignment (0.0); @@ -140,7 +140,7 @@ DocumentMetadata::build_metadata() if ( entity->editable == RDF_EDIT_GENERIC ) { EntityEntry *w = EntityEntry::create (entity, _wr); _rdflist.push_back (w); - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 @@ -164,7 +164,7 @@ DocumentMetadata::build_metadata() _page_metadata2.show(); row = 0; - Gtk::Label *llabel = manage (new Gtk::Label); + Gtk::Label *llabel = Gtk::manage (new Gtk::Label); llabel->set_markup (_("License")); llabel->set_alignment (0.0); @@ -178,7 +178,7 @@ DocumentMetadata::build_metadata() /* add license selector pull-down and URI */ ++row; _licensor.init (_wr); - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index a31ab1a09..508fc52b1 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -297,7 +297,7 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); #endif } else { - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 @@ -317,11 +317,11 @@ void DocumentProperties::build_page() { _page_page->show(); - Gtk::Label* label_gen = manage (new Gtk::Label); + Gtk::Label* label_gen = Gtk::manage (new Gtk::Label); label_gen->set_markup (_("General")); - Gtk::Label *label_for = manage (new Gtk::Label); + Gtk::Label *label_for = Gtk::manage (new Gtk::Label); label_for->set_markup (_("Page Size")); - Gtk::Label* label_dsp = manage (new Gtk::Label); + Gtk::Label* label_dsp = Gtk::manage (new Gtk::Label); label_dsp->set_markup (_("Display")); _page_sizer.init(); @@ -356,7 +356,7 @@ void DocumentProperties::build_guides() { _page_guides->show(); - Gtk::Label *label_gui = manage (new Gtk::Label); + Gtk::Label *label_gui = Gtk::manage (new Gtk::Label); label_gui->set_markup (_("Guides")); Gtk::Widget *const widget_array[] = @@ -374,13 +374,13 @@ void DocumentProperties::build_snap() { _page_snap->show(); - Gtk::Label *label_o = manage (new Gtk::Label); + Gtk::Label *label_o = Gtk::manage (new Gtk::Label); label_o->set_markup (_("Snap to objects")); - Gtk::Label *label_gr = manage (new Gtk::Label); + Gtk::Label *label_gr = Gtk::manage (new Gtk::Label); label_gr->set_markup (_("Snap to grids")); - Gtk::Label *label_gu = manage (new Gtk::Label); + Gtk::Label *label_gu = Gtk::manage (new Gtk::Label); label_gu->set_markup (_("Snap to guides")); - Gtk::Label *label_m = manage (new Gtk::Label); + Gtk::Label *label_m = Gtk::manage (new Gtk::Label); label_m->set_markup (_("Miscellaneous")); Gtk::Widget *const array[] = @@ -607,9 +607,9 @@ void DocumentProperties::removeSelectedProfile(){ void DocumentProperties::build_cms() { _page_cms->show(); - Gtk::Label *label_link= manage (new Gtk::Label("", Gtk::ALIGN_START)); + Gtk::Label *label_link= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START)); label_link->set_markup (_("Linked Color Profiles:")); - Gtk::Label *label_avail = manage (new Gtk::Label("", Gtk::ALIGN_START)); + Gtk::Label *label_avail = Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START)); label_avail->set_markup (_("Available Color Profiles:")); _link_btn.set_tooltip_text(_("Link Profile")); @@ -746,7 +746,7 @@ void DocumentProperties::build_scripting() //# External scripts tab _page_external_scripts->show(); - Gtk::Label *label_external= manage (new Gtk::Label("", Gtk::ALIGN_START)); + Gtk::Label *label_external= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START)); label_external->set_markup (_("External script files:")); _external_add_btn.set_tooltip_text(_("Add the current file name or browse for a file")); @@ -835,7 +835,7 @@ void DocumentProperties::build_scripting() //# Embedded scripts tab _page_embedded_scripts->show(); - Gtk::Label *label_embedded= manage (new Gtk::Label("", Gtk::ALIGN_START)); + Gtk::Label *label_embedded= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START)); label_embedded->set_markup (_("Embedded script files:")); _embed_new_btn.set_tooltip_text(_("New")); @@ -922,7 +922,7 @@ void DocumentProperties::build_scripting() // TODO restore? _EmbeddedScriptsList.set_fixed_height_mode(true); //# Set up the Embedded Scripts content box - Gtk::Label *label_embedded_content= manage (new Gtk::Label("", Gtk::ALIGN_START)); + Gtk::Label *label_embedded_content= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START)); label_embedded_content->set_markup (_("Content:")); label_embedded_content->set_alignment(0.0); @@ -1001,7 +1001,7 @@ void DocumentProperties::build_metadata() _page_metadata1->show(); - Gtk::Label *label = manage (new Gtk::Label); + Gtk::Label *label = Gtk::manage (new Gtk::Label); label->set_markup (_("Dublin Core Entities")); label->set_alignment (0.0); @@ -1019,7 +1019,7 @@ void DocumentProperties::build_metadata() if ( entity->editable == RDF_EDIT_GENERIC ) { EntityEntry *w = EntityEntry::create (entity, _wr); _rdflist.push_back (w); - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 @@ -1040,15 +1040,15 @@ void DocumentProperties::build_metadata() } } - Gtk::Button *button_save = manage (new Gtk::Button(_("_Save as default"),1)); + Gtk::Button *button_save = Gtk::manage (new Gtk::Button(_("_Save as default"),1)); button_save->set_tooltip_text(_("Save this metadata as the default metadata")); - Gtk::Button *button_load = manage (new Gtk::Button(_("Use _default"),1)); + Gtk::Button *button_load = Gtk::manage (new Gtk::Button(_("Use _default"),1)); button_load->set_tooltip_text(_("Use the previously saved default metadata here")); #if WITH_GTKMM_3_0 - Gtk::ButtonBox *box_buttons = manage (new Gtk::ButtonBox); + Gtk::ButtonBox *box_buttons = Gtk::manage (new Gtk::ButtonBox); #else - Gtk::HButtonBox *box_buttons = manage (new Gtk::HButtonBox); + Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox); #endif box_buttons->set_layout(Gtk::BUTTONBOX_END); @@ -1063,7 +1063,7 @@ void DocumentProperties::build_metadata() _page_metadata2->show(); row = 0; - Gtk::Label *llabel = manage (new Gtk::Label); + Gtk::Label *llabel = Gtk::manage (new Gtk::Label); llabel->set_markup (_("License")); llabel->set_alignment (0.0); @@ -1077,7 +1077,7 @@ void DocumentProperties::build_metadata() /* add license selector pull-down and URI */ ++row; _licensor.init (_wr); - Gtk::HBox *space = manage (new Gtk::HBox); + Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); #if WITH_GTKMM_3_0 @@ -1545,12 +1545,12 @@ void DocumentProperties::update() Gtk::HBox& DocumentProperties::_createPageTabLabel(const Glib::ustring& label, const char *label_image) { - Gtk::HBox *_tab_label_box = manage(new Gtk::HBox(false, 0)); + Gtk::HBox *_tab_label_box = Gtk::manage(new Gtk::HBox(false, 0)); _tab_label_box->set_spacing(4); _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION, label_image))); - Gtk::Label *_tab_label = manage(new Gtk::Label(label, true)); + Gtk::Label *_tab_label = Gtk::manage(new Gtk::Label(label, true)); _tab_label_box->pack_start(*_tab_label); _tab_label_box->show_all(); diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 19b873d54..c55d55cda 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -131,7 +131,7 @@ FillAndStroke::_savePagePref(guint page_num) void FillAndStroke::_layoutPageFill() { - fillWdgt = manage(sp_fill_style_widget_new()); + fillWdgt = Gtk::manage(sp_fill_style_widget_new()); #if WITH_GTKMM_3_0 _page_fill->table().attach(*fillWdgt, 0, 0, 1, 1); @@ -143,7 +143,7 @@ FillAndStroke::_layoutPageFill() void FillAndStroke::_layoutPageStrokePaint() { - strokeWdgt = manage(sp_stroke_style_paint_widget_new()); + strokeWdgt = Gtk::manage(sp_stroke_style_paint_widget_new()); #if WITH_GTKMM_3_0 _page_stroke_paint->table().attach(*strokeWdgt, 0, 0, 1, 1); @@ -195,11 +195,11 @@ FillAndStroke::showPageStrokeStyle() Gtk::HBox& FillAndStroke::_createPageTabLabel(const Glib::ustring& label, const char *label_image) { - Gtk::HBox *_tab_label_box = manage(new Gtk::HBox(false, 4)); + Gtk::HBox *_tab_label_box = Gtk::manage(new Gtk::HBox(false, 4)); _tab_label_box->pack_start(*Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_DECORATION, label_image))); - Gtk::Label *_tab_label = manage(new Gtk::Label(label, true)); + Gtk::Label *_tab_label = Gtk::manage(new Gtk::Label(label, true)); _tab_label_box->pack_start(*_tab_label); _tab_label_box->show_all(); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 03108b403..d826ece09 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1534,9 +1534,9 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui row++; #if WITH_GTKMM_3_0 - Gtk::ButtonBox *box_buttons = manage(new Gtk::ButtonBox); + Gtk::ButtonBox *box_buttons = Gtk::manage(new Gtk::ButtonBox); #else - Gtk::HButtonBox *box_buttons = manage (new Gtk::HButtonBox); + Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox); #endif box_buttons->set_layout(Gtk::BUTTONBOX_END); @@ -1549,14 +1549,14 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); #endif - UI::Widget::Button *kb_reset = manage(new UI::Widget::Button(_("Reset"), _("Remove all your customized keyboard shortcuts, and revert to the shortcuts in the shortcut file listed above"))); + UI::Widget::Button *kb_reset = Gtk::manage(new UI::Widget::Button(_("Reset"), _("Remove all your customized keyboard shortcuts, and revert to the shortcuts in the shortcut file listed above"))); box_buttons->pack_start(*kb_reset, true, true, 6); box_buttons->set_child_secondary(*kb_reset); - UI::Widget::Button *kb_import = manage(new UI::Widget::Button(_("Import ..."), _("Import custom keyboard shortcuts from a file"))); + UI::Widget::Button *kb_import = Gtk::manage(new UI::Widget::Button(_("Import ..."), _("Import custom keyboard shortcuts from a file"))); box_buttons->pack_end(*kb_import, true, true, 6); - UI::Widget::Button *kb_export = manage(new UI::Widget::Button(_("Export ..."), _("Export custom keyboard shortcuts to a file"))); + UI::Widget::Button *kb_export = Gtk::manage(new UI::Widget::Button(_("Export ..."), _("Export custom keyboard shortcuts to a file"))); box_buttons->pack_end(*kb_export, true, true, 6); kb_reset->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBReset) ); diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 2d4755fd2..4be6716a5 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -1151,9 +1151,9 @@ InputDialogImpl::ConfPanel::ConfPanel() : useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled)); #if WITH_GTKMM_3_0 - Gtk::ButtonBox *buttonBox = manage(new Gtk::ButtonBox); + Gtk::ButtonBox *buttonBox = Gtk::manage(new Gtk::ButtonBox); #else - Gtk::HButtonBox *buttonBox = manage (new Gtk::HButtonBox); + Gtk::HButtonBox *buttonBox = Gtk::manage (new Gtk::HButtonBox); #endif buttonBox->set_layout (Gtk::BUTTONBOX_END); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index f19828b1f..d5540b88a 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -213,7 +213,7 @@ LayerPropertiesDialog::_setup_layers_controls() { _tree.set_model( _store ); _tree.set_headers_visible(false); - Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( + Inkscape::UI::Widget::ImageToggler *eyeRenderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler( INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1; Gtk::TreeViewColumn* col = _tree.get_column(visibleColNum); @@ -221,7 +221,7 @@ LayerPropertiesDialog::_setup_layers_controls() { col->add_attribute( eyeRenderer->property_active(), _model->_colVisible ); } - Inkscape::UI::Widget::ImageToggler * renderer = manage( new Inkscape::UI::Widget::ImageToggler( + Inkscape::UI::Widget::ImageToggler * renderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler( INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-unlocked")) ); int lockedColNum = _tree.append_column("lock", *renderer) - 1; col = _tree.get_column(lockedColNum); @@ -229,7 +229,7 @@ LayerPropertiesDialog::_setup_layers_controls() { col->add_attribute( renderer->property_active(), _model->_colLocked ); } - Gtk::CellRendererText *_text_renderer = manage(new Gtk::CellRendererText()); + Gtk::CellRendererText *_text_renderer = Gtk::manage(new Gtk::CellRendererText()); int nameColNum = _tree.append_column("Name", *_text_renderer) - 1; Gtk::TreeView::Column *_name_column = _tree.get_column(nameColNum); _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 381810f1e..b5dac0595 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -92,7 +92,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i if ( iconName ) { GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName ); gtk_widget_show( child ); - btn.add( *manage(Glib::wrap(child)) ); + btn.add( *Gtk::manage(Glib::wrap(child)) ); btn.set_relief(Gtk::RELIEF_NONE); set = true; } @@ -104,7 +104,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i if ( !set && action && action->image ) { GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image ); gtk_widget_show( child ); - btn.add( *manage(Glib::wrap(child)) ); + btn.add( *Gtk::manage(Glib::wrap(child)) ); set = true; } @@ -149,7 +149,7 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code Gtk::Widget* wrapped = 0; if ( iconWidget ) { - wrapped = manage(Glib::wrap(iconWidget)); + wrapped = Gtk::manage(Glib::wrap(iconWidget)); wrapped->show(); } @@ -809,7 +809,7 @@ LayersPanel::LayersPanel() : _tree.set_reorderable(true); _tree.enable_model_drag_dest (Gdk::ACTION_MOVE); - Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( + Inkscape::UI::Widget::ImageToggler *eyeRenderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler( INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1; eyeRenderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); @@ -821,7 +821,7 @@ LayersPanel::LayersPanel() : } - Inkscape::UI::Widget::ImageToggler * renderer = manage( new Inkscape::UI::Widget::ImageToggler( + Inkscape::UI::Widget::ImageToggler * renderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler( INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-unlocked")) ); int lockedColNum = _tree.append_column("lock", *renderer) - 1; renderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); @@ -832,7 +832,7 @@ LayersPanel::LayersPanel() : col->add_attribute( renderer->property_active(), _model->_colLocked ); } - _text_renderer = manage(new Gtk::CellRendererText()); + _text_renderer = Gtk::manage(new Gtk::CellRendererText()); int nameColNum = _tree.append_column("Name", *_text_renderer) - 1; _name_column = _tree.get_column(nameColNum); _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel); @@ -880,40 +880,40 @@ LayersPanel::LayersPanel() : SPDesktop* targetDesktop = getDesktop(); - Gtk::Button* btn = manage( new Gtk::Button() ); + Gtk::Button* btn = Gtk::manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, INKSCAPE_ICON("list-add"), C_("Layers", "New") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) ); _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK); - btn = manage( new Gtk::Button() ); + btn = Gtk::manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, INKSCAPE_ICON("go-bottom"), C_("Layers", "Bot") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) ); _watchingNonBottom.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); - btn = manage( new Gtk::Button() ); + btn = Gtk::manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, INKSCAPE_ICON("go-down"), C_("Layers", "Dn") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) ); _watchingNonBottom.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); - btn = manage( new Gtk::Button() ); + btn = Gtk::manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, INKSCAPE_ICON("go-up"), C_("Layers", "Up") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) ); _watchingNonTop.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); - btn = manage( new Gtk::Button() ); + btn = Gtk::manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, INKSCAPE_ICON("go-top"), C_("Layers", "Top") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) ); _watchingNonTop.push_back( btn ); _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); -// btn = manage( new Gtk::Button("Dup") ); +// btn = Gtk::manage( new Gtk::Button("Dup") ); // btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) ); // _buttonsRow.add( *btn ); - btn = manage( new Gtk::Button() ); + btn = Gtk::manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, INKSCAPE_ICON("list-remove"), _("X") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) ); _watching.push_back( btn ); @@ -930,19 +930,19 @@ LayersPanel::LayersPanel() : _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_DUPLICATE, 0, "Duplicate", (int)BUTTON_DUPLICATE ) ); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_NEW, 0, "New", (int)BUTTON_NEW ) ); - _popupMenu.append(*manage(new Gtk::SeparatorMenuItem())); + _popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem())); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_SOLO, 0, "Solo", (int)BUTTON_SOLO ) ); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_SHOW_ALL, 0, "Show All", (int)BUTTON_SHOW_ALL ) ); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_HIDE_ALL, 0, "Hide All", (int)BUTTON_HIDE_ALL ) ); - _popupMenu.append(*manage(new Gtk::SeparatorMenuItem())); + _popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem())); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOCK_OTHERS, 0, "Lock Others", (int)BUTTON_LOCK_OTHERS ) ); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOCK_ALL, 0, "Lock All", (int)BUTTON_LOCK_ALL ) ); _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_UNLOCK_ALL, 0, "Unlock All", (int)BUTTON_UNLOCK_ALL ) ); - _popupMenu.append(*manage(new Gtk::SeparatorMenuItem())); + _popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem())); _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, INKSCAPE_ICON("go-up"), "Up", (int)BUTTON_UP ) ); _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, INKSCAPE_ICON("go-down"), "Down", (int)BUTTON_DOWN ) ); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index b81b300e2..0ab2fc9f7 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -172,7 +172,7 @@ LivePathEffectEditor::LivePathEffectEditor() effectlist_selection->signal_changed().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_effect_selection_changed) ); //Add the visibility icon column: - Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( + Inkscape::UI::Widget::ImageToggler *eyeRenderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler( INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1; eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) ); diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 71d1c22d0..f326bb3ee 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -29,7 +29,7 @@ NewFromTemplate::NewFromTemplate() get_vbox()->pack_start(_main_widget); Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); get_vbox()->pack_end(*align, Gtk::PACK_SHRINK); align->set_padding(0, 0, 0, 15); align->add(_create_template_button); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 5e77a28ab..4f0cb211a 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -645,7 +645,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : std::vector swatchSets = _getSwatchSets(); for ( std::vector::iterator it = swatchSets.begin(); it != swatchSets.end(); ++it) { SwatchPage* curr = *it; - Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, curr->_name)); + Gtk::RadioMenuItem* single = Gtk::manage(new Gtk::RadioMenuItem(groupOne, curr->_name)); if ( curr == first ) { hotItem = single; } diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 6b1f4542f..d75f81456 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -42,10 +42,10 @@ TemplateLoadTab::TemplateLoadTab() { set_border_width(10); - _info_widget = manage(new TemplateWidget()); + _info_widget = Gtk::manage(new TemplateWidget()); Gtk::Label *title; - title = manage(new Gtk::Label(_("Search:"))); + title = Gtk::manage(new Gtk::Label(_("Search:"))); _search_box.pack_start(*title, Gtk::PACK_SHRINK); _search_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 5); @@ -55,7 +55,7 @@ TemplateLoadTab::TemplateLoadTab() pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 5); Gtk::ScrolledWindow *scrolled; - scrolled = manage(new Gtk::ScrolledWindow()); + scrolled = Gtk::manage(new Gtk::ScrolledWindow()); scrolled->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); scrolled->add(_tlist_view); _tlist_box.pack_start(*scrolled, Gtk::PACK_EXPAND_WIDGET, 5); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index d8e6f9b4f..ef91962d4 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -47,7 +47,7 @@ TemplateWidget::TemplateWidget() _short_description_label.set_line_wrap(true); Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); pack_end(*align, Gtk::PACK_SHRINK); align->add(_more_info_button); diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index bd467555e..11e75391b 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -778,7 +778,7 @@ TraceDialogImpl::TraceDialogImpl() : rightVBox.pack_start(sioxBox, false, false, 0); //## preview - Gtk::HBox *previewButtonHBox = manage(new Gtk::HBox(false, MARGIN )); + Gtk::HBox *previewButtonHBox = Gtk::manage(new Gtk::HBox(false, MARGIN )); previewLiveButton.set_label(_("Live Preview")); previewLiveButton.set_use_underline(true); previewLiveCallback(); diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 38f6f353f..21f3f38d7 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -49,25 +49,25 @@ PreviewHolder::PreviewHolder() : _wrap(false), _border(BORDER_NONE) { - _scroller = manage(new Gtk::ScrolledWindow()); + _scroller = Gtk::manage(new Gtk::ScrolledWindow()); ((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); #if WITH_GTKMM_3_0 - _insides = manage(new Gtk::Grid()); + _insides = Gtk::manage(new Gtk::Grid()); _insides->set_column_spacing(8); // Add a container with the scroller and a spacer - Gtk::Grid* spaceHolder = manage(new Gtk::Grid()); + Gtk::Grid* spaceHolder = Gtk::manage(new Gtk::Grid()); _scroller->set_hexpand(); _scroller->set_vexpand(); #else - _insides = manage(new Gtk::Table( 1, 2 )); + _insides = Gtk::manage(new Gtk::Table( 1, 2 )); _insides->set_col_spacings( 8 ); // Add a container with the scroller and a spacer - Gtk::Table* spaceHolder = manage( new Gtk::Table(1, 2) ); + Gtk::Table* spaceHolder = Gtk::manage( new Gtk::Table(1, 2) ); #endif _scroller->add( *_insides ); @@ -134,8 +134,8 @@ void PreviewHolder::addPreview( Previewable* preview ) switch(_view) { case VIEW_TYPE_LIST: { - Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); - Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); + Gtk::Widget* label = Gtk::manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); + Gtk::Widget* thing = Gtk::manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); #if WITH_GTKMM_3_0 thing->set_hexpand(); @@ -154,7 +154,7 @@ void PreviewHolder::addPreview( Previewable* preview ) break; case VIEW_TYPE_GRID: { - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio, _border)); + Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio, _border)); int width = 1; int height = 1; @@ -408,10 +408,10 @@ void PreviewHolder::rebuildUI() { #if WITH_GTKMM_3_0 - _insides = manage(new Gtk::Grid()); + _insides = Gtk::manage(new Gtk::Grid()); _insides->set_column_spacing(8); #else - _insides = manage(new Gtk::Table( 1, 2 )); + _insides = Gtk::manage(new Gtk::Table( 1, 2 )); _insides->set_col_spacings( 8 ); #endif @@ -424,10 +424,10 @@ void PreviewHolder::rebuildUI() } for ( unsigned int i = 0; i < items.size(); i++ ) { - Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio, _border)); + Gtk::Widget* label = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio, _border)); //label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border)); + Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border)); #if WITH_GTKMM_3_0 thing->set_hexpand(); @@ -458,19 +458,19 @@ void PreviewHolder::rebuildUI() // If this is the last row, flag so the previews can draw a bottom ::BorderStyle border = ((row == height -1) && (_border == BORDER_SOLID)) ? BORDER_SOLID_LAST_ROW : _border; - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, border)); + Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, border)); if ( !_insides ) { calcGridSize( thing, items.size(), width, height ); #if WITH_GTKMM_3_0 - _insides = manage(new Gtk::Grid()); + _insides = Gtk::manage(new Gtk::Grid()); if (_border == BORDER_WIDE) { _insides->set_column_spacing(1); _insides->set_row_spacing(1); } #else - _insides = manage(new Gtk::Table( height, width )); + _insides = Gtk::manage(new Gtk::Table( height, width )); if (_border == BORDER_WIDE) { _insides->set_col_spacings( 1 ); _insides->set_row_spacings( 1 ); @@ -493,9 +493,9 @@ void PreviewHolder::rebuildUI() } if ( !_insides ) { #if WITH_GTKMM_3_0 - _insides = manage(new Gtk::Grid()); + _insides = Gtk::manage(new Gtk::Grid()); #else - _insides = manage(new Gtk::Table( 1, 2 )); + _insides = Gtk::manage(new Gtk::Table( 1, 2 )); #endif } diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index c729354cb..42f352e3c 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -97,7 +97,7 @@ void Licensor::init (Registry& wr) LicenseItem *i; wr.setUpdating (true); - i = manage (new LicenseItem (&_proprietary_license, _eentry, wr, NULL)); + i = Gtk::manage (new LicenseItem (&_proprietary_license, _eentry, wr, NULL)); Gtk::RadioButtonGroup group = i->get_group(); add (*i); LicenseItem *pd = i; @@ -105,17 +105,17 @@ void Licensor::init (Registry& wr) for (struct rdf_license_t * license = rdf_licenses; license && license->name; license++) { - i = manage (new LicenseItem (license, _eentry, wr, &group)); + i = Gtk::manage (new LicenseItem (license, _eentry, wr, &group)); add(*i); } // add Other at the end before the URI field for the confused ppl. - LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr, &group)); + LicenseItem *io = Gtk::manage (new LicenseItem (&_other_license, _eentry, wr, &group)); add (*io); pd->set_active(); wr.setUpdating (false); - Gtk::HBox *box = manage (new Gtk::HBox); + Gtk::HBox *box = Gtk::manage (new Gtk::HBox); pack_start (*box, true, true, 0); box->pack_start (_eentry->_label, false, false, 5); diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index d60eeefe0..b37137228 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -115,8 +115,8 @@ void Panel::_init() Gtk::RadioMenuItem::Group group; Glib::ustring one_label(_("List")); Glib::ustring two_label(_("Grid")); - Gtk::RadioMenuItem *one = manage(new Gtk::RadioMenuItem(group, one_label)); - Gtk::RadioMenuItem *two = manage(new Gtk::RadioMenuItem(group, two_label)); + Gtk::RadioMenuItem *one = Gtk::manage(new Gtk::RadioMenuItem(group, one_label)); + Gtk::RadioMenuItem *two = Gtk::manage(new Gtk::RadioMenuItem(group, two_label)); if (panel_mode == 0) { one->set_active(true); @@ -128,7 +128,7 @@ void Panel::_init() _non_horizontal.push_back(one); _menu->append(*two); _non_horizontal.push_back(two); - Gtk::MenuItem* sep = manage(new Gtk::SeparatorMenuItem()); + Gtk::MenuItem* sep = Gtk::manage(new Gtk::SeparatorMenuItem()); _menu->append(*sep); _non_horizontal.push_back(sep); one->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 0)); @@ -147,14 +147,14 @@ void Panel::_init() NC_("Swatches height", "Huge") }; - Gtk::MenuItem *sizeItem = manage(new Gtk::MenuItem(heightItemLabel)); - Gtk::Menu *sizeMenu = manage(new Gtk::Menu()); + Gtk::MenuItem *sizeItem = Gtk::manage(new Gtk::MenuItem(heightItemLabel)); + Gtk::Menu *sizeMenu = Gtk::manage(new Gtk::Menu()); sizeItem->set_submenu(*sizeMenu); Gtk::RadioMenuItem::Group heightGroup; for (unsigned int i = 0; i < G_N_ELEMENTS(heightLabels); i++) { Glib::ustring _label(g_dpgettext2(NULL, "Swatches height", heightLabels[i])); - Gtk::RadioMenuItem* _item = manage(new Gtk::RadioMenuItem(heightGroup, _label)); + Gtk::RadioMenuItem* _item = Gtk::manage(new Gtk::RadioMenuItem(heightGroup, _label)); sizeMenu->append(*_item); if (i == panel_size) { _item->set_active(true); @@ -177,8 +177,8 @@ void Panel::_init() NC_("Swatches width", "Wider") }; - Gtk::MenuItem *item = manage( new Gtk::MenuItem(widthItemLabel)); - Gtk::Menu *type_menu = manage(new Gtk::Menu()); + Gtk::MenuItem *item = Gtk::manage( new Gtk::MenuItem(widthItemLabel)); + Gtk::Menu *type_menu = Gtk::manage(new Gtk::Menu()); item->set_submenu(*type_menu); _menu->append(*item); @@ -194,7 +194,7 @@ void Panel::_init() } for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) { Glib::ustring _label(g_dpgettext2(NULL, "Swatches width", widthLabels[i])); - Gtk::RadioMenuItem *_item = manage(new Gtk::RadioMenuItem(widthGroup, _label)); + Gtk::RadioMenuItem *_item = Gtk::manage(new Gtk::RadioMenuItem(widthGroup, _label)); type_menu->append(*_item); if ( i <= hot_index ) { _item->set_active(true); @@ -213,8 +213,8 @@ void Panel::_init() NC_("Swatches border", "Wide"), }; - Gtk::MenuItem *item = manage( new Gtk::MenuItem(widthItemLabel)); - Gtk::Menu *type_menu = manage(new Gtk::Menu()); + Gtk::MenuItem *item = Gtk::manage( new Gtk::MenuItem(widthItemLabel)); + Gtk::Menu *type_menu = Gtk::manage(new Gtk::Menu()); item->set_submenu(*type_menu); _menu->append(*item); @@ -230,7 +230,7 @@ void Panel::_init() } for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) { Glib::ustring _label(g_dpgettext2(NULL, "Swatches border", widthLabels[i])); - Gtk::RadioMenuItem *_item = manage(new Gtk::RadioMenuItem(widthGroup, _label)); + Gtk::RadioMenuItem *_item = Gtk::manage(new Gtk::RadioMenuItem(widthGroup, _label)); type_menu->append(*_item); if ( i <= hot_index ) { _item->set_active(true); @@ -242,7 +242,7 @@ void Panel::_init() { //TRANSLATORS: "Wrap" indicates how colour swatches are displayed Glib::ustring wrap_label(C_("Swatches","Wrap")); - Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrap_label)); + Gtk::CheckMenuItem *check = Gtk::manage(new Gtk::CheckMenuItem(wrap_label)); check->set_active(panel_wrap); _menu->append(*check); _non_vertical.push_back(check); @@ -251,7 +251,7 @@ void Panel::_init() } Gtk::SeparatorMenuItem *sep; - sep = manage(new Gtk::SeparatorMenuItem()); + sep = Gtk::manage(new Gtk::SeparatorMenuItem()); _menu->append(*sep); _menu->show_all_children(); @@ -284,7 +284,7 @@ void Panel::_init() pack_start(_top_bar, false, false); - Gtk::HBox* boxy = manage(new Gtk::HBox()); + Gtk::HBox* boxy = Gtk::manage(new Gtk::HBox()); boxy->pack_start(_contents, true, true); boxy->pack_start(_right_bar, false, true); diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 175f6471c..92cb3f03d 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -429,11 +429,11 @@ RegisteredRadioButtonPair::RegisteredRadioButtonPair (const Glib::ustring& label setProgrammatically = false; - add (*manage (new Gtk::Label (label))); - _rb1 = manage (new Gtk::RadioButton (label1, true)); + add(*Gtk::manage(new Gtk::Label(label))); + _rb1 = Gtk::manage(new Gtk::RadioButton(label1, true)); add (*_rb1); Gtk::RadioButtonGroup group = _rb1->get_group(); - _rb2 = manage (new Gtk::RadioButton (group, label2, true)); + _rb2 = Gtk::manage(new Gtk::RadioButton(group, label2, true)); add (*_rb2); _rb2->set_active(); _rb1->set_tooltip_text(tip1); diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index d166e3831..5fc588fdc 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -71,19 +71,19 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la // hbox _vbox = new Gtk::VBox; - _hbox = manage (new Gtk::HBox); + _hbox = Gtk::manage(new Gtk::HBox); - Gtk::Label *theLabel1 = manage (new Gtk::Label (label1)); + Gtk::Label *theLabel1 = Gtk::manage(new Gtk::Label(label1)); theLabel1->set_use_underline(); theLabel1->set_alignment(0, 0.5); // align the label with the checkbox text above by indenting 22 px. _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); #if WITH_GTKMM_3_0 - _hscale = manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); + _hscale = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); _hscale->set_range(1.0, 51.0); #else - _hscale = manage (new Gtk::HScale (1.0, 51, 1.0)); + _hscale = Gtk::manage (new Gtk::HScale (1.0, 51, 1.0)); #endif theLabel1->set_mnemonic_widget (*_hscale); @@ -96,13 +96,13 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la _hbox->add (*_hscale); - Gtk::Label *theLabel2 = manage (new Gtk::Label (label2)); + Gtk::Label *theLabel2 = Gtk::manage(new Gtk::Label(label2)); theLabel2->set_use_underline(); - Gtk::Label *theLabel3 = manage (new Gtk::Label (label3)); + Gtk::Label *theLabel3 = Gtk::manage(new Gtk::Label(label3)); theLabel3->set_use_underline(); - _button1 = manage (new Gtk::RadioButton); + _button1 = Gtk::manage(new Gtk::RadioButton); _radio_button_group = _button1->get_group(); - _button2 = manage (new Gtk::RadioButton); + _button2 = Gtk::manage(new Gtk::RadioButton); _button2->set_group(_radio_button_group); _button1->set_tooltip_text (tip2); _button2->set_tooltip_text (tip3); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 9567f81ba..a4cca9472 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -114,7 +114,7 @@ StrokeStyle::StrokeStyleButton::StrokeStyleButton(Gtk::RadioButtonGroup &grp, show(); set_mode(false); - Gtk::Widget *px = manage(Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_LARGE_TOOLBAR, icon))); + Gtk::Widget *px = Gtk::manage(Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_LARGE_TOOLBAR, icon))); g_assert(px != NULL); px->show(); add(*px); @@ -198,7 +198,7 @@ StrokeStyle::StrokeStyle() : hb->pack_start(*widthSpin, false, false, 0); unitSelector = new Inkscape::UI::Widget::UnitMenu(); unitSelector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); - Gtk::Widget *us = manage(unitSelector); + Gtk::Widget *us = Gtk::manage(unitSelector); SPDesktop *desktop = SP_ACTIVE_DESKTOP; unitSelector->addUnit(*unit_table.getUnit("%")); @@ -328,7 +328,7 @@ StrokeStyle::StrokeStyle() : // implement a set_mnemonic_source function in the // SPDashSelector class, so that we do not have to // expose any of the underlying widgets? - dashSelector = manage(new SPDashSelector); + dashSelector = Gtk::manage(new SPDashSelector); dashSelector->show(); @@ -354,7 +354,7 @@ StrokeStyle::StrokeStyle() : hb = spw_hbox(table, 1, 1, i); i++; - startMarkerCombo = manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START)); + startMarkerCombo = Gtk::manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START)); startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape")); startMarkerConn = startMarkerCombo->signal_changed().connect( sigc::bind( @@ -363,7 +363,7 @@ StrokeStyle::StrokeStyle() : hb->pack_start(*startMarkerCombo, true, true, 0); - midMarkerCombo = manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID)); + midMarkerCombo = Gtk::manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID)); midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes")); midMarkerConn = midMarkerCombo->signal_changed().connect( sigc::bind( @@ -372,7 +372,7 @@ StrokeStyle::StrokeStyle() : hb->pack_start(*midMarkerCombo, true, true, 0); - endMarkerCombo = manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END)); + endMarkerCombo = Gtk::manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END)); endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape")); endMarkerConn = endMarkerCombo->signal_changed().connect( sigc::bind( -- cgit v1.2.3 From b77af00c5d29d7a88d976530d3354052344151aa Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 31 Mar 2014 00:01:25 +0200 Subject: Removed some operator keywords. (bzr r13237) --- src/extension/internal/filter/color.h | 2 +- src/extension/system.cpp | 2 +- src/factory.h | 6 +++--- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/lpe-rough-hatches.cpp | 4 ++-- src/sp-conn-end.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 7059ad29b..19af6e969 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -941,7 +941,7 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream transparency; std::ostringstream hue; - if (ext->get_param_bool("hue") xor ext->get_param_bool("lightness")) { + if (ext->get_param_bool("hue") ^ ext->get_param_bool("lightness")) { hue << "\n"; } else { hue << ""; diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 7a50826ca..c244d9c16 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -99,7 +99,7 @@ SPDocument *open(Extension *key, gchar const *filename) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool ask = prefs->getBool("/dialogs/import/ask"); Glib::ustring id = Glib::ustring(imod->get_id(), 28); - if (!ask and id.compare( "org.inkscape.input.gdkpixbuf") == 0) { + if (!ask && id.compare( "org.inkscape.input.gdkpixbuf") == 0) { show = false; imod->set_gui(false); } diff --git a/src/factory.h b/src/factory.h index 7e466f95a..c76501cfd 100644 --- a/src/factory.h +++ b/src/factory.h @@ -65,9 +65,9 @@ public: if (it == this->_object_map.end()) { //throw FactoryExceptions::TypeNotRegistered(id); if (!(id.empty() // comments, usually - or id == "rdf:RDF" // no SP node yet - or id == "inkscape:clipboard" // SP node not necessary - or id == "inkscape:_templateinfo")) { + || id == "rdf:RDF" // no SP node yet + || id == "inkscape:clipboard" // SP node not necessary + || id == "inkscape:_templateinfo")) { g_warning("unknown type: %s", id.c_str()); } return NULL; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index e91677e18..581c632f5 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -493,7 +493,7 @@ LPEKnot::doEffect_path (std::vector const &path_in) } } for (unsigned comp = beg_comp; comp < end_comp; comp++){ - assert(dom.at(comp).min() >=0 and dom.at(comp).max() <= size_nondegenerate(gpaths.at(i0))); + assert(dom.at(comp).min() >=0 && dom.at(comp).max() <= size_nondegenerate(gpaths.at(i0))); path_out.push_back(gpaths[i0].portion(dom.at(comp))); } } diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 6ffb913bd..455653e46 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -319,7 +319,7 @@ LPERoughHatches::doEffect_pwd2 (Geom::Piecewise > const & transformed_pwd2_in = transformed_pwd2_in * bend_mat; tilter = Piecewise(shift(Linear(-bend_amount),1)); OptRect bbox = bounds_exact( transformed_pwd2_in ); - if (not(bbox)) return pwd2_in; + if (!(bbox)) return pwd2_in; tilter.setDomain((*bbox)[Y]); transformed_pwd2_in = bend(transformed_pwd2_in, tilter); transformed_pwd2_in = transformed_pwd2_in * bend_mat.inverse(); @@ -381,7 +381,7 @@ LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ Piecewise dx = derivative(x); OptInterval range = bounds_exact(x); - if (not range) return result; + if (!range) return result; std::vector levels = generateLevels(*range, org[X]); std::vector > times; times = multi_roots(x,levels); diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index c136cea66..3e5398ced 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -298,7 +298,7 @@ sp_conn_end_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, // This allows the connector tool to dive into a group's children // And connect to their children's centers. SPObject *parent = refobj->parent; - if (SP_IS_GROUP(parent) and ! SP_IS_LAYER(parent)) { + if (SP_IS_GROUP(parent) && ! SP_IS_LAYER(parent)) { connEnd._group_connection = SP_ITEM(parent)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_conn_end_shape_move), path)); -- cgit v1.2.3 From 7efa1b0a4f2d46fd19b2ff84d9c787cb90c50ee3 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 31 Mar 2014 00:06:27 +0200 Subject: Replaced one more operator. (bzr r13238) --- src/line-geometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index 982762a12..566af8840 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -118,7 +118,7 @@ bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point c // FIXME: Can we assume that it's safe to return true if the vectors point in different directions? return (Geom::dot (v1, v2) < 0); } - return (coords.first >= 0 and coords.second >= 0); + return (coords.first >= 0 && coords.second >= 0); } bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt) -- cgit v1.2.3 From a9c82bf5e7a7cd37cef0500317e4cfa095970d56 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 30 Mar 2014 23:08:49 +0100 Subject: inkjar: Handle return values correctly (bzr r13239) --- src/io/inkjar.cpp | 44 ++++++++++++++++++++++---------------------- src/io/inkjar.h | 6 +++--- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp index b31b98336..fb1fedf55 100644 --- a/src/io/inkjar.cpp +++ b/src/io/inkjar.cpp @@ -64,12 +64,11 @@ namespace Inkjar { -JarFile::JarFile(gchar const*new_filename) -{ - _filename = g_strdup(new_filename); - _last_filename = NULL; - fd = NULL; -} +JarFile::JarFile(gchar const*new_filename) : + _file(NULL), + _filename(g_strdup(new_filename)), + _last_filename(NULL) +{} //fixme: the following should probably just return a const gchar* and not // use strdup @@ -104,7 +103,7 @@ bool JarFile::init_inflation() bool JarFile::open() { - if ((fd = fopen(_filename, "r")) < 0) { + if ((_file = fopen(_filename, "r")) == NULL) { fprintf(stderr, "open failed.\n"); return false; } @@ -116,7 +115,7 @@ bool JarFile::open() bool JarFile::close() { - if (fd >= 0 && !fclose(fd)) { + if (_file != NULL && (fclose(_file) == 0)) { inflateEnd(&_zs); return true; } @@ -257,7 +256,7 @@ GByteArray *JarFile::get_next_file_contents() if (method == 8 || flags & 0x0008) { unsigned int file_length = 0;//uncompressed file length - fseek(fd, eflen, SEEK_CUR); + fseek(_file, eflen, SEEK_CUR); guint8 *file_data = get_compressed_file(compressed_size, file_length, crc, flags); if (file_data == NULL) { @@ -275,7 +274,7 @@ GByteArray *JarFile::get_next_file_contents() } g_byte_array_append(gba, file_data, compressed_size); } else { - fseek(fd, compressed_size+eflen, SEEK_CUR); + fseek(_file, compressed_size+eflen, SEEK_CUR); g_byte_array_free(gba, FALSE); return NULL; } @@ -314,7 +313,7 @@ guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, std::printf("%u bytes written\n", out_a); #endif } - fseek(fd, eflen, SEEK_CUR); + fseek(_file, eflen, SEEK_CUR); g_free(bytes); if (!check_crc(crc, crc2, flags)) { @@ -326,10 +325,10 @@ guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, return bytes; } -int JarFile::read(guint8 *buf, int count) +int JarFile::read(guint8 *buf, unsigned int count) { - int nbytes; - if ((nbytes = fread(buf, 1, count, fd)) != count) { + size_t nbytes; + if ((nbytes = fread(buf, 1, count, _file)) != count) { fprintf(stderr, "read error\n"); exit(1); return 0; @@ -347,22 +346,22 @@ guint8 *JarFile::get_compressed_file(guint32 compressed_size, guint8 in_buffer[RDSZ]; guint8 out_buffer[RDSZ]; - int nbytes; + size_t nbytes; unsigned int leftover_in = compressed_size; GByteArray *gba = g_byte_array_new(); _zs.avail_in = 0; guint32 crc = crc32(0, Z_NULL, 0); - do { - + do { if (!_zs.avail_in) { - - if ((nbytes = fread(in_buffer, 1, - (leftover_in < RDSZ ? leftover_in : RDSZ), fd)) - < 0) { + nbytes = fread(in_buffer, 1, + (leftover_in < RDSZ ? leftover_in : RDSZ), _file); + + if(ferror(_file) != 0) { fprintf(stderr, "jarfile read error"); } + _zs.avail_in = nbytes; _zs.next_in = in_buffer; crc = crc32(crc, in_buffer, _zs.avail_in); @@ -453,7 +452,7 @@ JarFile& JarFile::operator=(JarFile const& rhs) _last_filename = NULL; else _last_filename = g_strdup(rhs._last_filename); - fd = rhs.fd; + _file = rhs._file; return *this; } @@ -545,3 +544,4 @@ int main(int argc, char *argv[]) return 0; } #endif +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/io/inkjar.h b/src/io/inkjar.h index ee6e33526..637c05d80 100644 --- a/src/io/inkjar.h +++ b/src/io/inkjar.h @@ -91,7 +91,7 @@ typedef uint32_t ub4; class JarFile { public: - JarFile() : fd(NULL), _filename(NULL), _last_filename(NULL) {} + JarFile() : _file(NULL), _filename(NULL), _last_filename(NULL) {} virtual ~JarFile(); JarFile(gchar const *new_filename); @@ -99,14 +99,14 @@ public: gchar *get_last_filename() const; bool open(); bool close(); - int read(guint8 *buf, int count); + int read(guint8 *buf, unsigned int count); JarFile(JarFile const &rhs); JarFile &operator=(JarFile const &rhs); private: - FILE *fd; // File descriptor + FILE *_file; // File descriptor gchar *_filename; z_stream _zs; gchar *_last_filename; -- cgit v1.2.3 From 8ad7f3d261619d168ee0bf0e54824f9f354d2970 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 31 Mar 2014 00:44:37 +0200 Subject: imageicon: clean up unnecessary file existance check introduced in rev 12263. Could theoretically lead to uninitialized value use (of "info" struct) same for filedialogimpl-gtkmm (bzr r13240) --- src/ui/dialog/filedialogimpl-gtkmm.cpp | 31 ++++++++++--------- src/ui/widget/imageicon.cpp | 55 +++++++++++++--------------------- 2 files changed, 36 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index fdc9cecc3..60b437575 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -514,10 +514,11 @@ void SVGPreview::showTooLarge(long fileLength) bool SVGPreview::set(Glib::ustring &fileName, int dialogType) { - if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) + if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) { + showNoPreview(); return false; + } - //g_message("fname:%s", fileName.c_str()); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) { showNoPreview(); @@ -525,24 +526,22 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) } if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) - { + { Glib::ustring fileNameUtf8 = Glib::filename_to_utf8(fileName); - gchar *fName = const_cast(fileNameUtf8.c_str()); + gchar *fName = const_cast(fileNameUtf8.c_str()); // const-cast probably not necessary? (not necessary on Windows version of stat()) struct stat info; - if (g_file_test (fName, G_FILE_TEST_EXISTS) && g_stat(fName, &info)) - { - g_warning("SVGPreview::set() : %s : %s", - fName, strerror(errno)); - return FALSE; - } - long fileLen = info.st_size; - if (fileLen > 0xA00000L) - { + if (g_stat(fName, &info)) // stat returns 0 upon success + { + g_warning("SVGPreview::set() : %s : %s", fName, strerror(errno)); + return false; + } + if (info.st_size > 0xA00000L) + { showingNoPreview = false; - showTooLarge(fileLen); - return FALSE; - } + showTooLarge(info.st_size); + return false; } + } Glib::ustring svg = ".svg"; Glib::ustring svgz = ".svgz"; diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index cf41a16a4..22abd04ba 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -369,60 +369,47 @@ isValidImageIconFile(const Glib::ustring &fileName) return false; } +/// \fixme This function is almost an exact duplicate of SVGPreview::set() in ui/dialog/filedialogimpl-gtkmm.cpp. bool ImageIcon::show(const Glib::ustring &fileName) { - - if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) + if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) { + showBrokenImage("File does not exist"); return false; + } - gchar *fName = const_cast(fileName.c_str()); - //g_message("fname:%s\n", fName); - - - if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) - { + if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { + gchar *fName = const_cast(fileName.c_str()); // this const-cast seems not necessary, was it put there because of older sys/stat.h version? struct stat info; - if (g_file_test (fName, G_FILE_TEST_EXISTS) && stat(fName, &info)) - { - Glib::ustring err = "cannot get file info"; - showBrokenImage(err); + if (stat(fName, &info)) // stat returns 0 upon success + { + showBrokenImage("Cannot get file info"); return false; - } - long fileLen = info.st_size; - if (fileLen > 0x150000L) - { - Glib::ustring err = "File too large"; - showBrokenImage(err); + } + if (info.st_size > 0x150000L) { + showBrokenImage("File too large"); return false; - } } + } Glib::ustring svg = ".svg"; Glib::ustring svgz = ".svgz"; - if (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz) ) - { - if (!showSvgFile(fileName)) - { + if (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz)) { + if (!showSvgFile(fileName)) { showBrokenImage(bitmapError); return false; - } - return true; } - else if (isValidImageIconFile(fileName)) - { - if (!showBitmap(fileName)) - { + return true; + } else if (isValidImageIconFile(fileName)) { + if (!showBitmap(fileName)) { showBrokenImage(bitmapError); return false; - } - return true; } - else - { + return true; + } else { showBrokenImage("unsupported file type"); return false; - } + } } -- cgit v1.2.3 From 4f1e7157051832f957fc9acfe4ebc71a9e76c4e8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 31 Mar 2014 00:55:21 +0200 Subject: better code format filedialogimpl-gtkmm.cpp. Also cleanup some minor code issues (bzr r13241) --- src/ui/dialog/filedialogimpl-gtkmm.cpp | 1163 +++++++++++++++----------------- 1 file changed, 549 insertions(+), 614 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 60b437575..8ba3ad684 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -18,7 +18,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include "filedialogimpl-gtkmm.h" @@ -29,7 +29,7 @@ #include "preferences.h" #ifdef WITH_GNOME_VFS -# include +#include #endif #include @@ -46,24 +46,19 @@ #include "svg-view-widget.h" #include "inkscape.h" -//Routines from file.cpp +// Routines from file.cpp #undef INK_DUMP_FILENAME_CONV #ifdef INK_DUMP_FILENAME_CONV -void dump_str( const gchar* str, const gchar* prefix ); -void dump_ustr( const Glib::ustring& ustr ); +void dump_str(const gchar *str, const gchar *prefix); +void dump_ustr(const Glib::ustring &ustr); #endif -namespace Inkscape -{ -namespace UI -{ -namespace Dialog -{ - - +namespace Inkscape { +namespace UI { +namespace Dialog { @@ -71,64 +66,51 @@ namespace Dialog //### U T I L I T Y //######################################################################## -void -fileDialogExtensionToPattern(Glib::ustring &pattern, - Glib::ustring &extension) +void fileDialogExtensionToPattern(Glib::ustring &pattern, Glib::ustring &extension) { - for (unsigned int i = 0; i < extension.length(); i++ ) - { + for (unsigned int i = 0; i < extension.length(); ++i) { Glib::ustring::value_type ch = extension[i]; - if ( Glib::Unicode::isalpha(ch) ) - { + if (Glib::Unicode::isalpha(ch)) { pattern += '['; pattern += Glib::Unicode::toupper(ch); pattern += Glib::Unicode::tolower(ch); pattern += ']'; - } - else - { + } else { pattern += ch; - } } + } } -void -findEntryWidgets(Gtk::Container *parent, - std::vector &result) +void findEntryWidgets(Gtk::Container *parent, std::vector &result) { - if (!parent) + if (!parent) { return; + } std::vector children = parent->get_children(); - for (unsigned int i=0; igobj(); if (GTK_IS_ENTRY(wid)) - result.push_back(dynamic_cast(child)); + result.push_back(dynamic_cast(child)); else if (GTK_IS_CONTAINER(wid)) findEntryWidgets(dynamic_cast(child), result); - } - + } } -void -findExpanderWidgets(Gtk::Container *parent, - std::vector &result) +void findExpanderWidgets(Gtk::Container *parent, std::vector &result) { if (!parent) return; std::vector children = parent->get_children(); - for (unsigned int i=0; igobj(); if (GTK_IS_EXPANDER(wid)) - result.push_back(dynamic_cast(child)); + result.push_back(dynamic_cast(child)); else if (GTK_IS_CONTAINER(wid)) findExpanderWidgets(dynamic_cast(child), result); - } - + } } @@ -144,13 +126,13 @@ bool SVGPreview::setDocument(SPDocument *doc) doc->doRef(); document = doc; - //This should remove it from the box, and free resources + // This should remove it from the box, and free resources if (viewerGtk) Gtk::Container::remove(*viewerGtk); - viewerGtk = Glib::wrap(sp_svg_view_widget_new(doc)); + viewerGtk = Glib::wrap(sp_svg_view_widget_new(doc)); Gtk::VBox *vbox = Glib::wrap(gobj()); - vbox->pack_start(*viewerGtk, TRUE, TRUE, 0); + vbox->pack_start(*viewerGtk, TRUE, TRUE, 0); viewerGtk->show(); return true; } @@ -166,7 +148,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName) * I don't know why passing false to keepalive is bad. But it * prevents the display of an svg with a non-ascii filename */ - SPDocument *doc = SPDocument::createNewDoc (fileName.c_str(), true); + SPDocument *doc = SPDocument::createNewDoc(fileName.c_str(), true); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -189,7 +171,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) gint len = (gint)strlen(xmlBuffer); SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0); if (!doc) { - g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); + g_warning("SVGView: error loading buffer '%s'\n", xmlBuffer); return false; } @@ -216,21 +198,22 @@ void SVGPreview::showImage(Glib::ustring &theFileName) # display it nicely? #####################################*/ - //Arbitrary size of svg doc -- rather 'portrait' shaped - gint previewWidth = 400; + // Arbitrary size of svg doc -- rather 'portrait' shaped + gint previewWidth = 400; gint previewHeight = 600; - //Get some image info. Smart pointer does not need to be deleted + // Get some image info. Smart pointer does not need to be deleted Glib::RefPtr img(NULL); - try { + try + { img = Gdk::Pixbuf::create_from_file(fileName); } - catch (const Glib::FileError & e) + catch (const Glib::FileError &e) { g_message("caught Glib::FileError in SVGPreview::showImage"); return; } - catch (const Gdk::PixbufError & e) + catch (const Gdk::PixbufError &e) { g_message("Gdk::PixbufError in SVGPreview::showImage"); return; @@ -241,70 +224,66 @@ void SVGPreview::showImage(Glib::ustring &theFileName) return; } - gint imgWidth = img->get_width(); + gint imgWidth = img->get_width(); gint imgHeight = img->get_height(); - //Find the minimum scale to fit the image inside the preview area - double scaleFactorX = (0.9 *(double)previewWidth) / ((double)imgWidth); - double scaleFactorY = (0.9 *(double)previewHeight) / ((double)imgHeight); + // Find the minimum scale to fit the image inside the preview area + double scaleFactorX = (0.9 * (double)previewWidth) / ((double)imgWidth); + double scaleFactorY = (0.9 * (double)previewHeight) / ((double)imgHeight); double scaleFactor = scaleFactorX; if (scaleFactorX > scaleFactorY) scaleFactor = scaleFactorY; - //Now get the resized values - gint scaledImgWidth = (int) (scaleFactor * (double)imgWidth); - gint scaledImgHeight = (int) (scaleFactor * (double)imgHeight); + // Now get the resized values + gint scaledImgWidth = (int)(scaleFactor * (double)imgWidth); + gint scaledImgHeight = (int)(scaleFactor * (double)imgHeight); - //center the image on the area - gint imgX = (previewWidth - scaledImgWidth) / 2; + // center the image on the area + gint imgX = (previewWidth - scaledImgWidth) / 2; gint imgY = (previewHeight - scaledImgHeight) / 2; - //wrap a rectangle around the image - gint rectX = imgX-1; - gint rectY = imgY-1; - gint rectWidth = scaledImgWidth +2; - gint rectHeight = scaledImgHeight+2; - - //Our template. Modify to taste - gchar const *xformat = - "\n" - "\n" //# VALUES HERE - "\n" - "\n" - "\n" - "%d x %d\n" //# VALUES HERE - "\n\n"; - - //if (!Glib::get_charset()) //If we are not utf8 + // wrap a rectangle around the image + gint rectX = imgX - 1; + gint rectY = imgY - 1; + gint rectWidth = scaledImgWidth + 2; + gint rectHeight = scaledImgHeight + 2; + + // Our template. Modify to taste + gchar const *xformat = "\n" + "\n" //# VALUES HERE + "\n" + "\n" + "\n" + "%d x %d\n" //# VALUES HERE + "\n\n"; + + // if (!Glib::get_charset()) //If we are not utf8 fileName = Glib::filename_to_utf8(fileName); - //Fill in the template + // Fill in the template /* FIXME: Do proper XML quoting for fileName. */ - gchar *xmlBuffer = g_strdup_printf(xformat, - previewWidth, previewHeight, - imgX, imgY, scaledImgWidth, scaledImgHeight, - fileName.c_str(), - rectX, rectY, rectWidth, rectHeight, - imgWidth, imgHeight); + gchar *xmlBuffer = + g_strdup_printf(xformat, previewWidth, previewHeight, imgX, imgY, scaledImgWidth, scaledImgHeight, + fileName.c_str(), rectX, rectY, rectWidth, rectHeight, imgWidth, imgHeight); - //g_message("%s\n", xmlBuffer); + // g_message("%s\n", xmlBuffer); - //now show it! + // now show it! setFromMem(xmlBuffer); g_free(xmlBuffer); } @@ -313,97 +292,95 @@ void SVGPreview::showImage(Glib::ustring &theFileName) void SVGPreview::showNoPreview() { - //Are we already showing it? + // Are we already showing it? if (showingNoPreview) return; - //Arbitrary size of svg doc -- rather 'portrait' shaped - gint previewWidth = 300; + // Arbitrary size of svg doc -- rather 'portrait' shaped + gint previewWidth = 300; gint previewHeight = 600; - //Our template. Modify to taste + // Our template. Modify to taste gchar const *xformat = - "\n" - "\n" //# VALUES HERE - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "%s\n" //# VALUE HERE - "\n\n"; - - //Fill in the template - gchar *xmlBuffer = g_strdup_printf(xformat, - previewWidth, previewHeight, _("No preview")); - - //g_message("%s\n", xmlBuffer); - - //now show it! + "\n" + "\n" //# VALUES HERE + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + " \n" + "%s\n" //# VALUE HERE + "\n\n"; + + // Fill in the template + gchar *xmlBuffer = g_strdup_printf(xformat, previewWidth, previewHeight, _("No preview")); + + // g_message("%s\n", xmlBuffer); + + // now show it! setFromMem(xmlBuffer); g_free(xmlBuffer); showingNoPreview = true; - } @@ -414,101 +391,99 @@ void SVGPreview::showNoPreview() void SVGPreview::showTooLarge(long fileLength) { - //Arbitrary size of svg doc -- rather 'portrait' shaped - gint previewWidth = 300; + // Arbitrary size of svg doc -- rather 'portrait' shaped + gint previewWidth = 300; gint previewHeight = 600; - //Our template. Modify to taste + // Our template. Modify to taste gchar const *xformat = - "\n" - "\n" //# VALUES HERE - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "%5.1f MB\n" //# VALUE HERE - "%s\n" //# VALUE HERE - "\n\n"; - - //Fill in the template + "\n" + "\n" //# VALUES HERE + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "%5.1f MB\n" //# VALUE HERE + "%s\n" //# VALUE HERE + "\n\n"; + + // Fill in the template double floatFileLength = ((double)fileLength) / 1048576.0; - //printf("%ld %f\n", fileLength, floatFileLength); - gchar *xmlBuffer = g_strdup_printf(xformat, - previewWidth, previewHeight, floatFileLength, - _("too large for preview")); + // printf("%ld %f\n", fileLength, floatFileLength); + gchar *xmlBuffer = + g_strdup_printf(xformat, previewWidth, previewHeight, floatFileLength, _("too large for preview")); - //g_message("%s\n", xmlBuffer); + // g_message("%s\n", xmlBuffer); - //now show it! + // now show it! setFromMem(xmlBuffer); g_free(xmlBuffer); - } bool SVGPreview::set(Glib::ustring &fileName, int dialogType) @@ -525,18 +500,17 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) return false; } - if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) - { + if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { Glib::ustring fileNameUtf8 = Glib::filename_to_utf8(fileName); - gchar *fName = const_cast(fileNameUtf8.c_str()); // const-cast probably not necessary? (not necessary on Windows version of stat()) + gchar *fName = const_cast( + fileNameUtf8.c_str()); // const-cast probably not necessary? (not necessary on Windows version of stat()) struct stat info; if (g_stat(fName, &info)) // stat returns 0 upon success { g_warning("SVGPreview::set() : %s : %s", fName, strerror(errno)); return false; } - if (info.st_size > 0xA00000L) - { + if (info.st_size > 0xA00000L) { showingNoPreview = false; showTooLarge(info.st_size); return false; @@ -547,8 +521,7 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) Glib::ustring svgz = ".svgz"; if ((dialogType == SVG_TYPES || dialogType == IMPORT_TYPES) && - (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz) ) - ) { + (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz))) { bool retval = setFileName(fileName); showingNoPreview = false; return retval; @@ -566,16 +539,15 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) SVGPreview::SVGPreview() { if (!INKSCAPE) - inkscape_application_init("",false); + inkscape_application_init("", false); document = NULL; viewerGtk = NULL; - set_size_request(150,150); + set_size_request(150, 150); showingNoPreview = false; } SVGPreview::~SVGPreview() { - } @@ -588,32 +560,30 @@ void FileDialogBaseGtk::internalSetup() // Open executable file dialogs don't need the preview panel if (_dialogType != EXE_TYPES) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool enablePreview = prefs->getBool( preferenceBase + "/enable_preview", true); + bool enablePreview = prefs->getBool(preferenceBase + "/enable_preview", true); - previewCheckbox.set_label( Glib::ustring(_("Enable preview")) ); - previewCheckbox.set_active( enablePreview ); + previewCheckbox.set_label(Glib::ustring(_("Enable preview"))); + previewCheckbox.set_active(enablePreview); - previewCheckbox.signal_toggled().connect( - sigc::mem_fun(*this, &FileDialogBaseGtk::_previewEnabledCB) ); + previewCheckbox.signal_toggled().connect(sigc::mem_fun(*this, &FileDialogBaseGtk::_previewEnabledCB)); - //Catch selection-changed events, so we can adjust the text widget - signal_update_preview().connect( - sigc::mem_fun(*this, &FileDialogBaseGtk::_updatePreviewCallback) ); + // Catch selection-changed events, so we can adjust the text widget + signal_update_preview().connect(sigc::mem_fun(*this, &FileDialogBaseGtk::_updatePreviewCallback)); //###### Add a preview widget set_preview_widget(svgPreview); - set_preview_widget_active( enablePreview ); - set_use_preview_label (false); + set_preview_widget_active(enablePreview); + set_use_preview_label(false); } } -void FileDialogBaseGtk::cleanup( bool showConfirmed ) +void FileDialogBaseGtk::cleanup(bool showConfirmed) { if (_dialogType != EXE_TYPES) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if ( showConfirmed ) { - prefs->setBool( preferenceBase + "/enable_preview", previewCheckbox.get_active() ); + if (showConfirmed) { + prefs->setBool(preferenceBase + "/enable_preview", previewCheckbox.get_active()); } } } @@ -623,7 +593,7 @@ void FileDialogBaseGtk::_previewEnabledCB() { bool enabled = previewCheckbox.get_active(); set_preview_widget_active(enabled); - if ( enabled ) { + if (enabled) { _updatePreviewCallback(); } else { // Clears out any current preview image. @@ -642,12 +612,12 @@ void FileDialogBaseGtk::_updatePreviewCallback() bool enabled = previewCheckbox.get_active(); #ifdef WITH_GNOME_VFS - if ( fileName.empty() && gnome_vfs_initialized() ) { + if (fileName.empty() && gnome_vfs_initialized()) { fileName = get_preview_uri(); } #endif - if ( enabled && !fileName.empty() ) { + if (enabled && !fileName.empty()) { svgPreview.set(fileName, _dialogType); } else { svgPreview.showNoPreview(); @@ -662,11 +632,9 @@ void FileDialogBaseGtk::_updatePreviewCallback() /** * Constructor. Not called directly. Use the factory. */ -FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, - const Glib::ustring &dir, - FileDialogType fileTypes, - const Glib::ustring &title) : - FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_OPEN, fileTypes, "/dialogs/open") +FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window &parentWindow, const Glib::ustring &dir, + FileDialogType fileTypes, const Glib::ustring &title) + : FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_OPEN, fileTypes, "/dialogs/open") { @@ -699,7 +667,8 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, Glib::ustring::size_type len = udir.length(); // leaving a trailing backslash on the directory name leads to the infamous // double-directory bug on win32 - if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); + if (len != 0 && udir[len - 1] == '\\') + udir.erase(len - 1); if (_dialogType == EXE_TYPES) { set_filename(udir.c_str()); } else { @@ -708,21 +677,18 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, } if (_dialogType != EXE_TYPES) { - set_extra_widget( previewCheckbox ); + set_extra_widget(previewCheckbox); } //###### Add the file types menu createFilterMenu(); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK)); + set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK)); //###### Allow easy access to our examples folder - if ( Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_EXISTS) - && Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_IS_DIR) - && g_path_is_absolute(INKSCAPE_EXAMPLESDIR) - ) - { + if (Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_EXISTS) && + Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_IS_DIR) && g_path_is_absolute(INKSCAPE_EXAMPLESDIR)) { add_shortcut_folder(INKSCAPE_EXAMPLESDIR); } } @@ -732,23 +698,22 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, */ FileOpenDialogImplGtk::~FileOpenDialogImplGtk() { - } void FileOpenDialogImplGtk::addFilterMenu(Glib::ustring name, Glib::ustring pattern) { #if WITH_GTKMM_3_0 - Glib::RefPtr allFilter = Gtk::FileFilter::create(); - allFilter->set_name(_(name.c_str())); - allFilter->add_pattern(pattern); + Glib::RefPtr allFilter = Gtk::FileFilter::create(); + allFilter->set_name(_(name.c_str())); + allFilter->add_pattern(pattern); #else - Gtk::FileFilter allFilter; - allFilter.set_name(_(name.c_str())); - allFilter.add_pattern(pattern); + Gtk::FileFilter allFilter; + allFilter.set_name(_(name.c_str())); + allFilter.add_pattern(pattern); #endif - extensionMap[Glib::ustring(_("All Files"))]=NULL; - add_filter(allFilter); + extensionMap[Glib::ustring(_("All Files"))] = NULL; + add_filter(allFilter); } void FileOpenDialogImplGtk::createFilterMenu() @@ -767,68 +732,69 @@ void FileOpenDialogImplGtk::createFilterMenu() allFilter.set_name(_("All Files")); allFilter.add_pattern("*"); #endif - extensionMap[Glib::ustring(_("All Files"))]=NULL; + extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); } else { #if WITH_GTKMM_3_0 Glib::RefPtr allInkscapeFilter = Gtk::FileFilter::create(); allInkscapeFilter->set_name(_("All Inkscape Files")); - - Glib::RefPtr allFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allFilter = Gtk::FileFilter::create(); allFilter->set_name(_("All Files")); allFilter->add_pattern("*"); - - Glib::RefPtr allImageFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allImageFilter = Gtk::FileFilter::create(); allImageFilter->set_name(_("All Images")); - - Glib::RefPtr allVectorFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allVectorFilter = Gtk::FileFilter::create(); allVectorFilter->set_name(_("All Vectors")); - - Glib::RefPtr allBitmapFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allBitmapFilter = Gtk::FileFilter::create(); allBitmapFilter->set_name(_("All Bitmaps")); #else Gtk::FileFilter allInkscapeFilter; allInkscapeFilter.set_name(_("All Inkscape Files")); - - Gtk::FileFilter allFilter; + + Gtk::FileFilter allFilter; allFilter.set_name(_("All Files")); allFilter.add_pattern("*"); - - Gtk::FileFilter allImageFilter; + + Gtk::FileFilter allImageFilter; allImageFilter.set_name(_("All Images")); - - Gtk::FileFilter allVectorFilter; + + Gtk::FileFilter allVectorFilter; allVectorFilter.set_name(_("All Vectors")); - - Gtk::FileFilter allBitmapFilter; + + Gtk::FileFilter allBitmapFilter; allBitmapFilter.set_name(_("All Bitmaps")); #endif - extensionMap[Glib::ustring(_("All Inkscape Files"))]=NULL; + extensionMap[Glib::ustring(_("All Inkscape Files"))] = NULL; add_filter(allInkscapeFilter); - extensionMap[Glib::ustring(_("All Files"))]=NULL; + extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); - - extensionMap[Glib::ustring(_("All Images"))]=NULL; + + extensionMap[Glib::ustring(_("All Images"))] = NULL; add_filter(allImageFilter); - extensionMap[Glib::ustring(_("All Vectors"))]=NULL; + extensionMap[Glib::ustring(_("All Vectors"))] = NULL; add_filter(allVectorFilter); - extensionMap[Glib::ustring(_("All Bitmaps"))]=NULL; + extensionMap[Glib::ustring(_("All Bitmaps"))] = NULL; add_filter(allBitmapFilter); - //patterns added dynamically below + // patterns added dynamically below Inkscape::Extension::DB::InputList extension_list; Inkscape::Extension::db.get_input_list(extension_list); for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); current_item != extension_list.end(); ++current_item) { - Inkscape::Extension::Input * imod = *current_item; + Inkscape::Extension::Input *imod = *current_item; // FIXME: would be nice to grey them out instead of not listing them - if (imod->deactivated()) continue; + if (imod->deactivated()) + continue; Glib::ustring upattern("*"); Glib::ustring extension = imod->get_extension(); @@ -837,7 +803,7 @@ void FileOpenDialogImplGtk::createFilterMenu() Glib::ustring uname(_(imod->get_filetypename())); #if WITH_GTKMM_3_0 - Glib::RefPtr filter = Gtk::FileFilter::create(); + Glib::RefPtr filter = Gtk::FileFilter::create(); filter->set_name(uname); filter->add_pattern(upattern); #else @@ -849,14 +815,14 @@ void FileOpenDialogImplGtk::createFilterMenu() add_filter(filter); extensionMap[uname] = imod; - //g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); +// g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); #if WITH_GTKMM_3_0 allInkscapeFilter->add_pattern(upattern); - if ( strncmp("image", imod->get_mimetype(), 5)==0 ) + if (strncmp("image", imod->get_mimetype(), 5) == 0) allImageFilter->add_pattern(upattern); #else allInkscapeFilter.add_pattern(upattern); - if ( strncmp("image", imod->get_mimetype(), 5)==0 ) + if (strncmp("image", imod->get_mimetype(), 5) == 0) allImageFilter.add_pattern(upattern); #endif @@ -864,32 +830,32 @@ void FileOpenDialogImplGtk::createFilterMenu() // g_print ("%s\n", imod->get_mimetype()); // I don't know of any other way to define "bitmap" formats other than by listing them - if ( - strncmp("image/png", imod->get_mimetype(), 9)==0 || - strncmp("image/jpeg", imod->get_mimetype(), 10)==0 || - strncmp("image/gif", imod->get_mimetype(), 9)==0 || - strncmp("image/x-icon", imod->get_mimetype(), 12)==0 || - strncmp("image/x-navi-animation", imod->get_mimetype(), 22)==0 || - strncmp("image/x-cmu-raster", imod->get_mimetype(), 18)==0 || - strncmp("image/x-xpixmap", imod->get_mimetype(), 15)==0 || - strncmp("image/bmp", imod->get_mimetype(), 9)==0 || - strncmp("image/vnd.wap.wbmp", imod->get_mimetype(), 18)==0 || - strncmp("image/tiff", imod->get_mimetype(), 10)==0 || - strncmp("image/x-xbitmap", imod->get_mimetype(), 15)==0 || - strncmp("image/x-tga", imod->get_mimetype(), 11)==0 || - strncmp("image/x-pcx", imod->get_mimetype(), 11)==0 - ) + if (strncmp("image/png", imod->get_mimetype(), 9) == 0 || + strncmp("image/jpeg", imod->get_mimetype(), 10) == 0 || + strncmp("image/gif", imod->get_mimetype(), 9) == 0 || + strncmp("image/x-icon", imod->get_mimetype(), 12) == 0 || + strncmp("image/x-navi-animation", imod->get_mimetype(), 22) == 0 || + strncmp("image/x-cmu-raster", imod->get_mimetype(), 18) == 0 || + strncmp("image/x-xpixmap", imod->get_mimetype(), 15) == 0 || + strncmp("image/bmp", imod->get_mimetype(), 9) == 0 || + strncmp("image/vnd.wap.wbmp", imod->get_mimetype(), 18) == 0 || + strncmp("image/tiff", imod->get_mimetype(), 10) == 0 || + strncmp("image/x-xbitmap", imod->get_mimetype(), 15) == 0 || + strncmp("image/x-tga", imod->get_mimetype(), 11) == 0 || + strncmp("image/x-pcx", imod->get_mimetype(), 11) == 0) + { #if WITH_GTKMM_3_0 allBitmapFilter->add_pattern(upattern); #else allBitmapFilter.add_pattern(upattern); #endif - else + } else { #if WITH_GTKMM_3_0 allVectorFilter->add_pattern(upattern); #else allVectorFilter.add_pattern(upattern); #endif + } } } return; @@ -898,50 +864,43 @@ void FileOpenDialogImplGtk::createFilterMenu() /** * Show this dialog modally. Return true if user hits [OK] */ -bool -FileOpenDialogImplGtk::show() +bool FileOpenDialogImplGtk::show() { - set_modal (TRUE); //Window - sp_transientize(GTK_WIDGET(gobj())); //Make transient - gint b = run(); //Dialog + set_modal(TRUE); // Window + sp_transientize(GTK_WIDGET(gobj())); // Make transient + gint b = run(); // Dialog svgPreview.showNoPreview(); hide(); - if (b == Gtk::RESPONSE_OK) - { - //This is a hack, to avoid the warning messages that - //Gtk::FileChooser::get_filter() returns - //should be: Gtk::FileFilter *filter = get_filter(); + if (b == Gtk::RESPONSE_OK) { + // This is a hack, to avoid the warning messages that + // Gtk::FileChooser::get_filter() returns + // should be: Gtk::FileFilter *filter = get_filter(); GtkFileChooser *gtkFileChooser = Gtk::FileChooser::gobj(); GtkFileFilter *filter = gtk_file_chooser_get_filter(gtkFileChooser); - if (filter) - { - //Get which extension was chosen, if any + if (filter) { + // Get which extension was chosen, if any extension = extensionMap[gtk_file_filter_get_name(filter)]; - } + } myFilename = get_filename(); #ifdef WITH_GNOME_VFS if (myFilename.empty() && gnome_vfs_initialized()) myFilename = get_uri(); #endif - cleanup( true ); - return TRUE; - } - else - { - cleanup( false ); - return FALSE; - } + cleanup(true); + return true; + } else { + cleanup(false); + return false; + } } - /** * Get the file extension type that was selected by the user. Valid after an [OK] */ -Inkscape::Extension::Extension * -FileOpenDialogImplGtk::getSelectionType() +Inkscape::Extension::Extension *FileOpenDialogImplGtk::getSelectionType() { return extension; } @@ -950,8 +909,7 @@ FileOpenDialogImplGtk::getSelectionType() /** * Get the file name chosen by the user. Valid after an [OK] */ -Glib::ustring -FileOpenDialogImplGtk::getFilename (void) +Glib::ustring FileOpenDialogImplGtk::getFilename(void) { return myFilename; } @@ -960,7 +918,7 @@ FileOpenDialogImplGtk::getFilename (void) /** * To Get Multiple filenames selected at-once. */ -std::vectorFileOpenDialogImplGtk::getFilenames() +std::vector FileOpenDialogImplGtk::getFilenames() { #if WITH_GTKMM_3_0 std::vector result_tmp = get_filenames(); @@ -968,9 +926,8 @@ std::vectorFileOpenDialogImplGtk::getFilenames() // Copy filenames to a vector of type Glib::ustring std::vector result; - for (std::vector::iterator it = result_tmp.begin(); - it != result_tmp.end(); ++it) - result.push_back(*it); + for (std::vector::iterator it = result_tmp.begin(); it != result_tmp.end(); ++it) + result.push_back(*it); #else std::vector result = get_filenames(); @@ -990,7 +947,6 @@ Glib::ustring FileOpenDialogImplGtk::getCurrentDirectory() - //######################################################################## //# F I L E S A V E //######################################################################## @@ -998,16 +954,14 @@ Glib::ustring FileOpenDialogImplGtk::getCurrentDirectory() /** * Constructor */ -FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, - const Glib::ustring &dir, - FileDialogType fileTypes, - const Glib::ustring &title, - const Glib::ustring &/*default_key*/, - const gchar* docTitle, - const Inkscape::Extension::FileSaveMethod save_method) : - FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, - (save_method == Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY) ? "/dialogs/save_copy" : "/dialogs/save_as"), - save_method(save_method) +FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Glib::ustring &dir, + FileDialogType fileTypes, const Glib::ustring &title, + const Glib::ustring & /*default_key*/, const gchar *docTitle, + const Inkscape::Extension::FileSaveMethod save_method) + : FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, + (save_method == Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY) ? "/dialogs/save_copy" + : "/dialogs/save_as") + , save_method(save_method) { FileSaveDialog::myDocTitle = docTitle; @@ -1029,18 +983,19 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, _dialogType = fileTypes; /* Set the pwd and/or the filename */ - if (dir.size() > 0) - { + if (dir.size() > 0) { Glib::ustring udir(dir); Glib::ustring::size_type len = udir.length(); // leaving a trailing backslash on the directory name leads to the infamous // double-directory bug on win32 - if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); - myFilename = udir; + if ((len != 0) && (udir[len - 1] == '\\')) { + udir.erase(len - 1); } + myFilename = udir; + } //###### Add the file types menu - //createFilterMenu(); + // createFilterMenu(); //###### Do we want the .xxx extension automatically added? Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1054,60 +1009,54 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, if (_dialogType != CUSTOM_TYPE) createFileTypeMenu(); - fileTypeComboBox.set_size_request(200,40); - fileTypeComboBox.signal_changed().connect( - sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileTypeChangedCallback) ); + fileTypeComboBox.set_size_request(200, 40); + fileTypeComboBox.signal_changed().connect(sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileTypeChangedCallback)); - childBox.pack_start( checksBox ); - childBox.pack_end( fileTypeComboBox ); - checksBox.pack_start( fileTypeCheckbox ); - checksBox.pack_start( previewCheckbox ); + childBox.pack_start(checksBox); + childBox.pack_end(fileTypeComboBox); + checksBox.pack_start(fileTypeCheckbox); + checksBox.pack_start(previewCheckbox); - set_extra_widget( childBox ); + set_extra_widget(childBox); - //Let's do some customization + // Let's do some customization fileNameEntry = NULL; Gtk::Container *cont = get_toplevel(); std::vector entries; findEntryWidgets(cont, entries); - //g_message("Found %d entry widgets\n", entries.size()); - if (!entries.empty()) - { - //Catch when user hits [return] on the text field + // g_message("Found %d entry widgets\n", entries.size()); + if (!entries.empty()) { + // Catch when user hits [return] on the text field fileNameEntry = entries[0]; fileNameEntry->signal_activate().connect( - sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileNameEntryChangedCallback) ); - } + sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileNameEntryChangedCallback)); + } - //Let's do more customization + // Let's do more customization std::vector expanders; findExpanderWidgets(cont, expanders); - //g_message("Found %d expander widgets\n", expanders.size()); - if (!expanders.empty()) - { - //Always show the file list + // g_message("Found %d expander widgets\n", expanders.size()); + if (!expanders.empty()) { + // Always show the file list Gtk::Expander *expander = expanders[0]; expander->set_expanded(true); - } + } // allow easy access to the user's own templates folder - gchar *templates = profile_path ("templates"); - if ( Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) - && Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) - && g_path_is_absolute(templates) - ) - { + gchar *templates = profile_path("templates"); + if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) && + Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) { add_shortcut_folder(templates); } - g_free (templates); + g_free(templates); - //if (extension == NULL) + // if (extension == NULL) // checkbox.set_sensitive(FALSE); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); + set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); show_all_children(); } @@ -1128,27 +1077,27 @@ void FileSaveDialogImplGtk::fileNameEntryChangedCallback() return; Glib::ustring fileName = fileNameEntry->get_text(); - if (!Glib::get_charset()) //If we are not utf8 + if (!Glib::get_charset()) // If we are not utf8 fileName = Glib::filename_to_utf8(fileName); - //g_message("User hit return. Text is '%s'\n", fileName.c_str()); + // g_message("User hit return. Text is '%s'\n", fileName.c_str()); if (!Glib::path_is_absolute(fileName)) { - //try appending to the current path + // try appending to the current path // not this way: fileName = get_current_folder() + "/" + fileName; std::vector pathSegments; - pathSegments.push_back( get_current_folder() ); - pathSegments.push_back( fileName ); + pathSegments.push_back(get_current_folder()); + pathSegments.push_back(fileName); fileName = Glib::build_filename(pathSegments); } - //g_message("path:'%s'\n", fileName.c_str()); + // g_message("path:'%s'\n", fileName.c_str()); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) { set_current_folder(fileName); - } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) { - //dialog with either (1) select a regular file or (2) cd to dir - //simulate an 'OK' + } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/ 1) { + // dialog with either (1) select a regular file or (2) cd to dir + // simulate an 'OK' set_filename(fileName); response(Gtk::RESPONSE_OK); } @@ -1162,10 +1111,11 @@ void FileSaveDialogImplGtk::fileNameEntryChangedCallback() void FileSaveDialogImplGtk::fileTypeChangedCallback() { int sel = fileTypeComboBox.get_active_row_number(); - if (sel<0 || sel >= (int)fileTypes.size()) + if ((sel < 0) || (sel >= (int)fileTypes.size())) return; + FileType type = fileTypes[sel]; - //g_message("selected: %s\n", type.name.c_str()); + // g_message("selected: %s\n", type.name.c_str()); extension = type.extension; #if WITH_GTKMM_3_0 @@ -1192,7 +1142,7 @@ void FileSaveDialogImplGtk::addFileType(Glib::ustring name, Glib::ustring patter fileTypeComboBox.set_active(0); - fileTypeChangedCallback(); //call at least once to set the filter + fileTypeChangedCallback(); // call at least once to set the filter } void FileSaveDialogImplGtk::createFileTypeMenu() @@ -1202,20 +1152,20 @@ void FileSaveDialogImplGtk::createFileTypeMenu() knownExtensions.clear(); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) - { - Inkscape::Extension::Output * omod = *current_item; + current_item != extension_list.end(); ++current_item) { + Inkscape::Extension::Output *omod = *current_item; // FIXME: would be nice to grey them out instead of not listing them - if (omod->deactivated()) continue; + if (omod->deactivated()) + continue; FileType type; - type.name = (_(omod->get_filetypename())); - type.pattern = "*"; + type.name = (_(omod->get_filetypename())); + type.pattern = "*"; Glib::ustring extension = omod->get_extension(); - knownExtensions.insert( extension.casefold() ); - fileDialogExtensionToPattern (type.pattern, extension); - type.extension= omod; + knownExtensions.insert(extension.casefold()); + fileDialogExtensionToPattern(type.pattern, extension); + type.extension = omod; fileTypeComboBox.append(type.name); fileTypes.push_back(type); } @@ -1230,23 +1180,20 @@ void FileSaveDialogImplGtk::createFileTypeMenu() fileTypeComboBox.set_active(0); - fileTypeChangedCallback(); //call at least once to set the filter + fileTypeChangedCallback(); // call at least once to set the filter } - - /** * Show this dialog modally. Return true if user hits [OK] */ -bool -FileSaveDialogImplGtk::show() +bool FileSaveDialogImplGtk::show() { change_path(myFilename); - set_modal (TRUE); //Window - sp_transientize(GTK_WIDGET(gobj())); //Make transient - gint b = run(); //Dialog + set_modal(TRUE); // Window + sp_transientize(GTK_WIDGET(gobj())); // Make transient + gint b = run(); // Dialog svgPreview.showNoPreview(); set_preview_widget_active(false); hide(); @@ -1254,7 +1201,7 @@ FileSaveDialogImplGtk::show() if (b == Gtk::RESPONSE_OK) { updateNameAndExtension(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - + // Store changes of the "Append filename automatically" checkbox back to preferences. if (save_method == Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY) { prefs->setBool("/dialogs/save_copy/append_extension", fileTypeCheckbox.get_active()); @@ -1262,14 +1209,14 @@ FileSaveDialogImplGtk::show() prefs->setBool("/dialogs/save_as/append_extension", fileTypeCheckbox.get_active()); } - Inkscape::Extension::store_file_extension_in_prefs ((extension != NULL ? extension->get_id() : "" ), save_method); + Inkscape::Extension::store_file_extension_in_prefs((extension != NULL ? extension->get_id() : ""), save_method); - cleanup( true ); + cleanup(true); - return TRUE; + return true; } else { - cleanup( false ); - return FALSE; + cleanup(false); + return false; } } @@ -1277,23 +1224,22 @@ FileSaveDialogImplGtk::show() /** * Get the file extension type that was selected by the user. Valid after an [OK] */ -Inkscape::Extension::Extension * -FileSaveDialogImplGtk::getSelectionType() +Inkscape::Extension::Extension *FileSaveDialogImplGtk::getSelectionType() { return extension; } -void FileSaveDialogImplGtk::setSelectionType( Inkscape::Extension::Extension * key ) +void FileSaveDialogImplGtk::setSelectionType(Inkscape::Extension::Extension *key) { // If no pointer to extension is passed in, look up based on filename extension. - if ( !key ) { + if (!key) { // Not quite UTF-8 here. gchar *filenameLower = g_ascii_strdown(myFilename.c_str(), -1); - for ( int i = 0; !key && (i < (int)fileTypes.size()); i++ ) { - Inkscape::Extension::Output *ext = dynamic_cast(fileTypes[i].extension); - if ( ext && ext->get_extension() ) { - gchar *extensionLower = g_ascii_strdown( ext->get_extension(), -1 ); - if ( g_str_has_suffix(filenameLower, extensionLower) ) { + for (int i = 0; !key && (i < (int)fileTypes.size()); i++) { + Inkscape::Extension::Output *ext = dynamic_cast(fileTypes[i].extension); + if (ext && ext->get_extension()) { + gchar *extensionLower = g_ascii_strdown(ext->get_extension(), -1); + if (g_str_has_suffix(filenameLower, extensionLower)) { key = fileTypes[i].extension; } g_free(extensionLower); @@ -1303,17 +1249,17 @@ void FileSaveDialogImplGtk::setSelectionType( Inkscape::Extension::Extension * k } // Ensure the proper entry in the combo box is selected. - if ( key ) { + if (key) { extension = key; - gchar const * extensionID = extension->get_id(); - if ( extensionID ) { - for ( int i = 0; i < (int)fileTypes.size(); i++ ) { + gchar const *extensionID = extension->get_id(); + if (extensionID) { + for (int i = 0; i < (int)fileTypes.size(); i++) { Inkscape::Extension::Extension *ext = fileTypes[i].extension; - if ( ext ) { - gchar const * id = ext->get_id(); - if ( id && ( strcmp(extensionID, id) == 0) ) { + if (ext) { + gchar const *id = ext->get_id(); + if (id && (strcmp(extensionID, id) == 0)) { int oldSel = fileTypeComboBox.get_active_row_number(); - if ( i != oldSel ) { + if (i != oldSel) { fileTypeComboBox.set_active(i); } break; @@ -1339,32 +1285,34 @@ FileSaveDialogImplGtk::change_title(const Glib::ustring& title) /** * Change the default save path location. */ -void -FileSaveDialogImplGtk::change_path(const Glib::ustring& path) +void FileSaveDialogImplGtk::change_path(const Glib::ustring &path) { myFilename = path; if (Glib::file_test(myFilename, Glib::FILE_TEST_IS_DIR)) { - //fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str()); + // fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str()); set_current_folder(myFilename); } else { - //fprintf(stderr,"set_filename(%s)\n",myFilename.c_str()); - if ( Glib::file_test( myFilename, Glib::FILE_TEST_EXISTS ) ) { + // fprintf(stderr,"set_filename(%s)\n",myFilename.c_str()); + if (Glib::file_test(myFilename, Glib::FILE_TEST_EXISTS)) { set_filename(myFilename); } else { - std::string dirName = Glib::path_get_dirname( myFilename ); - if ( dirName != get_current_folder() ) { + std::string dirName = Glib::path_get_dirname(myFilename); + if (dirName != get_current_folder()) { set_current_folder(dirName); } } Glib::ustring basename = Glib::path_get_basename(myFilename); - //fprintf(stderr,"set_current_name(%s)\n",basename.c_str()); - try { - set_current_name( Glib::filename_to_utf8(basename) ); - } catch ( Glib::ConvertError& e ) { - g_warning( "Error converting save filename to UTF-8." ); + // fprintf(stderr,"set_current_name(%s)\n",basename.c_str()); + try + { + set_current_name(Glib::filename_to_utf8(basename)); + } + catch (Glib::ConvertError &e) + { + g_warning("Error converting save filename to UTF-8."); // try a fallback. - set_current_name( basename ); + set_current_name(basename); } } } @@ -1374,16 +1322,16 @@ void FileSaveDialogImplGtk::updateNameAndExtension() // Pick up any changes the user has typed in. Glib::ustring tmp = get_filename(); #ifdef WITH_GNOME_VFS - if ( tmp.empty() && gnome_vfs_initialized() ) { + if (tmp.empty() && gnome_vfs_initialized()) { tmp = get_uri(); } #endif - if ( !tmp.empty() ) { + if (!tmp.empty()) { myFilename = tmp; } - Inkscape::Extension::Output* newOut = extension ? dynamic_cast(extension) : 0; - if ( fileTypeCheckbox.get_active() && newOut ) { + Inkscape::Extension::Output *newOut = extension ? dynamic_cast(extension) : 0; + if (fileTypeCheckbox.get_active() && newOut) { // Append the file extension if it's not already present and display it in the file name entry field appendExtension(myFilename, newOut); change_path(myFilename); @@ -1406,27 +1354,27 @@ void FileExportDialogImpl::fileNameEntryChangedCallback() return; Glib::ustring fileName = fileNameEntry->get_text(); - if (!Glib::get_charset()) //If we are not utf8 + if (!Glib::get_charset()) // If we are not utf8 fileName = Glib::filename_to_utf8(fileName); - //g_message("User hit return. Text is '%s'\n", fileName.c_str()); + // g_message("User hit return. Text is '%s'\n", fileName.c_str()); if (!Glib::path_is_absolute(fileName)) { - //try appending to the current path + // try appending to the current path // not this way: fileName = get_current_folder() + "/" + fileName; std::vector pathSegments; - pathSegments.push_back( get_current_folder() ); - pathSegments.push_back( fileName ); + pathSegments.push_back(get_current_folder()); + pathSegments.push_back(fileName); fileName = Glib::build_filename(pathSegments); } - //g_message("path:'%s'\n", fileName.c_str()); + // g_message("path:'%s'\n", fileName.c_str()); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) { set_current_folder(fileName); - } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) { - //dialog with either (1) select a regular file or (2) cd to dir - //simulate an 'OK' + } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/ 1) { + // dialog with either (1) select a regular file or (2) cd to dir + // simulate an 'OK' set_filename(fileName); response(Gtk::RESPONSE_OK); } @@ -1440,10 +1388,11 @@ void FileExportDialogImpl::fileNameEntryChangedCallback() void FileExportDialogImpl::fileTypeChangedCallback() { int sel = fileTypeComboBox.get_active_row_number(); - if (sel<0 || sel >= (int)fileTypes.size()) + if ((sel < 0) || (sel >= (int)fileTypes.size())) return; + FileType type = fileTypes[sel]; - //g_message("selected: %s\n", type.name.c_str()); + // g_message("selected: %s\n", type.name.c_str()); Gtk::FileFilter filter; filter.add_pattern(type.pattern); set_filter(filter); @@ -1457,19 +1406,19 @@ void FileExportDialogImpl::createFileTypeMenu() Inkscape::Extension::db.get_output_list(extension_list); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) - { - Inkscape::Extension::Output * omod = *current_item; + current_item != extension_list.end(); ++current_item) { + Inkscape::Extension::Output *omod = *current_item; // FIXME: would be nice to grey them out instead of not listing them - if (omod->deactivated()) continue; + if (omod->deactivated()) + continue; FileType type; - type.name = (_(omod->get_filetypename())); - type.pattern = "*"; + type.name = (_(omod->get_filetypename())); + type.pattern = "*"; Glib::ustring extension = omod->get_extension(); - fileDialogExtensionToPattern (type.pattern, extension); - type.extension= omod; + fileDialogExtensionToPattern(type.pattern, extension); + type.extension = omod; fileTypeComboBox.append_text(type.name); fileTypes.push_back(type); } @@ -1484,28 +1433,26 @@ void FileExportDialogImpl::createFileTypeMenu() fileTypeComboBox.set_active(0); - fileTypeChangedCallback(); //call at least once to set the filter + fileTypeChangedCallback(); // call at least once to set the filter } /** * Constructor */ -FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - const Glib::ustring &dir, - FileDialogType fileTypes, - const Glib::ustring &title, - const Glib::ustring &/*default_key*/ ) : - FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "/dialogs/export"), - sourceX0Spinner("X0", _("Left edge of source")), - sourceY0Spinner("Y0", _("Top edge of source")), - sourceX1Spinner("X1", _("Right edge of source")), - sourceY1Spinner("Y1", _("Bottom edge of source")), - sourceWidthSpinner("Width", _("Source width")), - sourceHeightSpinner("Height", _("Source height")), - destWidthSpinner("Width", _("Destination width")), - destHeightSpinner("Height", _("Destination height")), - destDPISpinner("DPI", _("Resolution (dots per inch)")) +FileExportDialogImpl::FileExportDialogImpl(Gtk::Window &parentWindow, const Glib::ustring &dir, + FileDialogType fileTypes, const Glib::ustring &title, + const Glib::ustring & /*default_key*/) + : FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "/dialogs/export") + , sourceX0Spinner("X0", _("Left edge of source")) + , sourceY0Spinner("Y0", _("Top edge of source")) + , sourceX1Spinner("X1", _("Right edge of source")) + , sourceY1Spinner("Y1", _("Bottom edge of source")) + , sourceWidthSpinner("Width", _("Source width")) + , sourceHeightSpinner("Height", _("Source height")) + , destWidthSpinner("Width", _("Destination width")) + , destHeightSpinner("Height", _("Destination height")) + , destDPISpinner("DPI", _("Resolution (dots per inch)")) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); append_extension = prefs->getBool("/dialogs/save_export/append_extension", true); @@ -1528,15 +1475,15 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, _dialogType = fileTypes; /* Set the pwd and/or the filename */ - if (dir.size()>0) - { + if (dir.size() > 0) { Glib::ustring udir(dir); Glib::ustring::size_type len = udir.length(); // leaving a trailing backslash on the directory name leads to the infamous // double-directory bug on win32 - if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); + if ((len != 0) && (udir[len - 1] == '\\')) + udir.erase(len - 1); set_current_folder(udir.c_str()); - } + } //######################################### //## EXTRA WIDGET -- SOURCE SIDE @@ -1563,16 +1510,16 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - //dimension buttons - sourceTable.resize(3,3); - sourceTable.attach(sourceX0Spinner, 0,1,0,1); - sourceTable.attach(sourceY0Spinner, 1,2,0,1); + // dimension buttons + sourceTable.resize(3, 3); + sourceTable.attach(sourceX0Spinner, 0, 1, 0, 1); + sourceTable.attach(sourceY0Spinner, 1, 2, 0, 1); sourceUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR); - sourceTable.attach(sourceUnitsSpinner, 2,3,0,1); - sourceTable.attach(sourceX1Spinner, 0,1,1,2); - sourceTable.attach(sourceY1Spinner, 1,2,1,2); - sourceTable.attach(sourceWidthSpinner, 0,1,2,3); - sourceTable.attach(sourceHeightSpinner, 1,2,2,3); + sourceTable.attach(sourceUnitsSpinner, 2, 3, 0, 1); + sourceTable.attach(sourceX1Spinner, 0, 1, 1, 2); + sourceTable.attach(sourceY1Spinner, 1, 2, 1, 2); + sourceTable.attach(sourceWidthSpinner, 0, 1, 2, 3); + sourceTable.attach(sourceHeightSpinner, 1, 2, 2, 3); sourceBox.pack_start(sourceTable); sourceFrame.set_label(_("Source")); @@ -1585,12 +1532,12 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, //######################################### - destTable.resize(3,3); - destTable.attach(destWidthSpinner, 0,1,0,1); - destTable.attach(destHeightSpinner, 1,2,0,1); + destTable.resize(3, 3); + destTable.attach(destWidthSpinner, 0, 1, 0, 1); + destTable.attach(destHeightSpinner, 1, 2, 0, 1); destUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR); - destTable.attach(destUnitsSpinner, 2,3,0,1); - destTable.attach(destDPISpinner, 0,1,1,2); + destTable.attach(destUnitsSpinner, 2, 3, 0, 1); + destTable.attach(destDPISpinner, 0, 1, 1, 2); destBox.pack_start(destTable); @@ -1608,8 +1555,6 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - - //###### File options //###### Do we want the .xxx extension automatically added? fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically"))); @@ -1618,9 +1563,8 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, //###### File type menu createFileTypeMenu(); - fileTypeComboBox.set_size_request(200,40); - fileTypeComboBox.signal_changed().connect( - sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback) ); + fileTypeComboBox.set_size_request(200, 40); + fileTypeComboBox.signal_changed().connect(sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback)); destBox.pack_start(fileTypeComboBox); @@ -1636,38 +1580,35 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - - //Let's do some customization + // Let's do some customization fileNameEntry = NULL; Gtk::Container *cont = get_toplevel(); std::vector entries; findEntryWidgets(cont, entries); - //g_message("Found %d entry widgets\n", entries.size()); - if (!entries.empty()) - { - //Catch when user hits [return] on the text field + // g_message("Found %d entry widgets\n", entries.size()); + if (!entries.empty()) { + // Catch when user hits [return] on the text field fileNameEntry = entries[0]; fileNameEntry->signal_activate().connect( - sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback) ); - } + sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback)); + } - //Let's do more customization + // Let's do more customization std::vector expanders; findExpanderWidgets(cont, expanders); - //g_message("Found %d expander widgets\n", expanders.size()); - if (!expanders.empty()) - { - //Always show the file list + // g_message("Found %d expander widgets\n", expanders.size()); + if (!expanders.empty()) { + // Always show the file list Gtk::Expander *expander = expanders[0]; expander->set_expanded(true); - } + } - //if (extension == NULL) + // if (extension == NULL) // checkbox.set_sensitive(FALSE); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); + set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); show_all_children(); } @@ -1684,30 +1625,28 @@ FileExportDialogImpl::~FileExportDialogImpl() /** * Show this dialog modally. Return true if user hits [OK] */ -bool -FileExportDialogImpl::show() +bool FileExportDialogImpl::show() { - Glib::ustring s = Glib::filename_to_utf8 (get_current_folder()); - if (s.length() == 0) - s = getcwd (NULL, 0); - set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing - set_modal (TRUE); //Window - sp_transientize(GTK_WIDGET(gobj())); //Make transient - gint b = run(); //Dialog + Glib::ustring s = Glib::filename_to_utf8(get_current_folder()); + if (s.length() == 0) { + s = getcwd(NULL, 0); + } + set_current_folder(Glib::filename_from_utf8(s)); // hack to force initial dir listing + set_modal(TRUE); // Window + sp_transientize(GTK_WIDGET(gobj())); // Make transient + gint b = run(); // Dialog svgPreview.showNoPreview(); hide(); - if (b == Gtk::RESPONSE_OK) - { - int sel = fileTypeComboBox.get_active_row_number (); - if (sel>=0 && sel< (int)fileTypes.size()) - { + if (b == Gtk::RESPONSE_OK) { + int sel = fileTypeComboBox.get_active_row_number(); + if (sel >= 0 && sel < (int)fileTypes.size()) { FileType &type = fileTypes[sel]; extension = type.extension; - } + } myFilename = get_filename(); #ifdef WITH_GNOME_VFS - if ( myFilename.empty() && gnome_vfs_initialized() ) { + if (myFilename.empty() && gnome_vfs_initialized()) { myFilename = get_uri(); } #endif @@ -1721,20 +1660,17 @@ FileExportDialogImpl::show() prefs->setBool("/dialogs/save_export/append_extension", append_extension); prefs->setBool("/dialogs/save_export/default", ( extension != NULL ? extension->get_id() : "" )); */ - return TRUE; - } - else - { - return FALSE; - } + return true; + } else { + return false; + } } /** * Get the file extension type that was selected by the user. Valid after an [OK] */ -Inkscape::Extension::Extension * -FileExportDialogImpl::getSelectionType() +Inkscape::Extension::Extension *FileExportDialogImpl::getSelectionType() { return extension; } @@ -1743,8 +1679,7 @@ FileExportDialogImpl::getSelectionType() /** * Get the file name chosen by the user. Valid after an [OK] */ -Glib::ustring -FileExportDialogImpl::getFilename() +Glib::ustring FileExportDialogImpl::getFilename() { return myFilename; } @@ -1752,9 +1687,9 @@ FileExportDialogImpl::getFilename() #endif // NEW_EXPORT_DIALOG -} //namespace Dialog -} //namespace UI -} //namespace Inkscape +} // namespace Dialog +} // namespace UI +} // namespace Inkscape /* Local Variables: -- cgit v1.2.3 From 08692dea2a2b45f0358a70db8e7d08fd73c6e3e4 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 31 Mar 2014 11:10:00 +0100 Subject: Fix Gtkmm 3.8 build issues on systems with Gtk+ 3.10 (bzr r13242) --- src/ui/dialog/document-properties.cpp | 12 ++++++------ src/ui/dialog/livepatheffect-editor.cpp | 8 ++++---- src/ui/dialog/polar-arrange-tab.h | 3 +-- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 508fc52b1..67e788e21 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -613,7 +613,7 @@ void DocumentProperties::build_cms() label_avail->set_markup (_("Available Color Profiles:")); _link_btn.set_tooltip_text(_("Link Profile")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _link_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_link = Gtk::manage(new Gtk::Image()); @@ -622,7 +622,7 @@ void DocumentProperties::build_cms() #endif _unlink_btn.set_tooltip_text(_("Unlink Profile")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _unlink_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_unlink = Gtk::manage(new Gtk::Image()); @@ -750,7 +750,7 @@ void DocumentProperties::build_scripting() label_external->set_markup (_("External script files:")); _external_add_btn.set_tooltip_text(_("Add the current file name or browse for a file")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _external_add_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_ext_add = Gtk::manage(new Gtk::Image()); @@ -759,7 +759,7 @@ void DocumentProperties::build_scripting() #endif _external_remove_btn.set_tooltip_text(_("Remove")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _external_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_ext_rm = Gtk::manage(new Gtk::Image()); @@ -839,7 +839,7 @@ void DocumentProperties::build_scripting() label_embedded->set_markup (_("Embedded script files:")); _embed_new_btn.set_tooltip_text(_("New")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _embed_new_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_embed_new = Gtk::manage(new Gtk::Image()); @@ -848,7 +848,7 @@ void DocumentProperties::build_scripting() #endif _embed_remove_btn.set_tooltip_text(_("Remove")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _embed_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_embed_rm = Gtk::manage(new Gtk::Image()); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 0ab2fc9f7..9a569725c 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -107,7 +107,7 @@ LivePathEffectEditor::LivePathEffectEditor() effectcontrol_frame.add(effectcontrol_vbox); button_add.set_tooltip_text(_("Add path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_add.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_add = Gtk::manage(new Gtk::Image()); @@ -117,7 +117,7 @@ LivePathEffectEditor::LivePathEffectEditor() button_add.set_relief(Gtk::RELIEF_NONE); button_remove.set_tooltip_text(_("Delete current path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_remove.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_remove = Gtk::manage(new Gtk::Image()); @@ -127,7 +127,7 @@ LivePathEffectEditor::LivePathEffectEditor() button_remove.set_relief(Gtk::RELIEF_NONE); button_up.set_tooltip_text(_("Raise the current path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_up.set_image_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_up = Gtk::manage(new Gtk::Image()); @@ -137,7 +137,7 @@ LivePathEffectEditor::LivePathEffectEditor() button_up.set_relief(Gtk::RELIEF_NONE); button_down.set_tooltip_text(_("Lower the current path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_down.set_image_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_down = Gtk::manage(new Gtk::Image()); diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index bfed40bbd..f6c3b2906 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -10,9 +10,8 @@ #ifndef INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H #define INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H -#include "ui/dialog/arrange-tab.h" - #include "ui/widget/anchor-selector.h" +#include "ui/dialog/arrange-tab.h" #include "ui/widget/scalar-unit.h" namespace Inkscape { -- cgit v1.2.3 From 7f76e57b71213ded4ffc75f42af0f19ece24e04c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 31 Mar 2014 22:50:32 +0200 Subject: partial 2geom update: fix compiler error on some platforms (mavericks in any case) (bzr r13244) --- src/2geom/sbasis-roots.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis-roots.cpp b/src/2geom/sbasis-roots.cpp index 813e471e8..acf4e1abc 100644 --- a/src/2geom/sbasis-roots.cpp +++ b/src/2geom/sbasis-roots.cpp @@ -114,7 +114,7 @@ OptInterval bounds_fast(const SBasis &sb, int order) { res[1]=lerp(t, a+v*t, b); } } - if (order>0) res*=pow(.25,order); + if (order>0) res*=std::pow(.25,order); return res; } @@ -151,7 +151,7 @@ OptInterval bounds_local(const SBasis &sb, const OptInterval &i, int order) { } } Interval res = Interval(lo,hi); - if (order>0) res*=pow(.25,order); + if (order>0) res*=std::pow(.25,order); return res; } -- cgit v1.2.3 From 24335d0da5da0df3e7ee0f235d04e57807c97a69 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 31 Mar 2014 22:55:53 +0200 Subject: fix windows build (bzr r13245) --- src/ui/dialog/pixelartdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 31449d4e7..2d25f54d7 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -410,8 +410,8 @@ void PixelArtDialogImpl::vectorize() lastOptions = options(); g_atomic_int_set(&abortThread, false); - thread = Glib::Thread::create( - sigc::mem_fun(*this, &PixelArtDialogImpl::workerThread) ); + thread = Glib::Thread::create(sigc::mem_fun(*this, &PixelArtDialogImpl::workerThread), + /*joinable =*/true); } void PixelArtDialogImpl::processLibdepixelize(const Input &input) -- cgit v1.2.3 From 3394f340295af7b454b27250cdce1d845ad4b64d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:09:09 +0200 Subject: partial 2geom update (fixes warning) (bzr r13246) --- src/2geom/recursive-bezier-intersection.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/2geom/recursive-bezier-intersection.cpp b/src/2geom/recursive-bezier-intersection.cpp index 0c7977970..548065196 100644 --- a/src/2geom/recursive-bezier-intersection.cpp +++ b/src/2geom/recursive-bezier-intersection.cpp @@ -13,6 +13,8 @@ unsigned intersect_steps = 0; using std::vector; +using std::swap; + namespace Geom { class OldBezier { @@ -31,7 +33,7 @@ public: minax = p[0][X]; // These are the most likely to be extremal maxax = p.back()[X]; if( minax > maxax ) - std::swap(minax, maxax); + swap(minax, maxax); for(unsigned i = 1; i < p.size()-1; i++) { if( p[i][X] < minax ) minax = p[i][X]; @@ -42,7 +44,7 @@ public: minay = p[0][Y]; // These are the most likely to be extremal maxay = p.back()[Y]; if( minay > maxay ) - std::swap(minay, maxay); + swap(minay, maxay); for(unsigned i = 1; i < p.size()-1; i++) { if( p[i][Y] < minay ) minay = p[i][Y]; @@ -71,9 +73,6 @@ find_intersections_bezier_recursive( std::vector > &xs } -/* The value of 1.0 / (1L<<14) is enough for most applications */ -const double INV_EPS = (1L<<14); - /* * split the curve at the midpoint, returning an array with the two parts * Temporary storage is minimized by using part of the storage for the result @@ -318,9 +317,14 @@ double Lmax(Point p) { return std::max(fabs(p[X]), fabs(p[Y])); } + unsigned wangs_theorem(OldBezier /*a*/) { return 6; // seems a good approximation! - /*double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) ); + + /* + const double INV_EPS = (1L<<14); // The value of 1.0 / (1L<<14) is enough for most applications + + double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) ); double la2 = Lmax( ( a.p[3] - a.p[2] ) - (a.p[2] - a.p[1]) ); double l0 = std::max(la1, la2); unsigned ra; -- cgit v1.2.3 From a8809d5d4f115dc1f4415a41f1feb5828e4201c9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:11:37 +0200 Subject: 2geom: silence warning (bzr r13247) --- src/2geom/svg-path-parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/svg-path-parser.cpp b/src/2geom/svg-path-parser.cpp index fa31b57b5..ccc383920 100644 --- a/src/2geom/svg-path-parser.cpp +++ b/src/2geom/svg-path-parser.cpp @@ -1144,7 +1144,7 @@ static const char _svg_path_trans_actions[] = { static const int svg_path_start = 1; static const int svg_path_first_final = 270; -static const int svg_path_en_main = 1; +//static const int svg_path_en_main = 1; #line 144 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" -- cgit v1.2.3 From 04b06fe3ed0824c37cf65b425bf820d8b6f226a2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:25:06 +0200 Subject: partial 2geom update: - main reason for update: better swap for Path (fixes C++11 warning/error) - faster implementation for Path * Translate (~6x), Inkscape's code has to be modified to use it though (bzr r13248) --- src/2geom/bezier-curve.h | 11 +++++++++++ src/2geom/bezier.h | 12 ++++++++++++ src/2geom/curve.h | 16 ++++++++++++++++ src/2geom/elliptical-arc.h | 7 +++++++ src/2geom/path.cpp | 34 +++++++++++++++++++++++++++++++--- src/2geom/path.h | 24 +++++++++++++----------- src/2geom/sbasis-curve.h | 7 +++++++ 7 files changed, 97 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/2geom/bezier-curve.h b/src/2geom/bezier-curve.h index c0224e850..d379526fa 100644 --- a/src/2geom/bezier-curve.h +++ b/src/2geom/bezier-curve.h @@ -39,6 +39,7 @@ #include <2geom/curve.h> #include <2geom/sbasis-curve.h> // for non-native winding method #include <2geom/bezier.h> +#include <2geom/transforms.h> namespace Geom { @@ -118,6 +119,7 @@ public: virtual Curve *reverse() const { return new BezierCurve(Geom::reverse(inner)); } + virtual Curve *transformed(Affine const &m) const { BezierCurve *ret = new BezierCurve(); std::vector ps = points(); @@ -127,6 +129,11 @@ public: ret->setPoints(ps); return ret; } + virtual Curve &operator*=(Translate const &m) { + inner += m.vector(); + return *this; + }; + virtual Curve *derivative() const { return new BezierCurve(Geom::derivative(inner[X]), Geom::derivative(inner[Y])); } @@ -248,6 +255,10 @@ public: return ret; } } + virtual Curve &operator*=(Translate const &m) { + inner += m.vector(); + return *this; + } virtual Curve *derivative() const; // the method below is defined so that LineSegment can specialize it diff --git a/src/2geom/bezier.h b/src/2geom/bezier.h index 176128328..51d5211d9 100644 --- a/src/2geom/bezier.h +++ b/src/2geom/bezier.h @@ -391,6 +391,18 @@ inline Bezier operator-(const Bezier & a, double v) { return result; } +inline Bezier& operator+=(Bezier & a, double v) { + for(unsigned i = 0; i <= a.order(); ++i) + a[i] = a[i] + v; + return a; +} + +inline Bezier& operator-=(Bezier & a, double v) { + for(unsigned i = 0; i <= a.order(); ++i) + a[i] = a[i] - v; + return a; +} + inline Bezier operator*(const Bezier & a, double v) { Bezier result = Bezier(Bezier::Order(a)); for(unsigned i = 0; i <= a.order(); i++) diff --git a/src/2geom/curve.h b/src/2geom/curve.h index 77f6808e1..172fd7ddc 100644 --- a/src/2geom/curve.h +++ b/src/2geom/curve.h @@ -162,6 +162,7 @@ public: /** @brief Create an exact copy of this curve. * @return Pointer to a newly allocated curve, identical to the original */ virtual Curve *duplicate() const = 0; + /** @brief Create a curve transformed by an affine transformation. * This method returns a new curve instead modifying the existing one, because some curve * types are not closed under affine transformations. The returned curve may be of different @@ -169,6 +170,15 @@ public: * @param m Affine describing the affine transformation * @return Pointer to a new, transformed curve */ virtual Curve *transformed(Affine const &m) const = 0; + + /** @brief Translate the curve (i.e. displace by Point) + * This method modifies the curve; all curve types are closed under + * translations (the result can be expressed in its own curve type). + * This function yields the same result as transformed(m). + * @param p Point by which to translate the curve + * @return reference to self */ + virtual Curve &operator*=(Translate const &m) = 0; + /** @brief Create a curve that corresponds to a part of this curve. * For \f$a > b\f$, the returned portion will be reversed with respect to the original. * The returned curve will always be of the same type. @@ -282,6 +292,12 @@ Coord nearest_point(Point const& p, Curve const& c) { return c.nearestPoint(p); } +// for make benefit glorious library of Boost Pointer Container +inline +Curve *new_clone(Curve const &c) { + return c.duplicate(); +} + } // end namespace Geom diff --git a/src/2geom/elliptical-arc.h b/src/2geom/elliptical-arc.h index e1e757207..5527aa6bc 100644 --- a/src/2geom/elliptical-arc.h +++ b/src/2geom/elliptical-arc.h @@ -229,6 +229,13 @@ public: virtual int degreesOfFreedom() const { return 7; } virtual Curve *derivative() const; virtual Curve *transformed(Affine const &m) const; + virtual Curve &operator*=(Translate const &m) { + _initial_point += m.vector(); + _final_point += m.vector(); + _center += m.vector(); + return *this; + } + /** * The size of the returned vector equals n+1. diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index 93def6c55..5797f475c 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -35,9 +35,10 @@ #include <2geom/path.h> +#include <2geom/transforms.h> #include - +using std::swap; using namespace Geom::PathInternal; namespace Geom @@ -102,10 +103,35 @@ Path &Path::operator*=(Affine const &m) { return *this; } +Path &Path::operator*=(Translate const &m) { + unshare(); + Sequence::iterator last = get_curves().end() - 1; + Sequence::iterator it; + Point prev; + for (it = get_curves().begin() ; it != last ; ++it) { + *(const_cast(&**it)) *= m; + if ( it != get_curves().begin() && (*it)->initialPoint() != prev ) { + THROW_CONTINUITYERROR(); + } + prev = (*it)->finalPoint(); + } + for ( int i = 0 ; i < 2 ; ++i ) { + final_->setPoint(i, (*final_)[i] + m.vector()); + } + if (get_curves().size() > 1) { + if ( front().initialPoint() != initialPoint() || back().finalPoint() != finalPoint() ) { + THROW_CONTINUITYERROR(); + } + } + return *this; +} + std::vector Path::allNearestPoints(Point const& _point, double from, double to) const { - if ( from > to ) std::swap(from, to); + using std::swap; + + if ( from > to ) swap(from, to); const Path& _path = *this; unsigned int sz = _path.size(); if ( _path.closed() ) ++sz; @@ -215,7 +241,9 @@ Path::nearestPointPerCurve(Point const& _point) const double Path::nearestPoint(Point const &_point, double from, double to, double *distance_squared) const { - if ( from > to ) std::swap(from, to); + using std::swap; + + if ( from > to ) swap(from, to); const Path& _path = *this; unsigned int sz = _path.size(); if ( _path.closed() ) ++sz; diff --git a/src/2geom/path.h b/src/2geom/path.h index 48d7acaaf..28d2a25e4 100644 --- a/src/2geom/path.h +++ b/src/2geom/path.h @@ -40,6 +40,7 @@ #include #include <2geom/curve.h> #include <2geom/bezier-curve.h> +#include <2geom/transforms.h> namespace Geom { @@ -205,11 +206,14 @@ public: // Path &operator=(Path const &other) - use default assignment operator + /// \todo Add noexcept specifiers for C++11 void swap(Path &other) { - std::swap(other.curves_, curves_); - std::swap(other.final_, final_); - std::swap(other.closed_, closed_); + using std::swap; + swap(other.curves_, curves_); + swap(other.final_, final_); + swap(other.closed_, closed_); } + friend inline void swap(Path &a, Path &b) { a.swap(b); } Curve const &operator[](unsigned i) const { return *get_curves()[i]; } Curve const &at_index(unsigned i) const { return *get_curves()[i]; } @@ -289,8 +293,14 @@ public: ret *= m; return ret; } + Path operator*(Translate const &m) const { // specialization over Affine, for faster computation + Path ret(*this); + ret *= m; + return ret; + } Path &operator*=(Affine const &m); + Path &operator*=(Translate const &m); // specialization over Affine, for faster computation Point pointAt(double t) const { @@ -686,14 +696,6 @@ Coord nearest_point(Point const& p, Path const& c) } // end namespace Geom -namespace std { - -template <> -inline void swap(Geom::Path &a, Geom::Path &b) { - a.swap(b); -} - -} // end namespace std #endif // LIB2GEOM_SEEN_PATH_H diff --git a/src/2geom/sbasis-curve.h b/src/2geom/sbasis-curve.h index 554b702e6..a5c3f2ca7 100644 --- a/src/2geom/sbasis-curve.h +++ b/src/2geom/sbasis-curve.h @@ -39,6 +39,7 @@ #include <2geom/curve.h> #include <2geom/nearest-point.h> #include <2geom/sbasis-geometric.h> +#include <2geom/transforms.h> namespace Geom { @@ -117,7 +118,13 @@ public: virtual Curve *portion(Coord f, Coord t) const { return new SBasisCurve(Geom::portion(inner, f, t)); } + virtual Curve *transformed(Affine const &m) const { return new SBasisCurve(inner * m); } + virtual Curve &operator*=(Translate const &m) { + inner += m.vector(); + return *this; + }; + virtual Curve *derivative() const { return new SBasisCurve(Geom::derivative(inner)); } -- cgit v1.2.3