From 9ffede11acaf9769bb1889702dda5c49e86db43f Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Mon, 9 Jul 2012 15:34:46 -0500 Subject: Add support for libvisio Fixed bugs: - https://launchpad.net/bugs/1015572 (bzr r11533.1.1) --- src/Makefile.am | 2 ++ src/extension/init.cpp | 6 ++++++ src/extension/internal/Makefile_insert | 5 +++++ 3 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index c27af0800..fc1065b34 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,6 +51,7 @@ all_libs = \ $(PYTHON_LIBS) \ $(INKBOARD_LIBS) \ $(LIBWPG_LIBS) \ + $(LIBVISIO_LIBS) \ $(DBUS_LIBS) \ $(GDL_LIBS) \ $(IMAGEMAGICK_LIBS) @@ -74,6 +75,7 @@ INCLUDES = \ $(IMAGEMAGICK_CFLAGS) \ $(INKBOARD_CFLAGS) \ $(LIBWPG_CFLAGS) \ + $(LIBVISIO_CFLAGS) \ $(DBUS_CFLAGS) \ $(GDL_CFLAGS) \ $(XFT_CFLAGS) \ diff --git a/src/extension/init.cpp b/src/extension/init.cpp index b0732568f..d59c2b2e3 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -53,6 +53,9 @@ #ifdef WITH_LIBWPG #include "internal/wpg-input.h" #endif +#ifdef WITH_LIBVISIO +#include "internal/vsd-input.h" +#endif #include "preferences.h" #include "io/sys.h" #ifdef WITH_DBUS @@ -183,6 +186,9 @@ init() #ifdef WITH_LIBWPG Internal::WpgInput::init(); #endif +#ifdef WITH_LIBVISIO + Internal::VsdInput::init(); +#endif /* Effects */ Internal::BlurEdge::init(); diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 06fa275cb..9e5b4bd7e 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -4,7 +4,12 @@ if WITH_LIBWPG ink_common_sources += \ extension/internal/wpg-input.cpp \ extension/internal/wpg-input.h +endif +if WITH_LIBVISIO +ink_common_sources += \ + extension/internal/vsd-input.cpp \ + extension/internal/vsd-input.h endif if USE_IMAGE_MAGICK -- cgit v1.2.3 From 157767bdd321e70ae9b871d5342689d56090e22e Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Mon, 9 Jul 2012 16:31:20 -0500 Subject: Added Visio Files (bzr r11533.1.2) --- src/extension/internal/vsd-input.cpp | 289 +++++++++++++++++++++++++++++++++++ src/extension/internal/vsd-input.h | 54 +++++++ 2 files changed, 343 insertions(+) create mode 100644 src/extension/internal/vsd-input.cpp create mode 100644 src/extension/internal/vsd-input.h (limited to 'src') diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp new file mode 100644 index 000000000..6d71ce72a --- /dev/null +++ b/src/extension/internal/vsd-input.cpp @@ -0,0 +1,289 @@ +/* + * This file came from libwpg as a source, their utility wpg2svg + * specifically. It has been modified to work as an Inkscape extension. + * The Inkscape extension code is covered by this copyright, but the + * rest is covered by the one bellow. + * + * Authors: + * Fridrich Strba (fridrich.strba@bluewin.ch) + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + * + */ + +#include +#include "config.h" + +#include "vsd-input.h" + +#ifdef WITH_LIBVISIO + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "extension/system.h" +#include "extension/input.h" +#include "document.h" + +#include "document-private.h" +#include "document-undo.h" +#include "inkscape.h" + +#include "dialogs/dialog-events.h" +#include +#include "ui/widget/spinbutton.h" +#include "ui/widget/frame.h" +#include + +#include + +#include "svg-view.h" +#include "svg-view-widget.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + + +class VsdImportDialog : public Gtk::Dialog { +public: + VsdImportDialog(const std::vector &vec); + virtual ~VsdImportDialog(); + + bool showDialog(); + unsigned getSelectedPage(); + void getImportSettings(Inkscape::XML::Node *prefs); + +private: + void _setPreviewPage(unsigned page); + + // Signal handlers +#if !WITH_GTKMM_3_0 + bool _onExposePreview(GdkEventExpose *event); +#endif + + void _onPageNumberChanged(); + + class Gtk::Button * cancelbutton; + class Gtk::Button * okbutton; + class Gtk::Label * _labelSelect; + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin; + class Gtk::Label * _labelTotalPages; + class Gtk::VBox * vbox1; + class Gtk::VBox * vbox2; + class Gtk::Widget * _previewArea; + + const std::vector &_vec; // Document to be imported + unsigned _current_page; // Current selected page + int _preview_width, _preview_height; // Size of the preview area +}; + +VsdImportDialog::VsdImportDialog(const std::vector &vec) + : _vec(vec), _current_page(1) +{ + int num_pages = _vec.size(); + if ( num_pages <= 1 ) + return; + cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); + okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); + _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); + + // Page number +#if WITH_GTKMM_3_0 + Glib::RefPtr _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1)); +#else + Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( + new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); +#endif + _labelTotalPages = Gtk::manage(new class Gtk::Label()); + gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); + _labelTotalPages->set_label(label_text); + g_free(label_text); + + vbox1 = Gtk::manage(new class Gtk::VBox(false, 4)); + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0); + _previewArea = Glib::wrap(sp_svg_view_widget_new(doc)); + + vbox2 = Gtk::manage(new class Gtk::VBox(false, 4)); + cancelbutton->set_can_focus(); + cancelbutton->set_can_default(); + cancelbutton->set_relief(Gtk::RELIEF_NORMAL); + okbutton->set_can_focus(); + okbutton->set_can_default(); + okbutton->set_relief(Gtk::RELIEF_NORMAL); + this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); + _labelSelect->set_line_wrap(false); + _labelSelect->set_use_markup(false); + _labelSelect->set_selectable(false); + _pageNumberSpin->set_can_focus(); + _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); + _pageNumberSpin->set_numeric(true); + _pageNumberSpin->set_digits(0); + _pageNumberSpin->set_wrap(false); + _labelTotalPages->set_line_wrap(false); + _labelTotalPages->set_use_markup(false); + _labelTotalPages->set_selectable(false); + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); + this->get_vbox()->set_homogeneous(false); + this->get_vbox()->set_spacing(0); + this->get_vbox()->pack_start(*vbox2); + this->set_title(_("Page Selector")); + this->set_modal(true); + sp_transientize((GtkWidget *)this->gobj()); //Make transient + this->property_window_position().set_value(Gtk::WIN_POS_NONE); + this->set_resizable(true); + this->property_destroy_with_parent().set_value(false); + this->get_action_area()->add(*_labelSelect); + this->add_action_widget(*_pageNumberSpin, -7); + this->get_action_area()->add(*_labelTotalPages); + this->add_action_widget(*cancelbutton, -6); + this->add_action_widget(*okbutton, -5); + cancelbutton->show(); + okbutton->show(); + _labelSelect->show(); + _pageNumberSpin->show(); + _labelTotalPages->show(); + vbox1->show(); + _previewArea->show(); + vbox2->show(); + + // Connect signals + _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged)); +} + +VsdImportDialog::~VsdImportDialog() {} + +bool VsdImportDialog::showDialog() +{ + show(); + gint b = run(); + hide(); + if ( b == Gtk::RESPONSE_OK ) { + return TRUE; + } else { + return FALSE; + } +} + +unsigned VsdImportDialog::getSelectedPage() +{ + return _current_page; +} + +void VsdImportDialog::_onPageNumberChanged() +{ + int page = _pageNumberSpin->get_value_as_int(); + _current_page = CLAMP(page, 1, _vec.size()); + _setPreviewPage(_current_page); +} + +/** + * \brief Renders the given page's thumbnail + */ +void VsdImportDialog::_setPreviewPage(unsigned page) +{ + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0); + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc)); + std::swap(_previewArea, tmpPreviewArea); + if (tmpPreviewArea) { + _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() ); + delete tmpPreviewArea; + } + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); + _previewArea->show_now(); +} + +SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) +{ + WPXFileStream input(uri); + + if (!libvisio::VisioDocument::isSupported(&input)) { + return NULL; + } + + libvisio::VSDStringVector output; + if (!libvisio::VisioDocument::generateSVG(&input, output)) { + return NULL; + } + + if (output.empty()) { + return NULL; + } + + std::vector tmpSVGOutput; + for (unsigned i=0; i\n\n"); + tmpString.append(output[i]); + tmpSVGOutput.push_back(tmpString); + } + + unsigned page_num = 1; + + // If only one page is present, import that one without bothering user + if (tmpSVGOutput.size() > 1) { + VsdImportDialog *dlg = 0; + if (inkscape_use_gui()) { + dlg = new VsdImportDialog(tmpSVGOutput); + if (!dlg->showDialog()) { + delete dlg; + return NULL; + } + } + + // Get needed page + if (dlg) { + page_num = dlg->getSelectedPage(); + if (page_num < 1) + page_num = 1; + if (page_num > tmpSVGOutput.size()) + page_num = tmpSVGOutput.size(); + } + } + + SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); + return doc; +} + +#include "clear-n_.h" + +void VsdInput::init(void) +{ + Inkscape::Extension::build_from_mem( + "\n" + "" N_("VSD Input") "\n" + "org.inkscape.input.vsd\n" + "\n" + ".vsd\n" + "application/vnd.visio\n" + "" N_("Microsoft Visio Diagram (*.vsd)") "\n" + "" N_("File format used by Microsoft Visio 6 and later") "\n" + "\n" + "", new VsdInput()); +} // init + +} } } /* namespace Inkscape, Extension, Implementation */ +#endif /* WITH_LIBVISIO */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/internal/vsd-input.h b/src/extension/internal/vsd-input.h new file mode 100644 index 000000000..acc52debf --- /dev/null +++ b/src/extension/internal/vsd-input.h @@ -0,0 +1,54 @@ +/* + * This code abstracts the libwpg interfaces into the Inkscape + * input extension interface. + * + * Authors: + * Fridrich Strba (fridrich.strba@bluewin.ch) + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__ +#define __EXTENSION_INTERNAL_VSDOUTPUT_H__ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef WITH_LIBVISIO + +#include + +#include "../implementation/implementation.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +class VsdInput : public Inkscape::Extension::Implementation::Implementation { + VsdInput () { }; +public: + SPDocument *open( Inkscape::Extension::Input *mod, + const gchar *uri ); + static void init( void ); + +}; + +} } } /* namespace Inkscape, Extension, Implementation */ + +#endif /* WITH_LIBVISIO */ +#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_H__ */ + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 3d71bbcdde6255ee9e587124aaccf58dd8741ed6 Mon Sep 17 00:00:00 2001 From: su_v Date: Fri, 21 Sep 2012 14:24:26 +0200 Subject: Fix for bug #1053024: set current layer from template in new blank document after closing last window Fixed bugs: - https://launchpad.net/bugs/1053024 (bzr r11689) --- src/interface.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 710211fe7..acd56f8da 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -322,6 +322,7 @@ sp_ui_close_view(GtkWidget */*widget*/) SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); dt->change_document(doc); sp_namedview_window_from_document(dt); + sp_namedview_update_layers_from_document(dt); return; } -- cgit v1.2.3 From 5ab9fc74c53a9e59dd4f46a1f8ff027f878e7836 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 10:43:42 +0900 Subject: Fix for 1014988 : Add gimp spin scale widget (bzr r11690) --- src/ui/widget/Makefile_insert | 4 + src/ui/widget/gimpspinscale.c | 1089 +++++++++++++++++++++++++++++++++++++++++ src/ui/widget/gimpspinscale.h | 76 +++ src/ui/widget/spin-scale.cpp | 248 ++++++++++ src/ui/widget/spin-scale.h | 117 +++++ 5 files changed, 1534 insertions(+) create mode 100644 src/ui/widget/gimpspinscale.c create mode 100644 src/ui/widget/gimpspinscale.h create mode 100644 src/ui/widget/spin-scale.cpp create mode 100644 src/ui/widget/spin-scale.h (limited to 'src') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index 8589f16b0..bbda64648 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -19,6 +19,8 @@ ink_common_sources += \ ui/widget/entry.h \ ui/widget/filter-effect-chooser.h \ ui/widget/filter-effect-chooser.cpp \ + ui/widget/gimpspinscale.c \ + ui/widget/gimpspinscale.h \ ui/widget/frame.cpp \ ui/widget/frame.h \ ui/widget/imageicon.cpp \ @@ -62,6 +64,8 @@ ink_common_sources += \ ui/widget/selected-style.cpp \ ui/widget/spinbutton.h \ ui/widget/spinbutton.cpp \ + ui/widget/spin-scale.h \ + ui/widget/spin-scale.cpp \ ui/widget/spin-slider.h \ ui/widget/spin-slider.cpp \ ui/widget/style-subject.h \ diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c new file mode 100644 index 000000000..1b7ac7bfe --- /dev/null +++ b/src/ui/widget/gimpspinscale.c @@ -0,0 +1,1089 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpspinscale.c + * Copyright (C) 2010 Michael Natterer + * 2012 Øyvind Kolås + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#include "gimpspinscale.h" + + +enum +{ + PROP_0, + PROP_LABEL, + PROP_FOCUS_WIDGET +}; + +typedef enum +{ + TARGET_NUMBER, + TARGET_UPPER, + TARGET_LOWER +#if WITH_GTKMM_3_0 + ,TARGET_NONE +#endif +} SpinScaleTarget; + +typedef enum +{ + APPEARANCE_FULL = 1, /* Full size suitable for tablets */ + APPEARANCE_COMPACT, /* Compact, suitable for desktops with mouse control */ +} SpinScaleAppearance; + +typedef struct _GimpSpinScalePrivate GimpSpinScalePrivate; + +struct _GimpSpinScalePrivate +{ + gchar *label; + + gboolean scale_limits_set; + gdouble scale_lower; + gdouble scale_upper; + gdouble gamma; + + PangoLayout *layout; + gboolean changing_value; + gboolean relative_change; + gdouble start_x; + gdouble start_value; + + GtkWidget* focusWidget; + gboolean transferFocus; + SpinScaleAppearance appearanceMode; +}; + +#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + GIMP_TYPE_SPIN_SCALE, \ + GimpSpinScalePrivate)) + + +static void gimp_spin_scale_dispose (GObject *object); +static void gimp_spin_scale_finalize (GObject *object); +static void gimp_spin_scale_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_spin_scale_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void gimp_spin_scale_style_set (GtkWidget *widget, + GtkStyle *prev_style); + +#if WITH_GTKMM_3_0 +static void gimp_spin_scale_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); +static void gimp_spin_scale_get_preferred_height (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); +static gboolean gimp_spin_scale_draw (GtkWidget *widget, + cairo_t *cr); +#else +static void gimp_spin_scale_size_request (GtkWidget *widget, + GtkRequisition *requisition); + +static gboolean gimp_spin_scale_expose (GtkWidget *widget, + GdkEventExpose *event); +#endif + +static gboolean gimp_spin_scale_button_press (GtkWidget *widget, + GdkEventButton *event); +static gboolean gimp_spin_scale_button_release (GtkWidget *widget, + GdkEventButton *event); +static gboolean gimp_spin_scale_motion_notify (GtkWidget *widget, + GdkEventMotion *event); +static gboolean gimp_spin_scale_leave_notify (GtkWidget *widget, + GdkEventCrossing *event); +static gboolean gimp_spin_scale_keypress( GtkWidget *widget, + GdkEventKey *event); + +static void gimp_spin_scale_defocus( GtkSpinButton *spin_button ); + +static void gimp_spin_scale_value_changed (GtkSpinButton *spin_button); + + +G_DEFINE_TYPE (GimpSpinScale, gimp_spin_scale, GTK_TYPE_SPIN_BUTTON); + +#define parent_class gimp_spin_scale_parent_class + + +static void +gimp_spin_scale_class_init (GimpSpinScaleClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GtkSpinButtonClass *spin_button_class = GTK_SPIN_BUTTON_CLASS (klass); + + object_class->dispose = gimp_spin_scale_dispose; + object_class->finalize = gimp_spin_scale_finalize; + object_class->set_property = gimp_spin_scale_set_property; + object_class->get_property = gimp_spin_scale_get_property; + + widget_class->style_set = gimp_spin_scale_style_set; +#if WITH_GTKMM_3_0 + widget_class->get_preferred_width = gimp_spin_scale_get_preferred_width; + widget_class->get_preferred_height = gimp_spin_scale_get_preferred_height; + widget_class->draw = gimp_spin_scale_draw; +#else + widget_class->size_request = gimp_spin_scale_size_request; + widget_class->expose_event = gimp_spin_scale_expose; +#endif + widget_class->button_press_event = gimp_spin_scale_button_press; + widget_class->button_release_event = gimp_spin_scale_button_release; + widget_class->motion_notify_event = gimp_spin_scale_motion_notify; + widget_class->leave_notify_event = gimp_spin_scale_leave_notify; + widget_class->key_press_event = gimp_spin_scale_keypress; + + spin_button_class->value_changed = gimp_spin_scale_value_changed; + + g_object_class_install_property (object_class, PROP_LABEL, + g_param_spec_string ("label", NULL, NULL, + NULL, + G_PARAM_READWRITE)); + + g_type_class_add_private (klass, sizeof (GimpSpinScalePrivate)); +} + +static void +gimp_spin_scale_init (GimpSpinScale *scale) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (scale); + + gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE); + + private->gamma = 1.0; + private->focusWidget = NULL; + private->transferFocus = FALSE; + private->appearanceMode = APPEARANCE_COMPACT; +} + +static void +gimp_spin_scale_dispose (GObject *object) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (object); + + if (private->layout) + { + g_object_unref (private->layout); + private->layout = NULL; + } + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +gimp_spin_scale_finalize (GObject *object) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (object); + + if (private->label) + { + g_free (private->label); + private->label = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gimp_spin_scale_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (object); + + switch (property_id) + { + case PROP_LABEL: + g_free (private->label); + private->label = g_value_dup_string (value); + if (private->layout) + { + g_object_unref (private->layout); + private->layout = NULL; + } + gtk_widget_queue_resize (GTK_WIDGET (object)); + break; + + case PROP_FOCUS_WIDGET: + { + /* TODO unhook prior */ + private->focusWidget = (GtkWidget*)g_value_get_pointer( value ); + } + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_spin_scale_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (object); + + switch (property_id) + { + case PROP_LABEL: + g_value_set_string (value, private->label); + break; + + case PROP_FOCUS_WIDGET: + g_value_set_pointer( value, private->focusWidget ); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +void +gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget ) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (scale); + + /* TODO unhook prior */ + + private->focusWidget = widget; +} + +void +gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + + if ( strcmp("full", appearance) == 0 ) { + private->appearanceMode = APPEARANCE_FULL; + } else if ( strcmp("compact", appearance) == 0 ) { + private->appearanceMode = APPEARANCE_COMPACT; + } +} + +static void +#if WITH_GTKMM_3_0 +gimp_spin_scale_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +#else +gimp_spin_scale_size_request (GtkWidget *widget, + GtkRequisition *requisition) +#endif +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + GtkStyle *style = gtk_widget_get_style (widget); + PangoContext *context = gtk_widget_get_pango_context (widget); + PangoFontMetrics *metrics; + +#if WITH_GTKMM_3_0 + GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, + minimum_width, + natural_width); +#else + gint height; + GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); +#endif + + metrics = pango_context_get_metrics (context, style->font_desc, + pango_context_get_language (context)); + +#if WITH_GTKMM_3_0 +#else + height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + + pango_font_metrics_get_descent (metrics)); + + if (private->appearanceMode == APPEARANCE_COMPACT) { + requisition->height += 1; + } else { + requisition->height += height; + } + +#endif + + + if (private->label) + { + gint char_width; + gint digit_width; + gint char_pixels; + + char_width = pango_font_metrics_get_approximate_char_width (metrics); + digit_width = pango_font_metrics_get_approximate_digit_width (metrics); + char_pixels = PANGO_PIXELS (MAX (char_width, digit_width)); + +#if WITH_GTKMM_3_0 + *minimum_width += char_pixels * 3; + *natural_width += char_pixels * 3; +#else + /* ~3 chars for the ellipses */ + requisition->width += char_pixels * 3; +#endif + + } + + pango_font_metrics_unref (metrics); +} + +#if WITH_GTKMM_3_0 +static void +gimp_spin_scale_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkStyle *style = gtk_widget_get_style (widget); + PangoContext *context = gtk_widget_get_pango_context (widget); + PangoFontMetrics *metrics; + //gint height; + + GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget, + minimum_height, + natural_height); + + metrics = pango_context_get_metrics (context, style->font_desc, + pango_context_get_language (context)); + + //height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + + // pango_font_metrics_get_descent (metrics)); + + *minimum_height += 1; + *natural_height += 1; + + pango_font_metrics_unref (metrics); +} +#endif + +static void +gimp_spin_scale_style_set (GtkWidget *widget, + GtkStyle *prev_style) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + + GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); + + if (private->layout) + { + g_object_unref (private->layout); + private->layout = NULL; + } +} + + +static gboolean + +#if WITH_GTKMM_3_0 + gimp_spin_scale_draw (GtkWidget *widget, cairo_t *cr) +#else + gimp_spin_scale_expose (GtkWidget *widget, GdkEventExpose *event) +#endif +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + GtkStyle *style = gtk_widget_get_style (widget); + + +#if WITH_GTKMM_3_0 + GtkAllocation allocation; + + cairo_save (cr); + GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); + cairo_restore (cr); + + gtk_widget_get_allocation (widget, &allocation); + + +#else + cairo_t *cr; + gint w; + + GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + + cr = gdk_cairo_create (event->window); + gdk_cairo_region (cr, event->region); + cairo_clip (cr); + + w = gdk_window_get_width (event->window); + +#endif + + cairo_set_line_width (cr, 1.0); + + +#if WITH_GTKMM_3_0 + if (private->label) + { + GdkRectangle text_area; + gint minimum_width; + gint natural_width; +#else + if (private->label && + gtk_widget_is_drawable (widget) && + event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) + { + GtkRequisition requisition; + GtkAllocation allocation; +#endif + + PangoRectangle logical; + gint layout_offset_x; + gint layout_offset_y; + +#if WITH_GTKMM_3_0 + gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); + + GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, + &minimum_width, + &natural_width); +#else + GTK_WIDGET_CLASS (parent_class)->size_request (widget, &requisition); + gtk_widget_get_allocation (widget, &allocation); +#endif + + if (! private->layout) + { + private->layout = gtk_widget_create_pango_layout (widget, + private->label); + pango_layout_set_ellipsize (private->layout, PANGO_ELLIPSIZE_END); + } + + pango_layout_set_width (private->layout, + PANGO_SCALE * +#if WITH_GTKMM_3_0 + (allocation.width - minimum_width + 10)); +#else + (allocation.width - requisition.width + 10)); +#endif + pango_layout_get_pixel_extents (private->layout, NULL, &logical); + + gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y); + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) +#if WITH_GTKMM_3_0 + layout_offset_x = text_area.x + text_area.width - logical.width - 4; +#else + layout_offset_x = w - logical.width - 4; +#endif + else + layout_offset_x = 4; + + layout_offset_x -= logical.x; + +#if WITH_GTKMM_3_0 + cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); +#else + cairo_move_to (cr, layout_offset_x, layout_offset_y-3); +#endif + + gdk_cairo_set_source_color (cr, + &style->text[gtk_widget_get_state (widget)]); + + pango_cairo_show_layout (cr, private->layout); + } + +#if WITH_GTKMM_3_0 +#else + cairo_destroy (cr); +#endif + + return FALSE; +} + +#if WITH_GTKMM_3_0 +/* Returns TRUE if a translation should be done */ +static gboolean +gtk_widget_get_translation_to_window (GtkWidget *widget, + GdkWindow *window, + int *x, + int *y) +{ + GdkWindow *w, *widget_window; + + if (!gtk_widget_get_has_window (widget)) + { + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + + *x = -allocation.x; + *y = -allocation.y; + } + else + { + *x = 0; + *y = 0; + } + + widget_window = gtk_widget_get_window (widget); + + for (w = window; w && w != widget_window; w = gdk_window_get_parent (w)) + { + int wx, wy; + gdk_window_get_position (w, &wx, &wy); + *x += wx; + *y += wy; + } + + if (w == NULL) + { + *x = 0; + *y = 0; + return FALSE; + } + + return TRUE; +} + +static void +gimp_spin_scale_event_to_widget_coords (GtkWidget *widget, + GdkWindow *window, + gdouble event_x, + gdouble event_y, + gint *widget_x, + gint *widget_y) +{ + gint tx, ty; + + if (gtk_widget_get_translation_to_window (widget, window, &tx, &ty)) + { + event_x += tx; + event_y += ty; + } + + *widget_x = event_x; + *widget_y = event_y; +} +#endif + +static SpinScaleTarget +gimp_spin_scale_get_target (GtkWidget *widget, + gdouble x, + gdouble y) +{ + GtkAllocation allocation; + PangoRectangle logical; + gint layout_x; + gint layout_y; + + gtk_widget_get_allocation (widget, &allocation); + gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y); + pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)), + NULL, &logical); + +#if WITH_GTKMM_3_0 + GdkRectangle text_area; + gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); + + if (x >= text_area.x && x < text_area.width && + y >= text_area.y && y < text_area.height) + { + x -= text_area.x; + y -= text_area.y; + + if (x > layout_x && x < layout_x + logical.width && + y > layout_y && y < layout_y + logical.height) + { + return TARGET_NUMBER; + } + else if (y > text_area.height / 2) + { + return TARGET_LOWER; + } + + return TARGET_UPPER; + } + + return TARGET_NONE; +#else + if (x > layout_x && x < layout_x + logical.width && + y > layout_y && y < layout_y + logical.height) + { + return TARGET_NUMBER; + } + + else if (y > allocation.height / 2) + { + return TARGET_LOWER; + } + return TARGET_UPPER; +#endif +} + +static void +gimp_spin_scale_get_limits (GimpSpinScale *scale, + gdouble *lower, + gdouble *upper) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (scale); + + if (private->scale_limits_set) + { + *lower = private->scale_lower; + *upper = private->scale_upper; + } + else + { + GtkSpinButton *spin_button = GTK_SPIN_BUTTON (scale); + GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); + + *lower = gtk_adjustment_get_lower (adjustment); + *upper = gtk_adjustment_get_upper (adjustment); + } +} + +static void +gimp_spin_scale_change_value (GtkWidget *widget, + gdouble x) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); + GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); + gdouble lower; + gdouble upper; + gdouble value; +#if WITH_GTKMM_3_0 +#else +#endif +#if WITH_GTKMM_3_0 + GdkRectangle text_area; + gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); + gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); +#else + GdkWindow *text_window = gtk_entry_get_text_window (GTK_ENTRY (widget)); + gint width; + + gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); + width = gdk_window_get_width (text_window); + +#endif + + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) +#if WITH_GTKMM_3_0 + x = text_area.width - x; +#else + x = width - x; +#endif + + + if (private->relative_change) + { + gdouble diff; + gdouble step; + + +#if WITH_GTKMM_3_0 + step = (upper - lower) / text_area.width / 10.0; +#else + step = (upper - lower) / width / 10.0; +#endif + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + +#if WITH_GTKMM_3_0 + diff = x - (text_area.width - private->start_x); +#else + diff = x - (width - private->start_x); +#endif + else + diff = x - private->start_x; + + value = (private->start_value + diff * step); + } + else + { + gdouble fraction; + + +#if WITH_GTKMM_3_0 + fraction = x / (gdouble) text_area.width; +#else + fraction = x / (gdouble) width; +#endif + if (fraction > 0.0) + fraction = pow (fraction, private->gamma); + + value = fraction * (upper - lower) + lower; + } + + gtk_adjustment_set_value (adjustment, value); +} + +static gboolean +gimp_spin_scale_button_press (GtkWidget *widget, + GdkEventButton *event) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + + private->changing_value = FALSE; + private->relative_change = FALSE; + +#if WITH_GTKMM_3_0 + gint x, y; + gimp_spin_scale_event_to_widget_coords (widget, event->window, + event->x, event->y, + &x, &y); + switch (gimp_spin_scale_get_target (widget, x, y)) + { + case TARGET_UPPER: + private->changing_value = TRUE; + + gtk_widget_grab_focus (widget); + + gimp_spin_scale_change_value (widget, x); + + return TRUE; + + case TARGET_LOWER: + private->changing_value = TRUE; + + gtk_widget_grab_focus (widget); + + private->relative_change = TRUE; + private->start_x = x; + private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget))); + + return TRUE; + + default: + break; + } +#else + if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) + { + switch (gimp_spin_scale_get_target (widget, event->x, event->y)) + { + case TARGET_UPPER: + private->changing_value = TRUE; + + gtk_widget_grab_focus (widget); + + gimp_spin_scale_change_value (widget, event->x); + + return TRUE; + + case TARGET_LOWER: + private->changing_value = TRUE; + + gtk_widget_grab_focus (widget); + + private->relative_change = TRUE; + private->start_x = event->x; + private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget))); + + return TRUE; + + default: + break; + } + } +#endif + + return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); +} + +static gboolean +gimp_spin_scale_button_release (GtkWidget *widget, + GdkEventButton *event) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); +#if WITH_GTKMM_3_0 + gint x, y; + + gimp_spin_scale_event_to_widget_coords (widget, event->window, + event->x, event->y, + &x, &y); +#endif + + if (private->changing_value) + { + private->changing_value = FALSE; +#if WITH_GTKMM_3_0 + gimp_spin_scale_change_value (widget, x); +#else + gimp_spin_scale_change_value (widget, event->x); +#endif + return TRUE; + } + + return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event); +} + +static gboolean +gimp_spin_scale_motion_notify (GtkWidget *widget, + GdkEventMotion *event) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); +#if WITH_GTKMM_3_0 + gint x, y; + + gimp_spin_scale_event_to_widget_coords (widget, event->window, + event->x, event->y, + &x, &y); +#endif + + if (private->changing_value) + { +#if WITH_GTKMM_3_0 + gimp_spin_scale_change_value (widget, x); +#else + gimp_spin_scale_change_value (widget, event->x); +#endif + + return TRUE; + } + + GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event); + + if (! (event->state & + (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) +#if WITH_GTKMM_3_0 +#else + && event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)) +#endif + ) + { + GdkDisplay *display = gtk_widget_get_display (widget); + GdkCursor *cursor = NULL; + +#if WITH_GTKMM_3_0 + switch (gimp_spin_scale_get_target (widget, x, y)) +#else + switch (gimp_spin_scale_get_target (widget, event->x, event->y)) +#endif + { + case TARGET_NUMBER: + cursor = gdk_cursor_new_for_display (display, GDK_XTERM); + break; + + case TARGET_UPPER: + cursor = gdk_cursor_new_for_display (display, GDK_SB_UP_ARROW); + break; + + case TARGET_LOWER: + cursor = gdk_cursor_new_for_display (display, GDK_SB_H_DOUBLE_ARROW); + break; + + default: + break; + } + + +#if WITH_GTKMM_3_0 + if (cursor) + { + gdk_window_set_cursor (event->window, cursor); + g_object_unref (cursor); + } +#else + gdk_window_set_cursor (event->window, cursor); + gdk_cursor_unref (cursor); +#endif + } + + return FALSE; +} + +static gboolean +gimp_spin_scale_leave_notify (GtkWidget *widget, + GdkEventCrossing *event) +{ + gdk_window_set_cursor (event->window, NULL); + + return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event); +} + +gboolean gimp_spin_scale_keypress( GtkWidget *widget, GdkEventKey *event) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (widget); + guint key = 0; + gdk_keymap_translate_keyboard_state( gdk_keymap_get_for_display( gdk_display_get_default() ), + event->hardware_keycode, (GdkModifierType)event->state, + 0, &key, 0, 0, 0 ); + + switch ( key ) { + + case GDK_KEY_Escape: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: + { + private->transferFocus = TRUE; + gimp_spin_scale_defocus( GTK_SPIN_BUTTON(widget) ); + } + break; + + } + + return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); +} + +static void +gimp_spin_scale_defocus( GtkSpinButton *spin_button ) +{ + GimpSpinScalePrivate *private = GET_PRIVATE (spin_button); + + if ( private->transferFocus ) { + if ( private->focusWidget ) { + gtk_widget_grab_focus( private->focusWidget ); + } + } +} + +static void +gimp_spin_scale_value_changed (GtkSpinButton *spin_button) +{ + GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button); + GimpSpinScalePrivate *private = GET_PRIVATE (spin_button); + gdouble lower; + gdouble upper; + gdouble value; + + gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper); + + value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper); + + + gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button), + pow ((value - lower) / (upper - lower), + 1.0 / private->gamma)); + + // TODO - Allow scrollwheel to change value then return focus, + // but clicks/keypress should keep focus in the control + //if ( gtk_widget_has_focus( GTK_WIDGET(spin_button) ) ) { + // gimp_spin_scale_defocus( spin_button ); + //} +} + + +/* public functions */ + +GtkWidget * +gimp_spin_scale_new (GtkAdjustment *adjustment, + const gchar *label, + gint digits) +{ + g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL); + + return g_object_new (GIMP_TYPE_SPIN_SCALE, + "adjustment", adjustment, + "label", label, + "digits", digits, + NULL); +} + +void +gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, + gdouble lower, + gdouble upper) +{ + GimpSpinScalePrivate *private; + GtkSpinButton *spin_button; + GtkAdjustment *adjustment; + + g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); + + private = GET_PRIVATE (scale); + spin_button = GTK_SPIN_BUTTON (scale); + adjustment = gtk_spin_button_get_adjustment (spin_button); + + g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment)); + g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment)); + + private->scale_limits_set = TRUE; + private->scale_lower = lower; + private->scale_upper = upper; + private->gamma = 1.0; + + gimp_spin_scale_value_changed (spin_button); +} + +void +gimp_spin_scale_set_gamma (GimpSpinScale *scale, + gdouble gamma) +{ + GimpSpinScalePrivate *private; + + g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); + + private = GET_PRIVATE (scale); + + private->gamma = gamma; + + gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); +} + +gdouble +gimp_spin_scale_get_gamma (GimpSpinScale *scale) +{ + GimpSpinScalePrivate *private; + + g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0); + + private = GET_PRIVATE (scale); + + return private->gamma; +} + +void +gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale) +{ + GimpSpinScalePrivate *private; + + g_return_if_fail (GIMP_IS_SPIN_SCALE (scale)); + + private = GET_PRIVATE (scale); + + private->scale_limits_set = FALSE; + private->scale_lower = 0.0; + private->scale_upper = 0.0; + + gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale)); +} + +gboolean +gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, + gdouble *lower, + gdouble *upper) +{ + GimpSpinScalePrivate *private; + + g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE); + + private = GET_PRIVATE (scale); + + if (lower) + *lower = private->scale_lower; + + if (upper) + *upper = private->scale_upper; + + return private->scale_limits_set; +} diff --git a/src/ui/widget/gimpspinscale.h b/src/ui/widget/gimpspinscale.h new file mode 100644 index 000000000..ad63625ac --- /dev/null +++ b/src/ui/widget/gimpspinscale.h @@ -0,0 +1,76 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpspinscale.h + * Copyright (C) 2010 Michael Natterer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __GIMP_SPIN_SCALE_H__ +#define __GIMP_SPIN_SCALE_H__ + +#ifndef WITH_GIMP +#include +#endif + +G_BEGIN_DECLS + +#define GIMP_TYPE_SPIN_SCALE (gimp_spin_scale_get_type ()) +#define GIMP_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScale)) +#define GIMP_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass)) +#define GIMP_IS_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SPIN_SCALE)) +#define GIMP_IS_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SPIN_SCALE)) +#define GIMP_SPIN_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass)) + + +typedef struct _GimpSpinScale GimpSpinScale; +typedef struct _GimpSpinScaleClass GimpSpinScaleClass; + +struct _GimpSpinScale +{ + GtkSpinButton parent_instance; +}; + +struct _GimpSpinScaleClass +{ + GtkSpinButtonClass parent_class; +}; + + +GType gimp_spin_scale_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment, + const gchar *label, + gint digits); + +void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale, + gdouble lower, + gdouble upper); +void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale); +gboolean gimp_spin_scale_get_scale_limits (GimpSpinScale *scale, + gdouble *lower, + gdouble *upper); + +void gimp_spin_scale_set_gamma (GimpSpinScale *scale, + gdouble gamma); +gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale); + +void gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget ); + +void gimp_spin_scale_set_appearance( GtkWidget *scale, const gchar *appearance); + +G_END_DECLS + +#endif /* __GIMP_SPIN_SCALE_H__ */ diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp new file mode 100644 index 000000000..00c575568 --- /dev/null +++ b/src/ui/widget/spin-scale.cpp @@ -0,0 +1,248 @@ +/* + * Author: + * + * Copyright (C) 2012 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#include +#include +#include +#include + +#include "spin-scale.h" +#include "ui/widget/gimpspinscale.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +SpinScale::SpinScale(const char* label, double value, double lower, double upper, double step_inc, + double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text) + : AttrWidget(a, value) +{ + +#if WITH_GTKMM_3_0 + _adjustment = Gtk::Adjustment::create(value, lower, upper, step_inc); + _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); +#else + _adjustment = new Gtk::Adjustment(value, lower, upper, step_inc); + _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); +#endif + + signal_value_changed().connect(signal_attr_changed().make_slot()); + + pack_start(*Gtk::manage(Glib::wrap(_spinscale))); + + if (tip_text){ + gtk_widget_set_tooltip_text( _spinscale, tip_text ); + } + + show_all_children(); +} + +SpinScale::SpinScale(const char* label, +#if WITH_GTKMM_3_0 + Glib::RefPtr adj, +#else + Gtk::Adjustment *adj, +#endif + int digits, const SPAttributeEnum a, const char* tip_text) + : AttrWidget(a, 0.0), + _adjustment(adj) + +{ + + _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); + + signal_value_changed().connect(signal_attr_changed().make_slot()); + + pack_start(*Gtk::manage(Glib::wrap(_spinscale))); + + if (tip_text){ + gtk_widget_set_tooltip_text( _spinscale, tip_text ); + } + + show_all_children(); +} + +Glib::ustring SpinScale::get_as_attribute() const +{ + const double val = _adjustment->get_value(); + + //if(_spin.get_digits() == 0) + // return Glib::Ascii::dtostr((int)val); + //else + return Glib::Ascii::dtostr(val); +} + +void SpinScale::set_from_attribute(SPObject* o) +{ + const gchar* val = attribute_value(o); + if(val) + _adjustment->set_value(Glib::Ascii::strtod(val)); + else + _adjustment->set_value(get_default()->as_double()); +} + +Glib::SignalProxy0 SpinScale::signal_value_changed() +{ + return _adjustment->signal_value_changed(); +} + +double SpinScale::get_value() const +{ + return _adjustment->get_value(); +} + +void SpinScale::set_value(const double val) +{ + _adjustment->set_value(val); +} + +void SpinScale::set_focuswidget(GtkWidget *widget) +{ + gimp_spin_scale_set_focuswidget(_spinscale, widget); +} + + +void SpinScale::set_appearance(const gchar* appearance) +{ + gimp_spin_scale_set_appearance(_spinscale, appearance); +} + +#if WITH_GTKMM_3_0 +const Glib::RefPtr SpinScale::get_adjustment() const +#else +const Gtk::Adjustment *SpinScale::get_adjustment() const +#endif +{ + return _adjustment; +} +#if WITH_GTKMM_3_0 +Glib::RefPtr SpinScale::get_adjustment() +#else +Gtk::Adjustment *SpinScale::get_adjustment() +#endif +{ + return _adjustment; +} + + +DualSpinScale::DualSpinScale(const char* label1, const char* label2, double value, double lower, double upper, double step_inc, + double climb_rate, int digits, const SPAttributeEnum a, char* tip_text1, char* tip_text2) + : AttrWidget(a), + _s1(label1, value, lower, upper, step_inc, climb_rate, digits, SP_ATTR_INVALID, tip_text1), + _s2(label2, value, lower, upper, step_inc, climb_rate, digits, SP_ATTR_INVALID, tip_text2), + //TRANSLATORS: "Link" means to _link_ two sliders together + _link(C_("Sliders", "Link")) +{ + signal_value_changed().connect(signal_attr_changed().make_slot()); + + _s1.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot()); + _s2.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot()); + _s1.get_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinScale::update_linked)); + + _link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinScale::link_toggled)); + + Gtk::VBox* vb = Gtk::manage(new Gtk::VBox); + vb->add(_s1); + vb->add(_s2); + pack_start(*vb); + pack_start(_link, false, false); + _link.set_active(true); + + show_all(); +} + +Glib::ustring DualSpinScale::get_as_attribute() const +{ + if(_link.get_active()) + return _s1.get_as_attribute(); + else + return _s1.get_as_attribute() + " " + _s2.get_as_attribute(); +} + +void DualSpinScale::set_from_attribute(SPObject* o) +{ + const gchar* val = attribute_value(o); + if(val) { + // Split val into parts + gchar** toks = g_strsplit(val, " ", 2); + + if(toks) { + double v1 = 0.0, v2 = 0.0; + if(toks[0]) + v1 = v2 = Glib::Ascii::strtod(toks[0]); + if(toks[1]) + v2 = Glib::Ascii::strtod(toks[1]); + + _link.set_active(toks[1] == 0); + + _s1.get_adjustment()->set_value(v1); + _s2.get_adjustment()->set_value(v2); + + g_strfreev(toks); + } + } +} + +sigc::signal& DualSpinScale::signal_value_changed() +{ + return _signal_value_changed; +} + +const SpinScale& DualSpinScale::get_SpinScale1() const +{ + return _s1; +} + +SpinScale& DualSpinScale::get_SpinScale1() +{ + return _s1; +} + +const SpinScale& DualSpinScale::get_SpinScale2() const +{ + return _s2; +} + +SpinScale& DualSpinScale::get_SpinScale2() +{ + return _s2; +} + +/*void DualSpinScale::remove_scale() +{ + _s1.remove_scale(); + _s2.remove_scale(); +}*/ + +void DualSpinScale::link_toggled() +{ + _s2.set_sensitive(!_link.get_active()); + update_linked(); +} + +void DualSpinScale::update_linked() +{ + if(_link.get_active()) + _s2.set_value(_s1.get_value()); +} + + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h new file mode 100644 index 000000000..a8403307f --- /dev/null +++ b/src/ui/widget/spin-scale.h @@ -0,0 +1,117 @@ +/* + * Author: + * + * Copyright (C) 2012 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_SPIN_SCALE_H +#define INKSCAPE_UI_WIDGET_SPIN_SCALE_H + +#include +#include +#include +#include +#include "spinbutton.h" +#include "attr-widget.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * Wrap the gimpspinscale class + * A combo widget with label, scale slider, spinbutton and adjustment + */ +class SpinScale : public Gtk::HBox, public AttrWidget +{ + +public: + SpinScale(const char* label, double value, double lower, double upper, double step_inc, double climb_rate, + int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); + + SpinScale(const char* label, +#if WITH_GTKMM_3_0 + Glib::RefPtr adj, +#else + Gtk::Adjustment *adj, +#endif + int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); + + virtual Glib::ustring get_as_attribute() const; + virtual void set_from_attribute(SPObject*); + + // Shortcuts to _adjustment + Glib::SignalProxy0 signal_value_changed(); + double get_value() const; + void set_value(const double); + void set_focuswidget(GtkWidget *widget); + void set_appearance(const gchar* appearance); + +#if WITH_GTKMM_3_0 + const Glib::RefPtr get_adjustment() const; + Glib::RefPtr get_adjustment(); +#else + const Gtk::Adjustment *get_adjustment() const; + Gtk::Adjustment *get_adjustment(); +#endif + +private: +#if WITH_GTKMM_3_0 + Glib::RefPtr _adjustment; +#else + Gtk::Adjustment *_adjustment; +#endif + + GtkWidget *_spinscale; +}; + + +/** + * Contains two SpinScales for controlling number-opt-number attributes. + * + * @see SpinScale + */ +class DualSpinScale : public Gtk::HBox, public AttrWidget +{ +public: + DualSpinScale(const char* label1, const char* label2, double value, double lower, double upper, double step_inc, + double climb_rate, int digits, const SPAttributeEnum, char* tip_text1, char* tip_text2); + + virtual Glib::ustring get_as_attribute() const; + virtual void set_from_attribute(SPObject*); + + sigc::signal& signal_value_changed(); + + const SpinScale& get_SpinScale1() const; + SpinScale& get_SpinScale1(); + + const SpinScale& get_SpinScale2() const; + SpinScale& get_SpinScale2(); + + //void remove_scale(); +private: + void link_toggled(); + void update_linked(); + sigc::signal _signal_value_changed; + SpinScale _s1, _s2; + Gtk::ToggleButton _link; +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_SPIN_SCALE_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 7c0506c103c881790a2e347e2a68aecdf8935d5c Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 12:27:14 +0900 Subject: Fix for 1014988 : Converts slide widgets to new spin-scale widget (bzr r11691) --- src/ege-adjustment-action.cpp | 10 +--- src/extension/param/float.cpp | 25 ++++---- src/extension/param/int.cpp | 25 ++++---- src/ui/dialog/document-properties.cpp | 18 +++--- src/ui/dialog/fill-and-stroke.cpp | 2 +- src/ui/dialog/filter-effects-dialog.cpp | 88 ++++++++++++++--------------- src/ui/dialog/filter-effects-dialog.h | 1 + src/ui/widget/filter-effect-chooser.cpp | 15 +---- src/ui/widget/filter-effect-chooser.h | 8 +-- src/ui/widget/object-composite-settings.cpp | 58 ++++++------------- src/ui/widget/object-composite-settings.h | 12 +--- src/ui/widget/spin-slider.cpp | 2 +- 12 files changed, 110 insertions(+), 154 deletions(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 7881498b9..cf179478d 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -47,6 +47,7 @@ #include "icon-size.h" #include "ege-adjustment-action.h" +#include "ui/widget/gimpspinscale.h" static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ); @@ -835,15 +836,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { /* Slider */ - gchar *leakyForNow = g_value_dup_string( &value ); -#if GTK_CHECK_VERSION(3,0,0) - spinbutton = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, act->private_data->adj); -#else - spinbutton = gtk_hscale_new( act->private_data->adj); -#endif + spinbutton = gimp_spin_scale_new (act->private_data->adj, g_value_get_string( &value ), 0); gtk_widget_set_size_request(spinbutton, 100, -1); - gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); - g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { spinbutton = gtk_scale_button_new( GTK_ICON_SIZE_MENU, 0, 100, 2, 0 ); diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index b9ffe68d2..81508f6c0 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -14,6 +14,7 @@ #include #include #include "ui/widget/spinbutton.h" +#include "ui/widget/spin-scale.h" #include "xml/node.h" #include "extension/extension.h" @@ -175,9 +176,6 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, true, true, _indent); #if WITH_GTKMM_3_0 ParamFloatAdjustment * pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); @@ -187,24 +185,27 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod #endif if (_mode == FULL) { -#if WITH_GTKMM_3_0 - Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust)); -#else - Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); -#endif - scale->set_draw_value(false); - scale->set_size_request(200, -1); + + UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision); + scale->set_size_request(400, -1); scale->show(); hbox->pack_start(*scale, false, false); + } + else if (_mode == MINIMAL) { + + Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + label->show(); + hbox->pack_start(*label, true, true, _indent); #if WITH_GTKMM_3_0 Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision)); #else Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision)); #endif - spin->show(); - hbox->pack_start(*spin, false, false); + spin->show(); + hbox->pack_start(*spin, false, false); + } hbox->show(); diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index 7cb930f50..c286018fd 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -14,6 +14,7 @@ #include #include #include "ui/widget/spinbutton.h" +#include "ui/widget/spin-scale.h" #include "xml/node.h" #include "extension/extension.h" @@ -156,9 +157,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, true, true, _indent); + #if WITH_GTKMM_3_0 ParamIntAdjustment * pia = new ParamIntAdjustment(this, doc, node, changeSignal); @@ -168,24 +167,26 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal #endif if (_mode == FULL) { -#if WITH_GTKMM_3_0 - Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust)); -#else - Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); -#endif - scale->set_draw_value(false); - scale->set_size_request(200, -1); + + UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, 0); + scale->set_size_request(400, -1); scale->show(); hbox->pack_start(*scale, false, false); } + else if (_mode == MINIMAL) { + Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); + label->show(); + hbox->pack_start(*label, true, true, _indent); + #if WITH_GTKMM_3_0 Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0)); #else Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0)); #endif - spin->show(); - hbox->pack_start(*spin, false, false); + spin->show(); + hbox->pack_start(*spin, false, false); + } hbox->show(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index c7be0877d..7bd1b81c0 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -959,16 +959,18 @@ void DocumentProperties::removeEmbeddedScript(){ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); while ( current ) { - SPObject* obj = SP_OBJECT(current->data); - if (id == obj->getId()){ + if (current->data && SP_IS_OBJECT(current->data)) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ - //XML Tree being used directly here while it shouldn't be. - Inkscape::XML::Node *repr = obj->getRepr(); - if (repr){ - sp_repr_unparent(repr); + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); - // inform the document, so we can undo - DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script")); + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script")); + } } } current = g_slist_next(current); diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 74c19fea7..c7efd3bf2 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -63,7 +63,7 @@ FillAndStroke::FillAndStroke() _layoutPageStrokePaint(); _layoutPageStrokeStyle(); - contents->pack_start(_composite_settings, false, false, 0); + contents->pack_start(_composite_settings, true, true, 0); show_all_children(); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 317cb2773..c3c44f6c3 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -78,8 +78,8 @@ namespace Dialog { using Inkscape::UI::Widget::AttrWidget; using Inkscape::UI::Widget::ComboBoxEnum; -using Inkscape::UI::Widget::DualSpinSlider; -using Inkscape::UI::Widget::SpinSlider; +using Inkscape::UI::Widget::DualSpinScale; +using Inkscape::UI::Widget::SpinScale; // Returns the number of inputs available for the filter primitive type @@ -484,8 +484,8 @@ public: : AttrWidget(SP_ATTR_VALUES), // TRANSLATORS: this dialog is accessible via menu Filters - Filter editor _matrix(SP_ATTR_VALUES, _("This matrix determines a linear transform on color space. Each line affects one of the color components. Each column determines how much of each color component from the input is passed to the output. The last column does not depend on input colors, so can be used to adjust a constant component value.")), - _saturation(0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES), - _angle(0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES), + _saturation("", 0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES), + _angle("", 0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES), _label(_("None"), Gtk::ALIGN_START), _use_stored(false), _saturation_store(0), @@ -567,8 +567,8 @@ private: } MatrixAttr _matrix; - SpinSlider _saturation; - SpinSlider _angle; + SpinScale _saturation; + SpinScale _angle; Gtk::Label _label; // Store separate values for the different color modes @@ -808,22 +808,22 @@ public: return cmv; } - // SpinSlider - SpinSlider* add_spinslider(double def, const SPAttributeEnum attr, const Glib::ustring& label, + // SpinScale + SpinScale* add_spinscale(double def, const SPAttributeEnum attr, const Glib::ustring& label, const double lo, const double hi, const double step_inc, const double climb, const int digits, char* tip_text = NULL) { - SpinSlider* spinslider = new SpinSlider(def, lo, hi, step_inc, climb, digits, attr, tip_text); + SpinScale* spinslider = new SpinScale("", def, lo, hi, step_inc, climb, digits, attr, tip_text); add_widget(spinslider, label); add_attr_widget(spinslider); return spinslider; } - // DualSpinSlider - DualSpinSlider* add_dualspinslider(const SPAttributeEnum attr, const Glib::ustring& label, + // DualSpinScale + DualSpinScale* add_dualspinscale(const SPAttributeEnum attr, const Glib::ustring& label, const double lo, const double hi, const double step_inc, const double climb, const int digits, char* tip_text1 = NULL, char* tip_text2 = NULL) { - DualSpinSlider* dss = new DualSpinSlider(lo, lo, hi, step_inc, climb, digits, attr, tip_text1, tip_text2); + DualSpinScale* dss = new DualSpinScale("", "", lo, lo, hi, step_inc, climb, digits, attr, tip_text1, tip_text2); add_widget(dss, label); add_attr_widget(dss); return dss; @@ -971,8 +971,8 @@ public: // FIXME: these range values are complete crap _settings.type(LIGHT_DISTANT); - _settings.add_spinslider(0, SP_ATTR_AZIMUTH, _("Azimuth"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the XY plane, in degrees")); - _settings.add_spinslider(0, SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the YZ plane, in degrees")); + _settings.add_spinscale(0, SP_ATTR_AZIMUTH, _("Azimuth"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the XY plane, in degrees")); + _settings.add_spinscale(0, SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the YZ plane, in degrees")); _settings.type(LIGHT_POINT); _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location:"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); @@ -982,9 +982,9 @@ public: _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_POINTSATX, SP_ATTR_POINTSATY, SP_ATTR_POINTSATZ, _("Points At"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); - _settings.add_spinslider(1, SP_ATTR_SPECULAREXPONENT, _("Specular Exponent"), 1, 100, 1, 1, 0, _("Exponent value controlling the focus for the light source")); + _settings.add_spinscale(1, SP_ATTR_SPECULAREXPONENT, _("Specular Exponent"), 1, 100, 1, 1, 0, _("Exponent value controlling the focus for the light source")); //TODO: here I have used 100 degrees as default value. But spec says that if not specified, no limiting cone is applied. So, there should be a way for the user to set a "no limiting cone" option. - _settings.add_spinslider(100, SP_ATTR_LIMITINGCONEANGLE, _("Cone Angle"), 1, 100, 1, 1, 0, _("This is the angle between the spot light axis (i.e. the axis between the light source and the point to which it is pointing at) and the spot light cone. No light is projected outside this cone.")); + _settings.add_spinscale(100, SP_ATTR_LIMITINGCONEANGLE, _("Cone Angle"), 1, 100, 1, 1, 0, _("This is the angle between the spot light axis (i.e. the axis between the light source and the point to which it is pointing at) and the spot light cone. No light is projected outside this cone.")); } Gtk::VBox& get_box() @@ -2331,7 +2331,7 @@ void FilterEffectsDialog::show_all_vfunc() void FilterEffectsDialog::init_settings_widgets() { - // TODO: Find better range/climb-rate/digits values for the SpinSliders, + // TODO: Find better range/climb-rate/digits values for the SpinScales, // most of the current values are complete guesses! _empty_settings.set_sensitive(false); @@ -2358,18 +2358,18 @@ void FilterEffectsDialog::init_settings_widgets() /* //TRANSLATORS: for info on "Slope" and "Intercept", see http://id.mind.net/~zona/mmts/functionInstitute/linearFunctions/lsif.html _settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter); - _ct_slope = _settings->add_spinslider(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2); - _ct_intercept = _settings->add_spinslider(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2); - _ct_amplitude = _settings->add_spinslider(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2); - _ct_exponent = _settings->add_spinslider(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2); - _ct_offset = _settings->add_spinslider(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/ + _ct_slope = _settings->add_spinscale(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2); + _ct_intercept = _settings->add_spinscale(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2); + _ct_amplitude = _settings->add_spinscale(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2); + _ct_exponent = _settings->add_spinscale(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2); + _ct_offset = _settings->add_spinscale(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/ _settings->type(NR_FILTER_COMPOSITE); _settings->add_combo(COMPOSITE_OVER, SP_ATTR_OPERATOR, _("Operator:"), CompositeOperatorConverter); - _k1 = _settings->add_spinslider(0, SP_ATTR_K1, _("K1:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); - _k2 = _settings->add_spinslider(0, SP_ATTR_K2, _("K2:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); - _k3 = _settings->add_spinslider(0, SP_ATTR_K3, _("K3:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); - _k4 = _settings->add_spinslider(0, SP_ATTR_K4, _("K4:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); + _k1 = _settings->add_spinscale(0, SP_ATTR_K1, _("K1:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); + _k2 = _settings->add_spinscale(0, SP_ATTR_K2, _("K2:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); + _k3 = _settings->add_spinscale(0, SP_ATTR_K3, _("K3:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); + _k4 = _settings->add_spinscale(0, SP_ATTR_K4, _("K4:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively.")); _settings->type(NR_FILTER_CONVOLVEMATRIX); _convolve_order = _settings->add_dualspinbutton((char*)"3", SP_ATTR_ORDER, _("Size:"), 1, 5, 1, 1, 0, _("width of the convolve matrix"), _("height of the convolve matrix")); @@ -2377,50 +2377,50 @@ void FilterEffectsDialog::init_settings_widgets() //TRANSLATORS: for info on "Kernel", see http://en.wikipedia.org/wiki/Kernel_(matrix) _convolve_matrix = _settings->add_matrix(SP_ATTR_KERNELMATRIX, _("Kernel:"), _("This matrix describes the convolve operation that is applied to the input image in order to calculate the pixel colors at the output. Different arrangements of values in this matrix result in various possible visual effects. An identity matrix would lead to a motion blur effect (parallel to the matrix diagonal) while a matrix filled with a constant non-zero value would lead to a common blur effect.")); _convolve_order->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::convolve_order_changed)); - _settings->add_spinslider(0, SP_ATTR_DIVISOR, _("Divisor:"), 0, 1000, 1, 0.1, 2, _("After applying the kernelMatrix to the input image to yield a number, that number is divided by divisor to yield the final destination color value. A divisor that is the sum of all the matrix values tends to have an evening effect on the overall color intensity of the result.")); - _settings->add_spinslider(0, SP_ATTR_BIAS, _("Bias:"), -10, 10, 1, 0.01, 1, _("This value is added to each component. This is useful to define a constant value as the zero response of the filter.")); + _settings->add_spinscale(0, SP_ATTR_DIVISOR, _("Divisor:"), 0, 1000, 1, 0.1, 2, _("After applying the kernelMatrix to the input image to yield a number, that number is divided by divisor to yield the final destination color value. A divisor that is the sum of all the matrix values tends to have an evening effect on the overall color intensity of the result.")); + _settings->add_spinscale(0, SP_ATTR_BIAS, _("Bias:"), -10, 10, 1, 0.01, 1, _("This value is added to each component. This is useful to define a constant value as the zero response of the filter.")); _settings->add_combo(CONVOLVEMATRIX_EDGEMODE_DUPLICATE, SP_ATTR_EDGEMODE, _("Edge Mode:"), ConvolveMatrixEdgeModeConverter, _("Determines how to extend the input image as necessary with color values so that the matrix operations can be applied when the kernel is positioned at or near the edge of the input image.")); _settings->add_checkbutton(false, SP_ATTR_PRESERVEALPHA, _("Preserve Alpha"), "true", "false", _("If set, the alpha channel won't be altered by this filter primitive.")); _settings->type(NR_FILTER_DIFFUSELIGHTING); _settings->add_color(/*default: white*/ 0xffffffff, SP_PROP_LIGHTING_COLOR, _("Diffuse Color:"), _("Defines the color of the light source")); - _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.01, 0.001, 3, _("This value amplifies the heights of the bump map defined by the input alpha channel")); - _settings->add_spinslider(1, SP_ATTR_DIFFUSECONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model.")); - _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1); + _settings->add_spinscale(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.01, 0.001, 3, _("This value amplifies the heights of the bump map defined by the input alpha channel")); + _settings->add_spinscale(1, SP_ATTR_DIFFUSECONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model.")); + _settings->add_dualspinscale(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1); _settings->add_lightsource(); _settings->type(NR_FILTER_DISPLACEMENTMAP); - _settings->add_spinslider(0, SP_ATTR_SCALE, _("Scale:"), 0, 100, 1, 0.01, 1, _("This defines the intensity of the displacement effect.")); + _settings->add_spinscale(0, SP_ATTR_SCALE, _("Scale:"), 0, 100, 1, 0.01, 1, _("This defines the intensity of the displacement effect.")); _settings->add_combo(DISPLACEMENTMAP_CHANNEL_ALPHA, SP_ATTR_XCHANNELSELECTOR, _("X displacement:"), DisplacementMapChannelConverter, _("Color component that controls the displacement in the X direction")); _settings->add_combo(DISPLACEMENTMAP_CHANNEL_ALPHA, SP_ATTR_YCHANNELSELECTOR, _("Y displacement:"), DisplacementMapChannelConverter, _("Color component that controls the displacement in the Y direction")); _settings->type(NR_FILTER_FLOOD); _settings->add_color(/*default: black*/ 0, SP_PROP_FLOOD_COLOR, _("Flood Color:"), _("The whole filter region will be filled with this color.")); - _settings->add_spinslider(1, SP_PROP_FLOOD_OPACITY, _("Opacity:"), 0, 1, 0.1, 0.01, 2); + _settings->add_spinscale(1, SP_PROP_FLOOD_OPACITY, _("Opacity:"), 0, 1, 0.1, 0.01, 2); _settings->type(NR_FILTER_GAUSSIANBLUR); - _settings->add_dualspinslider(SP_ATTR_STDDEVIATION, _("Standard Deviation:"), 0.01, 100, 1, 0.01, 1, _("The standard deviation for the blur operation.")); + _settings->add_dualspinscale(SP_ATTR_STDDEVIATION, _("Standard Deviation:"), 0.01, 100, 1, 0.01, 1, _("The standard deviation for the blur operation.")); _settings->type(NR_FILTER_MERGE); _settings->add_no_params(); _settings->type(NR_FILTER_MORPHOLOGY); _settings->add_combo(MORPHOLOGY_OPERATOR_ERODE, SP_ATTR_OPERATOR, _("Operator:"), MorphologyOperatorConverter, _("Erode: performs \"thinning\" of input image.\nDilate: performs \"fattenning\" of input image.")); - _settings->add_dualspinslider(SP_ATTR_RADIUS, _("Radius:"), 0, 100, 1, 0.01, 1); + _settings->add_dualspinscale(SP_ATTR_RADIUS, _("Radius:"), 0, 100, 1, 0.01, 1); _settings->type(NR_FILTER_IMAGE); _settings->add_fileorelement(SP_ATTR_XLINK_HREF, _("Source of Image:")); _settings->type(NR_FILTER_OFFSET); - _settings->add_spinslider(0, SP_ATTR_DX, _("Delta X:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted to the right")); - _settings->add_spinslider(0, SP_ATTR_DY, _("Delta Y:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted downwards")); + _settings->add_spinscale(0, SP_ATTR_DX, _("Delta X:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted to the right")); + _settings->add_spinscale(0, SP_ATTR_DY, _("Delta Y:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted downwards")); _settings->type(NR_FILTER_SPECULARLIGHTING); _settings->add_color(/*default: white*/ 0xffffffff, SP_PROP_LIGHTING_COLOR, _("Specular Color:"), _("Defines the color of the light source")); - _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.1, 0.01, 2, _("This value amplifies the heights of the bump map defined by the input alpha channel")); - _settings->add_spinslider(1, SP_ATTR_SPECULARCONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model.")); - _settings->add_spinslider(1, SP_ATTR_SPECULAREXPONENT, _("Exponent:"), 1, 50, 1, 0.01, 1, _("Exponent for specular term, larger is more \"shiny\".")); - _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1); + _settings->add_spinscale(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.1, 0.01, 2, _("This value amplifies the heights of the bump map defined by the input alpha channel")); + _settings->add_spinscale(1, SP_ATTR_SPECULARCONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model.")); + _settings->add_spinscale(1, SP_ATTR_SPECULAREXPONENT, _("Exponent:"), 1, 50, 1, 0.01, 1, _("Exponent for specular term, larger is more \"shiny\".")); + _settings->add_dualspinscale(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1); _settings->add_lightsource(); _settings->type(NR_FILTER_TILE); @@ -2429,9 +2429,9 @@ void FilterEffectsDialog::init_settings_widgets() _settings->type(NR_FILTER_TURBULENCE); // _settings->add_checkbutton(false, SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch"); _settings->add_combo(TURBULENCE_TURBULENCE, SP_ATTR_TYPE, _("Type:"), TurbulenceTypeConverter, _("Indicates whether the filter primitive should perform a noise or turbulence function.")); - _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 1, 0.001, 0.01, 3); - _settings->add_spinslider(1, SP_ATTR_NUMOCTAVES, _("Octaves:"), 1, 10, 1, 1, 0); - _settings->add_spinslider(0, SP_ATTR_SEED, _("Seed:"), 0, 1000, 1, 1, 0, _("The starting number for the pseudo random number generator.")); + _settings->add_dualspinscale(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 1, 0.001, 0.01, 3); + _settings->add_spinscale(1, SP_ATTR_NUMOCTAVES, _("Octaves:"), 1, 10, 1, 1, 0); + _settings->add_spinscale(0, SP_ATTR_SEED, _("Seed:"), 0, 1000, 1, 1, 0, _("The starting number for the pseudo random number generator.")); } void FilterEffectsDialog::add_primitive() diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 38811354e..acdeecb71 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -20,6 +20,7 @@ #include "sp-filter.h" #include "ui/widget/combo-enums.h" #include "ui/widget/spin-slider.h" +#include "ui/widget/spin-scale.h" #include "xml/helper-observer.h" #include "ui/dialog/desktop-tracker.h" diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index 8d6bcf60f..65706a9dc 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -22,12 +22,9 @@ namespace UI { namespace Widget { SimpleFilterModifier::SimpleFilterModifier(int flags) - : _hb_blur(false, 0), - _lb_blend(_("Blend mode:")), - _lb_blur(_("_Blur:")), - _lb_blur_unit(_("%")), + : _lb_blend(_("Blend mode:")), _blend(BlendModeConverter, SP_ATTR_INVALID, false), - _blur(0, 0, 100, 1, 0.01, 1) + _blur(_("Blur (%)"), 0, 0, 100, 1, 0.01, 1) { _flags = flags; @@ -37,11 +34,7 @@ SimpleFilterModifier::SimpleFilterModifier(int flags) _hb_blend.pack_start(_blend); } if (flags & BLUR) { - add(_hb_blur); - _lb_blur.set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER); - _hb_blur.pack_start(_lb_blur, false, false, 0); - _hb_blur.pack_start(_blur, true, true, 0); - _hb_blur.pack_start(_lb_blur_unit, false, false, 3); + add(_blur); } show_all_children(); @@ -49,8 +42,6 @@ SimpleFilterModifier::SimpleFilterModifier(int flags) _hb_blend.set_spacing(12); _lb_blend.set_use_underline(); _lb_blend.set_mnemonic_widget(_blend); - _lb_blur.set_use_underline(); - _lb_blur.set_mnemonic_widget(_blur.get_scale()); _blend.signal_changed().connect(signal_blend_blur_changed()); _blur.signal_value_changed().connect(signal_blend_blur_changed()); } diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h index 6afb6c180..ae3ec07c4 100644 --- a/src/ui/widget/filter-effect-chooser.h +++ b/src/ui/widget/filter-effect-chooser.h @@ -18,6 +18,7 @@ #include "combo-enums.h" #include "filter-enums.h" #include "spin-slider.h" +#include "spin-scale.h" namespace Inkscape { namespace UI { @@ -45,17 +46,14 @@ public: double get_blur_value() const; void set_blur_value(const double); void set_blur_sensitive(const bool); - Gtk::Label *get_blur_label() { return &_lb_blur; }; - private: int _flags; Gtk::HBox _hb_blend; - Gtk::HBox _hb_blur; - Gtk::Label _lb_blend, _lb_blur, _lb_blur_unit; + Gtk::Label _lb_blend; ComboBoxEnum _blend; - SpinSlider _blur; + SpinScale _blur; sigc::signal _signal_blend_blur_changed; }; diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 1cb384501..2789676ea 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -16,6 +16,7 @@ #include +#include "desktop.h" #include "desktop-handles.h" #include "desktop-style.h" #include "document.h" @@ -32,6 +33,7 @@ #include "ui/icon-names.h" #include "display/sp-canvas.h" #include "ui/widget/style-subject.h" +#include "ui/widget/gimpspinscale.h" namespace Inkscape { namespace UI { @@ -62,50 +64,34 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co _blur_tag(Glib::ustring(history_prefix) + ":blur"), _opacity_tag(Glib::ustring(history_prefix) + ":opacity"), _opacity_vbox(false, 0), - _opacity_label(_("Opacity:")), - _opacity_label_unit(_("%")), -#if WITH_GTKMM_3_0 - _opacity_adjustment(Gtk::Adjustment::create(100.0, 0.0, 100.0, 1.0, 1.0, 0.0)), -#else - _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0), -#endif - _opacity_hscale(_opacity_adjustment), - _opacity_spin_button(_opacity_adjustment, 0.01, 1), + _opacity_scale(_("Opacity (%)"), 100.0, 0.0, 100.0, 1.0, 1.0, 1), _fe_cb(flags), _fe_vbox(false, 0), - _fe_alignment(1, 1, 1, 1), _blocked(false) { // Filter Effects pack_start(_fe_vbox, false, false, 2); - _fe_alignment.set_padding(0, 0, 4, 0); - _fe_alignment.add(_fe_cb); - _fe_vbox.pack_start(_fe_alignment, false, false, 0); + _fe_vbox.pack_start(_fe_cb, false, false, 0); _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged)); // Opacity pack_start(_opacity_vbox, false, false, 2); - _opacity_label.set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER); - _opacity_hbox.pack_start(_opacity_label, false, false, 3); - //_opacity_vbox.pack_start(_opacity_label_box, false, false, 0); - _opacity_vbox.pack_start(_opacity_hbox, false, false, 0); - _opacity_hbox.pack_start(_opacity_hscale, true, true, 0); - _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0); - _opacity_hbox.pack_start(_opacity_label_unit, false, false, 3); - _opacity_hscale.set_draw_value(false); -#if WITH_GTKMM_3_0 - _opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged)); - _opacity_label.set_mnemonic_widget(_opacity_hscale); -#else - _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged)); - _opacity_label.set_mnemonic_widget(_opacity_hscale); -#endif + _opacity_vbox.pack_start(_opacity_scale); + + _opacity_scale.set_appearance("compact"); + + _opacity_scale.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged)); + + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + _opacity_scale.set_focuswidget(GTK_WIDGET(desktop->canvas)); /* SizeGroup keeps the blur and opacity labels aligned in Fill & Stroke dlg */ +/* GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); gtk_size_group_add_widget(labels, (GtkWidget *) _opacity_label.gobj()); gtk_size_group_add_widget(labels, (GtkWidget *) _fe_cb.get_blur_label()->gobj()); +*/ show_all_children(); @@ -223,11 +209,7 @@ ObjectCompositeSettings::_opacityValueChanged() SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream os; -#if WITH_GTKMM_3_0 - os << CLAMP (_opacity_adjustment->get_value() / 100, 0.0, 1.0); -#else - os << CLAMP (_opacity_adjustment.get_value() / 100, 0.0, 1.0); -#endif + os << CLAMP (_opacity_scale.get_adjustment()->get_value() / 100, 0.0, 1.0); sp_repr_css_set_property (css, "opacity", os.str().c_str()); _subject->setCSS(css); @@ -263,18 +245,14 @@ ObjectCompositeSettings::_subjectChanged() { switch (result) { case QUERY_STYLE_NOTHING: - _opacity_hbox.set_sensitive(false); + _opacity_vbox.set_sensitive(false); // gtk_widget_set_sensitive (opa, FALSE); break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently case QUERY_STYLE_MULTIPLE_SAME: - _opacity_hbox.set_sensitive(true); -#if WITH_GTKMM_3_0 - _opacity_adjustment->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value)); -#else - _opacity_adjustment.set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value)); -#endif + _opacity_vbox.set_sensitive(true); + _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value)); break; } diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index 32da626d6..d3a208525 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -45,22 +45,12 @@ private: Glib::ustring _opacity_tag; Gtk::VBox _opacity_vbox; - Gtk::HBox _opacity_hbox; - Gtk::Label _opacity_label; - Gtk::Label _opacity_label_unit; -#if WITH_GTKMM_3_0 - Glib::RefPtr _opacity_adjustment; -#else - Gtk::Adjustment _opacity_adjustment; -#endif - Gtk::HScale _opacity_hscale; - Inkscape::UI::Widget::SpinButton _opacity_spin_button; + Inkscape::UI::Widget::SpinScale _opacity_scale; StyleSubject *_subject; SimpleFilterModifier _fe_cb; Gtk::VBox _fe_vbox; - Gtk::Alignment _fe_alignment; bool _blocked; gulong _desktop_activated; diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 97ae18e20..323b1209c 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -186,7 +186,7 @@ void DualSpinSlider::set_from_attribute(SPObject* o) gchar** toks = g_strsplit(val, " ", 2); if(toks) { - double v1, v2; + double v1 = 0.0, v2 = 0.0; if(toks[0]) v1 = v2 = Glib::Ascii::strtod(toks[0]); if(toks[1]) -- cgit v1.2.3 From 1b62c7c43dead73dd277bcd139d2abfb394d9de3 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 15:00:37 +0900 Subject: Fix for 166691 : Changing layer order does not update layer selector (bzr r11692) --- src/ui/widget/layer-selector.cpp | 26 ++++++++++++++++++++------ src/ui/widget/layer-selector.h | 5 ++++- 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index c6622627b..6dd45c402 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -185,7 +185,10 @@ void LayerSelector::setDesktop(SPDesktop *desktop) { if (_desktop) { // _desktop_shutdown_connection.disconnect(); - _layer_changed_connection.disconnect(); + if (_current_layer_changed_connection) + _current_layer_changed_connection.disconnect(); + if (_layers_changed_connection) + _layers_changed_connection.disconnect(); // g_signal_handlers_disconnect_by_func(_desktop, (gpointer)&detach, this); } _desktop = desktop; @@ -195,9 +198,13 @@ void LayerSelector::setDesktop(SPDesktop *desktop) { // sigc::bind (sigc::ptr_fun (detach), this)); // g_signal_connect_after(_desktop, "shutdown", GCallback(detach), this); - _layer_changed_connection = _desktop->connectCurrentLayerChanged( - sigc::mem_fun(*this, &LayerSelector::_selectLayer) - ); + LayerManager *mgr = _desktop->layer_manager; + if ( mgr ) { + _current_layer_changed_connection = mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayerSelector::_selectLayer) ); + //_layerUpdatedConnection = mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayerSelector::_updateLayer) ); + _layers_changed_connection = mgr->connectChanged( sigc::mem_fun(*this, &LayerSelector::_layersChanged) ); + } + _selectLayer(_desktop->currentLayer()); } } @@ -230,6 +237,11 @@ private: } +void LayerSelector::_layersChanged() +{ + _selectLayer(_desktop->currentLayer()); +} + /** Selects the given layer in the dropdown selector. */ void LayerSelector::_selectLayer(SPObject *layer) { @@ -300,11 +312,13 @@ void LayerSelector::_setDesktopLayer() { Gtk::ListStore::iterator selected(_selector.get_active()); SPObject *layer=_selector.get_active()->get_value(_model_columns.object); if ( _desktop && layer ) { - _layer_changed_connection.block(); + _current_layer_changed_connection.block(); + _layers_changed_connection.block(); _desktop->layer_manager->setCurrentLayer(layer); - _layer_changed_connection.unblock(); + _current_layer_changed_connection.unblock(); + _layers_changed_connection.unblock(); _selectLayer(_desktop->currentLayer()); } diff --git a/src/ui/widget/layer-selector.h b/src/ui/widget/layer-selector.h index 6fbdc9857..ff9e4ddfc 100644 --- a/src/ui/widget/layer-selector.h +++ b/src/ui/widget/layer-selector.h @@ -68,7 +68,8 @@ private: Glib::RefPtr _layer_model; // sigc::connection _desktop_shutdown_connection; - sigc::connection _layer_changed_connection; + sigc::connection _layers_changed_connection; + sigc::connection _current_layer_changed_connection; sigc::connection _selection_changed_connection; sigc::connection _visibility_toggled_connection; sigc::connection _lock_toggled_connection; @@ -76,6 +77,8 @@ private: SPObject *_layer; void _selectLayer(SPObject *layer); + void _layersChanged(); + void _setDesktopLayer(); void _buildEntry(unsigned depth, SPObject &object); -- cgit v1.2.3 From 2c8d19264256de07ca62926ca7be9a32e0b76183 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 18:46:47 +0900 Subject: Fix for 166691 : Revert fix (bzr r11693) --- src/ui/widget/layer-selector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 6dd45c402..a80a1aba0 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -239,7 +239,7 @@ private: void LayerSelector::_layersChanged() { - _selectLayer(_desktop->currentLayer()); + //_selectLayer(_desktop->currentLayer()); } /** Selects the given layer in the dropdown selector. -- cgit v1.2.3 From a8e76949f48267a704af633032e33d6982c682cc Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 18:59:01 +0900 Subject: Fix for 367548 : Invert doesnt work on objects with gradients (bzr r11694) --- src/gradient-chemistry.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/gradient-chemistry.h | 1 + src/gradient-context.cpp | 13 +------------ src/sp-gradient.h | 3 ++- src/ui/widget/selected-style.cpp | 12 ++++++++++++ src/widgets/gradient-toolbar.cpp | 22 +--------------------- 6 files changed, 54 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 34934f75b..2ddfe5ff7 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -26,7 +26,13 @@ #include "style.h" #include "document-private.h" +#include "document-undo.h" #include "desktop-style.h" +#include "desktop-handles.h" +#include "event-context.h" +#include "selection.h" +#include "verbs.h" +#include #include "sp-gradient-reference.h" #include "sp-gradient-vector.h" @@ -47,6 +53,7 @@ #define noSP_GR_VERBOSE +using Inkscape::DocumentUndo; namespace { @@ -1508,6 +1515,36 @@ SPGradient *sp_gradient_vector_for_object( SPDocument *const doc, SPDesktop *con } +void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke) +{ + Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPEventContext *ev = sp_desktop_event_context(desktop); + + if (!ev) { + return; + } + + GrDrag *drag = ev->get_drag(); + + // First try selected dragger + if (drag && drag->selected) { + drag->selected_reverse_vector(); + } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) + for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { + if (fill_or_stroke == Inkscape::FOR_FILL_AND_STROKE) { + sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); + sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); + } else { + sp_item_gradient_reverse_vector(SP_ITEM(i->data), fill_or_stroke); + } + } + } + + // we did an undoable action + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, + _("Invert gradient")); +} + /* Local Variables: mode:c++ diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h index 2f3ea4303..ff1f32dc7 100644 --- a/src/gradient-chemistry.h +++ b/src/gradient-chemistry.h @@ -70,6 +70,7 @@ SPStop *sp_vector_add_stop(SPGradient *vector, SPStop* prev_stop, SPStop* next_s void sp_gradient_transform_multiply(SPGradient *gradient, Geom::Affine postmul, bool set); +void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke); /** * Fetches either the fill or the stroke gradient from the given item. diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index aa8c8b929..356743eed 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -837,18 +837,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KEY_r: case GDK_KEY_R: if (MOD__SHIFT_ONLY) { - // First try selected dragger - if (drag && drag->selected) { - drag->selected_reverse_vector(); - } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); - } - } - // we did an undoable action - DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, - _("Invert gradient")); + sp_gradient_invert_selected_gradients(desktop, Inkscape::FOR_FILL_AND_STROKE); ret = TRUE; } break; diff --git a/src/sp-gradient.h b/src/sp-gradient.h index a21a413f4..36f6f92e6 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -77,7 +77,8 @@ namespace Inkscape { enum PaintTarget { FOR_FILL, - FOR_STROKE + FOR_STROKE, + FOR_FILL_AND_STROKE }; /** diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a37f36eea..b3c4fbdcd 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -48,6 +48,7 @@ #include "pixmaps/cursor-adj-s.xpm" #include "pixmaps/cursor-adj-l.xpm" #include "sp-cursor.h" +#include "gradient-chemistry.h" static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -598,6 +599,12 @@ void SelectedStyle::on_fill_invert() { SPCSSAttr *css = sp_repr_css_attr_new (); guint32 color = _thisselected[SS_FILL]; gchar c[64]; + if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { + g_message("Gradient"); + sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_FILL); + return; + } + if (_mode[SS_FILL] != SS_COLOR) return; sp_svg_write_color (c, sizeof(c), SP_RGBA32_U_COMPOSE( @@ -618,6 +625,11 @@ void SelectedStyle::on_stroke_invert() { SPCSSAttr *css = sp_repr_css_attr_new (); guint32 color = _thisselected[SS_STROKE]; gchar c[64]; + if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { + g_message("Gradient"); + sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_STROKE); + return; + } if (_mode[SS_STROKE] != SS_COLOR) return; sp_svg_write_color (c, sizeof(c), SP_RGBA32_U_COMPOSE( diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index ae85ed515..cc6b04413 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -633,27 +633,7 @@ static void gr_linked_changed(GtkToggleAction *act, gpointer /*data*/) static void gr_reverse(GtkWidget * /*button*/, gpointer data) { SPDesktop *desktop = static_cast(data); - Inkscape::Selection *selection = sp_desktop_selection(desktop); - SPEventContext *ev = sp_desktop_event_context(desktop); - - if (!ev) { - return; - } - - GrDrag *drag = ev->get_drag(); - - // First try selected dragger - if (drag && drag->selected) { - drag->selected_reverse_vector(); - } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); - } - } - // we did an undoable action - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, - _("Invert gradient")); + sp_gradient_invert_selected_gradients(desktop, Inkscape::FOR_FILL_AND_STROKE); } /* -- cgit v1.2.3 From 3f61bc675d5f2f0c92d7906b8552b09df3cd411f Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 21:14:14 +0900 Subject: Fix for 172222 : Move direct to specified layer (bzr r11695) --- src/interface.cpp | 18 +++++ src/interface.h | 1 + src/menus-skeleton.h | 1 + src/selection-chemistry.cpp | 30 +++++++ src/selection-chemistry.h | 1 + src/ui/dialog/layer-properties.cpp | 147 ++++++++++++++++++++++++++++++++++- src/ui/dialog/layer-properties.h | 44 +++++++++++ src/ui/dialog/livepatheffect-add.cpp | 3 +- src/verbs.cpp | 6 ++ src/verbs.h | 1 + 10 files changed, 249 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index acd56f8da..c3dbc47c8 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -79,6 +79,7 @@ // #include "inkscape.h" #include "ui/dialog/dialog-manager.h" // #include "../xml/repr.h" +#include "ui/dialog/layer-properties.h" #include #include @@ -1823,6 +1824,16 @@ void ContextMenu::MakeItemMenu (void) mi->show(); select_same_submenu->append(*mi); + /* Move to layer */ + mi = manage(new Gtk::MenuItem(_("_Move to layer ..."),1)); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } else { + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemMoveTo)); + } + mi->show(); + append(*mi); + /* Create link */ mi = manage(new Gtk::MenuItem(_("Create _Link"),1)); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink)); @@ -1938,6 +1949,13 @@ void ContextMenu::ItemSelectThis(void) _desktop->selection->set(_item); } +void ContextMenu::ItemMoveTo(void) +{ + Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(_desktop, _desktop->currentLayer()); +} + + + void ContextMenu::ItemCreateLink(void) { Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc(); diff --git a/src/interface.h b/src/interface.h index aa0281db3..ef520be28 100644 --- a/src/interface.h +++ b/src/interface.h @@ -171,6 +171,7 @@ class ContextMenu : public Gtk::Menu //callbacks for the context menu entries of an SP_TYPE_ITEM object void ItemProperties(void); void ItemSelectThis(void); + void ItemMoveTo(void); void SelectSameFillStroke(void); void SelectSameFillColor(void); void SelectSameStrokeColor(void); diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 999fb52fc..09366a33f 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -167,6 +167,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 068928d8f..4cdab4336 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1314,6 +1314,36 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) g_slist_free(const_cast(items)); } +void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) +{ + Inkscape::Selection *selection = sp_desktop_selection(dt); + + // check if something is selected + if (selection->isEmpty()) { + dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to move.")); + return; + } + + GSList const *items = g_slist_copy(const_cast(selection->itemList())); + + if (moveto) { + GSList *temp_clip = NULL; + sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs + sp_selection_delete_impl(items, false, false); + GSList *copied = sp_selection_paste_impl(sp_desktop_document(dt), moveto, &temp_clip); + selection->setReprList((GSList const *) copied); + g_slist_free(copied); + if (temp_clip) g_slist_free(temp_clip); + if (moveto) dt->setCurrentLayer(moveto); + if ( !suppressDone ) { + DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO, + _("Move selection to layer")); + } + } + + g_slist_free(const_cast(items)); +} + bool selection_contains_original(SPItem *item, Inkscape::Selection *selection) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 0ae2a9b06..3c9c1aea9 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -97,6 +97,7 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false ); void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false ); +void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false ); void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true); void sp_selection_remove_transform (SPDesktop *desktop); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 465192aee..35a235dbc 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -28,7 +28,10 @@ #include "sp-item.h" #include "verbs.h" #include "selection.h" - +#include "selection-chemistry.h" +#include "ui/icon-names.h" +#include "ui/widget/imagetoggler.h" +#include "event-context.h" namespace Inkscape { namespace UI { @@ -51,7 +54,7 @@ LayerPropertiesDialog::LayerPropertiesDialog() 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); _layout_table.attach(_layer_name_entry, 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); - mainVBox->pack_start(_layout_table, false, false, 4); + mainVBox->pack_start(_layout_table, true, true, 4); // Buttons _close_button.set_use_stock(true); @@ -82,6 +85,7 @@ LayerPropertiesDialog::LayerPropertiesDialog() } LayerPropertiesDialog::~LayerPropertiesDialog() { + _setDesktop(NULL); _setLayer(NULL); } @@ -168,6 +172,131 @@ LayerPropertiesDialog::_setup_position_controls() { show_all_children(); } +void +LayerPropertiesDialog::_setup_layers_controls() { + + ModelColumns *zoop = new ModelColumns(); + _model = zoop; + _store = Gtk::TreeStore::create( *zoop ); + _tree.set_model( _store ); + _tree.set_headers_visible(false); + + Inkscape::UI::Widget::ImageToggler *eyeRenderer = 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); + if ( col ) { + col->add_attribute( eyeRenderer->property_active(), _model->_colVisible ); + } + + Inkscape::UI::Widget::ImageToggler * renderer = 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); + if ( col ) { + col->add_attribute( renderer->property_active(), _model->_colLocked ); + } + + Gtk::CellRendererText *_text_renderer = 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); + + _tree.set_expander_column( *_tree.get_column(nameColNum) ); + _tree.signal_key_press_event().connect( sigc::mem_fun(*this, &LayerPropertiesDialog::_handleKeyEvent), false ); + _tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayerPropertiesDialog::_handleButtonEvent) ); + + _scroller.add( _tree ); + _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); + _scroller.set_shadow_type(Gtk::SHADOW_IN); + _scroller.set_size_request(220, 180); + + SPDocument* document = _desktop->doc(); + SPRoot* root = document->getRoot(); + if ( root ) { + SPObject* target = _desktop->currentLayer(); + _store->clear(); + _addLayer( document, (SPObject *)root, 0, target, 0 ); + } + + _layout_table.remove(_layer_name_entry); + _layout_table.remove(_layer_name_label); + + _layout_table.attach(_scroller, + 0, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND); + show_all_children(); +} + +void LayerPropertiesDialog::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level ) +{ + int _maxNestDepth = 20; + if ( _desktop && _desktop->layer_manager && layer && (level < _maxNestDepth) ) { + unsigned int counter = _desktop->layer_manager->childCount(layer); + for ( unsigned int i = 0; i < counter; i++ ) { + SPObject *child = _desktop->layer_manager->nthChildOf(layer, i); + if ( child ) { +#if DUMP_LAYERS + g_message(" %3d layer:%p {%s} [%s]", level, child, child->id, child->label() ); +#endif // DUMP_LAYERS + + Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); + Gtk::TreeModel::Row row = *iter; + row[_model->_colObject] = child; + row[_model->_colLabel] = child->label() ? child->label() : child->getId(); + row[_model->_colVisible] = SP_IS_ITEM(child) ? !SP_ITEM(child)->isHidden() : false; + row[_model->_colLocked] = SP_IS_ITEM(child) ? SP_ITEM(child)->isLocked() : false; + + if ( target && child == target ) { + _tree.expand_to_path( _store->get_path(iter) ); + + Glib::RefPtr select = _tree.get_selection(); + select->select(iter); + + //_checkTreeSelection(); + } + + _addLayer( doc, child, &row, target, level + 1 ); + } + } + } +} + +SPObject* LayerPropertiesDialog::_selectedLayer() +{ + SPObject* obj = 0; + + Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected(); + if ( iter ) { + Gtk::TreeModel::Row row = *iter; + obj = row[_model->_colObject]; + } + + return obj; +} + +bool LayerPropertiesDialog::_handleKeyEvent(GdkEventKey *event) +{ + + switch (get_group0_keyval(event)) { + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: { + _strategy->perform(*this); + _close(); + return true; + } + break; + } + return false; +} + +void LayerPropertiesDialog::_handleButtonEvent(GdkEventButton* event) +{ + if ( (event->type == GDK_2BUTTON_PRESS) && (event->button == 1) ) { + _strategy->perform(*this); + _close(); + } +} + /** Formats the label for a given layer row */ void LayerPropertiesDialog::_prepareLabelRenderer( @@ -231,6 +360,20 @@ void LayerPropertiesDialog::Create::perform(LayerPropertiesDialog &dialog) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("New layer created.")); } +void LayerPropertiesDialog::Move::setup(LayerPropertiesDialog &dialog) { + dialog.set_title(_("Move to Layer")); + //TODO: find an unused layer number, forming name from _("Layer ") + "%d" + dialog._layer_name_entry.set_text(_("Layer")); + dialog._apply_button.set_label(_("_Move")); + dialog._setup_layers_controls(); +} + +void LayerPropertiesDialog::Move::perform(LayerPropertiesDialog &dialog) { + + SPObject *moveto = dialog._selectedLayer(); + sp_selection_to_layer(dialog._desktop, moveto, false); +} + void LayerPropertiesDialog::_setDesktop(SPDesktop *desktop) { if (desktop) { Inkscape::GC::anchor (desktop); diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index c7d7de130..46b31ad35 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -18,8 +18,12 @@ #include #include #include +#include +#include +#include #include "layer-fns.h" +#include "ui/widget/layer-selector.h" class SPDesktop; @@ -40,6 +44,9 @@ class LayerPropertiesDialog : public Gtk::Dialog { static void showCreate(SPDesktop *desktop, SPObject *layer) { _showDialog(Create::instance(), desktop, layer); } + static void showMove(SPDesktop *desktop, SPObject *layer) { + _showDialog(Move::instance(), desktop, layer); + } protected: struct Strategy { @@ -57,9 +64,15 @@ protected: void setup(LayerPropertiesDialog &dialog); void perform(LayerPropertiesDialog &dialog); }; + struct Move : public Strategy { + static Move &instance() { static Move instance; return instance; } + void setup(LayerPropertiesDialog &dialog); + void perform(LayerPropertiesDialog &dialog); + }; friend class Rename; friend class Create; + friend class Move; Strategy *_strategy; SPDesktop *_desktop; @@ -82,6 +95,31 @@ protected: Gtk::Table _layout_table; bool _position_visible; + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { + public: + + ModelColumns() + { + add(_colObject); + add(_colVisible); + add(_colLocked); + add(_colLabel); + } + virtual ~ModelColumns() {} + + Gtk::TreeModelColumn _colObject; + Gtk::TreeModelColumn _colLabel; + Gtk::TreeModelColumn _colVisible; + Gtk::TreeModelColumn _colLocked; + }; + + Gtk::TreeView _tree; + ModelColumns* _model; + Glib::RefPtr _store; + Gtk::ScrolledWindow _scroller; + + PositionDropdownColumns _dropdown_columns; Gtk::CellRendererText _label_renderer; Glib::RefPtr _dropdown_list; @@ -104,8 +142,14 @@ protected: void _close(); void _setup_position_controls(); + void _setup_layers_controls(); void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row); + void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level ); + SPObject* _selectedLayer(); + bool _handleKeyEvent(GdkEventKey *event); + void _handleButtonEvent(GdkEventButton* event); + private: LayerPropertiesDialog(LayerPropertiesDialog const &); // no copy LayerPropertiesDialog &operator=(LayerPropertiesDialog const &); // no assign diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index c22aace37..e899dbcfc 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -48,6 +48,7 @@ LivePathEffectAdd::LivePathEffectAdd() : effectlist_treeview.set_model(effectlist_store); effectlist_treeview.set_headers_visible(false); effectlist_treeview.append_column("Name", _columns.name); + //effectlist_treeview.set_activates_default(true); /** * Initialize Effect list @@ -68,7 +69,7 @@ LivePathEffectAdd::LivePathEffectAdd() : * Buttons */ close_button.set_use_stock(true); - close_button.set_can_default(); + //close_button.set_can_default(); add_button.set_use_underline(true); add_button.set_can_default(); diff --git a/src/verbs.cpp b/src/verbs.cpp index d02472383..edfc45f8e 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1190,6 +1190,10 @@ void LayerVerb::perform(SPAction *action, void *data) sp_selection_to_prev_layer(dt); break; } + case SP_VERB_LAYER_MOVE_TO: { + Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(dt, dt->currentLayer()); + break; + } case SP_VERB_LAYER_TO_TOP: case SP_VERB_LAYER_TO_BOTTOM: case SP_VERB_LAYER_RAISE: @@ -2465,6 +2469,8 @@ Verb *Verb::_base_verbs[] = { N_("Move selection to the layer above the current"), INKSCAPE_ICON("selection-move-to-layer-above")), new LayerVerb(SP_VERB_LAYER_MOVE_TO_PREV, "LayerMoveToPrev", N_("Move Selection to Layer Bel_ow"), N_("Move selection to the layer below the current"), INKSCAPE_ICON("selection-move-to-layer-below")), + new LayerVerb(SP_VERB_LAYER_MOVE_TO, "LayerMoveTo", N_("Move Selection to Layer..."), + N_("Move selection to layer"), INKSCAPE_ICON("layer-rename")), new LayerVerb(SP_VERB_LAYER_TO_TOP, "LayerToTop", N_("Layer to _Top"), N_("Raise the current layer to the top"), INKSCAPE_ICON("layer-top")), new LayerVerb(SP_VERB_LAYER_TO_BOTTOM, "LayerToBottom", N_("Layer to _Bottom"), diff --git a/src/verbs.h b/src/verbs.h index 2f0ae85c1..aa801803c 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -139,6 +139,7 @@ enum { SP_VERB_LAYER_PREV, SP_VERB_LAYER_MOVE_TO_NEXT, SP_VERB_LAYER_MOVE_TO_PREV, + SP_VERB_LAYER_MOVE_TO, SP_VERB_LAYER_TO_TOP, SP_VERB_LAYER_TO_BOTTOM, SP_VERB_LAYER_RAISE, -- cgit v1.2.3 From a01a3fa9d658218f3afbe5ab9922deb9c3ce38be Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 23 Sep 2012 11:19:28 +0900 Subject: Fix for 367548 : Invert doesnt work on objects with gradients (bzr r11696) --- src/gradient-chemistry.cpp | 62 ++++++++++++++++++++++++++++++++++------ src/gradient-chemistry.h | 3 ++ src/gradient-context.cpp | 2 +- src/sp-gradient.h | 3 +- src/ui/widget/selected-style.cpp | 5 ++-- src/widgets/gradient-toolbar.cpp | 2 +- 6 files changed, 62 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 2ddfe5ff7..ed4e81f0d 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -959,6 +959,44 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or g_slist_free (child_objects); } +void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fill_or_stroke) +{ +#ifdef SP_GR_VERBOSE + g_message("sp_item_gradient_invert_vector_color(%p, %d)", item, fill_or_stroke); +#endif + SPGradient *gradient = getGradient(item, fill_or_stroke); + if (!gradient || !SP_IS_GRADIENT(gradient)) + return; + + SPGradient *vector = gradient->getVector(); + if (!vector) // orphan! + return; + + vector = sp_gradient_fork_vector_if_necessary (vector); + if ( gradient != vector && gradient->ref->getObject() != vector ) { + sp_gradient_repr_set_link(gradient->getRepr(), vector); + } + + for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) { + if (SP_IS_STOP(child)) { + guint32 color = sp_stop_get_rgba32(SP_STOP(child)); + //g_message("Stop color %d", color); + gchar c[64]; + sp_svg_write_color (c, sizeof(c), + SP_RGBA32_U_COMPOSE( + (255 - SP_RGBA32_R_U(color)), + (255 - SP_RGBA32_G_U(color)), + (255 - SP_RGBA32_B_U(color)), + SP_RGBA32_A_U(color) + ) + ); + SPCSSAttr *css = sp_repr_css_attr_new (); + sp_repr_css_set_property (css, "stop-color", c); + sp_repr_css_change(child->getRepr(), css, "style"); + sp_repr_css_attr_unref (css); + } + } +} /** Set the position of point point_type of the gradient applied to item (either fill_or_stroke) to @@ -1514,8 +1552,20 @@ SPGradient *sp_gradient_vector_for_object( SPDocument *const doc, SPDesktop *con return sp_document_default_gradient_vector( doc, color, singleStop ); } - void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke) +{ + Inkscape::Selection *selection = sp_desktop_selection(desktop); + + for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { + sp_item_gradient_invert_vector_color(SP_ITEM(i->data), fill_or_stroke); + } + + // we did an undoable action + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, + _("Invert gradient colors")); +} + +void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) { Inkscape::Selection *selection = sp_desktop_selection(desktop); SPEventContext *ev = sp_desktop_event_context(desktop); @@ -1531,18 +1581,14 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - if (fill_or_stroke == Inkscape::FOR_FILL_AND_STROKE) { - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); - } else { - sp_item_gradient_reverse_vector(SP_ITEM(i->data), fill_or_stroke); - } + sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); + sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); } } // we did an undoable action DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, - _("Invert gradient")); + _("Reverse gradient")); } /* diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h index ff1f32dc7..50422458c 100644 --- a/src/gradient-chemistry.h +++ b/src/gradient-chemistry.h @@ -70,6 +70,8 @@ SPStop *sp_vector_add_stop(SPGradient *vector, SPStop* prev_stop, SPStop* next_s void sp_gradient_transform_multiply(SPGradient *gradient, Geom::Affine postmul, bool set); +void sp_gradient_reverse_selected_gradients(SPDesktop *desktop); + void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke); /** @@ -98,6 +100,7 @@ void sp_item_gradient_stop_set_style(SPItem *item, GrPointType point_type, guint guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke); void sp_item_gradient_edit_stop(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke); void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or_stroke); +void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fill_or_stroke); #endif // SEEN_SP_GRADIENT_CHEMISTRY_H diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 356743eed..5b0e261de 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -837,7 +837,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KEY_r: case GDK_KEY_R: if (MOD__SHIFT_ONLY) { - sp_gradient_invert_selected_gradients(desktop, Inkscape::FOR_FILL_AND_STROKE); + sp_gradient_reverse_selected_gradients(desktop); ret = TRUE; } break; diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 36f6f92e6..a21a413f4 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -77,8 +77,7 @@ namespace Inkscape { enum PaintTarget { FOR_FILL, - FOR_STROKE, - FOR_FILL_AND_STROKE + FOR_STROKE }; /** diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index b3c4fbdcd..a4313f677 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -600,9 +600,9 @@ void SelectedStyle::on_fill_invert() { guint32 color = _thisselected[SS_FILL]; gchar c[64]; if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { - g_message("Gradient"); sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_FILL); return; + } if (_mode[SS_FILL] != SS_COLOR) return; @@ -625,8 +625,7 @@ void SelectedStyle::on_stroke_invert() { SPCSSAttr *css = sp_repr_css_attr_new (); guint32 color = _thisselected[SS_STROKE]; gchar c[64]; - if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { - g_message("Gradient"); + if (_mode[SS_STROKE] == SS_LGRADIENT || _mode[SS_STROKE] == SS_RGRADIENT) { sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_STROKE); return; } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index cc6b04413..7542e16b3 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -633,7 +633,7 @@ static void gr_linked_changed(GtkToggleAction *act, gpointer /*data*/) static void gr_reverse(GtkWidget * /*button*/, gpointer data) { SPDesktop *desktop = static_cast(data); - sp_gradient_invert_selected_gradients(desktop, Inkscape::FOR_FILL_AND_STROKE); + sp_gradient_reverse_selected_gradients(desktop); } /* -- cgit v1.2.3 From a17956f9fa43854a9b0f3b0a72542cdadfad916a Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 23 Sep 2012 11:44:45 +0900 Subject: Fix for 170395 : Add Trace Bitmap to context menu of images (bzr r11697) --- src/interface.cpp | 12 ++++++++++++ src/interface.h | 5 +++++ 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index c3dbc47c8..0db046559 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -2097,6 +2097,12 @@ void ContextMenu::MakeImageMenu (void) mi->set_sensitive( FALSE ); } + /* Trace Bitmap */ + mi = manage(new Gtk::MenuItem(_("_Trace Bitmap..."),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap)); + mi->show(); + insert(*mi,positionOfLastDialog++); + /* Embed image */ if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { mi = manage(new Gtk::MenuItem(C_("Context menu", "Embed Image"))); @@ -2208,6 +2214,12 @@ void ContextMenu::ImageEdit(void) } } +void ContextMenu::ImageTraceBitmap(void) +{ + inkscape_dialogs_unhide(); + _desktop->_dlg_mgr->showDialog("Trace"); +} + void ContextMenu::ImageEmbed(void) { if (_desktop->selection->isEmpty()) { diff --git a/src/interface.h b/src/interface.h index ef520be28..891e39957 100644 --- a/src/interface.h +++ b/src/interface.h @@ -224,6 +224,11 @@ class ContextMenu : public Gtk::Menu */ void ImageEmbed(void); + /** + * callback, is executed on clicking the "Trace Bitmap" menu entry + */ + void ImageTraceBitmap(void); + /** * callback, is executed on clicking the "Extract Image" menu entry */ -- cgit v1.2.3 From f29a0a4399cac653df3df4be98ff04cbfc4773cc Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 23 Sep 2012 17:33:15 +0900 Subject: Fix for 170395 : Add Trace Bitmap to context menu of images : Focus fix (bzr r11698) --- src/interface.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 0db046559..fdfdce5ae 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -2102,6 +2102,9 @@ void ContextMenu::MakeImageMenu (void) mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap)); mi->show(); insert(*mi,positionOfLastDialog++); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } /* Embed image */ if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { -- cgit v1.2.3 From 8569f055798b87d1bbc074006adc4addf0f43450 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 24 Sep 2012 07:27:49 +0900 Subject: Fix for 165865 : Assert when duplicating markers (bzr r11699) --- src/widgets/stroke-style.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 5f686881f..832865eae 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -601,7 +601,6 @@ StrokeStyle::forkMarker(SPObject *marker, int loc, SPItem *item) sp_repr_css_set_property(css_item, marker_id, g_strconcat("url(#", mark_repr->attribute("id"), ")", NULL)); sp_repr_css_change_recursive(item->getRepr(), css_item, "style"); - Inkscape::GC::release(mark_repr); sp_repr_css_attr_unref(css_item); css_item = 0; -- cgit v1.2.3 From 20d3984334363f00867eab6c0500fdda8b7d1c14 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 24 Sep 2012 12:18:20 +0900 Subject: Fix for 1055253 : Statusbar opacity widget is too small (bzr r11700) --- src/widgets/widget-sizes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h index 644740637..c3f9e1119 100644 --- a/src/widgets/widget-sizes.h +++ b/src/widgets/widget-sizes.h @@ -29,8 +29,8 @@ #define STATUS_ZOOM_WIDTH 57 -#define SELECTED_STYLE_SB_WIDTH 38 -#define SELECTED_STYLE_WIDTH 180 +#define SELECTED_STYLE_SB_WIDTH 48 +#define SELECTED_STYLE_WIDTH 190 #define STYLE_SWATCH_WIDTH 100 #define STATUS_LAYER_FONT_SIZE 7700 -- cgit v1.2.3 From 9aea36c592ab464aeacaa37527156570b216d81c Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 24 Sep 2012 20:40:32 +0900 Subject: Fix for 1052645 : On select toolbar 'lock' button resize icon on clicking (bzr r11701) --- src/ink-action.cpp | 6 ++++-- src/widgets/gradient-toolbar.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ink-action.cpp b/src/ink-action.cpp index 4c6008b01..c79cebd1e 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -458,8 +458,10 @@ static void ink_toggle_action_update_icon( InkToggleAction* action ) GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data); GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId ); - gtk_widget_show_all( child ); - gtk_tool_button_set_icon_widget( button, child ); + GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); + gtk_container_add( GTK_CONTAINER(align), child ); + gtk_widget_show_all( align ); + gtk_tool_button_set_icon_widget( button, align ); } } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 7542e16b3..ea88b96fa 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -1231,7 +1231,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, _("Link gradients"), _("Link gradients to change all related gradients"), INKSCAPE_ICON("object-unlocked"), - secondarySize ); + Inkscape::ICON_SIZE_DECORATION ); g_object_set( itact, "short_label", "Lock", NULL ); g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(gr_linked_changed), desktop) ; gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); -- cgit v1.2.3 From 925ee6d4e04c6df884687472e366b431553c3a72 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 25 Sep 2012 20:28:58 +0900 Subject: Fix for 293358 : Reduce width of Fill Stroke dialog (bzr r11702) --- src/widgets/gradient-selector.cpp | 2 +- src/widgets/stroke-marker-selector.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 3eba2da23..082f04a77 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -153,7 +153,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) Gtk::TreeView::Column* name_column = sel->treeview->get_column(1); sel->text_renderer->property_editable() = true; name_column->add_attribute(sel->text_renderer->property_text(), sel->columns->name); - name_column->set_min_width(200); + name_column->set_min_width(180); name_column->set_clickable(true); name_column->set_resizable(true); diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 206f166f9..62fa47603 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -57,8 +57,8 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : set_model(marker_store); pack_start(image_renderer, false); pack_end(label_renderer, true); - label_renderer.set_padding(5, 0); - image_renderer.set_padding(5, 0); + label_renderer.set_padding(2, 0); + image_renderer.set_padding(2, 0); set_cell_data_func(label_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareLabelRenderer)); set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL); @@ -562,6 +562,7 @@ MarkerComboBox::create_marker_image(unsigned psize, gchar const *mname, void MarkerComboBox::prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row ) { Glib::ustring name=(*row)[marker_columns.label]; label_renderer.property_markup() = name.c_str(); + label_renderer.property_scale() = 0.8; } void MarkerComboBox::prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ) { -- cgit v1.2.3 From 9d3fe73abe568e8df1f992bc6458b28904fbaeb8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 25 Sep 2012 20:35:04 +0900 Subject: Fix for 172190 : Hand/Pan tool cursor on middle-drag (bzr r11703) --- src/event-context.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src') diff --git a/src/event-context.cpp b/src/event-context.cpp index 2c9ed1abd..b8a2dc797 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -171,6 +171,27 @@ static void sp_event_context_dispose(GObject *object) { G_OBJECT_CLASS(parent_class)->dispose(object); } +/** + * Set the cursor to a standard GDK cursor + */ +void sp_event_context_set_cursor(SPEventContext *event_context, GdkCursorType cursor_type) { + + GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop)); + GdkDisplay *display = gdk_display_get_default(); + GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type); + +#if WITH_GTKMM_3_0 + if (cursor) { + gdk_window_set_cursor (gtk_widget_get_window (w), cursor); + g_object_unref (cursor); + } +#else + gdk_window_set_cursor (gtk_widget_get_window (w), cursor); + gdk_cursor_unref (cursor); +#endif + +} + /** * Recreates and draws cursor on desktop related to SPEventContext. */ @@ -360,6 +381,7 @@ static gint sp_event_context_private_root_handler( SPEventContext *event_context, GdkEvent *event) { static Geom::Point button_w; static unsigned int panning = 0; + static unsigned int panning_cursor = 0; static unsigned int zoom_rb = 0; SPDesktop *desktop = event_context->desktop; @@ -393,6 +415,7 @@ static gint sp_event_context_private_root_handler( switch (event->button.button) { case 1: if (event_context->space_panning) { + // When starting panning, make sure there are no snap events pending because these might disable the panning again sp_event_context_discard_delayed_snap_event(event_context); panning = 1; @@ -408,6 +431,7 @@ static gint sp_event_context_private_root_handler( if (event->button.state & GDK_SHIFT_MASK) { zoom_rb = 2; } else { + // When starting panning, make sure there are no snap events pending because these might disable the panning again sp_event_context_discard_delayed_snap_event(event_context); panning = 2; @@ -415,6 +439,7 @@ static gint sp_event_context_private_root_handler( GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, NULL, event->button.time - 1); + } ret = TRUE; break; @@ -466,6 +491,11 @@ static gint sp_event_context_private_root_handler( gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); + if (panning_cursor == 0) { + panning_cursor = 1; + sp_event_context_set_cursor(event_context, GDK_FLEUR); + } + Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point const moved_w(motion_w - button_w); event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw @@ -496,6 +526,11 @@ static gint sp_event_context_private_root_handler( break; case GDK_BUTTON_RELEASE: xp = yp = 0; + if (panning_cursor == 1) { + panning_cursor = 0; + GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop)); + gdk_window_set_cursor(gtk_widget_get_window (w), event_context->cursor); + } if (within_tolerance && (panning || zoom_rb)) { zoom_rb = 0; if (panning) { @@ -665,6 +700,7 @@ static gint sp_event_context_private_root_handler( if (event_context->space_panning) { event_context->space_panning = false; event_context->_message_context->clear(); + if (panning == 1) { panning = 0; sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), -- cgit v1.2.3 From 854c6d935cecf2512f4062c8ca0a236c8a22759e Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 26 Sep 2012 12:16:46 +0900 Subject: Fix for 169001 : Long layer names mess with the UI (bzr r11705) --- src/ui/widget/layer-selector.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index a80a1aba0..4bb4d8c98 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -34,6 +34,7 @@ #include "widgets/icon.h" #include "widgets/shrink-wrap-button.h" #include "xml/node-event-vector.h" +#include "widgets/gradient-vector.h" namespace Inkscape { namespace Widgets { @@ -578,8 +579,8 @@ void LayerSelector::_prepareLabelRenderer( gchar const *label; if ( object != root ) { - label = object->label(); - if (!label) { + label = gr_ellipsize_text (object->label(), 50).c_str(); + if (!object->label()) { label = object->defaultLabel(); label_defaulted = true; } @@ -599,6 +600,7 @@ void LayerSelector::_prepareLabelRenderer( _label_renderer.property_style() = ( label_defaulted ? Pango::STYLE_ITALIC : Pango::STYLE_NORMAL ); + } void LayerSelector::_lockLayer(bool lock) { -- cgit v1.2.3 From c58c848684c4d1d58e59ca0d8112530bc451175c Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 27 Sep 2012 11:58:05 +0900 Subject: Fix for 171177 : Border in palette swatches (bzr r11706) --- src/ui/dialog/color-item.cpp | 4 +- src/ui/dialog/color-item.h | 3 +- src/ui/previewable.h | 3 +- src/ui/previewfillable.h | 3 +- src/ui/previewholder.cpp | 31 ++++++++---- src/ui/previewholder.h | 4 +- src/ui/widget/panel.cpp | 99 +++++++++++++++++++++++++++++++++----- src/widgets/eek-preview.cpp | 110 ++++++++++++++++++++++++++----------------- src/widgets/eek-preview.h | 11 ++++- 9 files changed, 199 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index b0da4aecc..969aac7ab 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -546,7 +546,7 @@ void ColorItem::_regenPreview(EekPreview * preview) | (_isLive ? PREVIEW_LINK_OTHER:0)) ); } -Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio) +Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio, guint border) { Gtk::Widget* widget = 0; if ( style == PREVIEW_STYLE_BLURB) { @@ -565,7 +565,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS _regenPreview(preview); - eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio ); + eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio, border ); def.addCallback( _colorDefChanged, this ); diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h index e6f5c7b76..f54586192 100644 --- a/src/ui/dialog/color-item.h +++ b/src/ui/dialog/color-item.h @@ -53,7 +53,8 @@ public: virtual Gtk::Widget* getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, - guint ratio); + guint ratio, + guint border); void buttonClicked(bool secondary = false); void setGradient(SPGradient *grad); diff --git a/src/ui/previewable.h b/src/ui/previewable.h index 9a086a9a2..377e109fb 100644 --- a/src/ui/previewable.h +++ b/src/ui/previewable.h @@ -35,12 +35,13 @@ typedef enum { VIEW_TYPE_GRID } ViewType; + class Previewable { public: // TODO need to add some nice parameters virtual ~Previewable() {} - virtual Gtk::Widget* getPreview( PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio ) = 0; + virtual Gtk::Widget* getPreview( PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio, guint border) = 0; }; diff --git a/src/ui/previewfillable.h b/src/ui/previewfillable.h index d5f609a0b..044357503 100644 --- a/src/ui/previewfillable.h +++ b/src/ui/previewfillable.h @@ -28,11 +28,12 @@ public: virtual void addPreview( Previewable* preview ) = 0; virtual void freezeUpdates() = 0; virtual void thawUpdates() = 0; - virtual void setStyle( ::PreviewSize size, ViewType type, guint ratio) = 0; + virtual void setStyle( ::PreviewSize size, ViewType type, guint ratio, ::BorderStyle border ) = 0; virtual void setOrientation(SPAnchorType how) = 0; virtual ::PreviewSize getPreviewSize() const = 0; virtual ViewType getPreviewType() const = 0; virtual guint getPreviewRatio() const = 0; + virtual ::BorderStyle getPreviewBorder() const = 0; virtual void setWrap( bool b ) = 0; virtual bool getWrap() const = 0; }; diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index e1c2c718a..0dac18665 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -12,6 +12,7 @@ #include "previewholder.h" +#include "preferences.h" #include #include @@ -38,7 +39,8 @@ PreviewHolder::PreviewHolder() : _baseSize(PREVIEW_SIZE_SMALL), _ratio(100), _view(VIEW_TYPE_LIST), - _wrap(false) + _wrap(false), + _border(BORDER_NONE) { _scroller = manage(new Gtk::ScrolledWindow()); _insides = manage(new Gtk::Table( 1, 2 )); @@ -77,13 +79,13 @@ void PreviewHolder::addPreview( Previewable* preview ) int i = items.size() - 1; if ( _view == VIEW_TYPE_LIST ) { - Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio)); - Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio)); + 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)); _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); } else { - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio)); + Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio, _border)); int width = 1; int height = 1; @@ -129,12 +131,13 @@ void PreviewHolder::thawUpdates() rebuildUI(); } -void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio ) +void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio, ::BorderStyle border ) { - if ( size != _baseSize || view != _view || ratio != _ratio ) { + if ( size != _baseSize || view != _view || ratio != _ratio || border != _border ) { _baseSize = size; _view = view; _ratio = ratio; + _border = border; // Kludge to restore scrollbars if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER ); @@ -304,12 +307,15 @@ void PreviewHolder::rebuildUI() if ( _view == VIEW_TYPE_LIST ) { _insides = manage(new Gtk::Table( 1, 2 )); _insides->set_col_spacings( 8 ); + if (_border == BORDER_WIDE) { + _insides->set_row_spacings( 1 ); + } for ( unsigned int i = 0; i < items.size(); i++ ) { - Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio)); + Gtk::Widget* label = 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)); + Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border)); _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); @@ -322,11 +328,18 @@ void PreviewHolder::rebuildUI() int height = 1; for ( unsigned int i = 0; i < items.size(); i++ ) { - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio)); + + // 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)); if ( !_insides ) { calcGridSize( thing, items.size(), width, height ); _insides = manage(new Gtk::Table( height, width )); + if (_border == BORDER_WIDE) { + _insides->set_col_spacings( 1 ); + _insides->set_row_spacings( 1 ); + } } _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index b7073024e..8363498a6 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -33,13 +33,14 @@ public: virtual void addPreview( Previewable* preview ); virtual void freezeUpdates(); virtual void thawUpdates(); - virtual void setStyle( ::PreviewSize size, ViewType view, guint ratio ); + virtual void setStyle( ::PreviewSize size, ViewType view, guint ratio, ::BorderStyle border ); virtual void setOrientation(SPAnchorType how); virtual int getColumnPref() const { return _prefCols; } virtual void setColumnPref( int cols ); virtual ::PreviewSize getPreviewSize() const { return _baseSize; } virtual ViewType getPreviewType() const { return _view; } virtual guint getPreviewRatio() const { return _ratio; } + virtual ::BorderStyle getPreviewBorder() const { return _border; } virtual void setWrap( bool b ); virtual bool getWrap() const { return _wrap; } @@ -62,6 +63,7 @@ private: guint _ratio; ViewType _view; bool _wrap; + ::BorderStyle _border; }; } //namespace UI diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index a1ae6a36d..1f945ada6 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -42,7 +42,8 @@ static const int PANEL_SETTING_SIZE = 0; static const int PANEL_SETTING_MODE = 1; static const int PANEL_SETTING_SHAPE = 2; static const int PANEL_SETTING_WRAP = 3; -static const int PANEL_SETTING_NEXTFREE = 4; +static const int PANEL_SETTING_BORDER = 4; +static const int PANEL_SETTING_NEXTFREE = 5; void Panel::prep() { @@ -93,7 +94,7 @@ void Panel::_init() Glib::ustring tmp("<"); _anchor = SP_ANCHOR_CENTER; - guint panel_size = 0, panel_mode = 0, panel_ratio = 100; + guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0; bool panel_wrap = 0; if (!_prefs_path.empty()) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -101,6 +102,7 @@ void Panel::_init() panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE); panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10); panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 100, 0, 500 ); + panel_border = prefs->getIntLimited(_prefs_path + "/panel_border", BORDER_NONE, 0, 2 ); } _menu = new Gtk::Menu(); @@ -197,6 +199,42 @@ void Panel::_init() } } + { + Glib::ustring widthItemLabel(C_("Swatches", "Border")); + + //TRANSLATORS: Indicates border of colour swatches + const gchar *widthLabels[] = { + NC_("Swatches border", "None"), + NC_("Swatches border", "Solid"), + NC_("Swatches border", "Wide"), + }; + + Gtk::MenuItem *item = manage( new Gtk::MenuItem(widthItemLabel)); + Gtk::Menu *type_menu = manage(new Gtk::Menu()); + item->set_submenu(*type_menu); + _menu->append(*item); + + Gtk::RadioMenuItem::Group widthGroup; + + guint values[] = {0, 1, 2}; + guint hot_index = 0; + for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) { + // Assume all values are in increasing order + if ( values[i] <= panel_border ) { + hot_index = i; + } + } + 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)); + type_menu->append(*_item); + if ( i <= hot_index ) { + _item->set_active(true); + } + _item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_BORDER, values[i])); + } + } + { //TRANSLATORS: "Wrap" indicates how colour swatches are displayed Glib::ustring wrap_label(C_("Swatches","Wrap")); @@ -259,6 +297,7 @@ void Panel::_init() _bounceCall(PANEL_SETTING_MODE, panel_mode); _bounceCall(PANEL_SETTING_SHAPE, panel_ratio); _bounceCall(PANEL_SETTING_WRAP, panel_wrap); + _bounceCall(PANEL_SETTING_BORDER, panel_border); } void Panel::setLabel(Glib::ustring const &label) @@ -323,7 +362,7 @@ void Panel::present() void Panel::restorePanelPrefs() { - guint panel_size = 0, panel_mode = 0, panel_ratio = 100; + guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0; bool panel_wrap = 0; if (!_prefs_path.empty()) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -331,11 +370,13 @@ void Panel::restorePanelPrefs() panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE); panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10); panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 000, 0, 500 ); + panel_border = prefs->getIntLimited(_prefs_path + "/panel_border", BORDER_NONE, 0, 2 ); } _bounceCall(PANEL_SETTING_SIZE, panel_size); _bounceCall(PANEL_SETTING_MODE, panel_mode); _bounceCall(PANEL_SETTING_SHAPE, panel_ratio); _bounceCall(PANEL_SETTING_WRAP, panel_wrap); + _bounceCall(PANEL_SETTING_BORDER, panel_border); } sigc::signal &Panel::signalResponse() @@ -360,30 +401,32 @@ void Panel::_bounceCall(int i, int j) if (_fillable) { ViewType curr_type = _fillable->getPreviewType(); guint curr_ratio = _fillable->getPreviewRatio(); + ::BorderStyle curr_border = _fillable->getPreviewBorder(); + switch (j) { case 0: { - _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio); + _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio, curr_border); } break; case 1: { - _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio); + _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio, curr_border); } break; case 2: { - _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio); + _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio, curr_border); } break; case 3: { - _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio); + _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio, curr_border); } break; case 4: { - _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio); + _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio, curr_border); } break; default: @@ -399,15 +442,16 @@ void Panel::_bounceCall(int i, int j) if (_fillable) { ::PreviewSize curr_size = _fillable->getPreviewSize(); guint curr_ratio = _fillable->getPreviewRatio(); + ::BorderStyle curr_border = _fillable->getPreviewBorder(); switch (j) { case 0: { - _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio); + _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio, curr_border); } break; case 1: { - _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio); + _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio, curr_border); } break; default: @@ -423,7 +467,40 @@ void Panel::_bounceCall(int i, int j) if ( _fillable ) { ViewType curr_type = _fillable->getPreviewType(); ::PreviewSize curr_size = _fillable->getPreviewSize(); - _fillable->setStyle(curr_size, curr_type, j); + ::BorderStyle curr_border = _fillable->getPreviewBorder(); + + _fillable->setStyle(curr_size, curr_type, j, curr_border); + } + break; + case PANEL_SETTING_BORDER: + if (!_prefs_path.empty()) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt(_prefs_path + "/panel_border", j); + } + if ( _fillable ) { + ::PreviewSize curr_size = _fillable->getPreviewSize(); + ViewType curr_type = _fillable->getPreviewType(); + guint curr_ratio = _fillable->getPreviewRatio(); + + switch (j) { + case 0: + { + _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_NONE); + } + break; + case 1: + { + _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_SOLID); + } + break; + case 2: + { + _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_WIDE); + } + break; + default: + break; + } } break; case PANEL_SETTING_WRAP: diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 595c289f2..a0bc1ef15 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -42,6 +42,7 @@ using std::min; #include #include "eek-preview.h" +#include "preferences.h" #define PRIME_BUTTON_MAGIC_NUMBER 1 @@ -224,13 +225,27 @@ static gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* /* static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr) { - GtkStyle* style = gtk_widget_get_style(widget); - GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - EekPreview* preview = EEK_PREVIEW(widget); - GdkColor fg = {0, preview->_r, preview->_g, preview->_b}; - gint insetX = 0; - gint insetY = 0; + GtkStyle* style = gtk_widget_get_style(widget); + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + EekPreview* preview = EEK_PREVIEW(widget); + GdkColor fg = { 0, preview->_r, preview->_g, preview->_b }; + gint insetTop = 0, insetBottom = 0; + gint insetLeft = 0, insetRight = 0; + + if (preview->_border == BORDER_SOLID) { + insetTop = 1; + insetLeft = 1; + } + if (preview->_border == BORDER_SOLID_LAST_ROW) { + insetTop = insetBottom = 1; + insetLeft = 1; + } + if (preview->_border == BORDER_WIDE) { + insetTop = insetBottom = 1; + insetLeft = insetRight = 1; + } + #if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context = gtk_widget_get_style_context(widget); @@ -247,30 +262,32 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr) #else GdkWindow* window = gtk_widget_get_window(widget); - gtk_paint_flat_box( style, - window, - (GtkStateType)gtk_widget_get_state(widget), - GTK_SHADOW_NONE, - NULL, - widget, - NULL, - 0, 0, - allocation.width, allocation.height); + gtk_paint_flat_box( style, + window, + (GtkStateType)gtk_widget_get_state(widget), + GTK_SHADOW_NONE, + NULL, + widget, + NULL, + 0, 0, + allocation.width, allocation.height); gdk_colormap_alloc_color( gdk_colormap_get_system(), &fg, FALSE, TRUE ); #endif - GdkRectangle rect = {insetX, - insetY, - allocation.width - (insetX * 2), - allocation.height - (insetY * 2)}; + // Border + if (preview->_border != BORDER_NONE) { + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); + cairo_fill(cr); + } - gdk_cairo_set_source_color(cr, &fg); - gdk_cairo_rectangle(cr, &rect); - cairo_paint(cr); + cairo_set_source_rgb(cr, preview->_r/65535.0, preview->_g/65535.0, preview->_b/65535.0 ); + cairo_rectangle(cr, insetLeft, insetTop, allocation.width - (insetLeft + insetRight), allocation.height - (insetTop + insetBottom)); + cairo_fill(cr); - if ( preview->_previewPixbuf ) { - GtkDrawingArea *da = &(preview->drawing); + if ( preview->_previewPixbuf ) { + GtkDrawingArea *da = &(preview->drawing); GdkWindow *da_window = gtk_widget_get_window(GTK_WIDGET(da)); cairo_t *cr = gdk_cairo_create(da_window); @@ -278,29 +295,38 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr) gint w = gdk_window_get_width(da_window); gint h = gdk_window_get_height(da_window); #else - gint w = 0; - gint h = 0; + gint w = 0; + gint h = 0; gdk_drawable_get_size(da_window, &w, &h); #endif - + + if ((w != preview->_scaledW) || (h != preview->_scaledH)) { - if (preview->_scaled) { - g_object_unref(preview->_scaled); - } - preview->_scaled = gdk_pixbuf_scale_simple(preview->_previewPixbuf, w, h, GDK_INTERP_BILINEAR); - preview->_scaledW = w; - preview->_scaledH = h; + if (preview->_scaled) { + g_object_unref(preview->_scaled); } + preview->_scaled = gdk_pixbuf_scale_simple(preview->_previewPixbuf, w - (insetLeft + insetRight), h - (insetTop + insetBottom), GDK_INTERP_BILINEAR); + preview->_scaledW = w - (insetLeft + insetRight); + preview->_scaledH = h - (insetTop + insetBottom); + } + + GdkPixbuf *pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf; + + // Border + if (preview->_border != BORDER_NONE) { + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); + cairo_fill(cr); + } - GdkPixbuf *pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf; - gdk_cairo_set_source_pixbuf(cr, pix, 0, 0); + gdk_cairo_set_source_pixbuf(cr, pix, insetLeft, insetTop); cairo_paint(cr); cairo_destroy(cr); - } + } if ( preview->_linked ) { /* Draw arrow */ - GdkRectangle possible = {insetX, insetY, (allocation.width - (insetX * 2)), (allocation.height - (insetY * 2)) }; + GdkRectangle possible = {insetLeft, insetTop, (allocation.width - (insetLeft + insetRight)), (allocation.height - (insetTop + insetBottom)) }; GdkRectangle area = {possible.x, possible.y, possible.width / 2, possible.height / 2 }; /* Make it square */ @@ -370,7 +396,7 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr) } if ( preview->_linked & PREVIEW_LINK_OTHER ) { - GdkRectangle otherArea = {insetX, area.y, area.width, area.height}; + GdkRectangle otherArea = {insetLeft, area.y, area.width, area.height}; if ( otherArea.height < possible.height ) { otherArea.y = possible.y + (possible.height - otherArea.height) / 2; } @@ -752,7 +778,7 @@ void eek_preview_set_focus_on_click( EekPreview* preview, gboolean focus_on_clic } } -void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio ) +void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio, guint border ) { preview->_prevstyle = prevstyle; preview->_view = view; @@ -766,7 +792,7 @@ void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewT ratio = PREVIEW_MAX_RATIO; } preview->_ratio = ratio; - + preview->_border = border; gtk_widget_queue_draw(GTK_WIDGET(preview)); } @@ -802,7 +828,7 @@ static void eek_preview_init( EekPreview *preview ) preview->_view = VIEW_TYPE_LIST; preview->_size = PREVIEW_SIZE_SMALL; preview->_ratio = 100; - + preview->_border = BORDER_NONE; preview->_previewPixbuf = 0; preview->_scaled = 0; diff --git a/src/widgets/eek-preview.h b/src/widgets/eek-preview.h index 7275ab9b4..42e89a161 100644 --- a/src/widgets/eek-preview.h +++ b/src/widgets/eek-preview.h @@ -90,6 +90,14 @@ typedef enum { PREVIEW_LINK_ALL = 31 } LinkType; + +typedef enum { + BORDER_NONE = 0, + BORDER_SOLID, + BORDER_WIDE, + BORDER_SOLID_LAST_ROW, +} BorderStyle; + typedef struct _EekPreview EekPreview; typedef struct _EekPreviewClass EekPreviewClass; @@ -113,6 +121,7 @@ struct _EekPreview PreviewSize _size; guint _ratio; guint _linked; + guint _border; GdkPixbuf* _previewPixbuf; GdkPixbuf* _scaled; }; @@ -128,7 +137,7 @@ struct _EekPreviewClass GType eek_preview_get_type(void) G_GNUC_CONST; GtkWidget* eek_preview_new(void); -void eek_preview_set_details( EekPreview* splat, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio ); +void eek_preview_set_details( EekPreview* splat, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio, guint); void eek_preview_set_color( EekPreview* splat, int r, int g, int b ); void eek_preview_set_pixbuf( EekPreview* splat, GdkPixbuf* pixbuf ); -- cgit v1.2.3 From 0b8c171ccfdb7d75a83270ce5d6e6956a438ce5e Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 27 Sep 2012 12:08:07 +0900 Subject: Fix for 172030 : Width of Undo History palette could be optimized (bzr r11707) --- src/ui/dialog/undo-history.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index 73b76054e..b96c9158a 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -167,7 +167,7 @@ UndoHistory::UndoHistory() { if ( !_document || !_event_log || !_columns ) return; - set_size_request(300, 95); + set_size_request(-1, 95); _getContents()->pack_start(_scrolled_window); _scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); @@ -180,31 +180,35 @@ UndoHistory::UndoHistory() _event_list_view.set_headers_visible(false); CellRendererSPIcon* icon_renderer = Gtk::manage(new CellRendererSPIcon()); - icon_renderer->property_xpad() = 8; - icon_renderer->property_width() = 36; + icon_renderer->property_xpad() = 2; + icon_renderer->property_width() = 24; int cols_count = _event_list_view.append_column("Icon", *icon_renderer); Gtk::TreeView::Column* icon_column = _event_list_view.get_column(cols_count-1); icon_column->add_attribute(icon_renderer->property_event_type(), _columns->type); + CellRendererInt* children_renderer = Gtk::manage(new CellRendererInt(greater_than_1)); + children_renderer->property_weight() = 600; // =Pango::WEIGHT_SEMIBOLD (not defined in old versions of pangomm) + children_renderer->property_xalign() = 1.0; + children_renderer->property_xpad() = 2; + children_renderer->property_width() = 24; + + cols_count = _event_list_view.append_column("Children", *children_renderer); + Gtk::TreeView::Column* children_column = _event_list_view.get_column(cols_count-1); + children_column->add_attribute(children_renderer->property_number(), _columns->child_count); + Gtk::CellRendererText* description_renderer = Gtk::manage(new Gtk::CellRendererText()); + description_renderer->property_ellipsize() = Pango::ELLIPSIZE_END; cols_count = _event_list_view.append_column("Description", *description_renderer); Gtk::TreeView::Column* description_column = _event_list_view.get_column(cols_count-1); description_column->add_attribute(description_renderer->property_text(), _columns->description); description_column->set_resizable(); + description_column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE); + description_column->set_min_width (150); _event_list_view.set_expander_column( *_event_list_view.get_column(cols_count-1) ); - CellRendererInt* children_renderer = Gtk::manage(new CellRendererInt(greater_than_1)); - children_renderer->property_weight() = 600; // =Pango::WEIGHT_SEMIBOLD (not defined in old versions of pangomm) - children_renderer->property_xalign() = 1.0; - children_renderer->property_xpad() = 20; - - cols_count = _event_list_view.append_column("Children", *children_renderer); - Gtk::TreeView::Column* children_column = _event_list_view.get_column(cols_count-1); - children_column->add_attribute(children_renderer->property_number(), _columns->child_count); - _scrolled_window.add(_event_list_view); // connect EventLog callbacks -- cgit v1.2.3 From 01e3b60948d36b1f17380f43b46180157e96ec95 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 27 Sep 2012 12:32:48 +0900 Subject: Fix for 169001 : Long layer names mess with the UI (bzr r11708) --- src/ui/widget/layer-selector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 4bb4d8c98..4f8d921e6 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -579,7 +579,7 @@ void LayerSelector::_prepareLabelRenderer( gchar const *label; if ( object != root ) { - label = gr_ellipsize_text (object->label(), 50).c_str(); + label = object->label(); if (!object->label()) { label = object->defaultLabel(); label_defaulted = true; @@ -588,7 +588,7 @@ void LayerSelector::_prepareLabelRenderer( label = _("(root)"); } - gchar *text = g_markup_printf_escaped(format, label); + gchar *text = g_markup_printf_escaped(format, gr_ellipsize_text (label, 50).c_str()); _label_renderer.property_markup() = text; g_free(text); g_free(format); -- cgit v1.2.3 From 16a46ff9523431ae539865ed71328650e64327f5 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 27 Sep 2012 13:01:53 +0900 Subject: Fix for 166691 : Changing layer order does not update layer selector (bzr r11709) --- src/ui/widget/layer-selector.cpp | 4 +++- src/widgets/desktop-widget.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 4f8d921e6..c06f70185 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -240,7 +240,9 @@ private: void LayerSelector::_layersChanged() { - //_selectLayer(_desktop->currentLayer()); + if (_desktop) { + _selectLayer(_desktop->currentLayer()); + } } /** Selects the given layer in the dropdown selector. diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 81361f0f9..9f18cc671 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -680,6 +680,7 @@ static void sp_desktop_widget_dispose(GObject *object) g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); + dtw->layer_selector->setDesktop(NULL); dtw->layer_selector->unreference(); inkscape_remove_desktop (dtw->desktop); // clears selection too dtw->modified_connection.disconnect(); -- cgit v1.2.3 From e24a4f6919b78067bc7c2bd06144a3e351b335c3 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 28 Sep 2012 10:12:59 +0900 Subject: Fix for 1046740 : middle click on palette to set stroke colour (bzr r11710) --- src/widgets/eek-preview.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index a0bc1ef15..e0c5d9eac 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -550,7 +550,8 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton* gtk_widget_grab_focus(widget); } - if ( event->button == PRIME_BUTTON_MAGIC_NUMBER ) { + if ( event->button == PRIME_BUTTON_MAGIC_NUMBER || + event->button == 2 ) { preview->_hot = TRUE; if ( preview->_within ) { gtk_widget_set_state( widget, GTK_STATE_ACTIVE ); @@ -567,8 +568,10 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton EekPreview* preview = EEK_PREVIEW(widget); preview->_hot = FALSE; gtk_widget_set_state( widget, GTK_STATE_NORMAL ); - if ( preview->_within && event->button == PRIME_BUTTON_MAGIC_NUMBER ) { - gboolean isAlt = (event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK; + if ( preview->_within && + (event->button == PRIME_BUTTON_MAGIC_NUMBER || event->button == 2)) { + gboolean isAlt = ( ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) || + (event->button == 2)); if ( isAlt ) { g_signal_emit( widget, eek_preview_signals[ALTCLICKED_SIGNAL], 0, 2 ); -- cgit v1.2.3 From 9f81b5cdb66dcab4c39e92ba5e579ad45d9395ad Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 28 Sep 2012 12:12:45 +0900 Subject: Fix for 1000023 : Stop color notepad buttons expanding vertically (bzr r11711) --- src/widgets/sp-color-notebook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index bafc75b18..f2ae0425f 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -287,7 +287,7 @@ void ColorNotebook::init() sp_set_font_size_smaller (_buttonbox); gtk_table_attach (GTK_TABLE (table), _buttonbox, 0, 2, row, row + 1, static_cast(GTK_EXPAND|GTK_FILL), - static_cast(GTK_EXPAND|GTK_FILL), + static_cast(0), XPAD, YPAD); row++; -- cgit v1.2.3 From 56d3279ce493f79922fbc7200f670237fcf45ff2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 28 Sep 2012 13:14:02 +0200 Subject: Filters. Some filters fixes, renaming and simplifications. (bzr r11713) --- src/extension/internal/filter/color.h | 63 +++++++++++++++++------------------ src/extension/internal/filter/paint.h | 52 ++++++++++++----------------- 2 files changed, 53 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index b6b194c8b..22b77a8cc 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -615,9 +615,8 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Channel (enum, all colors, default Red) -> colormatrix (values) - * Background blend (enum, all blend modes, default Multiply) -> blend (mode) + * Background blend (enum, Normal, Multiply, Screen, default Normal) -> blend (mode) * Channel to alpha (boolean, default false) -> colormatrix (values) - * Invert (boolean, default false) -> colormatrix (values) */ class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter { @@ -637,16 +636,16 @@ public: "<_item value=\"r\">" N_("Red") "\n" "<_item value=\"g\">" N_("Green") "\n" "<_item value=\"b\">" N_("Blue") "\n" + "<_item value=\"c\">" N_("Cyan") "\n" + "<_item value=\"m\">" N_("Majenta") "\n" + "<_item value=\"y\">" N_("Yellow") "\n" "\n" "\n" "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"screen\">" N_("Screen") "\n" - "<_item value=\"darken\">" N_("Darken") "\n" - "<_item value=\"lighten\">" N_("Lighten") "\n" "\n" "false\n" - "false\n" "\n" "all\n" "\n" @@ -667,45 +666,45 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream blend; std::ostringstream colors; - std::ostringstream alpha; - std::ostringstream invert; blend << ext->get_param_enum("blend"); const gchar *channel = ext->get_param_enum("source"); if (ext->get_param_bool("alpha")) { - colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - } else if ((g_ascii_strcasecmp("r", channel) == 0)) { - colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0"; - } else if ((g_ascii_strcasecmp("g", channel) == 0)) { - colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0"; - } else { - colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1"; - } - - if (ext->get_param_bool("invert")) { if ((g_ascii_strcasecmp("r", channel) == 0)) { - alpha << "-1 0 0 1"; + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"; } else if ((g_ascii_strcasecmp("g", channel) == 0)) { - alpha << "0 -1 0 1"; + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0"; + } else if ((g_ascii_strcasecmp("b", channel) == 0)) { + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0"; + } else if ((g_ascii_strcasecmp("c", channel) == 0)) { + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 1 0"; + } else if ((g_ascii_strcasecmp("m", channel) == 0)) { + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0"; } else { - alpha << "0 0 -1 1"; + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0"; } } else { if ((g_ascii_strcasecmp("r", channel) == 0)) { - alpha << "1 0 0 0"; + colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"; } else if ((g_ascii_strcasecmp("g", channel) == 0)) { - alpha << "0 1 0 0"; + colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0"; + } else if ((g_ascii_strcasecmp("b", channel) == 0)) { + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0"; + } else if ((g_ascii_strcasecmp("c", channel) == 0)) { + colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0"; + } else if ((g_ascii_strcasecmp("m", channel) == 0)) { + colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0"; } else { - alpha << "0 0 1 0"; + colors << "0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0"; } } _filter = g_strdup_printf( "\n" - "\n" + "\n" "\n" - "\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() ); + "\n", colors.str().c_str(), blend.str().c_str() ); return _filter; }; /* ExtractChannel filter */ @@ -1157,9 +1156,9 @@ LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Lightness-Contrast filter */ /** - \brief Custom predefined Nudge filter. + \brief Custom predefined Nudge RGB filter. - Nudge separately RGB channels and blend them to different types of backgrounds + Nudge RGB channels separately and blend them to different types of backgrounds Filter's parameters: Offsets @@ -1193,8 +1192,8 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Nudge") "\n" - "org.inkscape.effect.filter.Nudge\n" + "" N_("Nudge RGB") "\n" + "org.inkscape.effect.filter.NudgeRGB\n" "\n" "\n" "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "\n" @@ -1232,7 +1231,7 @@ public: "\n" "\n" "\n" - "" N_("Nudge separately RGB channels and blend them to different types of backgrounds") "\n" + "" N_("Nudge RGB channels separately and blend them to different types of backgrounds") "\n" "\n" "\n", new Nudge()); }; @@ -1277,7 +1276,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1297,7 +1296,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; -}; /* Nudge filter */ +}; /* Nudge RGB filter */ /** \brief Custom predefined Quadritone filter. diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index debdd7d79..dcc51c815 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -3,7 +3,7 @@ /* Change the 'PAINT' above to be your file name */ /* - * Copyright (C) 2011 Authors: + * Copyright (C) 2012 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) * @@ -563,13 +563,13 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Lines type (enum, default smooth) -> - smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2") - hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1") - * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation) - * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation) - * Lightness (0.->10., default 0.5) -> composite1 (k3) + smooth = component2 (type="table"), composite1 (in2="blur2") + hard = component2 (type="discrete"), composite1 (in2="component1") + * Simplify (0.01->20., default 3) -> blur1 (stdDeviation) + * Line width (0.01->20., default 3) -> blur2 (stdDeviation) + * Lightness (0.->10., default 1) -> composite1 (k2) * Blend (enum [normal, multiply, screen], default normal) -> blend (mode) - * Dark mode (boolean, default false) -> composite1 (true: in2="component2") + * Dark mode (boolean, default false) -> composite2 (true: in2="component2") */ class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter { protected: @@ -588,15 +588,14 @@ public: "<_item value=\"table\">" N_("Smoothed") "\n" "<_item value=\"discrete\">" N_("Contrasted") "\n" "\n" - "1.5\n" - "1.5\n" - "0.5\n" + "3\n" + "3\n" + "1\n" "\n" "<_item value=\"normal\">Normal\n" "<_item value=\"multiply\">Multiply\n" "<_item value=\"screen\">Screen\n" "\n" - "false\n" "\n" "all\n" "\n" @@ -620,7 +619,6 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream width; std::ostringstream lightness; std::ostringstream type; - std::ostringstream dark; type << ext->get_param_enum("type"); blend << ext->get_param_enum("blend"); @@ -628,33 +626,27 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) width << ext->get_param_float("width"); lightness << ext->get_param_float("lightness"); - const gchar *typestr = ext->get_param_enum("type"); - if (ext->get_param_bool("dark")) { - dark << "component2"; - } else if ((g_ascii_strcasecmp("table", typestr) == 0)) { - dark << "blur2"; - } else { - dark << "component1"; - } - _filter = g_strdup_printf( "\n" "\n" "\n" + "\n" "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" "\n" - "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" + "\n" "\n" - "\n" + "\n" + "\n" "\n" - "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str()); + "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), lightness.str().c_str()); return _filter; }; /* NeonDraw filter */ -- cgit v1.2.3 From 1cb21cd6cfca11a693704c0e8047cce9ee6bd26b Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 29 Sep 2012 11:57:24 +0900 Subject: Fix for 1058432 : Trace Bitmap preview should be resizeable (bzr r11714) --- src/ui/dialog/tracedialog.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index a6495c205..a752ade21 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -294,8 +294,9 @@ void TraceDialogImpl::potraceProcess(bool do_i_trace) { int width = preview->get_width(); int height = preview->get_height(); - double scaleFX = 200.0 / (double)width; - double scaleFY = 200.0 / (double)height; + const Gtk::Allocation& vboxAlloc = previewImage.get_allocation(); + double scaleFX = vboxAlloc.get_width() / (double)width; + double scaleFY = vboxAlloc.get_height() / (double)height; double scaleFactor = scaleFX > scaleFY ? scaleFY : scaleFX; int newWidth = (int) (((double)width) * scaleFactor); int newHeight = (int) (((double)height) * scaleFactor); @@ -645,7 +646,7 @@ TraceDialogImpl::TraceDialogImpl() : //#### end left panel - mainHBox.pack_start(leftVBox); + mainHBox.pack_start(leftVBox, false, false, 0); //#### begin right panel @@ -677,7 +678,7 @@ TraceDialogImpl::TraceDialogImpl() : //#### end right panel - mainHBox.pack_start(rightVBox); + mainHBox.pack_start(rightVBox, true, true, 0); //#### Global stuff -- cgit v1.2.3 From a20d8f37c8f8c1df1eb65dccb0f695937905d6ab Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 29 Sep 2012 14:31:10 +0200 Subject: memleak fix (part of bug #1043571) (bzr r11715) --- src/libcroco/cr-term.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libcroco/cr-term.c b/src/libcroco/cr-term.c index 63b39271b..d95c4979f 100644 --- a/src/libcroco/cr-term.c +++ b/src/libcroco/cr-term.c @@ -365,9 +365,9 @@ cr_term_to_string (CRTerm * a_this) tmp_str = NULL; } - g_free (content); - content = NULL; } + g_free (content); + content = NULL; g_string_append (str_buf, ")"); } -- cgit v1.2.3 From 51a9de94671f1f7ee1cf2a57ef5dfde94b4a802b Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 30 Sep 2012 14:01:21 +0900 Subject: Fix for 1058470 : Trace Bitmap Live Preview (bzr r11716) --- src/ui/dialog/tracedialog.cpp | 158 ++++++++++++++++++++++++++++++++++++++---- src/ui/widget/panel.cpp | 14 ++-- src/ui/widget/panel.h | 6 +- 3 files changed, 158 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index a752ade21..1ad827a56 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -26,6 +26,8 @@ #include #include "desktop.h" +#include "desktop-tracker.h" +#include "selection.h" #include "trace/potrace/inkscape-potrace.h" #include "inkscape.h" @@ -83,6 +85,13 @@ class TraceDialogImpl : public TraceDialog void abort(); void previewCallback(); + void previewLiveCallback(); + void onSettingsChange(); + void onSelectionModified( guint flags ); + void onSetDefaults(); + + void setDesktop(SPDesktop *desktop); + void setTargetDesktop(SPDesktop *desktop); //############ General items @@ -90,6 +99,7 @@ class TraceDialogImpl : public TraceDialog Gtk::Button *mainOkButton; Gtk::Button *mainCancelButton; + Gtk::Button *mainResetButton; //######## Left pannel @@ -194,11 +204,40 @@ class TraceDialogImpl : public TraceDialog UI::Widget::Frame previewFrame; Gtk::VBox previewVBox; Gtk::Button previewButton; + Gtk::CheckButton previewLiveButton; + gboolean previewLive; Gtk::Image previewImage; + SPDesktop *desktop; + DesktopTracker deskTrack; + sigc::connection desktopChangeConn; + sigc::connection selectChangedConn; + sigc::connection selectModifiedConn; + }; +void TraceDialogImpl::setDesktop(SPDesktop *desktop) +{ + Panel::setDesktop(desktop); + deskTrack.setBase(desktop); +} +void TraceDialogImpl::setTargetDesktop(SPDesktop *desktop) +{ + if (this->desktop != desktop) { + if (this->desktop) { + selectChangedConn.disconnect(); + selectModifiedConn.disconnect(); + } + this->desktop = desktop; + if (desktop && desktop->selection) { + selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange))); + selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &TraceDialogImpl::onSelectionModified))); + + } + onSettingsChange(); + } +} //######################################################################### //## E V E N T S @@ -351,6 +390,58 @@ void TraceDialogImpl::abort() //## E V E N T S //######################################################################### +/** + * Callback for when any setting changes + */ +void TraceDialogImpl::onSettingsChange() +{ + if (previewLive) { + previewCallback(); + } +} + +void TraceDialogImpl::onSelectionModified( guint flags ) +{ + if (flags & ( SP_OBJECT_MODIFIED_FLAG | + SP_OBJECT_PARENT_MODIFIED_FLAG | + SP_OBJECT_STYLE_MODIFIED_FLAG) ) { + onSettingsChange(); + } +} + +/** + * Callback for when users resets defaults + */ +void TraceDialogImpl::onSetDefaults() +{ + + // temporarily disable live update + gboolean wasLive = previewLive; + previewLive = false; + + modeBrightnessRadioButton.set_active(true); + modeBrightnessSpinner.set_value(0.45); + modeCannyHiSpinner.set_value(0.65); + modeMultiScanNrColorSpinner.set_value(8.0); + modeMultiScanNrColorSpinner.set_value(8.0); + optionsSpecklesSizeSpinner.set_value(2); + optionsCornersThresholdSpinner.set_value(1.0); + optionsOptimToleranceSpinner.set_value(0.2); + + modeInvertButton.set_active(false); + modeMultiScanSmoothButton.set_active(true); + modeMultiScanStackButton.set_active(true); + modeMultiScanBackgroundButton.set_active(false); + optionsSpecklesButton.set_active(true); + optionsCornersButton.set_active(true); + optionsOptimButton.set_active(true); + sioxButton.set_active(false); + + previewLive = wasLive; + onSettingsChange(); + +} + /** * Callback from the Preview button. Can be called from elsewhere. */ @@ -359,25 +450,32 @@ void TraceDialogImpl::previewCallback() potraceProcess(false); } +/** + * Callback from the Preview Live button. + */ +void TraceDialogImpl::previewLiveCallback() +{ + previewLive = previewLiveButton.get_active(); + previewButton.set_sensitive(!previewLive); + onSettingsChange(); +} + /** * Default response from the dialog. Let's intercept it */ void TraceDialogImpl::responseCallback(int response_id) { - if (response_id == GTK_RESPONSE_OK) - { - // for now, we assume potrace, as it's the only one we have - potraceProcess(true); - } - else if (response_id == GTK_RESPONSE_CANCEL) - { + if (response_id == GTK_RESPONSE_OK) { + // for now, we assume potrace, as it's the only one we have + potraceProcess(true); + } else if (response_id == GTK_RESPONSE_CANCEL) { abort(); - } - else - { + } else if (response_id == GTK_RESPONSE_HELP) { + onSetDefaults(); + } else { hide(); return; - } + } } @@ -418,6 +516,7 @@ TraceDialogImpl::TraceDialogImpl() : modeBrightnessSpinner.set_value(0.45); modeBrightnessBox.pack_end(modeBrightnessSpinner, false, false, MARGIN); modeBrightnessSpinner.set_tooltip_text(_("Brightness cutoff for black/white")); + modeBrightnessSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeBrightnessSpinnerLabel.set_label(_("_Threshold:")); modeBrightnessSpinnerLabel.set_use_underline(true); @@ -436,6 +535,8 @@ TraceDialogImpl::TraceDialogImpl() : modeCannyRadioButton.set_use_underline(true); modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN); modeCannyRadioButton.set_tooltip_text(_("Trace with optimal edge detection by J. Canny's algorithm")); + modeCannyRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); + /* modeCannyBox.pack_start(modeCannySeparator); modeCannyLoSpinnerLabel.set_label(_("Low")); @@ -452,6 +553,7 @@ TraceDialogImpl::TraceDialogImpl() : modeCannyHiSpinner.set_value(0.65); modeCannyBox.pack_end(modeCannyHiSpinner, false, false, MARGIN); modeCannyHiSpinner.set_tooltip_text(_("Brightness cutoff for adjacent pixels (determines edge thickness)")); + modeCannyHiSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeCannyHiSpinnerLabel.set_label(_("T_hreshold:")); modeCannyHiSpinnerLabel.set_use_underline(true); @@ -470,6 +572,7 @@ TraceDialogImpl::TraceDialogImpl() : modeQuantRadioButton.set_use_underline(true); modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN); modeQuantRadioButton.set_tooltip_text(_("Trace along the boundaries of reduced colors")); + modeQuantRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeQuantNrColorSpinner.set_digits(0); modeQuantNrColorSpinner.set_increments(1.0, 0); @@ -477,6 +580,7 @@ TraceDialogImpl::TraceDialogImpl() : modeQuantNrColorSpinner.set_value(8.0); modeQuantBox.pack_end(modeQuantNrColorSpinner, false, false, MARGIN); modeQuantNrColorSpinner.set_tooltip_text(_("The number of reduced colors")); + modeQuantNrColorSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeQuantNrColorLabel.set_label(_("_Colors:")); modeQuantNrColorLabel.set_mnemonic_widget(modeQuantNrColorSpinner); @@ -492,6 +596,7 @@ TraceDialogImpl::TraceDialogImpl() : modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN); modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN); modeInvertButton.set_tooltip_text(_("Invert black and white regions")); + modeInvertButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeBrightnessFrame.add(modeBrightnessVBox); modePageBox.pack_start(modeBrightnessFrame, false, false, 0); @@ -505,6 +610,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanBrightnessRadioButton.set_use_underline(true); modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN); modeMultiScanBrightnessRadioButton.set_tooltip_text(_("Trace the given number of brightness levels")); + modeMultiScanBrightnessRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanNrColorSpinner.set_digits(0); modeMultiScanNrColorSpinner.set_increments(1.0, 0); @@ -516,6 +622,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanNrColorLabel.set_mnemonic_widget(modeMultiScanNrColorSpinner); modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN); modeMultiScanNrColorSpinner.set_tooltip_text(_("The desired number of scans")); + modeMultiScanNrColorSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN); @@ -524,6 +631,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanColorRadioButton.set_use_underline(true); modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN); modeMultiScanColorRadioButton.set_tooltip_text(_("Trace the given number of reduced colors")); + modeMultiScanColorRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN); @@ -532,6 +640,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanMonoRadioButton.set_use_underline(true); modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN); modeMultiScanMonoRadioButton.set_tooltip_text(_("Same as Colors, but the result is converted to grayscale")); + modeMultiScanMonoRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN); @@ -541,6 +650,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanSmoothButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN); modeMultiScanSmoothButton.set_tooltip_text(_("Apply Gaussian blur to the bitmap before tracing")); + modeMultiScanSmoothButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); // TRANSLATORS: "Stack" is a verb here modeMultiScanStackButton.set_label(_("Stac_k scans")); @@ -548,6 +658,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanStackButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN); modeMultiScanStackButton.set_tooltip_text(_("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)")); + modeMultiScanStackButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanBackgroundButton.set_label(_("Remo_ve background")); @@ -556,6 +667,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN); // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan modeMultiScanBackgroundButton.set_tooltip_text(_("Remove bottom (background) layer when done")); + modeMultiScanBackgroundButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox4, false, false, MARGIN); @@ -578,12 +690,14 @@ TraceDialogImpl::TraceDialogImpl() : optionsSpecklesButton.set_use_underline(true); optionsSpecklesButton.set_tooltip_text(_("Ignore small spots (speckles) in the bitmap")); optionsSpecklesButton.set_active(true); + optionsSpecklesButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsSpecklesBox.pack_start(optionsSpecklesButton, false, false, MARGIN); optionsSpecklesSizeSpinner.set_digits(0); optionsSpecklesSizeSpinner.set_increments(1, 0); optionsSpecklesSizeSpinner.set_range(0, 1000); optionsSpecklesSizeSpinner.set_value(2); optionsSpecklesSizeSpinner.set_tooltip_text(_("Speckles of up to this many pixels will be suppressed")); + optionsSpecklesSizeSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN); optionsSpecklesSizeLabel.set_label(_("S_ize:")); optionsSpecklesSizeLabel.set_use_underline(true); @@ -594,6 +708,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsCornersButton.set_use_underline(true); optionsCornersButton.set_tooltip_text(_("Smooth out sharp corners of the trace")); optionsCornersButton.set_active(true); + optionsCornersButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsCornersBox.pack_start(optionsCornersButton, false, false, MARGIN); optionsCornersThresholdSpinner.set_digits(2); optionsCornersThresholdSpinner.set_increments(0.01, 0); @@ -601,6 +716,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsCornersThresholdSpinner.set_value(1.0); optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN); optionsCornersThresholdSpinner.set_tooltip_text(_("Increase this to smooth corners more")); + optionsCornersThresholdSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsCornersThresholdLabel.set_label(_("_Threshold:")); optionsCornersThresholdLabel.set_use_underline(true); optionsCornersThresholdLabel.set_mnemonic_widget(optionsCornersThresholdSpinner); @@ -610,6 +726,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsOptimButton.set_use_underline(true); optionsOptimButton.set_active(true); optionsOptimButton.set_tooltip_text(_("Try to optimize paths by joining adjacent Bezier curve segments")); + optionsOptimButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsOptimBox.pack_start(optionsOptimButton, false, false, MARGIN); optionsOptimToleranceSpinner.set_digits(2); optionsOptimToleranceSpinner.set_increments(0.05, 0); @@ -617,6 +734,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsOptimToleranceSpinner.set_value(0.2); optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN); optionsOptimToleranceSpinner.set_tooltip_text(_("Increase this to reduce the number of nodes in the trace by more aggressive optimization")); + optionsOptimToleranceSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsOptimToleranceLabel.set_label(_("To_lerance:")); optionsOptimToleranceLabel.set_use_underline(true); optionsOptimToleranceLabel.set_mnemonic_widget(optionsOptimToleranceSpinner); @@ -659,12 +777,20 @@ TraceDialogImpl::TraceDialogImpl() : rightVBox.pack_start(sioxBox, false, false, 0); //## preview + Gtk::HBox *previewButtonHBox = manage(new Gtk::HBox(false, MARGIN )); + previewLiveButton.set_label(_("Live Preview")); + previewLiveButton.set_use_underline(true); + previewLiveCallback(); + previewLiveButton.signal_clicked().connect( + sigc::mem_fun(*this, &TraceDialogImpl::previewLiveCallback) ); previewButton.set_label(_("_Update")); previewButton.set_use_underline(true); previewButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) ); - previewVBox.pack_end(previewButton, false, false, 0); + previewButtonHBox->pack_start(previewLiveButton, false, false, 0); + previewButtonHBox->pack_end(previewButton, true, true, 0); + previewVBox.pack_end(*previewButtonHBox, false, false, 0); // I guess it's correct to call the "intermediate bitmap" a preview of the trace previewButton.set_tooltip_text(_("Preview the intermediate bitmap with the current settings, without actual tracing")); previewImage.set_size_request(200,200); @@ -683,6 +809,8 @@ TraceDialogImpl::TraceDialogImpl() : //#### Global stuff contents->pack_start(mainHBox); + mainResetButton = addResponseButton(_("Reset"), GTK_RESPONSE_HELP, true); + mainResetButton ->set_tooltip_text(_("Reset all settings to defaults")); //## The OK button mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL); @@ -695,6 +823,9 @@ TraceDialogImpl::TraceDialogImpl() : show_all_children(); + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &TraceDialogImpl::setTargetDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); + //## Connect the signal signalResponse().connect( sigc::mem_fun(*this, &TraceDialogImpl::responseCallback)); @@ -715,6 +846,9 @@ TraceDialog &TraceDialog::getInstance() */ TraceDialogImpl::~TraceDialogImpl() { + selectChangedConn.disconnect(); + selectModifiedConn.disconnect(); + desktopChangeConn.disconnect(); } diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 1f945ada6..42435f298 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -572,21 +572,21 @@ void Panel::_apply() g_warning("Apply button clicked for panel [Panel::_apply()]"); } -Gtk::Button *Panel::addResponseButton(const Glib::ustring &button_text, int response_id) +Gtk::Button *Panel::addResponseButton(const Glib::ustring &button_text, int response_id, bool pack_start) { Gtk::Button *button = new Gtk::Button(button_text); - _addResponseButton(button, response_id); + _addResponseButton(button, response_id, pack_start); return button; } -Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id) +Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id, bool pack_start) { Gtk::Button *button = new Gtk::Button(stock_id); - _addResponseButton(button, response_id); + _addResponseButton(button, response_id, pack_start); return button; } -void Panel::_addResponseButton(Gtk::Button *button, int response_id) +void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_start) { // Create a button box for the response buttons if it's the first button to be added if (!_action_area) { @@ -597,6 +597,10 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id) _action_area->pack_end(*button); + if (pack_start) { + _action_area->set_child_secondary( *button , true); + } + if (response_id != 0) { // Re-emit clicked signals as response signals button->signal_clicked().connect(sigc::bind(_signal_response.make_slot(), response_id)); diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 2d92d65c9..b4cc04809 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -96,8 +96,8 @@ public: /* Methods providing a Gtk::Dialog like interface for adding buttons that emit Gtk::RESPONSE * signals on click. */ - Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id); - Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id); + Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id, bool pack_start=false); + Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id, bool pack_start=false); void setDefaultResponse(int response_id); void setResponseSensitive(int response_id, bool setting); @@ -119,7 +119,7 @@ protected: virtual void _handleResponse(int response_id); /* Helper methods */ - void _addResponseButton(Gtk::Button *button, int response_id); + void _addResponseButton(Gtk::Button *button, int response_id, bool pack_start=false); Inkscape::Selection *_getSelection(); /** -- cgit v1.2.3 From c877d257fed8ff721d23d9e5d841be08bd769559 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 30 Sep 2012 14:15:19 +0900 Subject: Fix for 681625 : sort template names under File->New (bzr r11717) --- src/interface.cpp | 150 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 99 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index fdfdce5ae..f26b7ac74 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -778,69 +778,117 @@ sp_file_new_from_template(GtkWidget */*widget*/, gchar const *uri) sp_file_new(uri); } -void -sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) -{ - std::list sources; - sources.push_back( profile_path("templates") ); // first try user's local dir - sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir - // Use this loop to iterate through a list of possible document locations. - while (!sources.empty()) { - gchar *dirname = sources.front(); +static bool +compare_file_basenames(gchar const *a, gchar const *b) { + bool rc; + gchar *ba, *bb; - if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) { - GError *err = 0; - GDir *dir = g_dir_open(dirname, 0, &err); + bool sort_by_fullname = true; // Sort by full name (including path) or just filename + if (sort_by_fullname) { + ba = g_strdup(a); + bb = g_strdup(b); + } else { + ba = g_path_get_basename(a); + bb = g_path_get_basename(b); + } - if (dir) { - for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) { - if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) { - continue; // skip non-svg files - } + gchar *fa = g_filename_to_utf8(ba, -1, NULL, NULL, NULL); + gchar *fb = g_filename_to_utf8(bb, -1, NULL, NULL, NULL); + g_free(ba); + g_free(bb); - { - gchar *basename = g_path_get_basename(file); - if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) { - g_free(basename); - basename = 0; - continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already - } + rc = g_utf8_collate(fa, fb) < 0; + + g_free(fa); + g_free(fb); + + return rc; +} + +void +sp_menu_get_svg_filenames_from_dir(gchar const *dirname, std::list *files) +{ + if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) { + GError *err = 0; + GDir *dir = g_dir_open(dirname, 0, &err); + + if (dir) { + for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) { + if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) { + continue; // skip non-svg files + } + + { + gchar *basename = g_path_get_basename(file); + if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) { g_free(basename); basename = 0; + continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already } - - gchar const *filepath = g_build_filename(dirname, file, NULL); - gchar *dupfile = g_strndup(file, strlen(file) - 4); - gchar *filename = g_filename_to_utf8(dupfile, -1, NULL, NULL, NULL); - g_free(dupfile); - GtkWidget *item = gtk_menu_item_new_with_label(filename); - g_free(filename); - - gtk_widget_show(item); - // how does "filepath" ever get freed? - g_signal_connect(G_OBJECT(item), - "activate", - G_CALLBACK(sp_file_new_from_template), - (gpointer) filepath); - - if (view) { - // set null tip for now; later use a description from the template file - g_object_set_data(G_OBJECT(item), "view", (gpointer) view); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) NULL ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL); - } - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + g_free(basename); + basename = 0; } - g_dir_close(dir); + + gchar const *filepath = g_build_filename(dirname, file, NULL); + files->push_front(filepath); } + g_dir_close(dir); + } + } + + files->sort(compare_file_basenames); +} + +void +sp_menu_add_filenames_to_menu(GtkWidget *menu, Inkscape::UI::View::View *view, std::list *files) +{ + if (!files->empty()) { + GtkWidget *sep = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep); + } + + for(std::list::iterator it=files->begin(); it != files->end(); ++it) { + gchar const *filepath = *it; + gchar const *file = g_path_get_basename(filepath); + gchar *dupfile = g_strndup(file, strlen(file) - 4); + gchar *filename = g_filename_to_utf8(dupfile, -1, NULL, NULL, NULL); + g_free(dupfile); + + GtkWidget *item = gtk_menu_item_new_with_label(filename); + g_free(filename); + + gtk_widget_show(item); + // how does "filepath" ever get freed? + g_signal_connect(G_OBJECT(item), + "activate", + G_CALLBACK(sp_file_new_from_template), + (gpointer) filepath); + + if (view) { + // set null tip for now; later use a description from the template file + g_object_set_data(G_OBJECT(item), "view", (gpointer) view); + g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) NULL ); + g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL); } - // toss the dirname - g_free(dirname); - sources.pop_front(); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); } + +} +void +sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) +{ + // user's local dir + std::list userfiles; + sp_menu_get_svg_filenames_from_dir(profile_path("templates"), &userfiles); + sp_menu_add_filenames_to_menu(menu, view, &userfiles); + + // system templates dir + std::list templatefiles; + sp_menu_get_svg_filenames_from_dir(INKSCAPE_TEMPLATESDIR, &templatefiles); + sp_menu_add_filenames_to_menu(menu, view, &templatefiles); + } void -- cgit v1.2.3 From 6a101c3761dedff3281cf9a24f77fe1ce8ecb2d3 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 1 Oct 2012 16:03:27 +0900 Subject: Fix for 1059132 : --export-pdf crashes with inkscape trunk (bzr r11718) --- src/main.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index e3862589d..48d2e4de3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1557,25 +1557,21 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime } if (sp_export_area_drawing) { - (*i)->set_param_bool ("areaDrawing", TRUE); - } else { - (*i)->set_param_bool ("areaDrawing", FALSE); + (*i)->set_param_optiongroup ("area", "drawing"); } if (sp_export_area_page) { if (sp_export_eps) { g_warning ("EPS cannot have its bounding box extend beyond its content, so if your drawing is smaller than the page, --export-area-page will clip it to drawing."); } - (*i)->set_param_bool ("areaPage", TRUE); - } else { - (*i)->set_param_bool ("areaPage", FALSE); + (*i)->set_param_optiongroup ("area", "page"); } if (!sp_export_area_drawing && !sp_export_area_page && !sp_export_id) { // neither is set, set page as default for ps/pdf and drawing for eps if (sp_export_eps) { try { - (*i)->set_param_bool("areaDrawing", TRUE); + (*i)->set_param_optiongroup("area", "drawing"); } catch (...) {} } } -- cgit v1.2.3 From b137c6fc5e4d80891b6376e09ba6319b93a145c8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 1 Oct 2012 18:32:48 +0900 Subject: Fix for 831008 : Line width menu only show Px,Pt and mm (bzr r11719) --- src/ui/widget/selected-style.cpp | 70 +++++++++++++++++++++------------------- src/ui/widget/selected-style.h | 9 ++---- 2 files changed, 40 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a4313f677..e5992958b 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -23,6 +23,7 @@ #include "desktop-handles.h" #include "style.h" #include "desktop-style.h" +#include "sp-namedview.h" #include "sp-linear-gradient-fns.h" #include "sp-radial-gradient-fns.h" #include "sp-pattern.h" @@ -38,7 +39,6 @@ #include "sp-gradient.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" -#include "helper/units.h" #include "event-context.h" #include "message-context.h" #include "verbs.h" @@ -144,10 +144,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_blocked (false), - _popup_px(_sw_group), - _popup_pt(_sw_group), - _popup_mm(_sw_group), - + _unit_mis(NULL), _sw_unit(NULL) { _drop[0] = _drop[1] = 0; @@ -298,34 +295,39 @@ SelectedStyle::SelectedStyle(bool /*layout*/) } { - _popup_px.add(*(new Gtk::Label(_("px"), 0.0, 0.5))); - _popup_px.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_px)); - _popup_sw.attach(_popup_px, 0,1, 0,1); - - _popup_pt.add(*(new Gtk::Label(_("pt"), 0.0, 0.5))); - _popup_pt.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_pt)); - _popup_sw.attach(_popup_pt, 0,1, 1,2); - - _popup_mm.add(*(new Gtk::Label(_("mm"), 0.0, 0.5))); - _popup_mm.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_mm)); - _popup_sw.attach(_popup_mm, 0,1, 2,3); + int row = 0; + + // List of units should match with Fill/Stroke dialog stroke style width list + for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) { + SPUnit const *u = (SPUnit*)l->data; + Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); + mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5))); + _unit_mis = g_slist_append(_unit_mis, mi); + mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id)); + _popup_sw.attach(*mi, 0,1, row, row+1); + row++; + } - _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, 3,4); + _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); + row++; for (guint i = 0; i < G_N_ELEMENTS(_sw_presets_str); ++i) { Gtk::MenuItem *mi = Gtk::manage(new Gtk::MenuItem()); mi->add(*(new Gtk::Label(_sw_presets_str[i], 0.0, 0.5))); mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i)); - _popup_sw.attach(*mi, 0,1, 4+i, 5+i); + _popup_sw.attach(*mi, 0,1, row, row+1); + row++; } - guint i = G_N_ELEMENTS(_sw_presets_str) + 5; - - _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, i,i+1); + _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); + row++; _popup_sw_remove.add(*(new Gtk::Label(_("Remove"), 0.0, 0.5))); _popup_sw_remove.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_remove)); - _popup_sw.attach(_popup_sw_remove, 0,1, i+1,i+2); + _popup_sw.attach(_popup_sw_remove, 0,1, row, row+1); + row++; + + sp_set_font_size_smaller (GTK_WIDGET(_popup_sw.gobj())); _popup_sw.show_all(); } @@ -447,7 +449,17 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - //_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + _sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + + // Set the doc default unit active in the units list + gint length = g_slist_length(_unit_mis); + for (int i = 0; i < length; i++) { + Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i); + if (mi && mi->get_label() == Glib::ustring(_sw_unit->abbr)) { + mi->set_active(); + break; + } + } } void SelectedStyle::dragDataReceived( GtkWidget */*widget*/, @@ -887,16 +899,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_px() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PX)); - update(); -} -void SelectedStyle::on_popup_pt() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PT)); - update(); -} -void SelectedStyle::on_popup_mm() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_MM)); +void SelectedStyle::on_popup_units(SPUnitId id) { + _sw_unit = (SPUnit *) &(sp_unit_get_by_id(id)); update(); } diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 542983b53..a9e9d7274 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -27,6 +27,7 @@ #include #include "rotateable.h" +#include "helper/units.h" class SPDesktop; class SPUnit; @@ -250,12 +251,8 @@ protected: Gtk::Menu _popup_sw; Gtk::RadioButtonGroup _sw_group; - Gtk::RadioMenuItem _popup_px; - void on_popup_px(); - Gtk::RadioMenuItem _popup_pt; - void on_popup_pt(); - Gtk::RadioMenuItem _popup_mm; - void on_popup_mm(); + GSList *_unit_mis; + void on_popup_units(SPUnitId id); void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; -- cgit v1.2.3 From b95b098b2415091fcff97c9cf7d49457e3b2c9fe Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 1 Oct 2012 11:33:25 +0200 Subject: Translations. Adding new LPE to the translation template, UI consistency fixes and unstable tag removed. (bzr r11720) --- src/live_effects/effect.cpp | 6 +++--- src/live_effects/lpe-powerstroke.cpp | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 44e57addf..3b57de25c 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -120,9 +120,9 @@ const Util::EnumData LPETypeData[] = { {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, {SKETCH, N_("Sketch"), "sketch"}, {RULER, N_("Ruler"), "ruler"}, -/* 0.49 ?*/ - {POWERSTROKE, N_("[Unstable!] Power stroke"), "powerstroke"}, - {CLONE_ORIGINAL, N_("[Unstable!] Clone original path"), "clone_original"}, +/* 0.49 */ + {POWERSTROKE, N_("Power stroke"), "powerstroke"}, + {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 048742452..88a20c68a 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -135,13 +135,13 @@ static const Util::EnumDataConverter LineJoinTypeConverter(LineJoinTyp LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), - sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true), - interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), - interpolator_beta(_("Smoothness"), _("Sets the smoothness for the CubicBezierJohan interpolator. 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), - start_linecap_type(_("Start cap"), _("Determines the shape of the path's start."), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), - linejoin_type(_("Join"), _("Specifies the shape of the path's corners."), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), - miter_limit(_("Miter limit"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.), - end_linecap_type(_("End cap"), _("Determines the shape of the path's end."), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) + sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve"), "sort_points", &wr, this, true), + interpolator_type(_("Interpolator type:"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), + interpolator_beta(_("Smoothness:"), _("Sets the smoothness for the CubicBezierJohan interpolator; 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), + start_linecap_type(_("Start cap:"), _("Determines the shape of the path's start"), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), + linejoin_type(_("Join:"), _("Specifies the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), + miter_limit(_("Miter limit:"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.), + end_linecap_type(_("End cap:"), _("Determines the shape of the path's end"), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) { show_orig_path = true; -- cgit v1.2.3 From 4d22fea186d34345ac69678b505f9ca05d8fb296 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 2 Oct 2012 22:34:27 +0200 Subject: fix layout of object properties dialog (Bug #1050938 ; input fields in object properties dalog not aligned) (bzr r11722) --- src/ui/dialog/object-properties.cpp | 45 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 0aeb3816f..d8842f815 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -54,7 +54,7 @@ ObjectProperties::ObjectProperties (void) : LabelID(_("_ID:"), 1), LabelLabel(_("_Label:"), 1), LabelTitle(_("_Title:"),1), - LabelDescription(_("_Description"),1), + LabelDescription(_("_Description:"),1), FrameDescription("", FALSE), HBoxCheck(FALSE, 0), CheckTable(1, 2, TRUE), @@ -69,16 +69,15 @@ ObjectProperties::ObjectProperties (void) : subselChangedConn() { //initialize labels for the table at the bottom of the dialog - int_labels.push_back("onclick"); - int_labels.push_back("onmouseover"); - int_labels.push_back("onmouseout"); - int_labels.push_back("onmousedown"); - int_labels.push_back("onmouseup"); - int_labels.push_back("onmousemove"); - int_labels.push_back("onfocusin"); - int_labels.push_back("onfocusout"); - int_labels.push_back("onfocusout"); - int_labels.push_back("onload"); + int_labels.push_back("onclick:"); + int_labels.push_back("onmouseover:"); + int_labels.push_back("onmouseout:"); + int_labels.push_back("onmousedown:"); + int_labels.push_back("onmouseup:"); + int_labels.push_back("onmousemove:"); + int_labels.push_back("onfocusin:"); + int_labels.push_back("onfocusout:"); + int_labels.push_back("onload:"); desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectProperties::setTargetDesktop) ); deskTrack.connect(GTK_WIDGET(gobj())); @@ -101,10 +100,11 @@ void ObjectProperties::MakeWidget(void) TopTable.set_border_width(4); TopTable.set_row_spacings(4); - TopTable.set_col_spacings(4); - contents->pack_start (TopTable, true, true, 0); + TopTable.set_col_spacings(0); + contents->pack_start (TopTable, false, false, 0); /* Create the label for the object id */ + LabelID.set_label (LabelID.get_label() + " "); LabelID.set_alignment (1, 0.5); TopTable.attach (LabelID, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, @@ -124,6 +124,7 @@ void ObjectProperties::MakeWidget(void) EntryID.grab_focus(); /* Create the label for the object label */ + LabelLabel.set_label (LabelLabel.get_label() + " "); LabelLabel.set_alignment (1, 0.5); TopTable.attach (LabelLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, @@ -141,6 +142,7 @@ void ObjectProperties::MakeWidget(void) EntryLabel.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the label for the object title */ + LabelTitle.set_label (LabelTitle.get_label() + " "); LabelTitle.set_alignment (1, 0.5); TopTable.attach (LabelTitle, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, @@ -149,18 +151,15 @@ void ObjectProperties::MakeWidget(void) /* Create the entry box for the object title */ EntryTitle.set_sensitive (FALSE); EntryTitle.set_max_length (256); - TopTable.attach (EntryTitle, 1, 3, 2, 3, + TopTable.attach (EntryTitle, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); LabelTitle.set_mnemonic_widget (EntryTitle); /* Create the frame for the object description */ FrameDescription.set_label_widget (LabelDescription); - FrameDescription.set_padding (4,0,0,0); - - TopTable.attach (FrameDescription, 0, 3, 3, 4, - Gtk::EXPAND | Gtk::FILL, - Gtk::EXPAND | Gtk::FILL, 0, 0 ); + FrameDescription.set_padding (0,0,0,0); + contents->pack_start (FrameDescription, true, true, 0); /* Create the text view box for the object description */ FrameTextDescription.set_border_width(4); @@ -175,8 +174,8 @@ void ObjectProperties::MakeWidget(void) /* Check boxes */ contents->pack_start (HBoxCheck, FALSE, FALSE, 0); - CheckTable.set_border_width(0); - HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 10); + CheckTable.set_border_width(4); + HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 0); /* Hide */ CBHide.set_tooltip_text (_("Check to make the object invisible")); @@ -195,7 +194,9 @@ void ObjectProperties::MakeWidget(void) /* Button for setting the object's id, label, title and description. */ - HBoxCheck.pack_start (BSet, TRUE, TRUE, 10); + CheckTable.attach (BSet, 2, 3, 0, 1, + Gtk::EXPAND | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); BSet.signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the frame for interactivity options */ -- cgit v1.2.3 From c925ad2a0e5cd93bcd24200dbb8accd8b6daed1f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 2 Oct 2012 22:45:27 +0200 Subject: fix for bug 310206: although the path is made with only cubic beziers (bezier_fit_cubic...), the closing path segment is still a linearbezier so original code will bug for closed paths. made the code more general by standard 2geom code to determine the curvature of the end of a curve without knowing its type. Fixed bugs: - https://launchpad.net/bugs/310206 (bzr r11723) --- src/pencil-context.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index d5b61e1f0..19a040b24 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -789,11 +789,13 @@ interpolate(SPPencilContext *pc) /* Set up direction of next curve. */ { - Geom::CubicBezier const * last_seg = dynamic_cast(pc->green_curve->last_segment()); - g_assert( last_seg ); // Relevance: validity of (*last_seg)[2] + Geom::Curve const * last_seg = pc->green_curve->last_segment(); + g_assert( last_seg ); // Relevance: validity of (*last_seg) pc->p[0] = last_seg->finalPoint(); pc->npoints = 1; - Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] ); + Geom::Curve *last_seg_reverse = last_seg->reverse(); + Geom::Point const req_vec( -last_seg_reverse->unitTangentAt(0) ); + delete last_seg_reverse; pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) ) ? Geom::Point(0, 0) : Geom::unit_vector(req_vec) ); @@ -881,11 +883,13 @@ sketch_interpolate(SPPencilContext *pc) /* Set up direction of next curve. */ { - Geom::CubicBezier const * last_seg = dynamic_cast(pc->green_curve->last_segment()); - g_assert( last_seg ); // Relevance: validity of (*last_seg)[2] + Geom::Curve const * last_seg = pc->green_curve->last_segment(); + g_assert( last_seg ); // Relevance: validity of (*last_seg) pc->p[0] = last_seg->finalPoint(); pc->npoints = 1; - Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] ); + Geom::Curve *last_seg_reverse = last_seg->reverse(); + Geom::Point const req_vec( -last_seg_reverse->unitTangentAt(0) ); + delete last_seg_reverse; pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) ) ? Geom::Point(0, 0) : Geom::unit_vector(req_vec) ); @@ -926,16 +930,19 @@ fit_and_split(SPPencilContext *pc) /* Set up direction of next curve. */ { - Geom::CubicBezier const * last_seg = dynamic_cast(pc->red_curve->last_segment()); - g_assert( last_seg ); // Relevance: validity of (*last_seg)[2] + Geom::Curve const * last_seg = pc->red_curve->last_segment(); + g_assert( last_seg ); // Relevance: validity of (*last_seg) pc->p[0] = last_seg->finalPoint(); pc->npoints = 1; - Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] ); + Geom::Curve *last_seg_reverse = last_seg->reverse(); + Geom::Point const req_vec( -last_seg_reverse->unitTangentAt(0) ); + delete last_seg_reverse; pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) ) ? Geom::Point(0, 0) : Geom::unit_vector(req_vec) ); } + pc->green_curve->append_continuous(pc->red_curve, 0.0625); SPCurve *curve = pc->red_curve->copy(); -- cgit v1.2.3 From e6e9360b628bb6ba052c65a73a167fe8329f3305 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 2 Oct 2012 22:49:30 +0200 Subject: Fix for Bug #1049440 (Crash in Object Properties if label is empty string (regression, trunk)) (bzr r11724) --- src/document-subset.cpp | 2 +- src/ui/dialog/object-properties.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 365be64ef..7fad73d9e 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -99,7 +99,7 @@ struct DocumentSubset::Relations : public GC::Managed, Siblings new_children; bool found_one=false; for ( Siblings::iterator iter=children.begin() - ; iter != children.end() ; iter++ ) + ; iter != children.end() ; ++iter ) { if (obj->isAncestorOf(*iter)) { if (!found_one) { diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index d8842f815..8cf3f70e8 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -333,7 +333,6 @@ void ObjectProperties::label_changed(void) /* Retrieve the label widget for the object's label */ Glib::ustring label = EntryLabel.get_text(); - g_assert(!label.empty()); /* Give feedback on success of setting the drawing object's label * using the widget's label text -- cgit v1.2.3 From 7e42cac5c71505ca9e17db0f3201052da541814d Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 2 Oct 2012 22:58:12 +0200 Subject: fixed another UI inconsistency in object properties dialog (bzr r11725) --- src/ui/dialog/object-properties.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 8cf3f70e8..12ee2f762 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -155,6 +155,8 @@ void ObjectProperties::MakeWidget(void) Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); LabelTitle.set_mnemonic_widget (EntryTitle); + // pressing enter in the label field is the same as clicking Set: + EntryTitle.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the frame for the object description */ FrameDescription.set_label_widget (LabelDescription); -- cgit v1.2.3 From b8dd00deba5585ff33528d46028fbfa12ec9b2fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Oct 2012 11:45:35 +1000 Subject: add missing source files (bzr r11727) --- src/extension/CMakeLists.txt | 4 ++++ src/ui/CMakeLists.txt | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 5761b1e8b..e1f04fa10 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -41,6 +41,7 @@ set(extension_SRC internal/gdkpixbuf-input.cpp internal/gimpgrad.cpp internal/grid.cpp + internal/image-resolution.cpp internal/latex-pstricks.cpp internal/latex-pstricks-out.cpp internal/odf.cpp @@ -50,6 +51,7 @@ set(extension_SRC internal/javafx-out.cpp internal/svg.cpp internal/svgz.cpp + internal/vsd-input.cpp internal/filter/filter-all.cpp internal/filter/filter-file.cpp @@ -129,6 +131,7 @@ set(extension_SRC internal/gdkpixbuf-input.h internal/gimpgrad.h internal/grid.h + internal/image-resolution.h internal/javafx-out.h internal/latex-pstricks-out.h internal/latex-pstricks.h @@ -141,6 +144,7 @@ set(extension_SRC internal/pov-out.h internal/svg.h internal/svgz.h + internal/vsd-input.h script/InkscapeScript.h ) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index b3bcb3fdd..ec7782302 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -42,6 +42,7 @@ set(ui_SRC dialog/filter-effects-dialog.cpp dialog/find.cpp dialog/floating-behavior.cpp + dialog/font-substitution.cpp dialog/glyphs.cpp dialog/guides.cpp dialog/icon-preview.cpp @@ -82,6 +83,7 @@ set(ui_SRC widget/entry.cpp widget/filter-effect-chooser.cpp widget/frame.cpp + widget/gimpspinscale.c widget/imageicon.cpp widget/imagetoggler.cpp widget/labelled.cpp @@ -101,6 +103,7 @@ set(ui_SRC widget/scalar-unit.cpp widget/scalar.cpp widget/selected-style.cpp + widget/spin-scale.cpp widget/spin-slider.cpp widget/spinbutton.cpp widget/style-subject.cpp @@ -117,6 +120,7 @@ set(ui_SRC # Headers clipboard.h control-manager.h + control-types.h icon-names.h previewable.h previewfillable.h @@ -148,6 +152,7 @@ set(ui_SRC dialog/filter-effects-dialog.h dialog/find.h dialog/floating-behavior.h + dialog/font-substitution.h dialog/glyphs.h dialog/guides.h dialog/icon-preview.h @@ -204,6 +209,7 @@ set(ui_SRC widget/entry.h widget/filter-effect-chooser.h widget/frame.h + widget/gimpspinscale.h widget/imageicon.h widget/imagetoggler.h widget/labelled.h @@ -224,6 +230,7 @@ set(ui_SRC widget/scalar-unit.h widget/scalar.h widget/selected-style.h + widget/spin-scale.h widget/spin-slider.h widget/spinbutton.h widget/style-subject.h -- cgit v1.2.3 From e36c124c67c8748f567a1f069e211ff5bfc987fb Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 3 Oct 2012 16:43:30 +0900 Subject: Fix for 687655 : New color wheel should not increase the width of docked Fill&Stroke dialog when scaled (bzr r11729) --- src/widgets/sp-color-wheel-selector.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 4cc9f9e4a..bb8bba328 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -109,7 +109,8 @@ static void resizeHSVWheel( GtkHSV *hsv, GtkAllocation *allocation ) gint diam = std::min(allocation->width, allocation->height); // drop a little for resizing - diam -= 4; + // This magic number stops the dialog expanding in width when resizing height + diam -= 16; GtkStyle *style = gtk_widget_get_style( GTK_WIDGET(hsv) ); if ( style ) { @@ -161,7 +162,7 @@ void ColorWheelSelector::init() _wheel = gtk_hsv_new(); gtk_hsv_set_metrics( GTK_HSV(_wheel), 48, 8 ); gtk_widget_show( _wheel ); - gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), XPAD, YPAD); + gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); row++; -- cgit v1.2.3 From 48cc8d24e8130d6cec0468692cbd3cfb90e6c66e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 3 Oct 2012 20:57:47 +0200 Subject: fixing memory release issue (valgrind reported; bug #1043571 , comment 16 issue 2) (bzr r11731) --- src/display/nr-style.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 86102f9e8..ba2340074 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -60,7 +60,9 @@ NRStyle::~NRStyle() { if (fill_pattern) cairo_pattern_destroy(fill_pattern); if (stroke_pattern) cairo_pattern_destroy(stroke_pattern); - if (dash) delete dash; + if (dash){ + delete [] dash; + } } void NRStyle::set(SPStyle *style) @@ -126,7 +128,9 @@ void NRStyle::set(SPStyle *style) } miter_limit = style->stroke_miterlimit.value; - if (dash) delete [] dash; + if (dash){ + delete [] dash; + } n_dash = style->stroke_dash.n_dash; if (n_dash != 0) { -- cgit v1.2.3 From f0ac447fb379a4cdc63152dfb3b8c1be24de67fa Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 4 Oct 2012 07:59:08 +0900 Subject: Fix for 1014988 : gtk 2.22 compile issues (bzr r11732) --- src/ui/widget/gimpspinscale.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c index 1b7ac7bfe..df39b9644 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/ui/widget/gimpspinscale.c @@ -432,7 +432,11 @@ static gboolean gdk_cairo_region (cr, event->region); cairo_clip (cr); +#if GTK_CHECK_VERSION(2, 24,0) w = gdk_window_get_width (event->window); +#else + gdk_drawable_get_size (event->window, &w, NULL); +#endif #endif @@ -682,7 +686,12 @@ gimp_spin_scale_change_value (GtkWidget *widget, gint width; gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); + +#if GTK_CHECK_VERSION(2, 24,0) width = gdk_window_get_width (text_window); +#else + gdk_drawable_get_size (text_window, &width, NULL); +#endif #endif -- cgit v1.2.3 From 20a8f057b8621a3d68f31edb2cb21e10f95d4cce Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 4 Oct 2012 08:06:12 +0900 Subject: Fix for 168164 : gtk 2.22 compile issues (bzr r11733) --- src/widgets/font-selector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 0244621bf..61c6261bf 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -349,7 +349,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel ) #if GTK_CHECK_VERSION(2, 24,0) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), Glib::ustring::format(size).c_str()); #else - gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), size); + gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), Glib::ustring::format(size).c_str()); #endif } -- cgit v1.2.3 From 370a3f5cc9e39352a081e5d5dd8c43676547a6e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:45:44 +1000 Subject: code cleanup: add own includes to cpp files or make the functions static if they are not used elsewhere. (bzr r11735) --- src/arc-context.cpp | 2 +- src/box3d.cpp | 2 +- src/color.cpp | 2 +- src/conn-avoid-ref.cpp | 2 +- src/desktop-events.cpp | 1 + src/desktop-handles.cpp | 1 + src/desktop-style.cpp | 6 +++--- src/device-manager.cpp | 4 ++-- src/dir-util.cpp | 1 + src/document.cpp | 12 ++++++------ src/draw-context.cpp | 3 ++- src/dropper-context.cpp | 2 +- src/dyna-draw-context.cpp | 2 +- src/ege-adjustment-action.cpp | 2 +- src/eraser-context.cpp | 2 +- src/event-context.cpp | 2 +- src/extract-uri.cpp | 2 ++ src/filter-chemistry.cpp | 2 +- src/flood-context.cpp | 2 +- src/gradient-chemistry.cpp | 7 ++++--- src/gradient-context.cpp | 4 ++-- src/gradient-drag.cpp | 2 +- src/ink-comboboxentry-action.cpp | 2 +- src/inkscape.cpp | 6 +++--- src/interface.cpp | 16 +++++++-------- src/main.cpp | 10 +++++----- src/measure-context.cpp | 4 ++-- src/mod360.cpp | 2 ++ src/pen-context.cpp | 10 +++++----- src/rect-context.cpp | 2 +- src/removeoverlap.cpp | 1 + src/resource-manager.cpp | 4 ++-- src/satisfied-guide-cns.cpp | 11 ++++++----- src/select-context.cpp | 4 ++-- src/selection-chemistry.cpp | 24 +++++++++++------------ src/selection-describer.cpp | 6 +++--- src/sp-image.cpp | 8 ++++---- src/sp-item-notify-moveto.cpp | 1 + src/sp-item-rm-unsatisfied-cns.cpp | 1 + src/sp-item-transform.cpp | 1 + src/sp-item-update-cns.cpp | 5 +++-- src/sp-item.cpp | 4 ++-- src/sp-mesh-array.cpp | 4 ++-- src/sp-object-repr.cpp | 1 + src/sp-object.cpp | 2 +- src/sp-offset.cpp | 2 +- src/sp-pattern.cpp | 6 +++--- src/spiral-context.cpp | 2 +- src/splivarot.cpp | 4 ++-- src/spray-context.cpp | 34 ++++++++++++++++---------------- src/star-context.cpp | 2 +- src/style.cpp | 6 +++--- src/text-chemistry.cpp | 10 +++++----- src/tweak-context.cpp | 40 +++++++++++++++++++------------------- src/unclump.cpp | 19 +++++++++--------- src/vanishing-point.cpp | 2 +- 56 files changed, 169 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 95ff05b37..9675df8e3 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -159,7 +159,7 @@ static void sp_arc_context_dispose(GObject *object) * Callback that processes the "changed" signal on the selection; * destroys old and creates new knotholder. */ -void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer data) +static void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer data) { SPArcContext *ac = SP_ARC_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(ac); diff --git a/src/box3d.cpp b/src/box3d.cpp index 23f934b64..a011b1567 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -366,7 +366,7 @@ box3d_set_transform(SPItem *item, Geom::Affine const &xform) return Geom::identity(); } -Proj::Pt3 +static Proj::Pt3 box3d_get_proj_corner (guint id, Proj::Pt3 const &c0, Proj::Pt3 const &c7) { return Proj::Pt3 ((id & Box3D::X) ? c7[Proj::X] : c0[Proj::X], (id & Box3D::Y) ? c7[Proj::Y] : c0[Proj::Y], diff --git a/src/color.cpp b/src/color.cpp index 187a6ba6a..0a07d3f21 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -352,7 +352,7 @@ sp_color_rgb_to_hsl_floatv (float *hsl, float r, float g, float b) } } -float +static float hue_2_rgb (float v1, float v2, float h) { if (h < 0) h += 6.0; diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index d6f02e875..c0882c526 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -86,7 +86,7 @@ void SPAvoidRef::setAvoid(char const *value) } } -void print_connection_points(std::map& cp) +static void print_connection_points(std::map& cp) { std::map::iterator i; for (i=cp.begin(); i!=cp.end(); ++i) diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 6b47bdad6..1377fef9d 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -23,6 +23,7 @@ #include "ui/dialog/guides.h" #include "desktop.h" +#include "desktop-events.h" #include "desktop-handles.h" #include "dialogs/dialog-events.h" #include "display/canvas-axonomgrid.h" diff --git a/src/desktop-handles.cpp b/src/desktop-handles.cpp index d35df6454..aed2eec34 100644 --- a/src/desktop-handles.cpp +++ b/src/desktop-handles.cpp @@ -13,6 +13,7 @@ #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" #include "desktop.h" +#include "desktop-handles.h" SPEventContext * sp_desktop_event_context (SPDesktop const * desktop) diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 74e15e3e2..410e71730 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1117,7 +1117,7 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res) /** * Write to style_res the baseline numbers. */ -int +static int objects_query_baselines (GSList *objects, SPStyle *style_res) { bool different = false; @@ -1273,7 +1273,7 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } } -int +static int objects_query_fontspecification (GSList *objects, SPStyle *style_res) { bool different = false; @@ -1335,7 +1335,7 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res) } } -int +static int objects_query_blend (GSList *objects, SPStyle *style_res) { const int empty_prev = -2; diff --git a/src/device-manager.cpp b/src/device-manager.cpp index 059e1b52d..5c7048613 100644 --- a/src/device-manager.cpp +++ b/src/device-manager.cpp @@ -113,7 +113,7 @@ static std::map &getStringToAxis() return mapping; } -std::map &getAxisToString() +static std::map &getAxisToString() { static bool init = false; static std::map mapping; @@ -139,7 +139,7 @@ static std::map &getStringToMode() return mapping; } -std::map &getModeToString() +static std::map &getModeToString() { static bool init = false; static std::map mapping; diff --git a/src/dir-util.cpp b/src/dir-util.cpp index 7d4054745..c9b88b007 100644 --- a/src/dir-util.cpp +++ b/src/dir-util.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "dir-util.h" std::string sp_relative_path_from_path( std::string const &path, std::string const &base) { diff --git a/src/document.cpp b/src/document.cpp index e28356969..9d8291db0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1107,7 +1107,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, /** Returns true if an item is among the descendants of group (recursively). */ -bool item_is_in_group(SPItem *item, SPGroup *group) +static bool item_is_in_group(SPItem *item, SPGroup *group) { bool inGroup = false; for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) { @@ -1158,7 +1158,7 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ -SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) +static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { SPItem *seen = NULL; SPItem *newseen = NULL; @@ -1203,7 +1203,7 @@ SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const Returns the topmost non-layer group from the descendants of group which is at point p, or NULL if none. Recurses into layers but not into groups. */ -SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) +static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) { SPItem *seen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1374,7 +1374,7 @@ sp_document_resource_list_free(gpointer /*key*/, gpointer value, gpointer /*data return TRUE; } -unsigned int count_objects_recursive(SPObject *obj, unsigned int count) +static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself @@ -1385,12 +1385,12 @@ unsigned int count_objects_recursive(SPObject *obj, unsigned int count) return count; } -unsigned int objects_in_document(SPDocument *document) +static unsigned int objects_in_document(SPDocument *document) { return count_objects_recursive(document->getRoot(), 0); } -void vacuum_document_recursive(SPObject *obj) +static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) { diff --git a/src/draw-context.cpp b/src/draw-context.cpp index e33c94bda..daff0794a 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -44,6 +44,7 @@ #include "live_effects/lpe-powerstroke.h" #include "style.h" #include "ui/control-manager.h" +#include "draw-context.h" #include @@ -304,7 +305,7 @@ static void spdc_apply_powerstroke_shape(const std::vector & points lpe->getRepr()->setAttribute("interpolator_beta", "0.2"); } -void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) +static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 6ac00887b..4742f5cff 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -149,7 +149,7 @@ static void sp_dropper_context_finish(SPEventContext *ec) /** * Returns the current dropper context icc-color. */ -SPColor* sp_dropper_context_get_icc_color(SPEventContext */*ec*/) +static SPColor* sp_dropper_context_get_icc_color(SPEventContext */*ec*/) { //TODO: implement-me! diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index be767a3f3..3f488eca4 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -500,7 +500,7 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc) dc->npoints++; } -void +static void sp_ddc_update_toolbox (SPDesktop *desktop, const gchar *id, double value) { desktop->setToolboxAdjustmentValue (id, value); diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index cf179478d..78f3f48d6 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -778,7 +778,7 @@ static GtkWidget* create_menu_item( GtkAction* action ) return item; } -void value_changed_cb( GtkSpinButton* spin, EgeAdjustmentAction* act ) +static void value_changed_cb( GtkSpinButton* spin, EgeAdjustmentAction* act ) { if ( gtk_widget_has_focus( GTK_WIDGET(spin) ) ) { gint start = 0, end = 0; diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 0442d768c..76ea5c252 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -443,7 +443,7 @@ sp_eraser_brush(SPEraserContext *dc) dc->npoints++; } -void +static void sp_erc_update_toolbox (SPDesktop *desktop, const gchar *id, double value) { desktop->setToolboxAdjustmentValue (id, value); diff --git a/src/event-context.cpp b/src/event-context.cpp index b8a2dc797..6f89e862e 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -174,7 +174,7 @@ static void sp_event_context_dispose(GObject *object) { /** * Set the cursor to a standard GDK cursor */ -void sp_event_context_set_cursor(SPEventContext *event_context, GdkCursorType cursor_type) { +static void sp_event_context_set_cursor(SPEventContext *event_context, GdkCursorType cursor_type) { GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop)); GdkDisplay *display = gdk_display_get_default(); diff --git a/src/extract-uri.cpp b/src/extract-uri.cpp index 76778bacb..a25c8bb70 100644 --- a/src/extract-uri.cpp +++ b/src/extract-uri.cpp @@ -1,6 +1,8 @@ #include #include +#include "extract-uri.h" + // FIXME: kill this ugliness when we have a proper CSS parser // Functions as per 4.3.4 of CSS 2.1 diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 81cbbf401..fc74ee8a2 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -242,7 +242,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion * Creates a simple filter with a blend primitive and a blur primitive of specified radius for * an item with the given matrix expansion, width and height */ -SPFilter * +static SPFilter * new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdouble radius, double expansion, double expansionX, double expansionY, double width, double height) { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index f7c4ca365..a6c7fa0dc 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -167,7 +167,7 @@ static void sp_flood_context_dispose(GObject *object) * Callback that processes the "changed" signal on the selection; * destroys old and creates new knotholder. */ -void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data) +static void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPFloodContext *rc = SP_FLOOD_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(rc); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index ed4e81f0d..0038e9325 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -42,6 +42,7 @@ #include "sp-stop.h" #include "widgets/gradient-vector.h" #include "gradient-drag.h" +#include "gradient-chemistry.h" #include "sp-text.h" #include "sp-tspan.h" @@ -173,7 +174,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr /** Count how many times gr is used by the styles of o and its descendants */ -guint count_gradient_hrefs(SPObject *o, SPGradient *gr) +static guint count_gradient_hrefs(SPObject *o, SPGradient *gr) { if (!o) return 1; @@ -207,8 +208,8 @@ guint count_gradient_hrefs(SPObject *o, SPGradient *gr) /** * If gr has other users, create a new private; also check if gr links to vector, relink if not */ -SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector, - SPGradientType type, SPObject *o) +static SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector, + SPGradientType type, SPObject *o) { #ifdef SP_GR_VERBOSE g_message("sp_gradient_fork_private_if_necessary(%p, %p, %d, %p)", gr, vector, type, o); diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 5b0e261de..231490771 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -266,7 +266,7 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, Geom::Poi return close; } -std::vector +static std::vector sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSList **next_stops) { std::vector coords; @@ -419,7 +419,7 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc) g_slist_free (new_stops); } -double sqr(double x) {return x*x;} +static double sqr(double x) {return x*x;} static void sp_gradient_simplify(SPGradientContext *rc, double tolerance) diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index c72e47350..c775a19d7 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -132,7 +132,7 @@ static void gr_drag_sel_modified(Inkscape::Selection */*selection*/, guint /*fla * skip), and fill the \a style with the averaged color of all draggables of the selected dragger, if * any. */ -int gr_drag_style_query(SPStyle *style, int property, gpointer data) +static int gr_drag_style_query(SPStyle *style, int property, gpointer data) { GrDrag *drag = (GrDrag *) data; diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 99a48ae5d..14f8f83a6 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -789,7 +789,7 @@ static gboolean match_selected_cb( GtkEntryCompletion* /*widget*/, GtkTreeModel* return false; } -void ink_comboboxentry_action_defocus( Ink_ComboBoxEntry_Action* action ) +static void ink_comboboxentry_action_defocus( Ink_ComboBoxEntry_Action* action ) { if ( action->focusWidget ) { gtk_widget_grab_focus( action->focusWidget ); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 8548b398f..b1cc53b4e 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1065,7 +1065,7 @@ inkscape_find_desktop_by_dkey (unsigned int dkey) -unsigned int +static unsigned int inkscape_maximum_dkey() { unsigned int dkey = 0; @@ -1081,7 +1081,7 @@ inkscape_maximum_dkey() -SPDesktop * +static SPDesktop * inkscape_next_desktop () { SPDesktop *d = NULL; @@ -1112,7 +1112,7 @@ inkscape_next_desktop () -SPDesktop * +static SPDesktop * inkscape_prev_desktop () { SPDesktop *d = NULL; diff --git a/src/interface.cpp b/src/interface.cpp index f26b7ac74..2ee188ef7 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -396,7 +396,7 @@ sp_ui_menu_deselect(gpointer object) /** * Creates and attaches a scaled icon to the given menu item. */ -void +static void sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) { static bool iconsInjected = false; @@ -686,7 +686,7 @@ static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/, return FALSE; } -void +static void sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *view, gchar const *label, gchar const *tip, gchar const *pref, void (*callback_toggle)(GtkCheckMenuItem *, gpointer user_data), #if GTK_CHECK_VERSION(3,0,0) @@ -806,7 +806,7 @@ compare_file_basenames(gchar const *a, gchar const *b) { return rc; } -void +static void sp_menu_get_svg_filenames_from_dir(gchar const *dirname, std::list *files) { if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) { @@ -840,7 +840,7 @@ sp_menu_get_svg_filenames_from_dir(gchar const *dirname, std::list files->sort(compare_file_basenames); } -void +static void sp_menu_add_filenames_to_menu(GtkWidget *menu, Inkscape::UI::View::View *view, std::list *files) { if (!files->empty()) { @@ -876,7 +876,7 @@ sp_menu_add_filenames_to_menu(GtkWidget *menu, Inkscape::UI::View::View *view, s } } -void +static void sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) { // user's local dir @@ -891,7 +891,7 @@ sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) } -void +static void sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) { //sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu", @@ -915,7 +915,7 @@ sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) } -void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view) +static void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view) { gchar const* data[] = { C_("Interface setup", "Default"), _("Default interface setup"), @@ -982,7 +982,7 @@ private: * @param menu Menu to be added to * @param view The View that this menu is being built for */ -void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view) +static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view) { if (menus == NULL) return; if (menu == NULL) return; diff --git a/src/main.cpp b/src/main.cpp index 48d2e4de3..d1e087cac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -731,7 +731,7 @@ main(int argc, char **argv) -void fixupSingleFilename( gchar **orig, gchar **spare ) +static void fixupSingleFilename( gchar **orig, gchar **spare ) { if ( orig && *orig && **orig ) { GError *error = NULL; @@ -749,7 +749,7 @@ void fixupSingleFilename( gchar **orig, gchar **spare ) -GSList *fixupFilenameEncoding( GSList* fl ) +static GSList *fixupFilenameEncoding( GSList* fl ) { GSList *newFl = NULL; while ( fl ) { @@ -788,7 +788,7 @@ GSList *fixupFilenameEncoding( GSList* fl ) return newFl; } -int sp_common_main( int argc, char const **argv, GSList **flDest ) +static int sp_common_main( int argc, char const **argv, GSList **flDest ) { /// \todo fixme: Move these to some centralized location (Lauris) sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW); @@ -1002,7 +1002,7 @@ sp_main_gui(int argc, char const **argv) /** * Process file list */ -int sp_process_file_list(GSList *fl) +static int sp_process_file_list(GSList *fl) { int retVal = 0; while (fl) { @@ -1108,7 +1108,7 @@ int sp_process_file_list(GSList *fl) * Run the application as an interactive shell, parsing command lines from stdin * Returns -1 on error. */ -int sp_main_shell(char const* command_name) +static int sp_main_shell(char const* command_name) { int retval = 0; diff --git a/src/measure-context.cpp b/src/measure-context.cpp index cc6a9b04e..7a04b9915 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -306,7 +306,7 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte return ret; } -bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) +static bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) { if (p1[Geom::Y] == p2[Geom::Y]) { return p1[Geom::X] < p2[Geom::X]; @@ -315,7 +315,7 @@ bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) } } -void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector const &lineseg, SPCurve *curve, std::vector &intersections) +static void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector const &lineseg, SPCurve *curve, std::vector &intersections) { curve->transform(item->i2doc_affine()); diff --git a/src/mod360.cpp b/src/mod360.cpp index 13e9aa36a..ce5cea33a 100644 --- a/src/mod360.cpp +++ b/src/mod360.cpp @@ -1,6 +1,8 @@ #include #include +#include "mod360.h" + /** Returns \a x wrapped around to between 0 and less than 360, or 0 if \a x isn't finite. **/ diff --git a/src/pen-context.cpp b/src/pen-context.cpp index ade041019..cb20eb3eb 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -861,7 +861,7 @@ static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton cons return ret; } -void pen_redraw_all (SPPenContext *const pc) +static void pen_redraw_all (SPPenContext *const pc) { // green if (pc->green_bpaths) { @@ -915,7 +915,7 @@ void pen_redraw_all (SPPenContext *const pc) } } -void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) +static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) { if (pc->npoints != 5) return; @@ -936,12 +936,12 @@ void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) pen_redraw_all(pc); } -void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y) +static void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y) { pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom()); } -void pen_lastpoint_tocurve (SPPenContext *const pc) +static void pen_lastpoint_tocurve (SPPenContext *const pc) { if (pc->npoints != 5) return; @@ -956,7 +956,7 @@ void pen_lastpoint_tocurve (SPPenContext *const pc) pen_redraw_all(pc); } -void pen_lastpoint_toline (SPPenContext *const pc) +static void pen_lastpoint_toline (SPPenContext *const pc) { if (pc->npoints != 5) return; diff --git a/src/rect-context.cpp b/src/rect-context.cpp index d96ddf09a..33ccee93c 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -168,7 +168,7 @@ static void sp_rect_context_dispose(GObject *object) * Callback that processes the "changed" signal on the selection; * destroys old and creates new knotholder. */ -void sp_rect_context_selection_changed(Inkscape::Selection *selection, gpointer data) +static void sp_rect_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPRectContext *rc = SP_RECT_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(rc); diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 0c45e34a9..ba5740e55 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -17,6 +17,7 @@ #include "sp-item-transform.h" #include "libvpsc/generate-constraints.h" #include "libvpsc/remove_rectangle_overlap.h" +#include "removeoverlap.h" using vpsc::Rectangle; diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index c42ce6feb..8e2e95988 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -28,7 +28,7 @@ namespace Inkscape { -std::vector splitPath( std::string const &path ) +static std::vector splitPath( std::string const &path ) { std::vector parts; @@ -50,7 +50,7 @@ std::vector splitPath( std::string const &path ) return parts; } -std::string convertPathToRelative( std::string const &path, std::string const &docbase ) +static std::string convertPathToRelative( std::string const &path, std::string const &docbase ) { std::string result = path; diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp index 7aca3b0bd..57d4ffce3 100644 --- a/src/satisfied-guide-cns.cpp +++ b/src/satisfied-guide-cns.cpp @@ -1,8 +1,9 @@ -#include -#include -#include -#include -#include +#include "desktop-handles.h" +#include "sp-guide.h" +#include "sp-guide-constraint.h" +#include "sp-namedview.h" +#include "approx-equal.h" +#include "satisfied-guide-cns.h" void satisfied_guide_cns(SPDesktop const &desktop, std::vector const &snappoints, diff --git a/src/select-context.cpp b/src/select-context.cpp index 4555e51aa..7fecc7167 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -272,7 +272,7 @@ sp_select_context_abort(SPEventContext *event_context) return false; } -bool +static bool key_is_a_modifier (guint key) { return (key == GDK_KEY_Alt_L || key == GDK_KEY_Alt_R || @@ -284,7 +284,7 @@ key_is_a_modifier (guint key) { key == GDK_KEY_Meta_R); } -void +static void sp_select_context_up_one_layer(SPDesktop *desktop) { /* Click in empty place, go up one level -- but don't leave a layer to root. diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 4cdab4336..332e9a34e 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -256,7 +256,7 @@ void SelectionHelper::selectPrev(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -275,7 +275,7 @@ void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSLis *clip = g_slist_prepend(*clip, copy); } -void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc) { // Sort items: GSList *sorted_items = g_slist_copy(const_cast(items)); @@ -290,7 +290,7 @@ void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::D g_slist_free(static_cast(sorted_items)); } -GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip) +static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); @@ -321,7 +321,7 @@ GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip return copied; } -void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) +static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) { for (GSList const *i = items ; i ; i = i->next ) { sp_object_ref((SPObject *)i->data, NULL); @@ -372,7 +372,7 @@ void sp_selection_delete(SPDesktop *desktop) _("Delete")); } -void add_ids_recursive(std::vector &ids, SPObject *obj) +static void add_ids_recursive(std::vector &ids, SPObject *obj) { if (obj) { ids.push_back(obj->getId()); @@ -540,7 +540,7 @@ GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onl return list; } -void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool invert) +static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool invert) { if (!dt) return; @@ -626,7 +626,7 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) sp_edit_select_all_full(desktop, true, true); } -void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { +static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); @@ -845,7 +845,7 @@ enclose_items(GSList const *items) } // TODO determine if this is intentionally different from SPObject::getPrev() -SPObject *prev_sibling(SPObject *child) +static SPObject *prev_sibling(SPObject *child) { SPObject *prev = 0; if ( child && SP_IS_GROUP(child->parent) ) { @@ -1153,7 +1153,7 @@ void sp_selection_paste_livepatheffect(SPDesktop *desktop) } -void sp_selection_remove_livepatheffect_impl(SPItem *item) +static void sp_selection_remove_livepatheffect_impl(SPItem *item) { if ( item && SP_IS_LPE_ITEM(item) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) { @@ -1344,7 +1344,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) g_slist_free(const_cast(items)); } -bool +static bool selection_contains_original(SPItem *item, Inkscape::Selection *selection) { bool contains_original = false; @@ -1371,7 +1371,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) } -bool +static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection) { bool clone_with_original = false; @@ -1882,7 +1882,7 @@ GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrok return matches; } -bool item_type_match (SPItem *i, SPItem *j) +static bool item_type_match (SPItem *i, SPItem *j) { if ( SP_IS_RECT(i)) { return ( SP_IS_RECT(j) ); diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 3d1b97b04..c141c3da5 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -36,7 +36,7 @@ #include "sp-polyline.h" #include "sp-spiral.h" -const gchar * +static const gchar * type2term(GType type) { if (type == SP_TYPE_ANCHOR) @@ -80,7 +80,7 @@ type2term(GType type) return NULL; } -GSList *collect_terms (GSList *items) +static GSList *collect_terms (GSList *items) { GSList *r = NULL; for (GSList *i = items; i != NULL; i = i->next) { @@ -92,7 +92,7 @@ GSList *collect_terms (GSList *items) } // Returns the number of filtered items in the list -int count_filtered (GSList *items) +static int count_filtered (GSList *items) { int count=0; SPItem *item=NULL; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 07885ff4d..aa16bcdd4 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -234,7 +234,7 @@ private: PushPull(const PushPull& other); }; -void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length ) +static void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length ) { // g_message( "user_read_data(%d)", length ); @@ -255,12 +255,12 @@ void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length ) // g_message("things out"); } -void user_write_data( png_structp /*png_ptr*/, png_bytep /*data*/, png_size_t /*length*/ ) +static void user_write_data( png_structp /*png_ptr*/, png_bytep /*data*/, png_size_t /*length*/ ) { //g_message( "user_write_data(%d)", length ); } -void user_flush_data( png_structp /*png_ptr*/ ) +static void user_flush_data( png_structp /*png_ptr*/ ) { //g_message( "user_flush_data" ); } @@ -424,7 +424,7 @@ static bool readPngAndHeaders( PushPull &youme, gint & dpiX, gint & dpiY ) return good; } -static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& pixPath, GError **/*error*/ ) +GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& pixPath, GError **/*error*/ ) { GdkPixbuf* buf = NULL; PushPull youme; diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index fd27c896a..0f5117289 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -6,6 +6,7 @@ #include <2geom/transforms.h> #include #include +#include using std::vector; diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index de4c7dca1..c35e4fa48 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -6,6 +6,7 @@ #include "sp-guide.h" #include "sp-guide-constraint.h" #include "sp-item.h" +#include "sp-item-rm-unsatisfied-cns.h" using std::vector; diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index a8d553e9f..a27a1bc78 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -16,6 +16,7 @@ #include <2geom/transforms.h> #include "sp-item.h" +#include "sp-item-transform.h" void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) { diff --git a/src/sp-item-update-cns.cpp b/src/sp-item-update-cns.cpp index 315d09108..750f0d94f 100644 --- a/src/sp-item-update-cns.cpp +++ b/src/sp-item-update-cns.cpp @@ -1,8 +1,9 @@ #include "satisfied-guide-cns.h" #include "sp-guide-constraint.h" -#include -#include +#include "sp-item-update-cns.h" +#include "sp-guide.h" +#include "sp-item.h" #include using std::find; using std::vector; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index b1eb5a24a..a21ff3968 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1204,7 +1204,7 @@ void SPItem::adjust_stroke( gdouble ex ) /** * Find out the inverse of previous transform of an item (from its repr) */ -Geom::Affine sp_item_transform_repr (SPItem *item) +static Geom::Affine sp_item_transform_repr (SPItem *item) { Geom::Affine t_old(Geom::identity()); gchar const *t_attr = item->getRepr()->attribute("transform"); @@ -1253,7 +1253,7 @@ void SPItem::freeze_stroke_width_recursive(bool freeze) /** * Recursively adjust rx and ry of rects. */ -void +static void sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) { if (SP_IS_RECT (item)) { diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 2b7611bde..3b2d33bbd 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -72,7 +72,7 @@ enum { ROW, COL }; -void swap_p( Geom::Point *p1, Geom::Point *p2 ) { +static void swap_p( Geom::Point *p1, Geom::Point *p2 ) { Geom::Point temp = *p1; *p1 = *p2; *p2 = temp; @@ -957,7 +957,7 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) { Find default color based on color of first stop in "vector" gradient. This should be rewritten if dependence on "vector" is removed. */ -SPColor default_color( SPItem *item ) { +static SPColor default_color( SPItem *item ) { // Set initial color to the color of the object before adding the mesh. // This is a bit tricky as at the moment, a "vector" gradient is created diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 16e64ff49..992001f99 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -20,6 +20,7 @@ #include "sp-mesh-gradient-fns.h" #include "sp-mesh-row-fns.h" #include "sp-mesh-patch-fns.h" +#include "sp-object-repr.h" #include "sp-path.h" #include "sp-radial-gradient-fns.h" #include "sp-rect.h" diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 9ceeaf262..c16dbaeef 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -339,7 +339,7 @@ SPObject const *SPObject::nearestCommonAncestor(SPObject const *object) const { return longest_common_suffix(this, object, NULL, &same_objects); } -SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) { +static SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) { SPObject const *result = 0; if ( obj && ancestor ) { if (obj->parent == ancestor) { diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 817db92e8..b98399171 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -750,7 +750,7 @@ static void sp_offset_snappoints(SPItem const *item, std::vectorfirstChild() ; child && !hasChildren ; child = child->getNext() ) { diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index f344a3d92..052c9e853 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -162,7 +162,7 @@ sp_spiral_context_dispose(GObject *object) * Callback that processes the "changed" signal on the selection; * destroys old and creates new knotholder. */ -void sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer data) +static void sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPSpiralContext *sc = SP_SPIRAL_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(sc); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 4c1421684..f1360adda 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1778,7 +1778,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, //return true if we changed something, else false -bool +static bool sp_selected_path_simplify_item(SPDesktop *desktop, Inkscape::Selection *selection, SPItem *item, float threshold, bool justCoalesce, @@ -1982,7 +1982,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, return didSomething; } -void +static void sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles) { diff --git a/src/spray-context.cpp b/src/spray-context.cpp index bcdc69805..fe478583c 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -134,7 +134,7 @@ static void sp_spray_context_class_init(SPSprayContextClass *klass) } /* Method to rotate items */ -void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation) +static void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation) { Geom::Translate const s(c); Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); @@ -150,7 +150,7 @@ void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Ge } /* Method to scale items */ -void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) +static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) { Geom::Translate const s(c); item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); @@ -207,7 +207,7 @@ static void sp_spray_context_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); } -bool is_transform_modes(gint mode) +static bool is_transform_modes(gint mode) { return (mode == SPRAY_MODE_COPY || mode == SPRAY_MODE_CLONE || @@ -215,7 +215,7 @@ bool is_transform_modes(gint mode) mode == SPRAY_OPTION); } -void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) +static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) { SPEventContext *event_context = SP_EVENT_CONTEXT(tc); SPDesktop *desktop = event_context->desktop; @@ -342,12 +342,12 @@ static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event) } } -double get_dilate_radius(SPSprayContext *tc) +static double get_dilate_radius(SPSprayContext *tc) { return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom(); } -double get_path_force(SPSprayContext *tc) +static double get_path_force(SPSprayContext *tc) { double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE) /sqrt(SP_EVENT_CONTEXT(tc)->desktop->current_zoom()); @@ -357,28 +357,28 @@ double get_path_force(SPSprayContext *tc) return force * tc->force; } -double get_path_mean(SPSprayContext *tc) +static double get_path_mean(SPSprayContext *tc) { return tc->mean; } -double get_path_standard_deviation(SPSprayContext *tc) +static double get_path_standard_deviation(SPSprayContext *tc) { return tc->standard_deviation; } -double get_move_force(SPSprayContext *tc) +static double get_move_force(SPSprayContext *tc) { double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE); return force * tc->force; } -double get_move_mean(SPSprayContext *tc) +static double get_move_mean(SPSprayContext *tc) { return tc->mean; } -double get_move_standard_deviation(SPSprayContext *tc) +static double get_move_standard_deviation(SPSprayContext *tc) { return tc->standard_deviation; } @@ -392,7 +392,7 @@ double get_move_standard_deviation(SPSprayContext *tc) * @param[in] choice : */ -void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/) +static void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/) { // angle is taken from an uniform distribution angle = g_random_double_range(0, M_PI*2.0); @@ -411,7 +411,7 @@ void random_position(double &radius, double &angle, double &a, double &s, int /* } -bool sp_spray_recursive(SPDesktop *desktop, +static bool sp_spray_recursive(SPDesktop *desktop, Inkscape::Selection *selection, SPItem *item, Geom::Point p, @@ -572,7 +572,7 @@ bool sp_spray_recursive(SPDesktop *desktop, return did; } -bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) +static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) { Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop); SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop; @@ -617,7 +617,7 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, return did; } -void sp_spray_update_area(SPSprayContext *tc) +static void sp_spray_update_area(SPSprayContext *tc) { double radius = get_dilate_radius(tc); Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); @@ -625,7 +625,7 @@ void sp_spray_update_area(SPSprayContext *tc) sp_canvas_item_show(tc->dilate_area); } -void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) +static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) { // select the button mode SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); @@ -634,7 +634,7 @@ void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) sp_spray_update_cursor(tc, with_shift); } -void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) +static void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Juggling about so that prefs have the old value but tc->mode and the button show new mode: diff --git a/src/star-context.cpp b/src/star-context.cpp index 7861354e9..66e6b3116 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -170,7 +170,7 @@ sp_star_context_dispose (GObject *object) * * @param selection Should not be NULL. */ -void sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data) +static void sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data) { g_assert (selection != NULL); diff --git a/src/style.cpp b/src/style.cpp index 616474298..3e58a0404 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -4567,7 +4567,7 @@ sp_css_attr_unset_text(SPCSSAttr *css) return css; } -bool +static bool is_url(char const *p) { if (p == NULL) @@ -4607,7 +4607,7 @@ sp_css_attr_unset_uris(SPCSSAttr *css) /** * Scale a single-value property. */ -void +static void sp_css_attr_scale_property_single(SPCSSAttr *css, gchar const *property, double ex, bool only_with_units = false) { @@ -4631,7 +4631,7 @@ sp_css_attr_scale_property_single(SPCSSAttr *css, gchar const *property, /** * Scale a list-of-values property. */ -void +static void sp_css_attr_scale_property_list(SPCSSAttr *css, gchar const *property, double ex) { gchar const *string = sp_repr_css_property(css, property, NULL); diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 3446795ed..2046784f1 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -40,7 +40,7 @@ using Inkscape::DocumentUndo; -SPItem * +static SPItem * text_in_selection(Inkscape::Selection *selection) { for (GSList *items = (GSList *) selection->itemList(); @@ -52,7 +52,7 @@ text_in_selection(Inkscape::Selection *selection) return NULL; } -SPItem * +static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { for (GSList *items = (GSList *) selection->itemList(); @@ -64,7 +64,7 @@ flowtext_in_selection(Inkscape::Selection *selection) return NULL; } -SPItem * +static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { for (GSList *items = (GSList *) selection->itemList(); @@ -76,7 +76,7 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) return NULL; } -SPItem * +static SPItem * shape_in_selection(Inkscape::Selection *selection) { for (GSList *items = (GSList *) selection->itemList(); @@ -233,7 +233,7 @@ text_remove_from_path() } } -void +static void text_remove_all_kerns_recursively(SPObject *o) { o->getRepr()->setAttribute("dx", NULL); diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 0205fc703..33dab447c 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -176,7 +176,7 @@ sp_tweak_context_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); } -bool is_transform_mode (gint mode) +static bool is_transform_mode (gint mode) { return (mode == TWEAK_MODE_MOVE || mode == TWEAK_MODE_MOVE_IN_OUT || @@ -186,12 +186,12 @@ bool is_transform_mode (gint mode) mode == TWEAK_MODE_MORELESS); } -bool is_color_mode (gint mode) +static bool is_color_mode (gint mode) { return (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER || mode == TWEAK_MODE_BLUR); } -void +static void sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) { SPEventContext *event_context = SP_EVENT_CONTEXT(tc); @@ -376,14 +376,14 @@ sp_tweak_extinput(SPTweakContext *tc, GdkEvent *event) } } -double +static double get_dilate_radius (SPTweakContext *tc) { // 10 times the pen width: return 500 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom(); } -double +static double get_path_force (SPTweakContext *tc) { double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE) @@ -394,14 +394,14 @@ get_path_force (SPTweakContext *tc) return force * tc->force; } -double +static double get_move_force (SPTweakContext *tc) { double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE); return force * tc->force; } -bool +static bool sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::Point p, Geom::Point vector, gint mode, double radius, double force, double fidelity, bool reverse) { bool did = false; @@ -697,7 +697,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P return did; } -void +static void tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s, bool do_l) { float rgb_g[3]; @@ -729,7 +729,7 @@ tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s } } -void +static void tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l) { float hsl_c[3]; @@ -754,7 +754,7 @@ tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l) sp_color_hsl_to_rgb_floatv (color, hsl_c[0], hsl_c[1], hsl_c[2]); } -void +static void tweak_color (guint mode, float *color, guint32 goal, double force, bool do_h, bool do_s, bool do_l) { if (mode == TWEAK_MODE_COLORPAINT) { @@ -764,7 +764,7 @@ tweak_color (guint mode, float *color, guint32 goal, double force, bool do_h, bo } } -void +static void tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, double force) { double opacity = SP_SCALE24_TO_FLOAT (style_opacity->value); @@ -780,7 +780,7 @@ tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, doubl } -double +static double tweak_profile (double dist, double radius) { if (radius == 0) { @@ -797,9 +797,9 @@ tweak_profile (double dist, double radius) } } -void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke, - guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode, - bool do_h, bool do_s, bool do_l, bool /*do_o*/) +static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke, + guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode, + bool do_h, bool do_s, bool do_l, bool /*do_o*/) { SPGradient *gradient = getGradient(item, fill_or_stroke); @@ -917,7 +917,7 @@ void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke } } -bool +static bool sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, guint32 fill_goal, bool do_fill, guint32 stroke_goal, bool do_stroke, @@ -1051,7 +1051,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, } -bool +static bool sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse) { Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop); @@ -1141,7 +1141,7 @@ sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::P return did; } -void +static void sp_tweak_update_area (SPTweakContext *tc) { double radius = get_dilate_radius(tc); @@ -1150,7 +1150,7 @@ sp_tweak_update_area (SPTweakContext *tc) sp_canvas_item_show(tc->dilate_area); } -void +static void sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift) { SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode); @@ -1159,7 +1159,7 @@ sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift) sp_tweak_update_cursor (tc, with_shift); } -void +static void sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/unclump.cpp b/src/unclump.cpp index 43bcf5005..1427e8eab 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -15,6 +15,7 @@ #include #include <2geom/transforms.h> #include "sp-item.h" +#include "unclump.h" // Taking bbox of an item is an expensive operation, and we need to do it many times, so here we @@ -27,7 +28,7 @@ std::map wh_cache; /** Center of bbox of item */ -Geom::Point +static Geom::Point unclump_center (SPItem *item) { std::map::iterator i = c_cache.find(item->getId()); @@ -46,7 +47,7 @@ unclump_center (SPItem *item) } } -Geom::Point +static Geom::Point unclump_wh (SPItem *item) { Geom::Point wh; @@ -71,7 +72,7 @@ Distance between "edges" of item1 and item2. An item is considered to be an elli so its radius (distance from center to edge) depends on the w/h and the angle towards the other item. May be negative if the edge of item1 is between the center and the edge of item2. */ -double +static double unclump_dist (SPItem *item1, SPItem *item2) { Geom::Point c1 = unclump_center (item1); @@ -166,7 +167,7 @@ unclump_dist (SPItem *item1, SPItem *item2) /** Average unclump_dist from item to others */ -double unclump_average (SPItem *item, GSList *others) +static double unclump_average (SPItem *item, GSList *others) { int n = 0; double sum = 0; @@ -190,7 +191,7 @@ double unclump_average (SPItem *item, GSList *others) /** Closest to item among others */ -SPItem *unclump_closest (SPItem *item, GSList *others) +static SPItem *unclump_closest (SPItem *item, GSList *others) { double min = HUGE_VAL; SPItem *closest = NULL; @@ -214,7 +215,7 @@ SPItem *unclump_closest (SPItem *item, GSList *others) /** Most distant from item among others */ -SPItem *unclump_farest (SPItem *item, GSList *others) +static SPItem *unclump_farest (SPItem *item, GSList *others) { double max = -HUGE_VAL; SPItem *farest = NULL; @@ -240,7 +241,7 @@ Removes from the \a rest list those items that are "behind" \a closest as seen f i.e. those on the other side of the line through \a closest perpendicular to the direction from \a item to \a closest. Returns a newly created list which must be freed. */ -GSList * +static GSList * unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest) { Geom::Point it = unclump_center (item); @@ -282,7 +283,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest) /** Moves \a what away from \a from by \a dist */ -void +static void unclump_push (SPItem *from, SPItem *what, double dist) { Geom::Point it = unclump_center (what); @@ -305,7 +306,7 @@ unclump_push (SPItem *from, SPItem *what, double dist) /** Moves \a what towards \a to by \a dist */ -void +static void unclump_pull (SPItem *to, SPItem *what, double dist) { Geom::Point it = unclump_center (what); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index f342f2c69..3adcfbb40 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -204,7 +204,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const *ppointer, guint state, g dragger->dragging_started = true; } -void +static void vp_knot_grabbed_handler (SPKnot */*knot*/, unsigned int /*state*/, gpointer data) { VPDragger *dragger = (VPDragger *) data; -- cgit v1.2.3 From 864134765a33823e2040c012ec383bebd7dd5743 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:47:32 +1000 Subject: code cleanup: make more functions static or include their own headers. (bzr r11736) --- src/bind/dobinding.cpp | 2 +- src/bind/javabind.cpp | 28 ++++++++++---------- src/debug/timestamp.cpp | 1 + src/dialogs/find.cpp | 48 ++++++++++++++++++---------------- src/extension/internal/svg.cpp | 2 +- src/helper/gnome-utils.cpp | 2 ++ src/helper/stock-items.cpp | 2 +- src/io/ftos.cpp | 4 +-- src/live_effects/lpe-gears.cpp | 3 ++- src/live_effects/lpe-knot.cpp | 7 ++--- src/live_effects/lpe-powerstroke.cpp | 16 ++++++------ src/live_effects/lpe-rough-hatches.cpp | 4 +-- src/live_effects/spiro.cpp | 8 +++--- src/ui/dialog/align-and-distribute.cpp | 4 +-- src/ui/dialog/tile.cpp | 4 +-- src/ui/dialog/transformation.cpp | 2 +- src/widgets/eek-preview.cpp | 4 +-- src/widgets/font-selector.cpp | 2 +- src/widgets/text-toolbar.cpp | 4 +-- src/xml/quote.cpp | 1 + 20 files changed, 78 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp index 6da754716..03b16a9dd 100644 --- a/src/bind/dobinding.cpp +++ b/src/bind/dobinding.cpp @@ -180,7 +180,7 @@ static NativeClass nc_DOMBase = //######################################################################## -void JNICALL DOMImplementation_nCreateDocument +static void JNICALL DOMImplementation_nCreateDocument (JNIEnv *env, jobject obj) { DOMImplementationImpl domImpl; diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index 0831ddf19..d2d01f0b3 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -111,7 +111,7 @@ String normalizePath(const String &str) /** * Convert a java string to a C++ string */ -String getString(JNIEnv *env, jstring jstr) +static String getString(JNIEnv *env, jstring jstr) { const char *chars = env->GetStringUTFChars(jstr, JNI_FALSE); String str = chars; @@ -138,62 +138,62 @@ String getExceptionString(JNIEnv *env) return buf; } -jint getObjInt(JNIEnv *env, jobject obj, const char *name) +static jint getObjInt(JNIEnv *env, jobject obj, const char *name) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "I"); return env->GetIntField(obj, fid); } -void setObjInt(JNIEnv *env, jobject obj, const char *name, jint val) +static void setObjInt(JNIEnv *env, jobject obj, const char *name, jint val) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "I"); env->SetIntField(obj, fid, val); } -jlong getObjLong(JNIEnv *env, jobject obj, const char *name) +static jlong getObjLong(JNIEnv *env, jobject obj, const char *name) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "J"); return env->GetLongField(obj, fid); } -void setObjLong(JNIEnv *env, jobject obj, const char *name, jlong val) +static void setObjLong(JNIEnv *env, jobject obj, const char *name, jlong val) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "J"); env->SetLongField(obj, fid, val); } -jfloat getObjFloat(JNIEnv *env, jobject obj, const char *name) +static jfloat getObjFloat(JNIEnv *env, jobject obj, const char *name) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "F"); return env->GetFloatField(obj, fid); } -void setObjFloat(JNIEnv *env, jobject obj, const char *name, jfloat val) +static void setObjFloat(JNIEnv *env, jobject obj, const char *name, jfloat val) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "F"); env->SetFloatField(obj, fid, val); } -jdouble getObjDouble(JNIEnv *env, jobject obj, const char *name) +static jdouble getObjDouble(JNIEnv *env, jobject obj, const char *name) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "D"); return env->GetDoubleField(obj, fid); } -void setObjDouble(JNIEnv *env, jobject obj, const char *name, jdouble val) +static void setObjDouble(JNIEnv *env, jobject obj, const char *name, jdouble val) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "D"); env->SetDoubleField(obj, fid, val); } -String getObjString(JNIEnv *env, jobject obj, const char *name) +static String getObjString(JNIEnv *env, jobject obj, const char *name) { jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "Ljava/lang/String;"); jstring jstr = (jstring)env->GetObjectField(obj, fid); return getString(env, jstr); } -void setObjString(JNIEnv *env, jobject obj, const char *name, const String &val) +static void setObjString(JNIEnv *env, jobject obj, const char *name, const String &val) { jstring jstr = env->NewStringUTF(val.c_str()); jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "Ljava/lang/String;"); @@ -725,7 +725,7 @@ static void populateClassPath(const String &javaroot, * This is provided to scripts can grab the current copy or the * repr tree. If anyone has a smarter way of doing this, please implement. */ -jstring JNICALL documentGet(JNIEnv *env, jobject /*obj*/, jlong /*ptr*/) +static jstring JNICALL documentGet(JNIEnv *env, jobject /*obj*/, jlong /*ptr*/) { //JavaBinderyImpl *bind = (JavaBinderyImpl *)ptr; String buf = sp_repr_save_buf((SP_ACTIVE_DOCUMENT)->rdoc); @@ -737,7 +737,7 @@ jstring JNICALL documentGet(JNIEnv *env, jobject /*obj*/, jlong /*ptr*/) * This is provided to scripts can load an XML tree into Inkscape. * If anyone has a smarter way of doing this, please implement. */ -jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, jstring /*jstr*/) +static jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, jstring /*jstr*/) { /* JavaBinderyImpl *bind = (JavaBinderyImpl *)ptr; @@ -752,7 +752,7 @@ jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, js * redirect its logging stream here. * For the main C++/Java bindings, see dobinding.cpp */ -void JNICALL logWrite(JNIEnv */*env*/, jobject /*obj*/, jlong ptr, jint ch) +static void JNICALL logWrite(JNIEnv */*env*/, jobject /*obj*/, jlong ptr, jint ch) { JavaBinderyImpl *bind = reinterpret_cast(ptr); bind->log(ch); diff --git a/src/debug/timestamp.cpp b/src/debug/timestamp.cpp index e100134c8..6de03a463 100644 --- a/src/debug/timestamp.cpp +++ b/src/debug/timestamp.cpp @@ -13,6 +13,7 @@ #include #include #include "debug/simple-event.h" +#include "timestamp.h" namespace Inkscape { diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index 41d7f3418..8acc96596 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -18,7 +18,7 @@ //TODO : delete this GtkWidget * sp_find_dialog_old (void); -void +static void //GtkWidget * sp_find_dialog(){ // DialogFind::get().present(); @@ -102,7 +102,7 @@ static gboolean sp_find_dialog_delete(GObject *, GdkEvent *, gpointer /*data*/) return FALSE; // which means, go ahead and destroy it } -void +static void sp_find_squeeze_window() { GtkRequisition r; @@ -114,7 +114,7 @@ sp_find_squeeze_window() gtk_window_resize ((GtkWindow *) dlg, r.width, r.height); } -bool +static bool item_id_match (SPItem *item, const gchar *id, bool exact) { if (item->getRepr() == NULL) { @@ -138,7 +138,7 @@ item_id_match (SPItem *item, const gchar *id, bool exact) } } -bool +static bool item_text_match (SPItem *item, const gchar *text, bool exact) { if (item->getRepr() == NULL) { @@ -162,7 +162,7 @@ item_text_match (SPItem *item, const gchar *text, bool exact) return false; } -bool +static bool item_style_match (SPItem *item, const gchar *text, bool exact) { if (item->getRepr() == NULL) { @@ -181,7 +181,8 @@ item_style_match (SPItem *item, const gchar *text, bool exact) } } -bool item_attr_match(SPItem *item, const gchar *name, bool exact) +static bool +item_attr_match(SPItem *item, const gchar *name, bool exact) { bool result = false; if (item->getRepr()) { @@ -196,7 +197,7 @@ bool item_attr_match(SPItem *item, const gchar *name, bool exact) } -GSList * +static GSList * filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_function)(SPItem *, const gchar *, bool), bool exact) { GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), field)); @@ -218,13 +219,13 @@ filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_funct } -bool +static bool type_checkbox (GtkWidget *widget, const gchar *data) { return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (widget), data))); } -bool +static bool item_type_match (SPItem *item, GtkWidget *widget) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -263,7 +264,7 @@ item_type_match (SPItem *item, GtkWidget *widget) return false; } -GSList * +static GSList * filter_types (GSList *l, GObject *dlg, bool (*match_function)(SPItem *, GtkWidget *)) { GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), "types")); @@ -283,7 +284,7 @@ filter_types (GSList *l, GObject *dlg, bool (*match_function)(SPItem *, GtkWidge } -GSList * +static GSList * filter_list (GSList *l, GObject *dlg, bool exact) { l = filter_onefield (l, dlg, "text", item_text_match, exact); @@ -296,7 +297,7 @@ filter_list (GSList *l, GObject *dlg, bool exact) return l; } -GSList * +static GSList * all_items (SPObject *r, GSList *l, bool hidden, bool locked) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -321,7 +322,7 @@ all_items (SPObject *r, GSList *l, bool hidden, bool locked) return l; } -GSList * +static GSList * all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -343,7 +344,8 @@ all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool } -void sp_find_dialog_find(GObject *, GObject *dlg) +static void +sp_find_dialog_find(GObject *, GObject *dlg) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -392,7 +394,7 @@ void sp_find_dialog_find(GObject *, GObject *dlg) } } -void +static void sp_find_reset_searchfield (GObject *dlg, const gchar *field) { GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), field)); @@ -400,7 +402,7 @@ sp_find_reset_searchfield (GObject *dlg, const gchar *field) } -void +static void sp_find_dialog_reset (GObject *, GObject *dlg) { sp_find_reset_searchfield (dlg, "text"); @@ -417,7 +419,7 @@ sp_find_dialog_reset (GObject *, GObject *dlg) #define FIND_LABELWIDTH 80 -void +static void sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, const gchar *id, const gchar *tip) { #if GTK_CHECK_VERSION(3,0,0) @@ -442,7 +444,7 @@ sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, cons gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); } -void +static void sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gchar *tip, void (*function) (GObject *, GObject *)) { GtkWidget *b = gtk_button_new_with_mnemonic (label); @@ -452,7 +454,7 @@ sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gch gtk_widget_show (b); } -void +static void toggle_alltypes (GtkToggleButton *tb, gpointer data) { GtkWidget *alltypes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "all-pane")); @@ -475,7 +477,7 @@ toggle_alltypes (GtkToggleButton *tb, gpointer data) sp_find_squeeze_window(); } -void +static void toggle_shapes (GtkToggleButton *tb, gpointer data) { GtkWidget *shapes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "shapes-pane")); @@ -492,7 +494,7 @@ toggle_shapes (GtkToggleButton *tb, gpointer data) } -GtkWidget * +static GtkWidget * sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, const gchar *tip, const gchar *label, @@ -520,7 +522,7 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, return hb; } -GtkWidget * +static GtkWidget * sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean active, const gchar *tip, const gchar *label, @@ -548,7 +550,7 @@ sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean activ } -GtkWidget * +static GtkWidget * sp_find_types () { #if GTK_CHECK_VERSION(3,0,0) diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 9b1098afd..8b272af60 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -44,7 +44,7 @@ using Inkscape::XML::Node; -void pruneExtendedAttributes( Inkscape::XML::Node *repr ) +static void pruneExtendedAttributes( Inkscape::XML::Node *repr ) { if (repr) { if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) { diff --git a/src/helper/gnome-utils.cpp b/src/helper/gnome-utils.cpp index aa70dd1a2..d0bcaf8cd 100644 --- a/src/helper/gnome-utils.cpp +++ b/src/helper/gnome-utils.cpp @@ -16,6 +16,8 @@ #include #include +#include "gnome-utils.h" + /** * gnome_uri_list_extract_uris: * @uri_list: an uri-list in the standard format. diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 902aebdeb..a00507330 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -33,7 +33,7 @@ #include "inkscape.h" #include "io/sys.h" - +#include "stock-items.h" diff --git a/src/io/ftos.cpp b/src/io/ftos.cpp index 658c768e8..d0764d86c 100644 --- a/src/io/ftos.cpp +++ b/src/io/ftos.cpp @@ -172,7 +172,7 @@ using namespace std; // This routine counts from the end of a string like '10229000' to find the index // of the first non-'0' character (5 would be returned for the above number.) -int countDigs(char *p) +static int countDigs(char *p) { int length =0; while (*(p+length)!='\0') length++; // Count total length @@ -186,7 +186,7 @@ int countDigs(char *p) // is between 0 and 1. Returns 1 if v==0. Return value is positive for numbers // greater than or equal to 1, negative for numbers less than 0.1, and zero for // numbers between 0.1 and 1. -int countLhsDigits(double v) +static int countLhsDigits(double v) { if (v<0) v = -v; // Take abs value else if (v==0) return 1; // Special case if v==0 diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp index e57f5112e..003e22567 100644 --- a/src/live_effects/lpe-gears.cpp +++ b/src/live_effects/lpe-gears.cpp @@ -112,7 +112,8 @@ private: } }; -void makeContinuous(D2 &a, Point const b) { +static void +makeContinuous(D2 &a, Point const b) { for(unsigned d=0;d<2;d++) a[d][0][0] = b[d]; } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index d3dd10d26..746dbbb7a 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -51,7 +51,7 @@ public: }; -Geom::Path::size_type size_nondegenerate(Geom::Path const &path) { +static Geom::Path::size_type size_nondegenerate(Geom::Path const &path) { Geom::Path::size_type retval = path.size_open(); // if path is closed and closing segment is not degenerate @@ -283,7 +283,7 @@ CrossingPoints::get(unsigned const i, unsigned const ni) return CrossingPoint(); } -unsigned +static unsigned idx_of_nearest(CrossingPoints const &cpts, Geom::Point const &p) { double dist=-1; @@ -500,7 +500,8 @@ LPEKnot::doEffect_path (std::vector const &path_in) //recursively collect gpaths and stroke widths (stolen from "sp-lpe_item.cpp"). -void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &paths, std::vector &stroke_widths){ +static void +collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &paths, std::vector &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 88a20c68a..69d0808e4 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -36,7 +36,7 @@ namespace Geom { /** Find the point where two straight lines cross. */ -boost::optional intersection_point( Point const & origin_a, Point const & vector_a, +static boost::optional intersection_point( Point const & origin_a, Point const & vector_a, Point const & origin_b, Point const & vector_b) { Coord denom = cross(vector_b, vector_a); @@ -47,7 +47,7 @@ boost::optional intersection_point( Point const & origin_a, Point const & return boost::none; } -Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2 const & sbasis_in) +static Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2 const & sbasis_in) { std::vector temp; sbasis_to_bezier(temp, sbasis_in, 4); @@ -205,12 +205,12 @@ static bool compare_offsets (Geom::Point first, Geom::Point second) return first[Geom::X] < second[Geom::X]; } -Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise > const & B, - Geom::Piecewise const & y, // width path - LineJoinType jointype, - double miter_limit, - bool /*forward_direction*/, - double tol=Geom::EPSILON) +static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise > const & B, + Geom::Piecewise const & y, // width path + LineJoinType jointype, + double miter_limit, + bool /*forward_direction*/, + double tol=Geom::EPSILON) { /* per definition, each discontinuity should be fixed with a join-ending, as defined by linejoin_type */ diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index de40d4fb5..f52977fcb 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -68,7 +68,7 @@ struct LevelCrossingInfoOrder { typedef std::vector LevelCrossings; -std::vector +static std::vector discontinuities(Piecewise > const &f){ std::vector result; if (f.size()==0) return result; @@ -211,7 +211,7 @@ public: // Bend a path... //------------------------------------------------------- -Piecewise > bend(Piecewise > const &f, Piecewise bending){ +static Piecewise > bend(Piecewise > const &f, Piecewise bending){ D2 > ff = make_cuts_independent(f); ff[X] += compose(bending, ff[Y]); return sectionize(ff); diff --git a/src/live_effects/spiro.cpp b/src/live_effects/spiro.cpp index 14df5e92e..f50399a77 100644 --- a/src/live_effects/spiro.cpp +++ b/src/live_effects/spiro.cpp @@ -83,7 +83,7 @@ int n = 4; #endif /* Integrate polynomial spiral curve over range -.5 .. .5. */ -void +static void integrate_spiro(const double ks[4], double xy[2]) { #if 0 @@ -631,7 +631,7 @@ banbks11(const bandmat *m, const int *perm, double *v, int n) } } -int compute_jinc(char ty0, char ty1) +static int compute_jinc(char ty0, char ty1) { if (ty0 == 'o' || ty1 == 'o' || ty0 == ']' || ty1 == '[') @@ -645,7 +645,7 @@ int compute_jinc(char ty0, char ty1) return 0; } -int count_vec(const spiro_seg *s, int nseg) +static int count_vec(const spiro_seg *s, int nseg) { int i; int n = 0; @@ -807,7 +807,7 @@ spiro_iter(spiro_seg *s, bandmat *m, int *perm, double *v, int n) return norm; } -int +static int solve_spiro(spiro_seg *s, int nseg) { bandmat *m; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 67980cdc1..7545a613e 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -873,14 +873,14 @@ private : -void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad) +static void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop && sp_desktop_event_context(desktop)) daad->setMode(tools_active(desktop) == TOOLS_NODES); } -void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad) +static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad) { daad->randomize_bbox = Geom::OptRect(); } diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 5031a60b6..1ce78a278 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -42,7 +42,7 @@ * 0 *elem1 == *elem2 * >0 *elem1 goes after *elem2 */ -int sp_compare_x_position(SPItem *first, SPItem *second) +static int sp_compare_x_position(SPItem *first, SPItem *second) { using Geom::X; using Geom::Y; @@ -84,7 +84,7 @@ int sp_compare_x_position(SPItem *first, SPItem *second) /* * Sort items by their y co-ordinates. */ -int +static int sp_compare_y_position(SPItem *first, SPItem *second) { Geom::OptRect a = first->documentVisualBounds(); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 1c9d6689b..bbc218b83 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -42,7 +42,7 @@ namespace Inkscape { namespace UI { namespace Dialog { -void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, Transformation *daad) +static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, Transformation *daad) { int page = daad->getCurrentPage(); daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection); diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index e0c5d9eac..953beb69d 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -583,7 +583,7 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton return FALSE; } -gboolean eek_preview_key_press_event( GtkWidget* widget, GdkEventKey* event) +static gboolean eek_preview_key_press_event( GtkWidget* widget, GdkEventKey* event) { (void)widget; (void)event; @@ -591,7 +591,7 @@ gboolean eek_preview_key_press_event( GtkWidget* widget, GdkEventKey* event) return FALSE; } -gboolean eek_preview_key_release_event( GtkWidget* widget, GdkEventKey* event) +static gboolean eek_preview_key_release_event( GtkWidget* widget, GdkEventKey* event) { (void)widget; (void)event; diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 61c6261bf..1cb94a8e5 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -129,7 +129,7 @@ static void sp_font_selector_class_init(SPFontSelectorClass *c) object_class->dispose = sp_font_selector_dispose; } -void sp_font_selector_set_size_tooltip(SPFontSelector *fsel) +static void sp_font_selector_set_size_tooltip(SPFontSelector *fsel) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 60ede002f..352276b21 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1087,7 +1087,7 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject * /* * Set the default list of font sizes, scaled to the users preferred unit */ -void sp_text_set_sizes(GtkListStore* model_size, int unit) +static void sp_text_set_sizes(GtkListStore* model_size, int unit) { gtk_list_store_clear(model_size); @@ -1434,7 +1434,7 @@ static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, g sp_text_toolbox_selection_changed (selection, tbl); } -void +static void sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl) { sp_text_toolbox_selection_changed (NULL, tbl); diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index 51f9ffb97..030a6c764 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -13,6 +13,7 @@ #include #include +#include "quote.h" /** \return strlen(xml_quote_strdup(\a val)) (without doing the malloc). -- cgit v1.2.3 From aca1914d674a5e81234208248e3c8515a60dd19d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 12:30:12 +1000 Subject: code cleanup: make more functions static, add includes. (bzr r11737) --- src/dom/prop-css.cpp | 2 +- src/dom/prop-css2.cpp | 2 +- src/dom/util/ziptool.cpp | 2 +- src/extension/init.cpp | 2 ++ src/trace/quantize.cpp | 16 ++++++++++------ src/ui/dialog/align-and-distribute.cpp | 2 +- src/ui/dialog/debug.cpp | 8 ++++---- src/ui/dialog/dialog.cpp | 4 ++-- src/ui/dialog/filter-effects-dialog.cpp | 8 ++++---- src/ui/dialog/inkscape-preferences.cpp | 2 +- src/ui/dialog/swatches.cpp | 7 +++++-- src/ui/dialog/transformation.cpp | 8 ++++---- src/widgets/gradient-toolbar.cpp | 5 +++-- src/widgets/gradient-vector.cpp | 2 +- src/widgets/paint-selector.cpp | 4 ++-- src/widgets/select-toolbar.cpp | 1 + src/widgets/shrink-wrap-button.cpp | 2 ++ src/widgets/spinbutton-events.cpp | 1 + src/widgets/spw-utilities.cpp | 3 ++- src/xml/node-fns.cpp | 1 + src/xml/repr-sorting.cpp | 1 + src/xml/repr-util.cpp | 2 +- 22 files changed, 51 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/dom/prop-css.cpp b/src/dom/prop-css.cpp index a0d66d939..9922b4935 100644 --- a/src/dom/prop-css.cpp +++ b/src/dom/prop-css.cpp @@ -1137,7 +1137,7 @@ NULL -bool printTable() +static bool printTable() { for (CssProp *prop=cssProps; prop->name ; prop++) { diff --git a/src/dom/prop-css2.cpp b/src/dom/prop-css2.cpp index 33548fbb9..9fe998552 100644 --- a/src/dom/prop-css2.cpp +++ b/src/dom/prop-css2.cpp @@ -1279,7 +1279,7 @@ bool parseProperty(char *name, char *value) } -bool printTable() +static bool printTable() { for (CssProp *prop=cssProps; prop->name ; prop++) { diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp index 081bcbbc4..9d9d5685c 100644 --- a/src/dom/util/ziptool.cpp +++ b/src/dom/util/ziptool.cpp @@ -126,7 +126,7 @@ static unsigned long crc_table[256]; /** * make the table for a fast CRC. */ -void makeCrcTable() +static void makeCrcTable() { if (crc_table_ready) return; diff --git a/src/extension/init.cpp b/src/extension/init.cpp index d59c2b2e3..ac3c90421 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -102,6 +102,8 @@ #include "internal/filter/filter.h" +#include "init.h" + extern gboolean inkscape_app_use_gui( Inkscape::Application const *app ); namespace Inkscape { diff --git a/src/trace/quantize.cpp b/src/trace/quantize.cpp index 2db1bbf34..ba9306da8 100644 --- a/src/trace/quantize.cpp +++ b/src/trace/quantize.cpp @@ -16,6 +16,7 @@ #include "pool.h" #include "imagemap.h" +#include "quantize.h" typedef struct Ocnode_def Ocnode; @@ -211,16 +212,19 @@ static void ocnodePrint(Ocnode *node, int indent) ocnodePrint(node->child[i], indent+2); } } + +#if 0 void octreePrint(Ocnode *node) { printf("<>\n"); if (node) printf("[r:%p] ", node); ocnodePrint(node, 2); } +#endif /** * builds a single color leaf at location */ -void ocnodeLeaf(pool *pool, Ocnode **ref, RGB rgb) +static void ocnodeLeaf(pool *pool, Ocnode **ref, RGB rgb) { assert(ref); Ocnode *node = ocnodeNew(pool); @@ -237,7 +241,7 @@ void ocnodeLeaf(pool *pool, Ocnode **ref, RGB rgb) /** * merge nodes and at location with parent */ -int octreeMerge(pool *pool, Ocnode *parent, Ocnode **ref, Ocnode *node1, Ocnode *node2) +static int octreeMerge(pool *pool, Ocnode *parent, Ocnode **ref, Ocnode *node1, Ocnode *node2) { assert(ref); if (!node1 && !node2) return 0; @@ -415,7 +419,7 @@ static void ocnodeStrip(pool *pool, Ocnode **ref, int *count, unsigned l /** * reduce the leaves of an octree to a given number */ -void octreePrune(pool *pool, Ocnode **ref, int ncolor) +static void octreePrune(pool *pool, Ocnode **ref, int ncolor) { assert(ref); assert(ncolor > 0); @@ -435,8 +439,8 @@ void octreePrune(pool *pool, Ocnode **ref, int ncolor) * build an octree associated to the area of a color map , * included in the specified (x1,y1)--(x2,y2) rectangle. */ -void octreeBuildArea(pool *pool, RgbMap *rgbmap, Ocnode **ref, - int x1, int y1, int x2, int y2, int ncolor) +static void octreeBuildArea(pool *pool, RgbMap *rgbmap, Ocnode **ref, + int x1, int y1, int x2, int y2, int ncolor) { int dx = x2 - x1, dy = y2 - y1; int xm = x1 + dx/2, ym = y1 + dy/2; @@ -465,7 +469,7 @@ void octreeBuildArea(pool *pool, RgbMap *rgbmap, Ocnode **ref, * build an octree associated to the color map, * pruned to colors. */ -Ocnode *octreeBuild(pool *pool, RgbMap *rgbmap, int ncolor) +static Ocnode *octreeBuild(pool *pool, RgbMap *rgbmap, int ncolor) { //create the octree Ocnode *node = NULL; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 7545a613e..4b0f773b5 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -755,7 +755,7 @@ struct Baselines {} }; -bool operator< (const Baselines &a, const Baselines &b) +static bool operator< (const Baselines &a, const Baselines &b) { return (a._base[a._orientation] < b._base[b._orientation]); } diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index a026f3501..da38e2dde 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -171,10 +171,10 @@ void DebugDialog::showInstance() /*##### THIS IS THE IMPORTANT PART ##### */ -void dialogLoggingFunction(const gchar */*log_domain*/, - GLogLevelFlags /*log_level*/, - const gchar *messageText, - gpointer user_data) +static void dialogLoggingFunction(const gchar */*log_domain*/, + GLogLevelFlags /*log_level*/, + const gchar *messageText, + gpointer user_data) { DebugDialogImpl *dlg = static_cast(user_data); dlg->message(messageText); diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index f5f712103..f27d344fa 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -61,7 +61,7 @@ void sp_dialog_shutdown(GObject * /*object*/, gpointer dlgPtr) } -void hideCallback(GObject * /*object*/, gpointer dlgPtr) +static void hideCallback(GObject * /*object*/, gpointer dlgPtr) { g_return_if_fail( dlgPtr != NULL ); @@ -69,7 +69,7 @@ void hideCallback(GObject * /*object*/, gpointer dlgPtr) dlg->onHideF12(); } -void unhideCallback(GObject * /*object*/, gpointer dlgPtr) +static void unhideCallback(GObject * /*object*/, gpointer dlgPtr) { g_return_if_fail( dlgPtr != NULL ); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index c3c44f6c3..a755cfccd 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -83,7 +83,7 @@ using Inkscape::UI::Widget::SpinScale; // Returns the number of inputs available for the filter primitive type -int input_count(const SPFilterPrimitive* prim) +static int input_count(const SPFilterPrimitive* prim) { if(!prim) return 0; @@ -1087,8 +1087,8 @@ FilterEffectsDialog::LightSourceControl* FilterEffectsDialog::Settings::add_ligh return ls; } -Glib::RefPtr create_popup_menu(Gtk::Widget& parent, sigc::slot dup, - sigc::slot rem) +static Glib::RefPtr create_popup_menu(Gtk::Widget& parent, sigc::slot dup, + sigc::slot rem) { Glib::RefPtr menu(new Gtk::Menu); @@ -2123,7 +2123,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* } // Checks all of prim's inputs, removes any that use result -void check_single_connection(SPFilterPrimitive* prim, const int result) +static void check_single_connection(SPFilterPrimitive* prim, const int result) { if (prim && (result >= 0)) { if (prim->image_in == result) { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 62f48cce0..fbaebfbec 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -200,7 +200,7 @@ void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring cons } -void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch) +static void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 68bafe549..3baba3460 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -237,6 +237,9 @@ static void removeit( GtkWidget *widget, gpointer data ) gtk_container_remove( GTK_CONTAINER(data), widget ); } +/* extern'ed from colot-item.cpp */ +gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, gpointer user_data ); + gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, gpointer user_data ) { gboolean handled = FALSE; @@ -371,13 +374,13 @@ static char* trim( char* str ) { return ret; } -void skipWhitespace( char*& str ) { +static void skipWhitespace( char*& str ) { while ( *str == ' ' || *str == '\t' ) { str++; } } -bool parseNum( char*& str, int& val ) { +static bool parseNum( char*& str, int& val ) { val = 0; while ( '0' <= *str && *str <= '9' ) { val = val * 10 + (*str - '0'); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index bbc218b83..329450b52 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -48,10 +48,10 @@ static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape:: daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection); } -void on_selection_modified( Inkscape::Application */*inkscape*/, - Inkscape::Selection *selection, - guint /*flags*/, - Transformation *daad ) +static void on_selection_modified( Inkscape::Application */*inkscape*/, + Inkscape::Selection *selection, + guint /*flags*/, + Transformation *daad ) { int page = daad->getCurrentPage(); daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index ea88b96fa..b5fc0a0f2 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -55,6 +55,7 @@ #include "svg/svg-color.h" #include "desktop-style.h" #include "gradient-context.h" +#include "gradient-toolbar.h" #include "toolbox.h" @@ -918,7 +919,7 @@ static void gr_new_fillstroke_changed( EgeSelectOneAction *act, GObject * /*tbl* /* * User selected a gradient from the combobox */ -void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data) +static void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data) { if (blocked) { return; @@ -947,7 +948,7 @@ void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data) } -void gr_spread_change(EgeSelectOneAction *act, GtkWidget *widget) +static void gr_spread_change(EgeSelectOneAction *act, GtkWidget *widget) { if (blocked) { return; diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 88fe15dca..51013a2cd 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -377,7 +377,7 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr) return ((int)(hsl[0]*100 * 10000)) + ((int)(hsl[1]*100 * 100)) + ((int)(hsl[2]*100 * 1)); } -GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) +static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) { for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 6450abf52..5a6e774f5 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -359,7 +359,7 @@ sp_paint_selector_fillrule_toggled(GtkToggleButton *tb, SPPaintSelector *psel) } } -void +static void sp_paint_selector_show_fillrule(SPPaintSelector *psel, bool is_fill) { if (psel->fillrulebox) { @@ -791,7 +791,7 @@ static void sp_psel_pattern_change(GtkWidget * /*widget*/, SPPaintSelector *psel * Returns a list of patterns in the defs of the given source document as a GSList object * Returns NULL if there are no patterns in the document. */ -GSList * +static GSList * ink_pattern_list_get (SPDocument *source) { if (source == NULL) diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 61b04121a..3ccfa9cf9 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -52,6 +52,7 @@ #include "ink-action.h" #include <2geom/rect.h> #include "ui/icon-names.h" +#include "select-toolbar.h" using Inkscape::UnitTracker; using Inkscape::DocumentUndo; diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index fc844f5ec..941a0466c 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -16,6 +16,8 @@ #include #include +#include "shrink-wrap-button.h" + namespace Inkscape { namespace Widgets { diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp index 290b0bb75..444aa278e 100644 --- a/src/widgets/spinbutton-events.cpp +++ b/src/widgets/spinbutton-events.cpp @@ -20,6 +20,7 @@ #include "sp-widget.h" #include "widget-sizes.h" +#include "spinbutton-events.h" gboolean spinbutton_focus_in (GtkWidget *w, GdkEventKey */*event*/, gpointer /*data*/) diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index e7db45581..8adc72cd7 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -24,6 +24,7 @@ #include "selection.h" #include "helper/unit-menu.h" +#include "spw-utilities.h" #include @@ -194,7 +195,7 @@ spw_unit_selector(GtkWidget * dialog, GtkWidget * table, return sb; } -void +static void sp_set_font_size_recursive (GtkWidget *w, gpointer font) { guint size = GPOINTER_TO_UINT (font); diff --git a/src/xml/node-fns.cpp b/src/xml/node-fns.cpp index 20e9fbc38..eb3870978 100644 --- a/src/xml/node-fns.cpp +++ b/src/xml/node-fns.cpp @@ -9,6 +9,7 @@ #include "xml/node-iterators.h" #include "util/find-if-before.h" +#include "node-fns.h" namespace Inkscape { namespace XML { diff --git a/src/xml/repr-sorting.cpp b/src/xml/repr-sorting.cpp index fd485925b..09a39acb2 100644 --- a/src/xml/repr-sorting.cpp +++ b/src/xml/repr-sorting.cpp @@ -2,6 +2,7 @@ #include "util/longest-common-suffix.h" #include "xml/repr.h" #include "xml/node-iterators.h" +#include "repr-sorting.h" static bool same_repr(Inkscape::XML::Node const &a, Inkscape::XML::Node const &b) { diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 5b8ab12ae..7e9f9c484 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -75,7 +75,7 @@ static char *sp_xml_ns_auto_prefix(char const *uri); /** * Locale-independent double to string conversion */ -unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf) +static unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf) { double dival, fval, epsilon; int idigits, ival, i; -- cgit v1.2.3 From 5cea988c97a9f100a78453bb3d7bc25d4775d656 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 5 Oct 2012 10:41:20 +0900 Subject: Fix for 570695 : show default|fallback autosave path (bzr r11738) --- src/ui/dialog/inkscape-preferences.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index fbaebfbec..57a3e34b6 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1041,10 +1041,14 @@ void InkscapePreferences::initPageIO() // Autosave options _save_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", false); _page_autosave.add_line(false, "", _save_autosave_enable, "", _("Automatically save the current document(s) at a given interval, thus minimizing loss in case of a crash"), false); + _save_autosave_path.init("/options/autosave/path", true); + if (prefs->getString("/options/autosave/path").empty()) { + // Show the default fallback "tmp dir" if autosave path is not set. + _save_autosave_path.set_text(Glib::get_tmp_dir()); + } + _page_autosave.add_line(false, C_("Filesystem", "Autosave _directory:"), _save_autosave_path, "", _("The directory where autosaves will be written"), false); _save_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false); _page_autosave.add_line(false, _("_Interval (in minutes):"), _save_autosave_interval, "", _("Interval (in minutes) at which document will be autosaved"), false); - _save_autosave_path.init("/options/autosave/path", true); - _page_autosave.add_line(false, C_("Filesystem", "_Path:"), _save_autosave_path, "", _("The directory where autosaves will be written"), false); _save_autosave_max.init("/options/autosave/max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false); _page_autosave.add_line(false, _("_Maximum number of autosaves:"), _save_autosave_max, "", _("Maximum number of autosaved files; use this to limit the storage space used"), false); -- cgit v1.2.3 From 28b187deab4fba42e835c5445881bbb10cee1f1c Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 6 Oct 2012 12:55:52 +0900 Subject: Fix for 587019 : Select and transform mouse cursor changes to normal cursor on object duplication (bzr r11739) --- src/select-context.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/select-context.cpp b/src/select-context.cpp index 7fecc7167..bc096d528 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -1140,8 +1140,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } // set cursor to default. if (!desktop->isWaitingCursor()) { - GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop))); - gdk_window_set_cursor(window, event_context->cursor); + // Do we need to reset the cursor here on key release ? + //GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop))); + //gdk_window_set_cursor(window, event_context->cursor); } break; default: -- cgit v1.2.3 From 88a1d1f28a10bf74e69774baf2010ebe8731aad9 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 6 Oct 2012 20:50:26 +0200 Subject: user message standardisation (bzr r11740) --- src/ui/dialog/inkscape-preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 57a3e34b6..bbaaecfd4 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -811,7 +811,7 @@ void InkscapePreferences::initPageIO() _("Maximum mouse drag (in screen pixels) which is considered a click, not a drag"), false); _mouse_grabsize.init("/options/grabsize/value", 1, 7, 1, 2, 3, 0); - _page_mouse.add_line(false, _("_Handle size"), _mouse_grabsize, "", + _page_mouse.add_line(false, _("_Handle size:"), _mouse_grabsize, "", _("Set the relative size of node handles"), true); _mouse_use_ext_input.init( _("Use pressure-sensitive tablet (requires restart)"), "/options/useextinput/value", true); -- cgit v1.2.3 From 3551e3f9f37481d8532dad92f3b301934414b302 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 6 Oct 2012 22:26:19 +0200 Subject: powerstroke: add arc-extrapolation, but disable it for release (bzr r11742) --- src/live_effects/lpe-powerstroke.cpp | 141 ++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 69d0808e4..698c09bcf 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -28,6 +28,7 @@ #include <2geom/path-intersection.h> #include <2geom/crossing.h> #include <2geom/ellipse.h> +#include #include "spiro.h" @@ -86,6 +87,70 @@ static Ellipse find_ellipse(Point P, Point Q, Point O) return Ellipse(A, B, C, D, E, F); } +/** + * Refer to: Weisstein, Eric W. "Circle-Circle Intersection." + From MathWorld--A Wolfram Web Resource. + http://mathworld.wolfram.com/Circle-CircleIntersection.html + * + * @return 0 if no intersection + * @return 1 if one circle is contained in the other + * @return 2 if intersections are found (they are written to p0 and p1) + */ +static int circle_circle_intersection(Circle const &circle0, Circle const &circle1, + Point & p0, Point & p1) +{ + Point X0 = circle0.center(); + double r0 = circle0.ray(); + Point X1 = circle1.center(); + double r1 = circle1.ray(); + + /* dx and dy are the vertical and horizontal distances between + * the circle centers. + */ + Point D = X1 - X0; + + /* Determine the straight-line distance between the centers. */ + double d = L2(D); + + /* Check for solvability. */ + if (d > (r0 + r1)) + { + /* no solution. circles do not intersect. */ + return 0; + } + if (d <= fabs(r0 - r1)) + { + /* no solution. one circle is contained in the other */ + return 1; + } + + /* 'point 2' is the point where the line through the circle + * intersection points crosses the line between the circle + * centers. + */ + + /* Determine the distance from point 0 to point 2. */ + double a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ; + + /* Determine the coordinates of point 2. */ + Point p2 = X0 + D * (a/d); + + /* Determine the distance from point 2 to either of the + * intersection points. + */ + double h = std::sqrt((r0*r0) - (a*a)); + + /* Now determine the offsets of the intersection points from + * point 2. + */ + Point r = (h/d)*rot90(D); + + /* Determine the absolute intersection points. */ + p0 = p2 + r; + p1 = p2 - r; + + return 2; +} } // namespace Geom @@ -121,7 +186,8 @@ enum LineJoinType { LINEJOIN_ROUND, LINEJOIN_EXTRP_MITER, LINEJOIN_MITER, - LINEJOIN_SPIRO + LINEJOIN_SPIRO, + LINEJOIN_EXTRP_MITER_ARC }; static const Util::EnumData LineJoinTypeData[] = { {LINEJOIN_BEVEL, N_("Beveled"), "bevel"}, @@ -129,6 +195,7 @@ static const Util::EnumData LineJoinTypeData[] = { {LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"}, {LINEJOIN_MITER, N_("Miter"), "miter"}, {LINEJOIN_SPIRO, N_("Spiro"), "spiro"}, +// {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, }; static const Util::EnumDataConverter LineJoinTypeConverter(LineJoinTypeData, sizeof(LineJoinTypeData)/sizeof(*LineJoinTypeData)); @@ -310,6 +377,78 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise derivs = reverse(B[prev_i]).valueAndDerivatives(0.,5); + for (unsigned deriv_n = 1, count = 0; deriv_n < derivs.size(); deriv_n++) { + Geom::Coord length = derivs[deriv_n].length(); + if ( ! Geom::are_near(length, 0) ) { + if (count == 0) { + tang0 = derivs[deriv_n] / length; + curv0 = length; // save the length of the tangent + count++; + } else { + //curv0 = length / curv0; // curvature = tangent' / tangent + break; // break out of for-loop + } + } + } + double r0 = curv0; + Geom::Point center0 = B[prev_i].at1() - r0*tang0.ccw(); + circle0 = Geom::Circle(center0, r0); + } + { + Geom::Point tang1(0.,0.); + Geom::Coord curv1 = 0; + std::vector derivs = B[i].valueAndDerivatives(0.,5); + for (unsigned deriv_n = 1, count = 0; deriv_n < derivs.size(); deriv_n++) { + Geom::Coord length = derivs[deriv_n].length(); + if ( ! Geom::are_near(length, 0) ) { + if (count == 0) { + tang1 = derivs[deriv_n] / length; + curv1 = length; // save the length of the tangent + count++; + } else { + //curv1 = length / curv1; // curvature = tangent' / tangent + break; // break out of for-loop + } + } + } + double r1 = curv1; + Geom::Point center1 = B[i].at0() - r1*tang1.ccw(); + circle1 = Geom::Circle(center1, r1); + } + + Geom::Point points[2]; + int solutions = circle_circle_intersection(circle0, circle1, points[0], points[1]); + if (solutions == 2) { + Geom::EllipticalArc *arc0 = circle0.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+B[i].at0()), points[0], true); + Geom::EllipticalArc *arc1 = circle1.arc(points[0], 0.5*(B[prev_i].at1()+B[i].at0()), B[i].at0(), true); + + if (arc0) { + build_from_sbasis(pb,arc0->toSBasis(), tol, false); + delete arc0; + arc0 = NULL; + } + if (arc1) { + build_from_sbasis(pb,arc1->toSBasis(), tol, false); + delete arc1; + arc1 = NULL; + } + } else if (solutions == 1) { // one circle is inside the other + // don't know what to do: default to bevel + pb.lineTo(B[i].at0()); + } else { // no intersections + // don't know what to do: default to bevel + pb.lineTo(B[i].at0()); + } + + break; + } case LINEJOIN_MITER: { boost::optional p = intersection_point( B[prev_i].at1(), tang1, B[i].at0(), tang2 ); -- cgit v1.2.3 From c48285ed644898a01d698ca67b6cfdbbe80573b4 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 6 Oct 2012 16:54:38 -0400 Subject: emf import. support for PATCOPY in EMR_BITBLT (Bug 1060141) Fixed bugs: - https://launchpad.net/bugs/1060141 (bzr r11743) --- src/extension/internal/emf-win32-inout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 7593a4806..2097402c7 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -1815,7 +1815,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * dbg_str << "\n"; PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR; - if (pEmr->dwRop == DPA) { + if ((pEmr->dwRop == PATCOPY) || (pEmr->dwRop == DPA)) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest); double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest); -- cgit v1.2.3 From c4e83e0bd3505b0c8d6b3f466ed75394cb34acd2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 7 Oct 2012 15:03:13 +0200 Subject: i18n. Adding gradient selector widget labels. (bzr r11745) --- src/widgets/gradient-selector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 082f04a77..dffda69e3 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -143,13 +143,13 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) sel->icon_renderer = Gtk::manage(new Gtk::CellRendererPixbuf()); sel->text_renderer = Gtk::manage(new Gtk::CellRendererText()); - sel->treeview->append_column("Gradient", *sel->icon_renderer); + sel->treeview->append_column(_("Gradient"), *sel->icon_renderer); Gtk::TreeView::Column* icon_column = sel->treeview->get_column(0); icon_column->add_attribute(sel->icon_renderer->property_pixbuf(), sel->columns->pixbuf); icon_column->set_sort_column(sel->columns->color); icon_column->set_clickable(true); - sel->treeview->append_column("Name", *sel->text_renderer); + sel->treeview->append_column(_("Name"), *sel->text_renderer); Gtk::TreeView::Column* name_column = sel->treeview->get_column(1); sel->text_renderer->property_editable() = true; name_column->add_attribute(sel->text_renderer->property_text(), sel->columns->name); -- cgit v1.2.3 From 274930257ebf311fe2c5b6d4f06a46ed79669977 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 7 Oct 2012 18:59:42 +0200 Subject: powerstroke: arc extrapolate fix (bzr r11748) --- src/live_effects/lpe-powerstroke.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 698c09bcf..21fc5c869 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -195,7 +195,9 @@ static const Util::EnumData LineJoinTypeData[] = { {LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"}, {LINEJOIN_MITER, N_("Miter"), "miter"}, {LINEJOIN_SPIRO, N_("Spiro"), "spiro"}, -// {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, +#ifdef LPE_ENABLE_TEST_EFFECTS + {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, +#endif }; static const Util::EnumDataConverter LineJoinTypeConverter(LineJoinTypeData, sizeof(LineJoinTypeData)/sizeof(*LineJoinTypeData)); @@ -426,8 +428,8 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::PiecewisetoSBasis(), tol, false); -- cgit v1.2.3 From c37bac565d73ab069263873307286eb19641b99c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 7 Oct 2012 19:41:26 +0200 Subject: Translations. Fix for Bug #425202 (Script messages not translated). (bzr r11749) --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index d1e087cac..578279929 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -625,6 +625,8 @@ main(int argc, char **argv) bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR("")); # else bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); + // needed by Python/Gettext + g_setenv("PACKAGE_LOCALE_DIR", PACKAGE_LOCALE_DIR, TRUE); # endif #endif -- cgit v1.2.3 From e95285010790e159177c24b1061047812f5dcf84 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 7 Oct 2012 19:46:44 +0200 Subject: Typo fix by Yuri Chornoivan. (bzr r11750) --- src/extension/internal/filter/color.h | 2 +- src/ui/dialog/inkscape-preferences.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 22b77a8cc..785059cca 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -637,7 +637,7 @@ public: "<_item value=\"g\">" N_("Green") "\n" "<_item value=\"b\">" N_("Blue") "\n" "<_item value=\"c\">" N_("Cyan") "\n" - "<_item value=\"m\">" N_("Majenta") "\n" + "<_item value=\"m\">" N_("Magenta") "\n" "<_item value=\"y\">" N_("Yellow") "\n" "\n" "\n" diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index bbaaecfd4..ce73f47f1 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -480,7 +480,7 @@ void InkscapePreferences::initPageTools() _misc_gradientangle.init("/dialogs/gradienteditor/angle", -359, 359, 1, 90, 0, false, false); _page_gradient.add_line( false, _("Linear gradient _angle:"), _misc_gradientangle, "", - _("Default angle of new linear gradients in degrees (clockwise from horizontal"), false); + _("Default angle of new linear gradients in degrees (clockwise from horizontal)"), false); //Dropper -- cgit v1.2.3 From f8f503f3f0150b96d34625ef8c604fb9ed552407 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 7 Oct 2012 20:44:28 +0200 Subject: powerstroke: arc extrp. corner case handling (bzr r11751) --- src/live_effects/lpe-powerstroke.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 21fc5c869..df94a761e 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -28,6 +28,7 @@ #include <2geom/path-intersection.h> #include <2geom/crossing.h> #include <2geom/ellipse.h> +#include <2geom/math-utils.h> #include #include "spiro.h" @@ -382,8 +383,9 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise derivs = reverse(B[prev_i]).valueAndDerivatives(0.,5); for (unsigned deriv_n = 1, count = 0; deriv_n < derivs.size(); deriv_n++) { @@ -394,17 +396,25 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise= 0 ) { + norm0 = tang0.ccw(); + } else { + norm0 = tang0.cw(); + } break; // break out of for-loop } } } double r0 = curv0; - Geom::Point center0 = B[prev_i].at1() - r0*tang0.ccw(); + Geom::Point center0 = B[prev_i].at1() - r0*norm0; circle0 = Geom::Circle(center0, r0); } + Geom::Point tang1(0.,0.); { - Geom::Point tang1(0.,0.); + Geom::Point norm1(0.,0.); Geom::Coord curv1 = 0; std::vector derivs = B[i].valueAndDerivatives(0.,5); for (unsigned deriv_n = 1, count = 0; deriv_n < derivs.size(); deriv_n++) { @@ -416,20 +426,31 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise= 0 ) { + norm1 = tang1.ccw(); + } else { + norm1 = tang1.cw(); + } break; // break out of for-loop } } } double r1 = curv1; - Geom::Point center1 = B[i].at0() - r1*tang1.ccw(); + Geom::Point center1 = B[i].at0() - r1*norm1; circle1 = Geom::Circle(center1, r1); } Geom::Point points[2]; int solutions = circle_circle_intersection(circle0, circle1, points[0], points[1]); if (solutions == 2) { - Geom::EllipticalArc *arc0 = circle0.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+points[0]), points[0], true); - Geom::EllipticalArc *arc1 = circle1.arc(points[0], 0.5*(points[0]+B[i].at0()), B[i].at0(), true); + Geom::Point sol = points[0]; + if ( dot(tang0,sol-B[prev_i].at1()) > 0 ) { + sol = points[1]; + } + Geom::EllipticalArc *arc0 = circle0.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+sol), sol, true); + Geom::EllipticalArc *arc1 = circle1.arc(sol, 0.5*(sol+B[i].at0()), B[i].at0(), true); if (arc0) { build_from_sbasis(pb,arc0->toSBasis(), tol, false); -- cgit v1.2.3 From c2901751674aaf09964bb3d2c0e08de5aefdcd2c Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 8 Oct 2012 20:52:24 +0900 Subject: Fix for 1060563 : Swatches : Sort the list of swatch names (bzr r11757) --- src/ui/dialog/swatches.cpp | 47 ++++++++++++++++++++++++++++++---------------- src/ui/widget/panel.cpp | 1 + 2 files changed, 32 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 3baba3460..9d5a2ac28 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -62,10 +62,10 @@ namespace Dialogs { #define VBLOCK 16 #define PREVIEW_PIXBUF_WIDTH 128 -void _loadPaletteFile( gchar const *filename ); +void _loadPaletteFile( gchar const *filename, gboolean user=FALSE ); - -std::vector possible; +std::list userSwatchPages; +std::list systemSwatchPages; static std::map docPalettes; static std::vector docTrackings; static std::map docPerPanel; @@ -391,7 +391,7 @@ static bool parseNum( char*& str, int& val ) { } -void _loadPaletteFile( gchar const *filename ) +void _loadPaletteFile( gchar const *filename, gboolean user/*=FALSE*/ ) { char block[1024]; FILE *f = Inkscape::IO::fopen_utf8name( filename, "r" ); @@ -493,7 +493,10 @@ void _loadPaletteFile( gchar const *filename ) } } while ( result && !hasErr ); if ( !hasErr ) { - possible.push_back(onceMore); + if (user) + userSwatchPages.push_back(onceMore); + else + systemSwatchPages.push_back(onceMore); #if ENABLE_MAGIC_COLORS ColorItem::_wireMagicColors( onceMore ); #endif // ENABLE_MAGIC_COLORS @@ -507,9 +510,16 @@ void _loadPaletteFile( gchar const *filename ) } } +static bool +compare_swatch_names(SwatchPage const *a, SwatchPage const *b) { + + return g_utf8_collate(a->_name.c_str(), b->_name.c_str()) < 0; +} + static void loadEmUp() { static bool beenHere = false; + gboolean userPalete = true; if ( !beenHere ) { beenHere = true; @@ -521,7 +531,6 @@ static void loadEmUp() // Use this loop to iterate through a list of possible document locations. while (!sources.empty()) { gchar *dirname = sources.front(); - if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) { GError *err = 0; @@ -535,11 +544,13 @@ static void loadEmUp() while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) { gchar* lower = g_ascii_strdown( filename, -1 ); // if ( g_str_has_suffix(lower, ".gpl") ) { + if ( !g_str_has_suffix(lower, "~") ) { gchar* full = g_build_filename(dirname, filename, NULL); if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) { - _loadPaletteFile(full); + _loadPaletteFile(full, userPalete); } g_free(full); + } // } g_free(lower); } @@ -550,15 +561,15 @@ static void loadEmUp() // toss the dirname g_free(dirname); sources.pop_front(); + userPalete = false; } } -} - - - - + // Sort the list of swatches by name, grouped by user/system + userSwatchPages.sort(compare_swatch_names); + systemSwatchPages.sort(compare_swatch_names); +} @@ -592,7 +603,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : } loadEmUp(); - if ( !possible.empty() ) { + if ( !systemSwatchPages.empty() ) { SwatchPage* first = 0; int index = 0; Glib::ustring targetName; @@ -603,8 +614,9 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : if (targetName == "Auto") { first = docPalettes[0]; } else { - index++; - for ( std::vector::iterator iter = possible.begin(); iter != possible.end(); ++iter ) { + //index++; + std::vector pages = _getSwatchSets(); + for ( std::vector::iterator iter = pages.begin(); iter != pages.end(); ++iter ) { if ( (*iter)->_name == targetName ) { first = *iter; break; @@ -635,6 +647,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : hotItem = single; } _regItem( single, 3, i ); + i++; } } @@ -1027,6 +1040,7 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) } } + std::vector SwatchesPanel::_getSwatchSets() const { std::vector tmp; @@ -1034,7 +1048,8 @@ std::vector SwatchesPanel::_getSwatchSets() const tmp.push_back(docPalettes[_currentDocument]); } - tmp.insert(tmp.end(), possible.begin(), possible.end()); + tmp.insert(tmp.end(), userSwatchPages.begin(), userSwatchPages.end()); + tmp.insert(tmp.end(), systemSwatchPages.begin(), systemSwatchPages.end()); return tmp; } diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 42435f298..dcf5956bf 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -560,6 +560,7 @@ void Panel::_regItem(Gtk::MenuItem* item, int group, int id) _menu->append(*item); item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &Panel::_bounceCall), group + PANEL_SETTING_NEXTFREE, id)); item->show(); + } void Panel::_handleAction(int /*set_id*/, int /*item_id*/) -- cgit v1.2.3 From aac03ec0fbc29057ed174647df1a735d43f443d2 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 8 Oct 2012 20:58:02 +0900 Subject: Fix for 303527 : GUI glitch on opacity box (bzr r11758) --- src/widgets/gradient-image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 3c84e606b..94918c614 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -127,7 +127,7 @@ static void sp_gradient_image_destroy(GtkObject *object) static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisition *requisition) { - requisition->width = 64; + requisition->width = 54; requisition->height = 12; } -- cgit v1.2.3 From 900d1a05ba36f84df3a51188b938a6551a5201d2 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 8 Oct 2012 21:00:57 +0900 Subject: Fix for 490338 : Try to create the autosave directory if that does not exists (bzr r11759) --- src/inkscape.cpp | 20 ++++++++++++++++++-- src/ui/dialog/inkscape-preferences.cpp | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index b1cc53b4e..0a94d0742 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -309,8 +309,24 @@ static gint inkscape_autosave(gpointer) GDir *autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL); if( !autosave_dir_ptr ){ - g_warning("Cannot open autosave directory!"); - return TRUE; + // Try to create the autosave directory if it doesn't exist + if (g_mkdir(autosave_dir.c_str(), 0755)) { + // the creation failed + Glib::ustring msg = Glib::ustring::format( + _("Autosave failed! Cannot create directory "), Glib::filename_to_utf8(autosave_dir)); + g_warning("%s", msg.c_str()); + SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg.c_str()); + return TRUE; + } + // Try to read dir again + autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL); + if( !autosave_dir_ptr ){ + Glib::ustring msg = Glib::ustring::format( + _("Autosave failed! Cannot open directory "), Glib::filename_to_utf8(autosave_dir)); + g_warning("%s", msg.c_str()); + SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg.c_str()); + return TRUE; + } } time_t sptime = time(NULL); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index ce73f47f1..2731b6174 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1046,7 +1046,7 @@ void InkscapePreferences::initPageIO() // Show the default fallback "tmp dir" if autosave path is not set. _save_autosave_path.set_text(Glib::get_tmp_dir()); } - _page_autosave.add_line(false, C_("Filesystem", "Autosave _directory:"), _save_autosave_path, "", _("The directory where autosaves will be written"), false); + _page_autosave.add_line(false, C_("Filesystem", "Autosave _directory:"), _save_autosave_path, "", _("The directory where autosaves will be written. This should be an absolute path (starts with / on UNIX or a drive letter such as C: on Windows). "), false); _save_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false); _page_autosave.add_line(false, _("_Interval (in minutes):"), _save_autosave_interval, "", _("Interval (in minutes) at which document will be autosaved"), false); _save_autosave_max.init("/options/autosave/max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false); -- cgit v1.2.3 From 1208e5f7938731244720438bff526c0b6e07c54f Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 9 Oct 2012 15:26:18 +0900 Subject: Fix for 191020 : Lock/Unlock all layers (bzr r11764) --- src/desktop.cpp | 13 +++++++++++-- src/desktop.h | 3 ++- src/ui/dialog/layers.cpp | 17 +++++++++++++++++ src/verbs.cpp | 20 +++++++++++++++++--- src/verbs.h | 2 ++ 5 files changed, 49 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index ca981a458..b01bf5d64 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -496,13 +496,22 @@ void SPDesktop::setCurrentLayer(SPObject *object) { _layer_hierarchy->setBottom(object); } -void SPDesktop::toggleAllLayers(bool hide) { +void SPDesktop::toggleHideAllLayers(bool hide) { - for ( SPObject* obj = currentRoot(); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { SP_ITEM(obj)->setHidden(hide); } } +void SPDesktop::toggleLockAllLayers(bool lock) { + + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + SP_ITEM(obj)->setLocked(lock); + } +} + + + void SPDesktop::toggleLayerSolo(SPObject *object) { g_return_if_fail(SP_IS_GROUP(object)); g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); diff --git a/src/desktop.h b/src/desktop.h index 919cd905e..3eb0294e7 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -280,7 +280,8 @@ public: void setCurrentLayer(SPObject *object); void toggleLayerSolo(SPObject *object); - void toggleAllLayers(bool hidden); + void toggleHideAllLayers(bool hide); + void toggleLockAllLayers(bool lock); SPObject *layerForObject(SPObject *object); bool isLayer(SPObject *object) const; bool isWithinViewport(SPItem *item) const; diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 70cf7075c..44eef89bb 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -69,6 +69,8 @@ enum { BUTTON_SOLO, BUTTON_SHOW_ALL, BUTTON_HIDE_ALL, + BUTTON_LOCK_ALL, + BUTTON_UNLOCK_ALL, DRAGNDROP }; @@ -263,6 +265,16 @@ bool LayersPanel::_executeAction() _fireAction( SP_VERB_LAYER_HIDE_ALL ); } break; + case BUTTON_LOCK_ALL: + { + _fireAction( SP_VERB_LAYER_LOCK_ALL ); + } + break; + case BUTTON_UNLOCK_ALL: + { + _fireAction( SP_VERB_LAYER_UNLOCK_ALL ); + } + break; case DRAGNDROP: { _doTreeMove( ); @@ -876,6 +888,11 @@ LayersPanel::LayersPanel() : _popupMenu.append(*manage(new Gtk::SeparatorMenuItem())); + _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())); + _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, "Up", (int)BUTTON_UP ) ); _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, "Down", (int)BUTTON_DOWN ) ); diff --git a/src/verbs.cpp b/src/verbs.cpp index edfc45f8e..591280d47 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1342,17 +1342,27 @@ void LayerVerb::perform(SPAction *action, void *data) break; } case SP_VERB_LAYER_SHOW_ALL: { - dt->toggleAllLayers( false ); + dt->toggleHideAllLayers( false ); DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:showall", SP_VERB_LAYER_SHOW_ALL, _("Show all layers")); break; } - case SP_VERB_LAYER_HIDE_ALL: { - dt->toggleAllLayers( true ); + dt->toggleHideAllLayers( true ); DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:hideall", SP_VERB_LAYER_HIDE_ALL, _("Hide all layers")); break; } + case SP_VERB_LAYER_LOCK_ALL: { + dt->toggleLockAllLayers( true ); + DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:lockall", SP_VERB_LAYER_LOCK_ALL, _("Lock all layers")); + break; + } + + case SP_VERB_LAYER_UNLOCK_ALL: { + dt->toggleLockAllLayers( false ); + DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:unlockall", SP_VERB_LAYER_UNLOCK_ALL, _("Unlock all layers")); + break; + } case SP_VERB_LAYER_TOGGLE_LOCK: case SP_VERB_LAYER_TOGGLE_HIDE: { if ( dt->currentLayer() == dt->currentRoot() ) { @@ -2489,6 +2499,10 @@ Verb *Verb::_base_verbs[] = { N_("Show all the layers"), NULL), new LayerVerb(SP_VERB_LAYER_HIDE_ALL, "LayerHideAll", N_("_Hide all layers"), N_("Hide all the layers"), NULL), + new LayerVerb(SP_VERB_LAYER_LOCK_ALL, "LayerLockAll", N_("_Lock all layers"), + N_("Lock all the layers"), NULL), + new LayerVerb(SP_VERB_LAYER_UNLOCK_ALL, "LayerUnlockAll", N_("_Unlock all layers"), + N_("Unlock all the layers"), NULL), new LayerVerb(SP_VERB_LAYER_TOGGLE_LOCK, "LayerToggleLock", N_("_Lock/Unlock Current Layer"), N_("Toggle lock on current layer"), NULL), new LayerVerb(SP_VERB_LAYER_TOGGLE_HIDE, "LayerToggleHide", N_("_Show/hide Current Layer"), diff --git a/src/verbs.h b/src/verbs.h index aa801803c..e8b271a18 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -149,6 +149,8 @@ enum { SP_VERB_LAYER_SOLO, SP_VERB_LAYER_SHOW_ALL, SP_VERB_LAYER_HIDE_ALL, + SP_VERB_LAYER_LOCK_ALL, + SP_VERB_LAYER_UNLOCK_ALL, SP_VERB_LAYER_TOGGLE_LOCK, SP_VERB_LAYER_TOGGLE_HIDE, /* Object */ -- cgit v1.2.3 From cc88abe36edd7dd478d4264742f61dd97ac5256b Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 9 Oct 2012 12:53:42 +0200 Subject: UI consistency fix (pointed Bug #955060, comment #24). (bzr r11768) --- src/live_effects/lpe-powerstroke.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index df94a761e..9fce832ab 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -209,7 +209,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : interpolator_type(_("Interpolator type:"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), interpolator_beta(_("Smoothness:"), _("Sets the smoothness for the CubicBezierJohan interpolator; 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), start_linecap_type(_("Start cap:"), _("Determines the shape of the path's start"), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), - linejoin_type(_("Join:"), _("Specifies the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), + linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), miter_limit(_("Miter limit:"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.), end_linecap_type(_("End cap:"), _("Determines the shape of the path's end"), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) { -- cgit v1.2.3 From 66aa9095eba57e263fff225583c7cbfff121a09d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 9 Oct 2012 13:36:06 +0200 Subject: Fix for Bug #1063831 (--export-text-to-path with SVG is undocumented) by Philipp Hagemeister. Greek and French man page translations updated. (bzr r11769) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 578279929..844aded56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -390,7 +390,7 @@ struct poptOption options[] = { {"export-text-to-path", 'T', POPT_ARG_NONE, &sp_export_text_to_path, SP_ARG_EXPORT_TEXT_TO_PATH, - N_("Convert text object to paths on export (PS, EPS, PDF)"), + N_("Convert text object to paths on export (PS, EPS, PDF, SVG)"), NULL}, {"export-ignore-filters", 0, -- cgit v1.2.3 From edf55384619442eed0ffee95e0eaa9b565477b86 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 9 Oct 2012 20:44:34 +0200 Subject: fix memory leak and access error in sp_repr_css_merge_from_decl (Bug #1061157) (bzr r11771) --- src/xml/repr-css.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 7fba4d7c6..f554d314d 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -351,7 +351,8 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con guchar *const str_value_unsigned = cr_term_to_string(decl->value); gchar *const str_value = reinterpret_cast(str_value_unsigned); gchar *value_unquoted = attribute_unquote (str_value); // libcroco returns strings quoted in "" - gchar *units = NULL; + Glib::ustring value_unquoted2 = value_unquoted ? value_unquoted : Glib::ustring(); + Glib::ustring units; /* * Problem with parsing of units em and ex, like font-size "1.2em" and "3.4ex" @@ -360,18 +361,22 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con * * HACK for now is to strip off em and ex units and add them back at the end */ - int l = strlen(value_unquoted); - if (!strncmp(&value_unquoted[l-2], "em", 2) || - !strncmp(&value_unquoted[l-2], "ex", 2)) { - units = g_strndup(&value_unquoted[l-2], 2); - value_unquoted = g_strndup(value_unquoted, l-2); + int le = value_unquoted2.length(); + if (le > 2) { + units = value_unquoted2.substr(le-2, 2); + if ((units == "em") || (units == "ex")) { + value_unquoted2 = value_unquoted2.substr(0, le-2); + } + else { + units.clear(); + } } // libcroco uses %.17f for formatting... leading to trailing zeros or small rounding errors. // CSSOStringStream is used here to write valid CSS (as in sp_style_write_string). This has // the additional benefit of respecting the numerical precission set in the SVG Output // preferences. We assume any numerical part comes first (if not, the whole string is copied). - std::stringstream ss( value_unquoted ); + std::stringstream ss( value_unquoted2 ); double number = 0; std::string characters; std::string temp; @@ -385,10 +390,9 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con Inkscape::CSSOStringStream os; if( number_valid ) os << number; os << characters; - if (units) { + if (!units.empty()) { os << units; //g_message("sp_repr_css_merge_from_decl looks like em or ex units %s --> %s", str_value, os.str().c_str()); - g_free(units); } ((Node *) css)->setAttribute(decl->property->stryng->str, os.str().c_str(), false); g_free(value_unquoted); -- cgit v1.2.3 From fab4c86f1347c48c3e87d645343faf0b167ea635 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 9 Oct 2012 21:26:18 +0200 Subject: Fix translation issue of rev 11759. (bzr r11772) --- src/inkscape.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 0a94d0742..fc9a9783f 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -312,8 +312,8 @@ static gint inkscape_autosave(gpointer) // Try to create the autosave directory if it doesn't exist if (g_mkdir(autosave_dir.c_str(), 0755)) { // the creation failed - Glib::ustring msg = Glib::ustring::format( - _("Autosave failed! Cannot create directory "), Glib::filename_to_utf8(autosave_dir)); + Glib::ustring msg = Glib::ustring::compose( + _("Autosave failed! Cannot create directory %1."), Glib::filename_to_utf8(autosave_dir)); g_warning("%s", msg.c_str()); SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg.c_str()); return TRUE; @@ -321,8 +321,8 @@ static gint inkscape_autosave(gpointer) // Try to read dir again autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL); if( !autosave_dir_ptr ){ - Glib::ustring msg = Glib::ustring::format( - _("Autosave failed! Cannot open directory "), Glib::filename_to_utf8(autosave_dir)); + Glib::ustring msg = Glib::ustring::compose( + _("Autosave failed! Cannot open directory %1."), Glib::filename_to_utf8(autosave_dir)); g_warning("%s", msg.c_str()); SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg.c_str()); return TRUE; -- cgit v1.2.3 From 665bcd1dd1dce0b5a99725ab1bc9414b3760d044 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 10 Oct 2012 23:21:29 +0200 Subject: powerstroke: fix stuff! (apparently commit didn't work yesterday) (bzr r11774) --- src/live_effects/lpe-powerstroke.cpp | 129 +++++++++++++++++------------------ 1 file changed, 61 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 9fce832ab..13fea76c5 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -153,6 +153,32 @@ static int circle_circle_intersection(Circle const &circle0, Circle const &circl return 2; } +/** + * Find circle that touches inside of the curve, with radius matching the curvature, at time value \c t. + * Because this method internally uses unitTangentAt, t should be smaller than 1.0 (see unitTangentAt). + */ +Circle touching_circle( D2 const &curve, double t, double tol=0.01 ) +{ + //Piecewise k = curvature(curve, tol); + D2 dM=derivative(curve); + if ( are_near(L2sq(dM(t)),0.) ) { + dM=derivative(dM); + } + if ( are_near(L2sq(dM(t)),0.) ) { // try second time + dM=derivative(dM); + } + Piecewise > unitv = unitVector(dM,tol); + Piecewise dMlength = dot(Piecewise >(dM),unitv); + Piecewise k = cross(derivative(unitv),unitv); + k = divide(k,dMlength,tol,3); + double curv = k(t); // note that this value is signed + + Geom::Point normal = unitTangentAt(curve, t).cw(); + double radius = 1/curv; + Geom::Point center = curve(t) + radius*normal; + return Geom::Circle(center, fabs(radius)); +} + } // namespace Geom namespace Inkscape { @@ -381,76 +407,26 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise derivs = reverse(B[prev_i]).valueAndDerivatives(0.,5); - for (unsigned deriv_n = 1, count = 0; deriv_n < derivs.size(); deriv_n++) { - Geom::Coord length = derivs[deriv_n].length(); - if ( ! Geom::are_near(length, 0) ) { - if (count == 0) { - tang0 = derivs[deriv_n] / length; - curv0 = length; // save the length of the tangent - count++; - } else { - // curv0 = need good way to calculate curvature - // calculate direction of normal - double angle = angle_between(tang0, derivs[deriv_n]); - if (angle >= 0 ) { - norm0 = tang0.ccw(); - } else { - norm0 = tang0.cw(); - } - break; // break out of for-loop - } - } - } - double r0 = curv0; - Geom::Point center0 = B[prev_i].at1() - r0*norm0; - circle0 = Geom::Circle(center0, r0); - } - Geom::Point tang1(0.,0.); - { - Geom::Point norm1(0.,0.); - Geom::Coord curv1 = 0; - std::vector derivs = B[i].valueAndDerivatives(0.,5); - for (unsigned deriv_n = 1, count = 0; deriv_n < derivs.size(); deriv_n++) { - Geom::Coord length = derivs[deriv_n].length(); - if ( ! Geom::are_near(length, 0) ) { - if (count == 0) { - tang1 = derivs[deriv_n] / length; - curv1 = length; // save the length of the tangent - count++; - } else { - //curv1 = length / curv1; // curvature = tangent' / tangent - // calculate direction of normal - double angle = angle_between(tang1, derivs[deriv_n]); - if (angle >= 0 ) { - norm1 = tang1.ccw(); - } else { - norm1 = tang1.cw(); - } - break; // break out of for-loop - } - } - } - double r1 = curv1; - Geom::Point center1 = B[i].at0() - r1*norm1; - circle1 = Geom::Circle(center1, r1); - } - + Geom::Circle circle1 = Geom::touching_circle(reverse(B[prev_i]),0.); + Geom::Circle circle2 = Geom::touching_circle(B[i],0.); Geom::Point points[2]; - int solutions = circle_circle_intersection(circle0, circle1, points[0], points[1]); + int solutions = circle_circle_intersection(circle1, circle2, points[0], points[1]); if (solutions == 2) { - Geom::Point sol = points[0]; - if ( dot(tang0,sol-B[prev_i].at1()) > 0 ) { + Geom::Point sol(0.,0.); + if ( dot(tang2,points[0]-B[i].at0()) > 0 ) { + // points[0] is bad, choose points[1] sol = points[1]; + } else if ( dot(tang2,points[1]-B[i].at0()) > 0 ) { // points[0] could be good, now check points[1] + // points[1] is bad, choose points[0] + sol = points[0]; + } else { + // both points are good, choose nearest + sol = ( distanceSq(B[i].at0(), points[0]) < distanceSq(B[i].at0(), points[1]) ) ? + points[0] : points[1]; } - Geom::EllipticalArc *arc0 = circle0.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+sol), sol, true); - Geom::EllipticalArc *arc1 = circle1.arc(sol, 0.5*(sol+B[i].at0()), B[i].at0(), true); + + Geom::EllipticalArc *arc0 = circle1.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+sol), sol, true); + Geom::EllipticalArc *arc1 = circle2.arc(sol, 0.5*(sol+B[i].at0()), B[i].at0(), true); if (arc0) { build_from_sbasis(pb,arc0->toSBasis(), tol, false); @@ -462,13 +438,30 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise p = intersection_point( B[prev_i].at1(), tang1, + B[i].at0(), tang2 ); + if (p) { + // check size of miter + Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width; + Geom::Coord len = distance(*p, point_on_path); + if (len <= fabs(width) * miter_limit) { + // miter OK + pb.lineTo(*p); + } + } + pb.lineTo(B[i].at0()); + } + /*else if (solutions == 1) { // one circle is inside the other // don't know what to do: default to bevel pb.lineTo(B[i].at0()); } else { // no intersections // don't know what to do: default to bevel pb.lineTo(B[i].at0()); - } + } */ break; } -- cgit v1.2.3 From df6576d515c2618b9bc79226e6164e7d935a508b Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 10 Oct 2012 18:26:40 -0400 Subject: emf import. re-implement filtering of isolated control characters (Bug 217231) Fixed bugs: - https://launchpad.net/bugs/217231 (bzr r11775) --- src/extension/internal/emf-win32-inout.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 2097402c7..872de045a 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -1905,6 +1905,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * (gchar *) g_utf16_to_utf8( (gunichar2 *) wide_text, pEmr->emrtext.nChars, NULL, NULL, NULL ); if (ansi_text) { + if ((wide_text[0] < 32) && (strlen(ansi_text) == 1)) { + g_free(ansi_text); // filter out isolated control characters + ansi_text = g_strdup(""); + } // gchar *p = ansi_text; // while (*p) { // if (*p < 32 || *p >= 127) { -- cgit v1.2.3 From b79646b8d32b6f842f8dcc6ce5a0b7171f28a7bb Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 11 Oct 2012 11:27:07 +0900 Subject: Fix for 246153 : Broken style indicator (bzr r11776) --- src/widgets/toolbox.cpp | 2 +- src/widgets/widget-sizes.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 49eb82de7..6e03c2606 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1446,7 +1446,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) swatch->setClickVerb( aux_toolboxes[i].swatch_verb_id ); swatch->setWatchedTool( aux_toolboxes[i].swatch_tool, true ); GtkWidget *swatch_ = GTK_WIDGET( swatch->gobj() ); - gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, 0 ); + gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, AUX_SPACING ); } gtk_widget_show_all( holder ); diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h index c3f9e1119..7de251ee6 100644 --- a/src/widgets/widget-sizes.h +++ b/src/widgets/widget-sizes.h @@ -31,7 +31,7 @@ #define SELECTED_STYLE_SB_WIDTH 48 #define SELECTED_STYLE_WIDTH 190 -#define STYLE_SWATCH_WIDTH 100 +#define STYLE_SWATCH_WIDTH 130 #define STATUS_LAYER_FONT_SIZE 7700 -- cgit v1.2.3 From 05c9f6824d14012a71528bd204bcdd4e6624db29 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 11 Oct 2012 12:34:08 +0900 Subject: Fix for 426763 : Cancelling import leads to error message (bzr r11777) --- src/extension/implementation/implementation.h | 1 + src/extension/input.cpp | 7 +++++-- src/extension/input.h | 4 ++++ src/extension/internal/pdfinput/pdf-input.cpp | 8 ++++++++ src/extension/internal/pdfinput/pdf-input.h | 4 +++- src/extension/system.cpp | 1 + src/file.cpp | 8 +++++++- 7 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index b0230b7c4..fb323cd78 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -104,6 +104,7 @@ public: virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; } virtual bool cancelProcessing () { return true; } + virtual bool wasCancelled () { return false; } virtual void commitDocument () {} // ----- Input functions ----- diff --git a/src/extension/input.cpp b/src/extension/input.cpp index 1662ef073..5cef38009 100644 --- a/src/extension/input.cpp +++ b/src/extension/input.cpp @@ -152,6 +152,10 @@ Input::open (const gchar *uri) SPDocument *const doc = imp->open(this, uri); + if (imp->wasCancelled()) { + throw Input::open_cancelled(); + } + return doc; } @@ -227,8 +231,7 @@ Input::prefs (const gchar *uri) delete dialog; - if (response == Gtk::RESPONSE_OK) return true; - return false; + return (response == Gtk::RESPONSE_OK); } } } /* namespace Inkscape, Extension */ diff --git a/src/extension/input.h b/src/extension/input.h index 8b198495e..b01ffeb86 100644 --- a/src/extension/input.h +++ b/src/extension/input.h @@ -39,6 +39,10 @@ public: virtual ~no_extension_found() throw() {} const char *what() const throw() { return "No suitable input extension found"; } }; + struct open_cancelled : public std::exception { + virtual ~open_cancelled() throw() {} + const char *what() const throw() { return "Open was cancelled"; } + }; Input (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp); diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 6b6107444..d2d594017 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -588,12 +588,19 @@ void PdfImportDialog::_setPreviewPage(int page) { //////////////////////////////////////////////////////////////////////////////// +bool +PdfInput::wasCancelled () { + return _cancelled; +} + /** * Parses the selected page of the given PDF document using PdfParser. */ SPDocument * PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { + _cancelled = false; + // Initialize the globalParams variable for poppler if (!globalParams) { globalParams = new GlobalParams(); @@ -648,6 +655,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { if (inkscape_use_gui()) { dlg = new PdfImportDialog(pdf_doc, uri); if (!dlg->showDialog()) { + _cancelled = true; delete dlg; delete pdf_doc; return NULL; diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 75fcfa69a..e9da5b27c 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -135,7 +135,9 @@ public: SPDocument *open( Inkscape::Extension::Input *mod, const gchar *uri ); static void init( void ); - + virtual bool wasCancelled(); +private: + bool _cancelled; }; } // namespace Implementation diff --git a/src/extension/system.cpp b/src/extension/system.cpp index fc20095c5..7fb6e1591 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -144,6 +144,7 @@ SPDocument *open(Extension *key, gchar const *filename) } SPDocument *doc = imod->open(filename); + if (!doc) { throw Input::open_failed(); } diff --git a/src/file.cpp b/src/file.cpp index 778306d5d..a03c459da 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -235,12 +235,16 @@ bool sp_file_open(const Glib::ustring &uri, } SPDocument *doc = NULL; + bool cancelled = false; try { doc = Inkscape::Extension::open(key, uri.c_str()); } catch (Inkscape::Extension::Input::no_extension_found &e) { doc = NULL; } catch (Inkscape::Extension::Input::open_failed &e) { doc = NULL; + } catch (Inkscape::Extension::Input::open_cancelled &e) { + doc = NULL; + cancelled = true; } if (desktop) { @@ -287,7 +291,7 @@ bool sp_file_open(const Glib::ustring &uri, } return TRUE; - } else { + } else if (!cancelled) { gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str()); gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), safeUri); sp_ui_error_dialog(text); @@ -295,6 +299,8 @@ bool sp_file_open(const Glib::ustring &uri, g_free(safeUri); return FALSE; } + + return FALSE; } /** -- cgit v1.2.3 From 3ca2c298a152f092b99d0c9978a47deec787ed8c Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 11 Oct 2012 17:03:21 +0900 Subject: Fix for 171904 : toggleToolbox verb (bzr r11778) --- src/desktop.cpp | 13 ++++++++++++- src/desktop.h | 1 + src/interface.cpp | 39 ++++++++++++++++++--------------------- src/interface.h | 1 + src/verbs.cpp | 25 +++++++++++++++++++++++++ src/verbs.h | 7 +++++++ 6 files changed, 64 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index b01bf5d64..bfec523db 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -55,6 +55,7 @@ #include "document.h" #include "event-log.h" #include "helper/units.h" +#include "interface.h" #include "inkscape-private.h" #include "layer-fns.h" #include "layer-manager.h" @@ -1318,6 +1319,17 @@ SPDesktop::toggleScrollbars() _widget->toggleScrollbars(); } + +void SPDesktop::toggleToolbar(gchar const *toolbar_name) +{ + Glib::ustring pref_path = getLayoutPrefPath(this) + toolbar_name + "/state"; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gboolean visible = prefs->getBool(pref_path, true); + prefs->setBool(pref_path, !visible); + + layoutWidget(); +} + void SPDesktop::layoutWidget() { @@ -1474,7 +1486,6 @@ void SPDesktop::toggleSnapGlobal() namedview->setSnapGlobal(!v); } - //---------------------------------------------------------------------- // Callback implementations. The virtual ones are connected by the view. diff --git a/src/desktop.h b/src/desktop.h index 3eb0294e7..958e881ed 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -365,6 +365,7 @@ public: void toggleSnapGlobal(); bool gridsEnabled() const { return grids_visible; }; void showGrids(bool show, bool dirty_document = true); + void toggleToolbar(gchar const *toolbar_name); bool is_iconified(); bool is_maximized(); diff --git a/src/interface.cpp b/src/interface.cpp index 2ee188ef7..bad95adc6 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -527,7 +527,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb } // end of sp_ui_menu_append_item_from_verb -static Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view ) +Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view ) { Glib::ustring prefPath; @@ -554,7 +554,7 @@ checkitem_toggled(GtkCheckMenuItem *menuitem, gpointer user_data) sp_ui_menu_activate(menuitem, action); } else if (pref) { - // The Show/Hide menu items without actions + // All check menu items should have actions now, but just in case Glib::ustring pref_path = getLayoutPrefPath( view ); pref_path += pref; pref_path += "/state"; @@ -596,19 +596,16 @@ static gboolean checkitem_update(GtkWidget *widget, GdkEventExpose * /*event*/, if (!strcmp(action->id, "ToggleGrid")) { ison = dt->gridsEnabled(); } - if (!strcmp(action->id, "ToggleGuides")) { + else if (!strcmp(action->id, "ToggleGuides")) { ison = dt->namedview->getGuides(); } - if (!strcmp(action->id, "ToggleSnapGlobal")) { + else if (!strcmp(action->id, "ToggleSnapGlobal")) { ison = dt->namedview->getSnapGlobal(); } - if (!strcmp(action->id, "ViewCmsToggle")) { + else if (!strcmp(action->id, "ViewCmsToggle")) { ison = dt->colorProfAdjustEnabled(); } - if (!strcmp(action->id, "ToggleRulers")) { - ison = getViewStateFromPref(view, pref); - } - if (!strcmp(action->id, "ToggleScrollbars")) { + else { ison = getViewStateFromPref(view, pref); } } else if (pref) { @@ -896,22 +893,22 @@ sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) { //sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu", // checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("_Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands", - checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("Sn_ap Controls Bar"), _("Show or hide the snapping controls"), "snaptoolbox", - checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("T_ool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel", - checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("_Toolbox"), _("Show or hide the main toolbox (on the left)"), "toolbox", - checkitem_toggled, checkitem_update, 0); + sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "commands", + checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_COMMANDS_TOOLBAR)); + sp_ui_menu_append_check_item_from_verb(m, view,NULL, NULL, "snaptoolbox", + checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_SNAP_TOOLBAR)); + sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "toppanel", + checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_TOOL_TOOLBAR)); + sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "toolbox", + checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_TOOLBOX)); sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "rulers", checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_RULERS)); sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "scrollbars", checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_SCROLLBARS)); - sp_ui_menu_append_check_item_from_verb(m, view, _("_Palette"), _("Show or hide the color palette"), "panels", - checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("_Statusbar"), _("Show or hide the statusbar (at the bottom of the window)"), "statusbar", - checkitem_toggled, checkitem_update, 0); + sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "panels", + checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_PALETTE)); + sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "statusbar", + checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_STATUSBAR)); } diff --git a/src/interface.h b/src/interface.h index 891e39957..2e9e7fc2e 100644 --- a/src/interface.h +++ b/src/interface.h @@ -81,6 +81,7 @@ GtkWidget *sp_ui_main_menubar (Inkscape::UI::View::View *view); void sp_menu_append_recent_documents (GtkWidget *menu); void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c); +Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view ); /** * diff --git a/src/verbs.cpp b/src/verbs.cpp index 591280d47..55d114e9d 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1785,6 +1785,24 @@ void ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_TOGGLE_SCROLLBARS: dt->toggleScrollbars(); break; + case SP_VERB_TOGGLE_COMMANDS_TOOLBAR: + dt->toggleToolbar("commands"); + break; + case SP_VERB_TOGGLE_SNAP_TOOLBAR: + dt->toggleToolbar("snaptoolbox"); + break; + case SP_VERB_TOGGLE_TOOL_TOOLBAR: + dt->toggleToolbar("toppanel"); + break; + case SP_VERB_TOGGLE_TOOLBOX: + dt->toggleToolbar("toolbox"); + break; + case SP_VERB_TOGGLE_PALETTE: + dt->toggleToolbar("panels"); + break; + case SP_VERB_TOGGLE_STATUSBAR: + dt->toggleToolbar("statusbar"); + break; case SP_VERB_TOGGLE_GUIDES: sp_namedview_toggle_guides(doc, repr); break; @@ -1843,6 +1861,7 @@ void ZoomVerb::perform(SPAction *action, void *data) inkscape_dialogs_unhide(); dt->_dlg_mgr->showDialog("IconPreviewPanel"); break; + default: break; } @@ -2646,6 +2665,12 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), INKSCAPE_ICON("show-grid")), new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), INKSCAPE_ICON("show-guides")), new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Enable snapping"), INKSCAPE_ICON("snap")), + new ZoomVerb(SP_VERB_TOGGLE_COMMANDS_TOOLBAR, "ToggleCommandsToolbar", N_("_Commands Bar"), N_("Show or hide the Commands bar (under the menu)"), NULL), + new ZoomVerb(SP_VERB_TOGGLE_SNAP_TOOLBAR, "ToggleSnapToolbar", N_("Sn_ap Controls Bar"), N_("Show or hide the snapping controls"), NULL), + new ZoomVerb(SP_VERB_TOGGLE_TOOL_TOOLBAR, "ToggleToolToolbar", N_("T_ool Controls Bar"), N_("Show or hide the Tool Controls bar"), NULL), + new ZoomVerb(SP_VERB_TOGGLE_TOOLBOX, "ToggleToolbox", N_("_Toolbox"), N_("Show or hide the main toolbox (on the left)"), NULL), + new ZoomVerb(SP_VERB_TOGGLE_PALETTE, "TogglePalette", N_("_Palette"), N_("Show or hide the color palette"), NULL), + new ZoomVerb(SP_VERB_TOGGLE_STATUSBAR, "ToggleStatusbar", N_("_Statusbar"), N_("Show or hide the statusbar (at the bottom of the window)"), NULL), new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"), INKSCAPE_ICON("zoom-next")), new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"), diff --git a/src/verbs.h b/src/verbs.h index e8b271a18..5a707ade3 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -224,6 +224,12 @@ enum { SP_VERB_TOGGLE_GRID, SP_VERB_TOGGLE_GUIDES, SP_VERB_TOGGLE_SNAPPING, + SP_VERB_TOGGLE_COMMANDS_TOOLBAR, + SP_VERB_TOGGLE_SNAP_TOOLBAR, + SP_VERB_TOGGLE_TOOL_TOOLBAR, + SP_VERB_TOGGLE_TOOLBOX, + SP_VERB_TOGGLE_PALETTE, + SP_VERB_TOGGLE_STATUSBAR, SP_VERB_ZOOM_NEXT, SP_VERB_ZOOM_PREV, SP_VERB_ZOOM_1_1, @@ -330,6 +336,7 @@ enum { SP_VERB_ALIGN_VERTICAL_BOTTOM, SP_VERB_ALIGN_VERTICAL_TOP_TO_ANCHOR, SP_VERB_ALIGN_VERTICAL_HORIZONTAL_CENTER, + /* Footer */ SP_VERB_LAST }; -- cgit v1.2.3 From c520388928f8cc85d91f24a2f01fa7549096fe83 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 11 Oct 2012 18:43:21 +0900 Subject: Fix for 191020 : Lock/Unlock all layers - Lock other layers (bzr r11779) --- src/desktop.cpp | 29 +++++++++++++++++++++++++++++ src/desktop.h | 1 + src/ui/dialog/layers.cpp | 7 +++++++ src/verbs.cpp | 13 +++++++++++-- src/verbs.h | 1 + 5 files changed, 49 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index bfec523db..fa0c8647f 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -511,6 +511,35 @@ void SPDesktop::toggleLockAllLayers(bool lock) { } } +void SPDesktop::toggleLockOtherLayers(SPObject *object) { + g_return_if_fail(SP_IS_GROUP(object)); + g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); + + bool othersLocked = false; + std::vector layers; + for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { + // Dont lock any ancestors, since that would in turn lock the layer as well + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersLocked |= !SP_ITEM(obj)->isLocked(); + } + } + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersLocked |= !SP_ITEM(obj)->isLocked(); + } + } + + SPItem *item = SP_ITEM(object); + if ( item->isLocked() ) { + item->setLocked(false); + } + + for ( std::vector::iterator it = layers.begin(); it != layers.end(); ++it ) { + SP_ITEM(*it)->setLocked(othersLocked); + } +} void SPDesktop::toggleLayerSolo(SPObject *object) { diff --git a/src/desktop.h b/src/desktop.h index 958e881ed..529199692 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -282,6 +282,7 @@ public: void toggleLayerSolo(SPObject *object); void toggleHideAllLayers(bool hide); void toggleLockAllLayers(bool lock); + void toggleLockOtherLayers(SPObject *object); SPObject *layerForObject(SPObject *object); bool isLayer(SPObject *object) const; bool isWithinViewport(SPItem *item) const; diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 44eef89bb..457f7c147 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -69,6 +69,7 @@ enum { BUTTON_SOLO, BUTTON_SHOW_ALL, BUTTON_HIDE_ALL, + BUTTON_LOCK_OTHERS, BUTTON_LOCK_ALL, BUTTON_UNLOCK_ALL, DRAGNDROP @@ -265,6 +266,11 @@ bool LayersPanel::_executeAction() _fireAction( SP_VERB_LAYER_HIDE_ALL ); } break; + case BUTTON_LOCK_OTHERS: + { + _fireAction( SP_VERB_LAYER_LOCK_OTHERS ); + } + break; case BUTTON_LOCK_ALL: { _fireAction( SP_VERB_LAYER_LOCK_ALL ); @@ -888,6 +894,7 @@ LayersPanel::LayersPanel() : _popupMenu.append(*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 ) ); diff --git a/src/verbs.cpp b/src/verbs.cpp index 55d114e9d..450b800c1 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1351,13 +1351,20 @@ void LayerVerb::perform(SPAction *action, void *data) DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:hideall", SP_VERB_LAYER_HIDE_ALL, _("Hide all layers")); break; } - case SP_VERB_LAYER_LOCK_ALL: { dt->toggleLockAllLayers( true ); DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:lockall", SP_VERB_LAYER_LOCK_ALL, _("Lock all layers")); break; } - + case SP_VERB_LAYER_LOCK_OTHERS: { + if ( dt->currentLayer() == dt->currentRoot() ) { + dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer.")); + } else { + dt->toggleLockOtherLayers( dt->currentLayer() ); + DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:lockothers", SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers")); + } + break; + } case SP_VERB_LAYER_UNLOCK_ALL: { dt->toggleLockAllLayers( false ); DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:unlockall", SP_VERB_LAYER_UNLOCK_ALL, _("Unlock all layers")); @@ -2520,6 +2527,8 @@ Verb *Verb::_base_verbs[] = { N_("Hide all the layers"), NULL), new LayerVerb(SP_VERB_LAYER_LOCK_ALL, "LayerLockAll", N_("_Lock all layers"), N_("Lock all the layers"), NULL), + new LayerVerb(SP_VERB_LAYER_LOCK_OTHERS, "LayerLockOthers", N_("Lock/Unlock _other layers"), + N_("Lock all the other layers"), NULL), new LayerVerb(SP_VERB_LAYER_UNLOCK_ALL, "LayerUnlockAll", N_("_Unlock all layers"), N_("Unlock all the layers"), NULL), new LayerVerb(SP_VERB_LAYER_TOGGLE_LOCK, "LayerToggleLock", N_("_Lock/Unlock Current Layer"), diff --git a/src/verbs.h b/src/verbs.h index 5a707ade3..da2adb52e 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -150,6 +150,7 @@ enum { SP_VERB_LAYER_SHOW_ALL, SP_VERB_LAYER_HIDE_ALL, SP_VERB_LAYER_LOCK_ALL, + SP_VERB_LAYER_LOCK_OTHERS, SP_VERB_LAYER_UNLOCK_ALL, SP_VERB_LAYER_TOGGLE_LOCK, SP_VERB_LAYER_TOGGLE_HIDE, -- cgit v1.2.3 From 756e60863f9997fc95365a21937b9ac402709441 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 11 Oct 2012 23:23:48 +0900 Subject: Fix for 1058402 : Inconsistent opacity indication (bzr r11781) --- src/ui/widget/style-swatch.cpp | 7 ++----- src/widgets/widget-sizes.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 857ae7019..60d5f6ecc 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -340,15 +340,12 @@ void StyleSwatch::setStyle(SPStyle *query) if (op != 1) { { gchar *str; - if (op == 0) - str = g_strdup_printf(_("O:%.3g"), op); - else - str = g_strdup_printf(_("O:.%d"), (int) (op*10)); + str = g_strdup_printf(_("O: %2.0f"), (op*100.0)); _opacity_value.set_markup (str); g_free (str); } { - gchar *str = g_strdup_printf(_("Opacity: %.3g"), op); + gchar *str = g_strdup_printf(_("Opacity: %2.1f %%"), (op*100.0)); _opacity_place.set_tooltip_text(str); g_free (str); } diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h index 7de251ee6..fe89d4574 100644 --- a/src/widgets/widget-sizes.h +++ b/src/widgets/widget-sizes.h @@ -31,7 +31,7 @@ #define SELECTED_STYLE_SB_WIDTH 48 #define SELECTED_STYLE_WIDTH 190 -#define STYLE_SWATCH_WIDTH 130 +#define STYLE_SWATCH_WIDTH 135 #define STATUS_LAYER_FONT_SIZE 7700 -- cgit v1.2.3 From f304ab600788b02cb02a4413f68f466e35cf1539 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 11 Oct 2012 19:54:14 +0200 Subject: Add symbols dialog. See: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog (bzr r11782) --- src/document.cpp | 35 ++- src/menus-skeleton.h | 5 + src/path-prefix.h | 4 + src/selection-chemistry.cpp | 158 +++++++++++ src/selection-chemistry.h | 5 +- src/selection-describer.cpp | 7 +- src/sp-object.cpp | 3 + src/sp-symbol.cpp | 5 + src/sp-use.cpp | 8 + src/ui/clipboard.cpp | 50 ++++ src/ui/clipboard.h | 2 + src/ui/dialog/Makefile_insert | 2 + src/ui/dialog/dialog-manager.cpp | 3 + src/ui/dialog/symbols.cpp | 574 +++++++++++++++++++++++++++++++++++++++ src/ui/dialog/symbols.h | 114 ++++++++ src/verbs.cpp | 16 ++ src/verbs.h | 3 + 17 files changed, 991 insertions(+), 3 deletions(-) create mode 100644 src/ui/dialog/symbols.cpp create mode 100644 src/ui/dialog/symbols.h (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 9d8291db0..172037518 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -7,10 +7,12 @@ * bulia byak * Jon A. Cruz * Abhishek Sharma + * Tavmjong Bah * * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. + * Copyright (C) 2012 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -59,6 +61,7 @@ #include "sp-item-group.h" #include "sp-namedview.h" #include "sp-object-repr.h" +#include "sp-symbol.h" #include "transf_mat_3x4.h" #include "unit-constants.h" #include "xml/repr.h" @@ -1454,9 +1457,10 @@ void SPDocument::importDefs(SPDocument *source) for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - // Prevent duplicates of solid swatches by checking if equivalent swatch already exists gboolean duplicate = false; SPObject *src = source->getObjectByRepr(def); + + // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *gr = SP_GRADIENT(src); if (gr->isSolid() || gr->getVector()->isSolid()) { @@ -1473,6 +1477,35 @@ void SPDocument::importDefs(SPDocument *source) } } + // Prevent duplication of symbols... could be more clever. + // The tag "_inkscape_duplicate" is added to "id" by ClipboardManagerImpl::copySymbol(). + // We assume that symbols are in defs section (not required by SVG spec). + if (src && SP_IS_SYMBOL(src)) { + + Glib::ustring id = src->getRepr()->attribute("id"); + size_t pos = id.find( "_inkscape_duplicate" ); + if( pos != Glib::ustring::npos ) { + + // This is our symbol, now get rid of tag + id.erase( pos ); + + // Check that it really is a duplicate + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if( trg && SP_IS_SYMBOL(trg) && src != trg ) { + std::string id2 = trg->getRepr()->attribute("id"); + + if( !id.compare( id2 ) ) { + duplicate = true; + break; + } + } + } + if ( !duplicate ) { + src->getRepr()->setAttribute("id", id.c_str() ); + } + } + } + if (!duplicate) { Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); target_defs->appendChild(dup); diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 09366a33f..fa39dbd3a 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -182,6 +182,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" @@ -198,6 +199,10 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/path-prefix.h b/src/path-prefix.h index bdb6b35f7..be57ae354 100644 --- a/src/path-prefix.h +++ b/src/path-prefix.h @@ -34,6 +34,7 @@ extern "C" { # define INKSCAPE_PALETTESDIR BR_DATADIR( "/inkscape/palettes" ) # define INKSCAPE_PATTERNSDIR BR_DATADIR( "/inkscape/patterns" ) # define INKSCAPE_SCREENSDIR BR_DATADIR( "/inkscape/screens" ) +# define INKSCAPE_SYMBOLSDIR BR_DATADIR( "/inkscape/symbols" ) # define INKSCAPE_TUTORIALSDIR BR_DATADIR( "/inkscape/tutorials" ) # define INKSCAPE_TEMPLATESDIR BR_DATADIR( "/inkscape/templates" ) # define INKSCAPE_UIDIR BR_DATADIR( "/inkscape/ui" ) @@ -56,6 +57,7 @@ extern "C" { # define INKSCAPE_PALETTESDIR WIN32_DATADIR("share\\palettes") # define INKSCAPE_PATTERNSDIR WIN32_DATADIR("share\\patterns") # define INKSCAPE_SCREENSDIR WIN32_DATADIR("share\\screens") +# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("share\\symbols") # define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("share\\tutorials") # define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("share\\templates") # define INKSCAPE_UIDIR WIN32_DATADIR("share\\ui") @@ -77,6 +79,7 @@ extern "C" { # define INKSCAPE_PALETTESDIR "Contents/Resources/palettes" # define INKSCAPE_PATTERNSDIR "Contents/Resources/patterns" # define INKSCAPE_SCREENSDIR "Contents/Resources/screens" +# define INKSCAPE_SYMBOLSDIR "Contents/Resources/symbols" # define INKSCAPE_TUTORIALSDIR "Contents/Resources/tutorials" # define INKSCAPE_TEMPLATESDIR "Contents/Resources/templates" # define INKSCAPE_UIDIR "Contents/Resources/ui" @@ -98,6 +101,7 @@ extern "C" { # define INKSCAPE_PALETTESDIR INKSCAPE_DATADIR "/inkscape/palettes" # define INKSCAPE_PATTERNSDIR INKSCAPE_DATADIR "/inkscape/patterns" # define INKSCAPE_SCREENSDIR INKSCAPE_DATADIR "/inkscape/screens" +# define INKSCAPE_SYMBOLSDIR INKSCAPE_DATADIR "/inkscape/symbols" # define INKSCAPE_TUTORIALSDIR INKSCAPE_DATADIR "/inkscape/tutorials" # define INKSCAPE_TEMPLATESDIR INKSCAPE_DATADIR "/inkscape/templates" # define INKSCAPE_UIDIR INKSCAPE_DATADIR "/inkscape/ui" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 332e9a34e..904e21960 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -11,6 +11,7 @@ * Martin Sucha * Abhishek Sharma * Kris De Gussem + * Tavmjong Bah (Symbol additions) * * Copyright (C) 1999-2010,2012 authors * Copyright (C) 2001-2002 Ximian, Inc. @@ -71,6 +72,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-gradient-reference.h" #include "sp-linear-gradient-fns.h" #include "sp-pattern.h" +#include "sp-symbol.h" #include "sp-radial-gradient-fns.h" #include "gradient-context.h" #include "sp-namedview.h" @@ -2887,6 +2889,162 @@ void sp_selection_to_guides(SPDesktop *desktop) DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); } +/* + * Convert to , leaving all elements referencing group unchanged. + */ +void sp_selection_symbol(SPDesktop *desktop, bool apply ) +{ + + if (desktop == NULL) { + return; + } + + SPDocument *doc = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + + Inkscape::Selection *selection = sp_desktop_selection(desktop); + + // Check if something is selected. + if (selection->isEmpty()) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one group to convert to symbol.")); + return; + } + + SPObject* group = selection->single(); + + // Make sure we have only one object in selection. + if( group == NULL ) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one group to convert to symbol.")); + return; + } + + // Make sure we convert the original. + if( SP_IS_USE( group ) ) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select original (Shift+D) to convert to symbol.")); + return; + } + + // Require that we really have a group. + if( !SP_IS_GROUP( group ) ) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Group selection first to convert to symbol.")); + return; + } + + doc->ensureUpToDate(); + + Inkscape::XML::Node *symbol = xml_doc->createElement("svg:symbol"); + symbol->setAttribute("style", group->getAttribute("style")); + symbol->setAttribute("title", group->getAttribute("title")); + symbol->setAttribute("transform", group->getAttribute("transform")); + + Glib::ustring id = group->getAttribute("id"); + + // Now we need to copy all children of group + GSList* children = group->childList(false); + children = g_slist_reverse(children); + for (GSList* i = children; i != NULL; i = i->next ) { + SPObject* child = SP_OBJECT(i->data); + Inkscape::XML::Node *dup = child->getRepr()->duplicate(xml_doc); + symbol->appendChild(dup); + child->deleteObject(true); + } + + // Need to delete ; all elements that referenced should + // auto-magically reference . + doc->getDefs()->getRepr()->appendChild(symbol); + symbol->setAttribute("id",id.c_str()); // After we delete group with same id. + // Mysterious, must set symbol ID before deleting group or all + // refering to symbol get turned into groups. (Linked to unlinking clones?) + group->deleteObject(true); + + Inkscape::GC::release(symbol); + selection->clear(); + // Group just disappears, nothing to select. + + // Need to signal Symbol dialog to update + + g_slist_free(children); + + DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); +} + +/* + * Convert to . All elements referencing symbol remain unchanged. + */ +void sp_selection_unsymbol(SPDesktop *desktop) +{ + + if (desktop == NULL) { + return; + } + + SPDocument *doc = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + + Inkscape::Selection *selection = sp_desktop_selection(desktop); + + // Check if something is selected. + if (selection->isEmpty()) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a symbol to extract objects from.")); + return; + } + + SPObject* use = selection->single(); + + // Make sure we have only one object in selection. + if( use == NULL ) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one symbol to convert to group.")); + return; + } + + // Require that we really have a that references a . + if( !SP_IS_USE( use ) && !SP_IS_SYMBOL( use->firstChild() ) ) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one symbol to convert to group.")); + return; + } + + doc->ensureUpToDate(); + + SPObject* symbol = use->firstChild(); + + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); + group->setAttribute("style", symbol->getAttribute("style")); + group->setAttribute("title", symbol->getAttribute("title")); + group->setAttribute("transform", symbol->getAttribute("transform")); + + Glib::ustring id = symbol->getAttribute("id"); + + // Now we need to copy all children of symbol + GSList* children = symbol->childList(false); + children = g_slist_reverse(children); + for (GSList* i = children; i != NULL; i = i->next ) { + SPObject* child = SP_OBJECT(i->data); + Inkscape::XML::Node *dup = child->getRepr()->duplicate(xml_doc); + group->appendChild(dup); + child->deleteObject(true); + } + + SPObject* parent = use->parent; // So we insert next to (easier to find) + + // Need to delete ; all other elements that referenced should + // auto-magically reference . + symbol->deleteObject(true); + group->setAttribute("id",id.c_str()); // After we delete symbol with same id. + parent->getRepr()->appendChild(group); + //use->deleteObject(true); + + SPItem *group_item = static_cast(sp_desktop_document(desktop)->getObjectByRepr(group)); + Inkscape::GC::release(group); + selection->clear(); + selection->set(group_item); + + // Need to signal Symbol dialog to update + + g_slist_free(children); + + DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol")); +} + void sp_selection_tile(SPDesktop *desktop, bool apply) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 3c9c1aea9..5b35ded09 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -11,7 +11,7 @@ * Jon A. Cruz * Abhishek Sharma * - * Copyright (C) 1999-2010 authors + * Copyright (C) 1999-2012 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -67,6 +67,9 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop); void sp_selection_to_marker(SPDesktop *desktop, bool apply = true); void sp_selection_to_guides(SPDesktop *desktop); +void sp_selection_symbol(SPDesktop *desktop, bool apply = true); +void sp_selection_unsymbol(SPDesktop *desktop); + void sp_selection_tile(SPDesktop *desktop, bool apply = true); void sp_selection_untile(SPDesktop *desktop); diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index c141c3da5..391db8950 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -24,6 +24,7 @@ #include "sp-offset.h" #include "sp-flowtext.h" #include "sp-use.h" +#include "sp-symbol.h" #include "sp-rect.h" #include "box3d.h" #include "sp-ellipse.h" @@ -192,7 +193,11 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select if (!items->next) { // one item char *item_desc = item->description(); - if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) { + if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) { + _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", + item_desc, in_phrase, + _("Convert symbol to group to edit"), _when_selected); + } else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", item_desc, in_phrase, _("Use Shift+D to look up original"), _when_selected); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index c16dbaeef..3e18c0835 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1409,6 +1409,9 @@ void SPObject::_requireSVGVersion(Inkscape::Version version) { be made. The same applies to 'desc' elements. Therefore, these functions ignore all but the first 'title' child element and first 'desc' child element, except when deleting a title or description. + + This will change in SVG 2, where multiple 'title' and 'desc' elements will + be allowed with different localized strings. */ gchar * SPObject::title() const diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 87cd210e4..56f862bf3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -405,6 +405,11 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran Geom::Affine const a( symbol->c2p * transform ); bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); } + } else { + // Need bounding box for Symbols dialog + + Geom::Affine const a; + bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); } return bbox; } diff --git a/src/sp-use.cpp b/src/sp-use.cpp index e39f560c3..0f45f5444 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -321,6 +321,14 @@ sp_use_description(SPItem *item) char *ret; if (use->child) { + + if( SP_IS_SYMBOL( use->child ) ) { + //char *symbol_desc = SP_ITEM(use->child)->description(); + //g_free(symbol_desc); + return g_strdup(_("Clone of Symbol")); + //return g_strdup_printf(_("Clone of Symbol: %s"), symbol_desc ); + } + static unsigned recursion_depth = 0; if (recursion_depth >= 4) { /* TRANSLATORS: Used for statusbar description for long chains: diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index f1f6c4ab4..8cdb37f4f 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -7,9 +7,11 @@ * Jon A. Cruz * Incorporates some code from selection-chemistry.cpp, see that file for more credits. * Abhishek Sharma + * Tavmjong Bah * * Copyright (C) 2008 authors * Copyright (C) 2010 Jon A. Cruz + * Copyright (C) 2012 Tavmjong Bah (Symbol additions) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -66,6 +68,8 @@ #include "sp-mask.h" #include "sp-textpath.h" #include "sp-rect.h" +#include "sp-use.h" +#include "sp-symbol.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" @@ -109,6 +113,7 @@ class ClipboardManagerImpl : public ClipboardManager { public: virtual void copy(SPDesktop *desktop); virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *); + virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style); virtual bool paste(SPDesktop *desktop, bool in_place); virtual bool pasteStyle(SPDesktop *desktop); virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y); @@ -294,6 +299,43 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam _setClipboardTargets(); } +/** + * Copy a symbol from the symbol dialog. + * @param symbol The Inkscape::XML::Node for the symbol. + */ +void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* style) +{ + //std::cout << "ClipboardManagerImpl::copySymbol" << std::endl; + if ( symbol == NULL ) { + return; + } + + _discardInternalClipboard(); + _createInternalClipboard(); + + // We add "_duplicate" to have a well defined symbol name that + // bypasses the "prevent_id_classes" routine. We'll get rid of it + // when we paste. + Inkscape::XML::Node *repr = symbol->duplicate(_doc); + Glib::ustring symbol_name = repr->attribute("id"); + + symbol_name += "_inkscape_duplicate"; + repr->setAttribute("id", symbol_name.c_str()); + _defs->appendChild(repr); + + Glib::ustring id("#"); + id += symbol->attribute("id"); + + Inkscape::XML::Node *use = _doc->createElement("svg:use"); + use->setAttribute("xlink:href", id.c_str() ); + // Set a default style in rather than so it can be changed. + use->setAttribute("style", style ); + _root->appendChild(use); + + fit_canvas_to_drawing(_clipboardSPDoc); + _setClipboardTargets(); +} + /** * Paste from the system clipboard into the active desktop. * @param in_place Whether to put the contents where they were when copied. @@ -725,6 +767,14 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } } + // Copy symbols: We may want to be more clever... + // if (SP_IS_USE(item)) { + // SPObject *symbol = SP_USE(item)->child; + // if( symbol && SP_IS_SYMBOL(symbol) ) { + // _copyNode(symbol->getRepr(), _doc, _defs); + // } + // } + // recurse for (SPObject *o = item->children ; o != NULL ; o = o->next) { if (SP_IS_ITEM(o)) { diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h index fb28bfc14..b565740c3 100644 --- a/src/ui/clipboard.h +++ b/src/ui/clipboard.h @@ -25,6 +25,7 @@ class SPDesktop; namespace Inkscape { class Selection; +namespace XML { class Node; } namespace LivePathEffect { class PathParam; } namespace UI { @@ -43,6 +44,7 @@ class ClipboardManager { public: virtual void copy(SPDesktop *desktop) = 0; virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0; + virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style) = 0; virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0; virtual bool pasteStyle(SPDesktop *desktop) = 0; virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0; diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index ba2f53a9e..580b47522 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -89,6 +89,8 @@ ink_common_sources += \ ui/dialog/svg-fonts-dialog.h \ ui/dialog/swatches.cpp \ ui/dialog/swatches.h \ + ui/dialog/symbols.cpp \ + ui/dialog/symbols.h \ ui/dialog/text-edit.cpp \ ui/dialog/text-edit.h \ ui/dialog/tile.cpp \ diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 60011ca9d..faba47769 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -33,6 +33,7 @@ #include "ui/dialog/memory.h" #include "ui/dialog/messages.h" #include "ui/dialog/scriptdialog.h" +#include "ui/dialog/symbols.h" #include "ui/dialog/tile.h" #include "ui/dialog/tracedialog.h" #include "ui/dialog/transformation.h" @@ -121,6 +122,7 @@ DialogManager::DialogManager() { registerFactory("SvgFontsDialog", &create); #endif registerFactory("Swatches", &create); + registerFactory("Symbols", &create); registerFactory("TileDialog", &create); registerFactory("Trace", &create); registerFactory("Transformation", &create); @@ -156,6 +158,7 @@ DialogManager::DialogManager() { registerFactory("SvgFontsDialog", &create); #endif registerFactory("Swatches", &create); + registerFactory("Symbols", &create); registerFactory("TileDialog", &create); registerFactory("Trace", &create); registerFactory("Transformation", &create); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp new file mode 100644 index 000000000..ea08c1cc8 --- /dev/null +++ b/src/ui/dialog/symbols.cpp @@ -0,0 +1,574 @@ +/** + * @file + * Symbols dialog. + */ +/* Authors: + * Copyright (C) 2012 Tavmjong Bah + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "path-prefix.h" +#include "io/sys.h" + +#include "ui/cache/svg_preview_cache.h" +#include "ui/clipboard.h" + +#include "symbols.h" + +#include "desktop.h" +#include "desktop-handles.h" +#include "document.h" +#include "inkscape.h" +#include "sp-root.h" +#include "sp-use.h" +#include "sp-symbol.h" + +#include "verbs.h" +#include "xml/repr.h" + +namespace Inkscape { +namespace UI { + +static Cache::SvgPreview svg_preview_cache; + +namespace Dialog { + + // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html +class SymbolColumns : public Gtk::TreeModel::ColumnRecord +{ +public: + + Gtk::TreeModelColumn symbol_id; + Gtk::TreeModelColumn symbol_title; + Gtk::TreeModelColumn< Glib::RefPtr > symbol_image; + + SymbolColumns() { + add(symbol_id); + add(symbol_title); + add(symbol_image); + } +}; + +SymbolColumns* SymbolsDialog::getColumns() +{ + SymbolColumns* columns = new SymbolColumns(); + return columns; +} + +/** + * Constructor + */ +SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : + UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS), + store(Gtk::ListStore::create(*getColumns())), + iconView(0), + previewScale(0), + previewSize(0), + currentDesktop(0), + deskTrack(), + currentDocument(0), + previewDocument(0), + instanceConns() +{ + + /******************** Table *************************/ + // Replace by Grid for GTK 3.0 + Gtk::Table *table = new Gtk::Table(2, 4, false); + // panel is a cloked Gtk::VBox + _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); + guint row = 0; + + /******************** Symbol Sets *************************/ + Gtk::Label* labelSet = new Gtk::Label("Symbol set: "); + table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); + + symbolSet = new Gtk::ComboBoxText(); // Fill in later + symbolSet->append("Current Document"); + symbolSet->set_active_text("Current Document"); + table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); + + sigc::connection connSet = + symbolSet->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + instanceConns.push_back(connSet); + + ++row; + + /********************* Icon View **************************/ + SymbolColumns* columns = getColumns(); + + iconView = new Gtk::IconView(static_cast >(store)); + //iconView->set_text_column( columns->symbol_id ); + iconView->set_tooltip_column( 1 ); + iconView->set_pixbuf_column( columns->symbol_image ); + + sigc::connection connIconChanged; + connIconChanged = + iconView->signal_selection_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); + instanceConns.push_back(connIconChanged); + + Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); + scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); + scroller->add(*Gtk::manage(iconView)); + table->attach(*Gtk::manage(scroller),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL); + + ++row; + + /******************** Preview Scale ***********************/ + Gtk::Label* labelScale = new Gtk::Label("Preview scale: "); + table->attach(*Gtk::manage(labelScale),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); + + previewScale = new Gtk::ComboBoxText(); + const gchar *scales[] = + {"Fit", "Fit to width", "Fit to height", "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL}; + for( int i = 0; scales[i]; ++i ) { + previewScale->append(scales[i]); + } + previewScale->set_active_text(scales[0]); + table->attach(*Gtk::manage(previewScale),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); + + sigc::connection connScale = + previewScale->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + instanceConns.push_back(connScale); + + ++row; + + /******************** Preview Size ************************/ + Gtk::Label* labelSize = new Gtk::Label("Preview size: "); + table->attach(*Gtk::manage(labelSize),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); + + previewSize = new Gtk::ComboBoxText(); + const gchar *sizes[] = {"16", "24", "32", "48", "64", NULL}; + for( int i = 0; sizes[i]; ++i ) { + previewSize->append(sizes[i]); + } + previewSize->set_active_text(sizes[2]); + table->attach(*Gtk::manage(previewSize),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); + + sigc::connection connSize = + previewSize->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + instanceConns.push_back(connSize); + + ++row; + + /**********************************************************/ + currentDesktop = inkscape_active_desktop(); + currentDocument = sp_desktop_document(currentDesktop); + + previewDocument = symbols_preview_doc(); /* Template to render symbols in */ + previewDocument->ensureUpToDate(); /* Necessary? */ + + key = SPItem::display_key_new(1); + renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY )); + + get_symbols(); + draw_symbols( currentDocument ); /* Defaults to current document */ + + desktopChangeConn = + deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); + instanceConns.push_back( desktopChangeConn ); + deskTrack.connect(GTK_WIDGET(gobj())); +} + +SymbolsDialog::~SymbolsDialog() +{ + for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { + it->disconnect(); + } + instanceConns.clear(); + deskTrack.disconnect(); +} + +SymbolsDialog& SymbolsDialog::getInstance() +{ + return *new SymbolsDialog(); +} + +void SymbolsDialog::rebuild() { + + store->clear(); + Glib::ustring symbolSetString = symbolSet->get_active_text(); + + SPDocument* symbolDocument = symbolSets[symbolSetString]; + if( !symbolDocument ) { + // Symbol must be from Current Document (this method of + // checking should be language independent). + symbolDocument = currentDocument; + } + draw_symbols( symbolDocument ); +} + +void SymbolsDialog::iconChanged() { +#if WITH_GTKMM_3_0 + std::vector iconArray = iconView->get_selected_items(); +#else + Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); +#endif + + if( iconArray.empty() ) { + //std::cout << " iconArray empty: huh? " << std::endl; + } else { + Gtk::TreeModel::Path const & path = *iconArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + Glib::ustring symbol_id = (*row)[getColumns()->symbol_id]; + + /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ + Glib::ustring symbolSetString = symbolSet->get_active_text(); + + SPDocument* symbolDocument = symbolSets[symbolSetString]; + if( !symbolDocument ) { + // Symbol must be from Current Document (this method of + // checking should be language independent). + symbolDocument = currentDocument; + } + + SPObject* symbol = symbolDocument->getObjectById(symbol_id); + if( symbol ) { + + // Find style for use in + // First look for default style stored in + gchar const* style = symbol->getAttribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in , look in documents. + if( symbolDocument == currentDocument ) { + style = style_from_use( symbol_id.c_str(), currentDocument ); + } else { + style = symbolDocument->getReprRoot()->attribute("style"); + } + } + + ClipboardManager *cm = ClipboardManager::get(); + cm->copySymbol(symbol->getRepr(), style); + } + } +} + +/* Hunts preference directories for symbol files */ +void SymbolsDialog::get_symbols() { + + std::list directories; + + if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) && + Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { + directories.push_back( INKSCAPE_SYMBOLSDIR ); + } + if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) && + Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { + directories.push_back( profile_path("symbols") ); + } + + std::list::iterator it; + for( it = directories.begin(); it != directories.end(); ++it ) { + + GError *err = 0; + GDir *dir = g_dir_open( (*it).c_str(), 0, &err ); + if( dir ) { + + gchar *filename = 0; + while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) { + + gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); + + if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) ) { + + SPDocument* symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); + if( symbol_doc ) { + symbolSets[Glib::ustring(filename)]= symbol_doc; + symbolSet->append(filename); + } + } + g_free( fullname ); + } + g_dir_close( dir ); + } + } +} + +GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) +{ + + // Stop multiple counting of same symbol + if( SP_IS_USE(r) ) { + return l; + } + + if( SP_IS_SYMBOL(r) ) { + l = g_slist_prepend (l, r); + } + + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { + l = symbols_in_doc_recursive( child, l ); + } + + return l; +} + +GSList* SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) { + + GSList *l = NULL; + l = symbols_in_doc_recursive (symbolDocument->getRoot(), l ); + return l; +} + +GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) +{ + + if( SP_IS_USE(r) ) { + l = g_slist_prepend (l, r); + } + + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { + l = use_in_doc_recursive( child, l ); + } + + return l; +} + +GSList* SymbolsDialog::use_in_doc( SPDocument* useDocument ) { + + GSList *l = NULL; + l = use_in_doc_recursive (useDocument->getRoot(), l ); + return l; +} + +// Returns style from first element found that references id. +// This is a last ditch effort to find a style. +gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* document) { + + gchar const* style = 0; + GSList* l = use_in_doc( document ); + for( ; l != NULL; l = l->next ) { + SPObject* use = SP_OBJECT(l->data); + if( SP_IS_USE( use ) ) { + gchar const *href = use->getRepr()->attribute("xlink:href"); + if( href ) { + Glib::ustring href2(href); + Glib::ustring id2(id); + id2 = "#" + id2; + if( !href2.compare(id2) ) { + style = use->getRepr()->attribute("style"); + break; + } + } + } + } + return style; +} + +void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) { + + + SymbolColumns* columns = getColumns(); + + GSList* l = symbols_in_doc( symbolDocument ); + for( ; l != NULL; l = l->next ) { + + SPObject* symbol = SP_OBJECT(l->data); + if (!SP_IS_SYMBOL(symbol)) { + //std::cout << " Error: not symbol" << std::endl; + continue; + } + + gchar const *id = symbol->getRepr()->attribute("id"); + gchar const *title = symbol->title(); // From title element + if( !title ) { + title = id; + } + + Glib::RefPtr pixbuf = create_symbol_image(id, symbolDocument, &renderDrawing, key ); + if( pixbuf ) { + + Gtk::ListStore::iterator row = store->append(); + (*row)[columns->symbol_id] = Glib::ustring( id ); + (*row)[columns->symbol_title] = Glib::ustring( title ); + (*row)[columns->symbol_image] = pixbuf; + } + } +} + +/* + * Returns image of symbol. + * + * Symbols normally are not visible. They must be referenced by a + * element. A temporary document is created with a dummy + * element and a element that references the symbol + * element. Each real symbol is swapped in for the dummy symbol and + * the temporary document is rendered. + */ +Glib::RefPtr +SymbolsDialog::create_symbol_image(gchar const *symbol_id, + SPDocument *source, + Inkscape::Drawing* drawing, + unsigned /*visionkey*/) +{ + + // Retrieve the symbol named 'symbol_id' from the source SVG document + SPObject const* symbol = source->getObjectById(symbol_id); + if (symbol == NULL) { + //std::cout << " Failed to find symbol: " << symbol_id << std::endl; + //return 0; + } + + // Create a copy repr of the symbol with id="the_symbol" + Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc(); + Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc); + repr->setAttribute("id", "the_symbol"); + + // Replace old "the_symbol" in previewDocument by new. + Inkscape::XML::Node *root = previewDocument->getReprRoot(); + SPObject *symbol_old = previewDocument->getObjectById("the_symbol"); + if (symbol_old) { + symbol_old->deleteObject(false); + } + + // First look for default style stored in + gchar const* style = repr->attribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in , look in documents. + if( source == currentDocument ) { + style = style_from_use( symbol_id, source ); + } else { + style = source->getReprRoot()->attribute("style"); + } + } + + // This is for display in Symbols dialog only + if( style ) { + repr->setAttribute( "style", style ); + } + + // BUG: Symbols don't work if defined outside of . Causes Inkscape + // crash when trying to read in such a file. + root->appendChild(repr); + //defsrepr->appendChild(repr); + Inkscape::GC::release(repr); + + // Uncomment this to get the previewDocument documents saved (useful for debugging) + // FILE *fp = fopen (g_strconcat(symbol_id, ".svg", NULL), "w"); + // sp_repr_save_stream(previewDocument->getReprDoc(), fp); + // fclose (fp); + + // Make sure previewDocument is up-to-date. + previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + previewDocument->ensureUpToDate(); + + // Make sure we have symbol in previewDocument + SPObject *object_temp = previewDocument->getObjectById( "the_use" ); + previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + previewDocument->ensureUpToDate(); + + // if( object_temp == NULL || !SP_IS_ITEM(object_temp) ) { + // //std::cout << " previewDocument broken?" << std::endl; + // //return 0; + // } + + SPItem *item = SP_ITEM(object_temp); + + // Find object's bbox in document. + // Note symbols can have own viewport... ignore for now. + //Geom::OptRect dbox = item->geometricBounds(); + Geom::OptRect dbox = item->documentVisualBounds(); + // if (!dbox) { + // //std::cout << " No dbox" << std::endl; + // //return NULL; + // } + + Glib::ustring previewSizeString = previewSize->get_active_text(); + unsigned psize = atol( previewSizeString.c_str() ); + + Glib::ustring previewScaleString = previewScale->get_active_text(); + int previewScaleRow = previewScale->get_active_row_number(); + + /* Update to renderable state */ + Glib::ustring key = svg_preview_cache.cache_key(previewDocument->getURI(), symbol_id, psize); + //std::cout << " Key: " << key << std::endl; + // FIX ME + //Glib::RefPtr pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key)); + Glib::RefPtr pixbuf = Glib::RefPtr(0); + + if (!pixbuf) { + + /* Scale symbols to fit */ + double scale = 1.0; + switch (previewScaleRow) { + case 0: + /* Fit */ + scale = psize/std::max(dbox->width(),dbox->height()); + break; + case 1: + /* Fit width */ + scale = psize/dbox->width(); + break; + case 2: + /* Fit height */ + scale = psize/dbox->height(); + break; + default: + scale = atof( previewScaleString.c_str() ); + } + + pixbuf = Glib::wrap(render_pixbuf(*drawing, scale, *dbox, psize)); + svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj()); + } + + return pixbuf; +} + +/* + * Return empty doc to render symbols in. + * Symbols are by default not rendered so a element is + * provided. + */ +SPDocument* SymbolsDialog::symbols_preview_doc() +{ + // BUG: must be inside + gchar const *buffer = +"" +" " +" " +" " +" " +""; + + return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); +} + +void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) +{ + if (this->currentDesktop != desktop) { + this->currentDesktop = desktop; + if( !symbolSets[symbolSet->get_active_text()] ) { + // Symbol set is from Current document, update + rebuild(); + } + } +} + + +} //namespace Dialogs +} //namespace UI +} //namespace Inkscape + + + diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h new file mode 100644 index 000000000..c2bb4448e --- /dev/null +++ b/src/ui/dialog/symbols.h @@ -0,0 +1,114 @@ +/** @file + * @brief Symbols dialog + */ +/* Authors: + * Tavmjong Bah + * + * Copyright (C) 2012 Tavmjong Bah + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_DIALOG_SYMBOLS_H +#define INKSCAPE_UI_DIALOG_SYMBOLS_H + +#include "ui/widget/panel.h" +#include "ui/widget/button.h" + +#include "ui/dialog/desktop-tracker.h" + +#include "display/drawing.h" + +#include +#include + +#include + +class SPObject; + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class SymbolColumns; // For Gtk::ListStore + +/** + * A dialog that displays selectable symbols. + */ +class SymbolsDialog : public UI::Widget::Panel { + +public: + SymbolsDialog( gchar const* prefsPath = "/dialogs/symbols" ); + virtual ~SymbolsDialog(); + + static SymbolsDialog& getInstance(); + +protected: + + +private: + SymbolsDialog(SymbolsDialog const &); // no copy + SymbolsDialog &operator=(SymbolsDialog const &); // no assign + + static SymbolColumns *getColumns(); + + void rebuild(); + void iconChanged(); + + void get_symbols(); + void draw_symbols( SPDocument* symbol_document ); + SPDocument* symbols_preview_doc(); + + GSList* symbols_in_doc_recursive(SPObject *r, GSList *l); + GSList* symbols_in_doc( SPDocument* document ); + GSList* use_in_doc_recursive(SPObject *r, GSList *l); + GSList* use_in_doc( SPDocument* document ); + gchar const* style_from_use( gchar const* id, SPDocument* document); + + Glib::RefPtr + create_symbol_image(gchar const *symbol_name, + SPDocument *source, Inkscape::Drawing* drawing, + unsigned /*visionkey*/); + + /* Keep track of all symbol template documents */ + std::map symbolSets; + + + Glib::RefPtr store; + Gtk::ComboBoxText* symbolSet; + Gtk::IconView* iconView; + Gtk::ComboBoxText* previewScale; + Gtk::ComboBoxText* previewSize; + + void setTargetDesktop(SPDesktop *desktop); + SPDesktop* currentDesktop; + DesktopTracker deskTrack; + SPDocument* currentDocument; + SPDocument* previewDocument; /* Document to render single symbol */ + + /* For rendering the template drawing */ + unsigned key; + Inkscape::Drawing renderDrawing; + + std::vector instanceConns; + sigc::connection desktopChangeConn; + +}; + +} //namespace Dialogs +} //namespace UI +} //namespace Inkscape + + +#endif // INKSCAPE_UI_DIALOG_SYMBOLS_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/verbs.cpp b/src/verbs.cpp index 450b800c1..8c45ce665 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -78,6 +78,7 @@ #include "ui/dialog/layers.h" #include "ui/dialog/object-properties.h" #include "ui/dialog/swatches.h" +#include "ui/dialog/symbols.h" #include "ui/dialog/spellcheck.h" #include "ui/icon-names.h" #include "ui/tool/node-tool.h" @@ -957,6 +958,12 @@ void EditVerb::perform(SPAction *action, void *data) case SP_VERB_EDIT_UNTILE: sp_selection_untile(dt); break; + case SP_VERB_EDIT_SYMBOL: + sp_selection_symbol(dt); + break; + case SP_VERB_EDIT_UNSYMBOL: + sp_selection_unsymbol(dt); + break; case SP_VERB_EDIT_CLEAR_ALL: sp_edit_clear_all(dt); break; @@ -1912,6 +1919,9 @@ void DialogVerb::perform(SPAction *action, void *data) case SP_VERB_DIALOG_SWATCHES: dt->_dlg_mgr->showDialog("Swatches"); break; + case SP_VERB_DIALOG_SYMBOLS: + dt->_dlg_mgr->showDialog("Symbols"); + break; case SP_VERB_DIALOG_TRANSFORM: dt->_dlg_mgr->showDialog("Transformation"); break; @@ -2375,6 +2385,10 @@ Verb *Verb::_base_verbs[] = { N_("Convert selection to a rectangle with tiled pattern fill"), NULL), new EditVerb(SP_VERB_EDIT_UNTILE, "ObjectsFromPattern", N_("Pattern to _Objects"), N_("Extract objects from a tiled pattern fill"), NULL), + new EditVerb(SP_VERB_EDIT_SYMBOL, "ObjectsToSymbol", N_("Group to Symbol"), + N_("Convert group to a symbol"), NULL), + new EditVerb(SP_VERB_EDIT_UNSYMBOL, "ObjectsFromSymbol", N_("Symbol to Group"), + N_("Extract group from a symbol"), NULL), new EditVerb(SP_VERB_EDIT_CLEAR_ALL, "EditClearAll", N_("Clea_r All"), N_("Delete all objects from document"), NULL), new EditVerb(SP_VERB_EDIT_SELECT_ALL, "EditSelectAll", N_("Select Al_l"), @@ -2748,6 +2762,8 @@ Verb *Verb::_base_verbs[] = { // TRANSLATORS: "Swatches" means: color samples new DialogVerb(SP_VERB_DIALOG_SWATCHES, "DialogSwatches", N_("S_watches..."), N_("Select colors from a swatches palette"), GTK_STOCK_SELECT_COLOR), + new DialogVerb(SP_VERB_DIALOG_SYMBOLS, "DialogSymbols", N_("S_ymbols..."), + N_("Select symbol from a symbols palette"), GTK_STOCK_SELECT_COLOR), new DialogVerb(SP_VERB_DIALOG_TRANSFORM, "DialogTransform", N_("Transfor_m..."), N_("Precisely control objects' transformations"), INKSCAPE_ICON("dialog-transform")), new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."), diff --git a/src/verbs.h b/src/verbs.h index da2adb52e..c47d3ae16 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -84,6 +84,8 @@ enum { SP_VERB_EDIT_SELECTION_2_GUIDES, SP_VERB_EDIT_TILE, SP_VERB_EDIT_UNTILE, + SP_VERB_EDIT_SYMBOL, + SP_VERB_EDIT_UNSYMBOL, SP_VERB_EDIT_CLEAR_ALL, SP_VERB_EDIT_SELECT_ALL, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, @@ -264,6 +266,7 @@ enum { SP_VERB_DIALOG_FILL_STROKE, SP_VERB_DIALOG_GLYPHS, SP_VERB_DIALOG_SWATCHES, + SP_VERB_DIALOG_SYMBOLS, SP_VERB_DIALOG_TRANSFORM, SP_VERB_DIALOG_ALIGN_DISTRIBUTE, SP_VERB_DIALOG_SPRAY_OPTION, -- cgit v1.2.3 From a67988fae58348562bcde83ea1c5fb8aa4eecb78 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 12 Oct 2012 13:15:19 +0900 Subject: Fix for 177931 : Shift click layer icons to trigger solo (bzr r11784) --- src/ui/dialog/layers.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 457f7c147..55a2f19a5 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -562,26 +562,36 @@ void LayersPanel::_handleButtonEvent(GdkEventButton* event) { static unsigned doubleclick = 0; - // TODO - fix to a better is-popup function if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) { + // TODO - fix to a better is-popup function + Gtk::TreeModel::Path path; + int x = static_cast(event->x); + int y = static_cast(event->y); + if ( _tree.get_path_at_pos( x, y, path ) ) { + _checkTreeSelection(); + _popupMenu.popup(event->button, event->time); + } + } - { - Gtk::TreeModel::Path path; - Gtk::TreeViewColumn* col = 0; - int x = static_cast(event->x); - int y = static_cast(event->y); - int x2 = 0; - int y2 = 0; - if ( _tree.get_path_at_pos( x, y, - path, col, - x2, y2 ) ) { - _checkTreeSelection(); - _popupMenu.popup(event->button, event->time); + if ( event->type == GDK_BUTTON_RELEASE && (event->button == 1) + && (event->state & GDK_SHIFT_MASK)) { + // Shift left click on the visible/lock columns toggles "solo" mode + Gtk::TreeModel::Path path; + Gtk::TreeViewColumn* col = 0; + int x = static_cast(event->x); + int y = static_cast(event->y); + int x2 = 0; + int y2 = 0; + if ( _tree.get_path_at_pos( x, y, path, col, x2, y2 ) ) { + if (col == _tree.get_column(COL_VISIBLE-1)) { + _takeAction(BUTTON_SOLO); + } else if (col == _tree.get_column(COL_LOCKED-1)) { + _takeAction(BUTTON_LOCK_OTHERS); } } - } + if ( (event->type == GDK_2BUTTON_PRESS) && (event->button == 1) ) { doubleclick = 1; } -- cgit v1.2.3 From c384a6116dd087856bd91806e9f8fb5e0eaa6dd8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 12 Oct 2012 14:39:08 +0900 Subject: Fix for 1019974 : Default layer names are inconsistent (bzr r11785) --- src/layer-manager.cpp | 81 ++++++++++++++++++++++---------------- src/layer-manager.h | 1 + src/ui/dialog/layer-properties.cpp | 7 +++- 3 files changed, 53 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index 894758a97..c02d75d16 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -159,53 +159,66 @@ void LayerManager::setCurrentLayer( SPObject* obj ) } } -void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify ) +/* + * Return a unique layer name similar to param label + * A unique name is made by substituting or appending the label's number suffix with + * the next unique larger number suffix not already used for any layer name + */ +Glib::ustring LayerManager::getNextLayerName( SPObject* obj, gchar const *label) { - Glib::ustring incoming( label ? label : "" ); + Glib::ustring incoming( label ? label : "Layer 1" ); Glib::ustring result(incoming); Glib::ustring base(incoming); + Glib::ustring split(" "); guint startNum = 1; - if (uniquify) { + gint pos = base.length()-1; + while (pos >= 0 && g_ascii_isdigit(base[pos])) { + pos-- ; + } - Glib::ustring::size_type pos = base.rfind('#'); - if ( pos != Glib::ustring::npos ) { - gchar* numpart = g_strdup(base.substr(pos+1).c_str()); - if ( numpart ) { - gchar* endPtr = NULL; - guint64 val = g_ascii_strtoull( numpart, &endPtr, 10); - if ( ((val > 0) || (endPtr != numpart)) && (val < 65536) ) { - base.erase( pos ); - result = base; - startNum = static_cast(val); - } - g_free(numpart); - } + gchar* numpart = g_strdup(base.substr(pos+1).c_str()); + if ( numpart ) { + gchar* endPtr = NULL; + guint64 val = g_ascii_strtoull( numpart, &endPtr, 10); + if ( ((val > 0) || (endPtr != numpart)) && (val < 65536) ) { + base.erase( pos+1); + result = incoming; + startNum = static_cast(val); + split = ""; } + g_free(numpart); + } - std::set currentNames; - GSList const *layers=_document->getResourceList("layer"); - SPObject *root=_desktop->currentRoot(); - if ( root ) { - for ( GSList const *iter=layers ; iter ; iter = iter->next ) { - SPObject *layer=static_cast(iter->data); - if ( layer != obj ) { - currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() ); - } + std::set currentNames; + GSList const *layers=_document->getResourceList("layer"); + SPObject *root=_desktop->currentRoot(); + if ( root ) { + for ( GSList const *iter=layers ; iter ; iter = iter->next ) { + SPObject *layer=static_cast(iter->data); + if ( layer != obj ) { + currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() ); } } + } - // Not sure if we need to cap it, but we'll just be paranoid for the moment - // Intentionally unsigned - guint endNum = startNum + 3000; - for ( guint i = startNum; (i < endNum) && (currentNames.find(result) != currentNames.end()); i++ ) { - gchar* suffix = g_strdup_printf("#%d", i); - result = base; - result += suffix; + // Not sure if we need to cap it, but we'll just be paranoid for the moment + // Intentionally unsigned + guint endNum = startNum + 3000; + for ( guint i = startNum; (i < endNum) && (currentNames.find(result) != currentNames.end()); i++ ) { + result = Glib::ustring::format(base, split, i); + } - g_free(suffix); - } + return result; +} +void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify ) +{ + Glib::ustring incoming( label ? label : "" ); + Glib::ustring result(incoming); + + if (uniquify) { + result = getNextLayerName(obj, label); } obj->setLabel( result.c_str() ); diff --git a/src/layer-manager.h b/src/layer-manager.h index fbb22d405..1b69324d5 100644 --- a/src/layer-manager.h +++ b/src/layer-manager.h @@ -30,6 +30,7 @@ public: void setCurrentLayer( SPObject* obj ); void renameLayer( SPObject* obj, gchar const *label, bool uniquify ); + Glib::ustring getNextLayerName( SPObject* obj, gchar const *label); sigc::connection connectCurrentLayerChanged(const sigc::slot & slot) { return _layer_changed_signal.connect(slot); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 35a235dbc..4f9edf774 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -331,8 +331,11 @@ void LayerPropertiesDialog::Rename::perform(LayerPropertiesDialog &dialog) { void LayerPropertiesDialog::Create::setup(LayerPropertiesDialog &dialog) { dialog.set_title(_("Add Layer")); - //TODO: find an unused layer number, forming name from _("Layer ") + "%d" - dialog._layer_name_entry.set_text(_("Layer")); + + // Set the initial name to the "next available" layer name + LayerManager *mgr = dialog._desktop->layer_manager; + Glib::ustring newName = mgr->getNextLayerName(NULL, dialog._desktop->currentLayer()->label()); + dialog._layer_name_entry.set_text(newName.c_str()); dialog._apply_button.set_label(_("_Add")); dialog._setup_position_controls(); } -- cgit v1.2.3 From 89f3de6cdd15aed516c23c07a0b02e7fb39b5ca1 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 12 Oct 2012 10:42:52 +0200 Subject: Fix for compiling with pre gtkmm 2.24 libraries. (bzr r11787) --- src/ui/dialog/symbols.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index ea08c1cc8..21a178b57 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -101,7 +101,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); symbolSet = new Gtk::ComboBoxText(); // Fill in later +#if WITH_GTKMM_2_24 symbolSet->append("Current Document"); +#else + symbolSet->append_text("Current Document"); +#endif symbolSet->set_active_text("Current Document"); table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); @@ -139,7 +143,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : const gchar *scales[] = {"Fit", "Fit to width", "Fit to height", "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL}; for( int i = 0; scales[i]; ++i ) { +#if WITH_GTKMM_2_24 previewScale->append(scales[i]); +#else + previewScale->append_text(scales[i]); +#endif } previewScale->set_active_text(scales[0]); table->attach(*Gtk::manage(previewScale),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); @@ -157,7 +165,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : previewSize = new Gtk::ComboBoxText(); const gchar *sizes[] = {"16", "24", "32", "48", "64", NULL}; for( int i = 0; sizes[i]; ++i ) { +#if WITH_GTKMM_2_24 previewSize->append(sizes[i]); +#else + previewSize->append_text(sizes[i]); +#endif + } previewSize->set_active_text(sizes[2]); table->attach(*Gtk::manage(previewSize),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); @@ -291,7 +304,11 @@ void SymbolsDialog::get_symbols() { SPDocument* symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { symbolSets[Glib::ustring(filename)]= symbol_doc; +#if WITH_GTKMM_2_24 symbolSet->append(filename); +#else + symbolSet->append_text(filename); +#endif } } g_free( fullname ); -- cgit v1.2.3 From d0cef66d9adeda493c6374de2176e16e78462a56 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 13 Oct 2012 14:23:11 +0200 Subject: Prevent crash if symbol is empty. Chnage default styling for symbol preview. (bzr r11790) --- src/ui/dialog/symbols.cpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 21a178b57..82af60fc2 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -435,7 +435,6 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, Inkscape::Drawing* drawing, unsigned /*visionkey*/) { - // Retrieve the symbol named 'symbol_id' from the source SVG document SPObject const* symbol = source->getObjectById(symbol_id); if (symbol == NULL) { @@ -465,6 +464,8 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, style = source->getReprRoot()->attribute("style"); } } + // Last ditch effort to provide some default styling + if( !style ) style = "fill:#bbbbbb;stroke:#808080"; // This is for display in Symbols dialog only if( style ) { @@ -498,15 +499,6 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPItem *item = SP_ITEM(object_temp); - // Find object's bbox in document. - // Note symbols can have own viewport... ignore for now. - //Geom::OptRect dbox = item->geometricBounds(); - Geom::OptRect dbox = item->documentVisualBounds(); - // if (!dbox) { - // //std::cout << " No dbox" << std::endl; - // //return NULL; - // } - Glib::ustring previewSizeString = previewSize->get_active_text(); unsigned psize = atol( previewSizeString.c_str() ); @@ -520,22 +512,40 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, //Glib::RefPtr pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key)); Glib::RefPtr pixbuf = Glib::RefPtr(0); + // Find object's bbox in document. + // Note symbols can have own viewport... ignore for now. + //Geom::OptRect dbox = item->geometricBounds(); + Geom::OptRect dbox = item->documentVisualBounds(); + if (!dbox) { + //std::cout << " No dbox" << std::endl; + return pixbuf; + } + if (!pixbuf) { /* Scale symbols to fit */ double scale = 1.0; + double width = dbox->width(); + double height = dbox->height(); + if( width == 0.0 ) { + width = 1.0; + } + if( height == 0.0 ) { + height = 1.0; + } + switch (previewScaleRow) { case 0: /* Fit */ - scale = psize/std::max(dbox->width(),dbox->height()); + scale = psize/std::max(width,height); break; case 1: /* Fit width */ - scale = psize/dbox->width(); + scale = psize/width; break; case 2: /* Fit height */ - scale = psize/dbox->height(); + scale = psize/height; break; default: scale = atof( previewScaleString.c_str() ); @@ -560,8 +570,7 @@ SPDocument* SymbolsDialog::symbols_preview_doc() "" +" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" " " " " " " @@ -582,10 +591,6 @@ void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) } } - } //namespace Dialogs } //namespace UI } //namespace Inkscape - - - -- cgit v1.2.3 From f903bca67cd52fce0079dfcccecf712b3bc726df Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 13 Oct 2012 23:38:45 +0200 Subject: Shift key should disable snapping when dragging a handle in the node tool Fixed bugs: - https://launchpad.net/bugs/1065931 (bzr r11791) --- src/ui/tool/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index bda410856..dc6e0fbae 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -293,7 +293,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point parent_pos = _parent->position(); Geom::Point origin = _last_drag_origin(); SnapManager &sm = _desktop->namedview->snap_manager; - bool snap = sm.someSnapperMightSnap(); + bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap(); boost::optional ctrl_constraint; // with Alt, preserve length -- cgit v1.2.3 From 162b892e2dd76ff4a028b9f0239eb6d8b1aa9452 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 14 Oct 2012 00:12:23 +0100 Subject: GTK+ 3: Fix crash with live-preview checkbox in extensions dialog Fixed bugs: - https://launchpad.net/bugs/1012741 (bzr r11792) --- src/extension/prefdialog.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 94f128a42..2d2604c7f 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -32,13 +32,13 @@ namespace Extension { /** \brief Creates a new preference dialog for extension preferences - \param name Name of the Extension who's dialog this is + \param name Name of the Extension whose dialog this is \param help The help string for the extension (NULL if none) \param controls The extension specific widgets in the dialog This function initializes the dialog with the name of the extension in the title. It adds a few buttons and sets up handlers for - them. It also places the passed in widgets into the dialog. + them. It also places the passed-in widgets into the dialog. */ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) : #if WITH_GTKMM_3_0 @@ -102,12 +102,10 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co Gtk::Box * hbox = dynamic_cast(_button_preview); if (hbox != NULL) { #if WITH_GTKMM_3_0 - Gtk::Widget * back = hbox->get_children().back(); + _checkbox_preview = dynamic_cast(hbox->get_children().front()); #else - Gtk::Widget * back = hbox->children().back().get_widget(); + _checkbox_preview = dynamic_cast(hbox->children().back().get_widget()); #endif - Gtk::CheckButton * cb = dynamic_cast(back); - _checkbox_preview = cb; } preview_toggle(); -- cgit v1.2.3 From e64e134d847ae7b741bf94839bd1b2c308984062 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 14 Oct 2012 17:00:27 +0900 Subject: Fix for 171221 : color panel improvements (bzr r11793) --- src/ui/previewholder.cpp | 17 +++++++++++++++++ src/ui/previewholder.h | 1 + 2 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 0dac18665..24049d2f9 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #define COLUMNS_FOR_SMALL 16 #define COLUMNS_FOR_LARGE 8 @@ -56,9 +57,25 @@ PreviewHolder::PreviewHolder() : PreviewHolder::~PreviewHolder() { + } +bool PreviewHolder::on_scroll_event(GdkEventScroll *event) +{ + // Scroll horizontally by page on mouse wheel + Gtk::Adjustment *adj = dynamic_cast(_scroller)->get_hadjustment(); + if (!adj) { + return FALSE; + } + + int move = (event->direction == GDK_SCROLL_DOWN) ? adj->get_page_size() : -adj->get_page_size(); + double value = std::min(adj->get_upper() - move, adj->get_value() + move ); + + adj->set_value(value); + + return FALSE; +} void PreviewHolder::clear() { diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index 8363498a6..4c591bfaf 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -46,6 +46,7 @@ public: protected: virtual void on_size_allocate( Gtk::Allocation& allocation ); + virtual bool on_scroll_event(GdkEventScroll*); // virtual void on_size_request( Gtk::Requisition* requisition ); -- cgit v1.2.3 From 1cbe814e9896f0120b085367991799b06fe911e9 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 14 Oct 2012 10:13:37 +0100 Subject: Don't try to set infinite bounds on SpinButtons in LPE Scalar (bzr r11794) --- src/live_effects/parameter/parameter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index f56df980e..8615721b0 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -51,8 +51,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, Effect* effect, gdouble default_value) : Parameter(label, tip, key, wr, effect), value(default_value), - min(-Geom::infinity()), - max(Geom::infinity()), + min(-G_MAXDOUBLE), + max(G_MAXDOUBLE), integer(false), defvalue(default_value), digits(2), -- cgit v1.2.3 From 07c44d98ba749d6fc9cf5c7dd7a2f73220da5460 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 14 Oct 2012 11:03:51 +0100 Subject: Fix build with new color palette features (bzr r11796) --- src/ui/previewholder.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 24049d2f9..0b280ccb9 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -63,7 +63,12 @@ PreviewHolder::~PreviewHolder() bool PreviewHolder::on_scroll_event(GdkEventScroll *event) { // Scroll horizontally by page on mouse wheel +#if WITH_GTKMM_3_0 + Glib::RefPtr adj = dynamic_cast(_scroller)->get_hadjustment(); +#else Gtk::Adjustment *adj = dynamic_cast(_scroller)->get_hadjustment(); +#endif + if (!adj) { return FALSE; } -- cgit v1.2.3 From 0afbb2021091bb43245ec7225ff825017cd88cf0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 14 Oct 2012 12:37:46 +0200 Subject: Use filter primitive region in flood filter primitive, fixes regression. (bzr r11797) --- src/display/nr-filter-flood.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 449255133..56a27ecd7 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -55,11 +55,34 @@ void FilterFlood::render_cairo(FilterSlot &slot) #endif cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); - cairo_t *ct = cairo_create(out); - cairo_set_source_rgba(ct, r, g, b, a); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_destroy(ct); + + // Get filter primitive area in user units + Geom::Rect fp = filter_primitive_area( slot.get_units() ); + + // Convert to Cairo units + Geom::Rect fp_cairo = fp * slot.get_units().get_matrix_user2pb(); + + // Get area in slot (tile to fill) + Geom::Rect sa = slot.get_slot_area(); + + // Get overlap + Geom::OptRect optoverlap = intersect( fp_cairo, sa ); + if( optoverlap ) { + + Geom::Rect overlap = *optoverlap; + + double dx = fp_cairo.min()[Geom::X] - sa.min()[Geom::X]; + double dy = fp_cairo.min()[Geom::Y] - sa.min()[Geom::Y]; + if( dx < 0.0 ) dx = 0.0; + if( dy < 0.0 ) dy = 0.0; + + cairo_t *ct = cairo_create(out); + cairo_set_source_rgba(ct, r, g, b, a); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_rectangle(ct, dx, dy, overlap.width(), overlap.height() ); + cairo_fill(ct); + cairo_destroy(ct); + } slot.set(_output, out); cairo_surface_destroy(out); -- cgit v1.2.3 From d03137a76998f8c3c25a5307f2d7087581ee06a6 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 14 Oct 2012 20:49:55 +0900 Subject: Fix for 657463 : Mousewheel zooming by two steps, not one (bzr r11798) --- src/display/canvas-arena.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index f0fd63ef4..809f14500 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -316,6 +316,14 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) ret = sp_canvas_arena_send_event (arena, event); break; + case GDK_SCROLL: + if (event->scroll.state & GDK_CONTROL_MASK) { + /* Zoom is emitted by the canvas as well, ignore here */ + return FALSE; + } + ret = sp_canvas_arena_send_event (arena, event); + break; + default: /* Just send event */ ret = sp_canvas_arena_send_event (arena, event); -- cgit v1.2.3 From fadd74ad4d027a6dfb290f3f55fd1197f9cd3376 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 14 Oct 2012 14:23:19 +0200 Subject: Remove invalid return statements (bzr r11799) --- src/object-edit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/object-edit.cpp b/src/object-edit.cpp index b91a6d1e9..ebd0f7584 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -1086,13 +1086,13 @@ sp_star_knot_click(SPItem *item, guint state) void StarKnotHolderEntity1::knot_click(guint state) { - return sp_star_knot_click(item, state); + sp_star_knot_click(item, state); } void StarKnotHolderEntity2::knot_click(guint state) { - return sp_star_knot_click(item, state); + sp_star_knot_click(item, state); } StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : -- cgit v1.2.3 From c524e974852c8bb0a356353e23702be96fff9b83 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 14 Oct 2012 20:06:40 +0200 Subject: Fix "shift disables snapping" for LPEs and for editing objects Fixed bugs: - https://launchpad.net/bugs/1065931 (bzr r11800) --- src/knot-holder-entity.cpp | 16 +++++++--- src/knot-holder-entity.h | 4 +-- src/live_effects/lpe-angle_bisector.cpp | 8 ++--- src/live_effects/lpe-copy_rotate.cpp | 8 ++--- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/lpe-parallel.cpp | 8 ++--- src/live_effects/lpe-perp_bisector.cpp | 14 ++++----- src/live_effects/lpe-perp_bisector.h | 4 +-- src/live_effects/lpe-perspective_path.cpp | 4 +-- src/live_effects/lpe-tangent_to_curve.cpp | 12 ++++---- src/live_effects/parameter/point.cpp | 4 +-- .../parameter/powerstrokepointarray.cpp | 4 +-- src/live_effects/parameter/vector.cpp | 4 +-- src/object-edit.cpp | 36 +++++++++++----------- 14 files changed, 68 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index cb8f29f46..75732f805 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -89,8 +89,12 @@ KnotHolderEntity::update_knot() } Geom::Point -KnotHolderEntity::snap_knot_position(Geom::Point const &p) +KnotHolderEntity::snap_knot_position(Geom::Point const &p, guint state) { + if (state & GDK_SHIFT_MASK) { // Don't snap when shift-key is held + return p; + } + Geom::Affine const i2dt (item->i2dt_affine()); Geom::Point s = p * i2dt; @@ -103,8 +107,12 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p) } Geom::Point -KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint) +KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, guint state) { + if (state & GDK_SHIFT_MASK) { // Don't snap when shift-key is held + return p; + } + Geom::Affine const i2d (item->i2dt_affine()); Geom::Point s = p * i2d; @@ -148,7 +156,7 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); // FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used. - Geom::Point p_snapped = snap_knot_position(p); + Geom::Point p_snapped = snap_knot_position(p, state); if ( state & GDK_CONTROL_MASK ) { if (fabs((p - origin)[Geom::X]) > fabs((p - origin)[Geom::Y])) { @@ -220,7 +228,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const & SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); // FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used. - Geom::Point p_snapped = snap_knot_position(p); + Geom::Point p_snapped = snap_knot_position(p, state); // get angle from current transform gdouble theta = sp_pattern_extract_theta(pat); diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index 58dc89bfd..09d70f8c9 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -65,8 +65,8 @@ public: void update_knot(); //private: - Geom::Point snap_knot_position(Geom::Point const &p); - Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint); + Geom::Point snap_knot_position(Geom::Point const &p, guint state); + Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, guint state); SPKnot *knot; SPItem *item; diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index ce152bb34..4e6176c92 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -99,11 +99,11 @@ LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt namespace AB { void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPEAngleBisector *lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir); lpe->length_left.param_set_value(-lambda); @@ -112,11 +112,11 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPEAngleBisector *lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir); lpe->length_right.param_set_value(lambda); diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 68242cc94..01c0e550c 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -152,7 +152,7 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const { LPECopyRotate* lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) @@ -172,7 +172,7 @@ KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const { LPECopyRotate* lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) @@ -191,14 +191,14 @@ Geom::Point KnotHolderEntityStartingAngle::knot_get() { LPECopyRotate* lpe = dynamic_cast(_effect); - return snap_knot_position(lpe->start_pos); + return lpe->start_pos; } Geom::Point KnotHolderEntityRotationAngle::knot_get() { LPECopyRotate* lpe = dynamic_cast(_effect); - return snap_knot_position(lpe->rot_pos); + return lpe->rot_pos; } } // namespace CR diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 746dbbb7a..61e457d35 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -634,7 +634,7 @@ Geom::Point KnotHolderEntityCrossingSwitcher::knot_get() { LPEKnot* lpe = dynamic_cast(_effect); - return snap_knot_position(lpe->switcher); + return lpe->switcher; } void diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index a6b894ce3..5638bf6de 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -113,13 +113,13 @@ void LPEParallel::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt namespace Pl { void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; LPEParallel *lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); lpe->length_left.param_set_value(-lambda); @@ -128,13 +128,13 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; LPEParallel *lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); lpe->length_right.param_set_value(lambda); diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index 7417c166f..df7e18dcf 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -31,7 +31,7 @@ namespace PB { class KnotHolderEntityEnd : public LPEKnotHolderEntity { public: KnotHolderEntityEnd(LPEPerpBisector *effect) : LPEKnotHolderEntity(effect) {}; - void bisector_end_set(Geom::Point const &p, bool left = true); + void bisector_end_set(Geom::Point const &p, guint state, bool left = true); }; class KnotHolderEntityLeftEnd : public KnotHolderEntityEnd { @@ -61,11 +61,11 @@ KnotHolderEntityRightEnd::knot_get() { } void -KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) { +KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, guint state, bool left) { LPEPerpBisector *lpe = dynamic_cast(_effect); if (!lpe) return; - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->M, lpe->perp_dir); if (left) { @@ -81,13 +81,13 @@ KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) { } void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - bisector_end_set(p); +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + bisector_end_set(p, state); } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - bisector_end_set(p, false); +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + bisector_end_set(p, state, false); } } //namescape PB diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h index 823717e62..f5a918028 100644 --- a/src/live_effects/lpe-perp_bisector.h +++ b/src/live_effects/lpe-perp_bisector.h @@ -27,7 +27,7 @@ namespace PB { class KnotHolderEntityEnd; class KnotHolderEntityLeftEnd; class KnotHolderEntityRightEnd; - void bisector_end_set(SPItem *item, Geom::Point const &p, bool left); + void bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left); } class LPEPerpBisector : public Effect { @@ -46,7 +46,7 @@ public: friend class PB::KnotHolderEntityEnd; friend class PB::KnotHolderEntityLeftEnd; friend class PB::KnotHolderEntityRightEnd; - friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, bool left = true); + friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left = true); void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index f3cf802a1..aeee77482 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -149,13 +149,13 @@ void LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop namespace PP { void -KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint /*state*/) +KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) { using namespace Geom; LPEPerspectivePath* lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); lpe->offsetx.param_set_value((s - origin)[Geom::X]); lpe->offsety.param_set_value(-(s - origin)[Geom::Y]); // additional minus sign is due to coordinate system flipping diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 93dacf3e0..d76675467 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -122,13 +122,13 @@ LPETangentToCurve::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desk namespace TtC { void -KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; LPETangentToCurve* lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); // FIXME: There must be a better way of converting the path's SPCurve* to pwd2. SPCurve *curve = SP_PATH(item)->get_curve_for_edit(); @@ -146,11 +146,11 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or } void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPETangentToCurve *lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->derivA); lpe->length_left.param_set_value(-lambda); @@ -159,11 +159,11 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPETangentToCurve *lpe = dynamic_cast(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->derivA); lpe->length_right.param_set_value(lambda); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index b751aeda3..2be87e048 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -141,9 +141,9 @@ private: }; void -PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); pparam->param_setValue(s); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 68d0175ca..93161ec0d 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -144,7 +144,7 @@ PowerStrokePointArrayParamKnotHolderEntity::PowerStrokePointArrayParamKnotHolder } void -PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; @@ -156,7 +156,7 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom: Piecewise > const & pwd2 = _pparam->get_pwd2(); Piecewise > const & n = _pparam->get_pwd2_normal(); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double t = nearest_point(s, pwd2); double offset = dot(s - pwd2.valueAt(t), n.valueAt(t)); _pparam->_vector.at(_index) = Geom::Point(t, offset); diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 8b62ba91e..a20c46042 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -149,8 +149,8 @@ public: VectorParamKnotHolderEntity_Origin(VectorParam *p) : param(p) { } virtual ~VectorParamKnotHolderEntity_Origin() {} - virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - Geom::Point const s = snap_knot_position(p); + virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + Geom::Point const s = snap_knot_position(p, state); param->setOrigin(s); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); }; diff --git a/src/object-edit.cpp b/src/object-edit.cpp index ebd0f7584..989d84c7f 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -141,7 +141,7 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig //In general we cannot just snap this radius to an arbitrary point, as we have only a single //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap //the radius then we should have a constrained snap. snap_knot_position() is unconstrained - Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0))); + Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)), state); if (state & GDK_CONTROL_MASK) { gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0; @@ -190,7 +190,7 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig //In general we cannot just snap this radius to an arbitrary point, as we have only a single //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap //the radius then we should have a constrained snap. snap_knot_position() is unconstrained - Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1))); + Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)), state); if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry, // resulting in a perfect circle (and not an ellipse) @@ -279,13 +279,13 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or // snap to horizontal or diagonal if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) { // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->height.computed = MAX(h_orig + minx / ratio, 0); } else { // closer to the horizontal, change only width, height is h_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->height.computed = MAX(h_orig, 0); @@ -296,13 +296,13 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or // snap to vertical or diagonal if (miny != 0 && fabs(minx/miny) > 0.5 * ratio && (SGN(minx) == SGN(miny))) { // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->width.computed = MAX(w_orig + miny * ratio, 0); } else { // closer to the vertical, change only height, width is w_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->width.computed = MAX(w_orig, 0); @@ -315,7 +315,7 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or } else { // move freely - s = snap_knot_position(p); + s = snap_knot_position(p, state); rect->width.computed = MAX(s[Geom::X] - rect->x.computed, 0); rect->height.computed = MAX(s[Geom::Y] - rect->y.computed, 0); rect->width._set = rect->height._set = true; @@ -369,14 +369,14 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin // snap to horizontal or diagonal if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) { // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->y.computed = MIN(origin[Geom::Y] + minx / ratio, opposite_y); rect->height.computed = MAX(h_orig - minx / ratio, 0); } else { // closer to the horizontal, change only width, height is h_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->y.computed = MIN(origin[Geom::Y], opposite_y); @@ -388,14 +388,14 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin // snap to vertical or diagonal if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) { // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->x.computed = MIN(origin[Geom::X] + miny * ratio, opposite_x); rect->width.computed = MAX(w_orig - miny * ratio, 0); } else { // closer to the vertical, change only height, width is w_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1))); + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; rect->x.computed = MIN(origin[Geom::X], opposite_x); @@ -409,7 +409,7 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin } else { // move freely - s = snap_knot_position(p); + s = snap_knot_position(p, state); minx = s[Geom::X] - origin[Geom::X]; miny = s[Geom::Y] - origin[Geom::Y]; @@ -483,7 +483,7 @@ Box3DKnotHolderEntity::knot_get_generic(SPItem *item, unsigned int knot_id) void Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, guint state) { - Geom::Point const s = snap_knot_position(new_pos); + Geom::Point const s = snap_knot_position(new_pos, state); g_assert(item != NULL); SPBox3D *box = SP_BOX3D(item); @@ -660,7 +660,7 @@ Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const & void Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, guint state) { - Geom::Point const s = snap_knot_position(new_pos); + Geom::Point const s = snap_knot_position(new_pos, state); SPBox3D *box = SP_BOX3D(item); Geom::Affine const i2dt (item->i2dt_affine ()); @@ -875,7 +875,7 @@ ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origi { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); ge->rx.computed = fabs( ge->cx.computed - s[Geom::X] ); @@ -910,7 +910,7 @@ ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origi { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); ge->ry.computed = fabs( ge->cy.computed - s[Geom::Y] ); @@ -995,7 +995,7 @@ StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origi { SPStar *star = SP_STAR(item); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); Geom::Point d = s - star->center; @@ -1021,7 +1021,7 @@ StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origi { SPStar *star = SP_STAR(item); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); if (star->flatsided == false) { Geom::Point d = s - star->center; -- cgit v1.2.3 From 9779ceaf104e71b3e72057025a5e820ae89fd422 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 14 Oct 2012 19:23:13 +0100 Subject: Stop using private GdlDockObject->master (broken in GDL 3.6) (bzr r11801) --- src/ui/widget/dock.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index a7dabef1c..a38a93fb1 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -81,9 +81,15 @@ Dock::Dock(Gtk::Orientation orientation) static_cast(prefs->getIntLimited("/options/dock/switcherstyle", GDL_SWITCHER_STYLE_BOTH, 0, 4)); - g_object_set (GDL_DOCK_OBJECT(_gdl_dock)->master, - "switcher-style", gdl_switcher_style, - NULL); + GdlDockMaster* master = NULL; + + g_object_get(GDL_DOCK_OBJECT(_gdl_dock), + "master", &master, + NULL); + + g_object_set(master, + "switcher-style", gdl_switcher_style, + NULL); GdlDockBarStyle gdl_dock_bar_style = static_cast(prefs->getIntLimited("/options/dock/dockbarstyle", -- cgit v1.2.3 From bd2871a7036bb8f907ad9921f18560d1460f7af9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 15 Oct 2012 12:50:00 +0200 Subject: Use filter primitive region and aspect ratio in image filter primitive, fixes regression. (bzr r11803) --- src/display/nr-filter-image.cpp | 132 +++++++++++++++++++++++++++++++++------- src/display/nr-filter-image.h | 1 - 2 files changed, 110 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index a9a5ec3e0..722a4ed7f 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -20,6 +20,7 @@ #include "display/nr-filter-image.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" +#include "enums.h" #include namespace Inkscape { @@ -50,22 +51,31 @@ void FilterImage::render_cairo(FilterSlot &slot) //cairo_surface_t *input = slot.getcairo(_input); + // Viewport is filter primitive area (in user coordinates). + // Note: viewport calculation in non-trivial. Do not use + // rely on get_matrix_primitiveunits2pb(). + Geom::Rect vp = filter_primitive_area( slot.get_units() ); + double feImageX = vp.min()[Geom::X]; + double feImageY = vp.min()[Geom::Y]; + double feImageWidth = vp.width(); + double feImageHeight = vp.height(); + + // feImage is suppose to use the same parameters as a normal SVG image. + // If a width or height is set to zero, the image is not suppose to be displayed. + // This does not seem to be what Firefox or Opera does, nor does the W3C displacement + // filter test expect this behavior. If the width and/or height are zero, we use + // the width and height of the object bounding box. Geom::Affine m = slot.get_units().get_matrix_user2filterunits().inverse(); Geom::Point bbox_00 = Geom::Point(0,0) * m; Geom::Point bbox_w0 = Geom::Point(1,0) * m; Geom::Point bbox_0h = Geom::Point(0,1) * m; double bbox_width = Geom::distance(bbox_00, bbox_w0); double bbox_height = Geom::distance(bbox_00, bbox_0h); - - // feImage is suppose to use the same parameters as a normal SVG image. - // If a width or height is set to zero, the image is not suppose to be displayed. - // This does not seem to be what Firefox or Opera does, nor does the W3C displacement - // filter test expect this behavior. If the width and/or height are zero, we use - // the width and height of the object bounding box. if( feImageWidth == 0 ) feImageWidth = bbox_width; if( feImageHeight == 0 ) feImageHeight = bbox_height; + // Internal image, like if (from_element) { if (!SVGElem) return; @@ -87,7 +97,7 @@ void FilterImage::render_cairo(FilterSlot &slot) drawing.setRoot(ai); Geom::Rect area = *optarea; - Geom::Affine pu2pb = slot.get_units().get_matrix_primitiveunits2pb(); + Geom::Affine user2pb = slot.get_units().get_matrix_user2pb(); double scaleX = feImageWidth / area.width(); double scaleY = feImageHeight / area.height(); @@ -96,9 +106,9 @@ void FilterImage::render_cairo(FilterSlot &slot) cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, sa.width(), sa.height()); Inkscape::DrawingContext ct(out, sa.min()); - ct.transform(pu2pb); // we are now in primitive units + ct.transform(user2pb); // we are now in primitive units ct.translate(feImageX, feImageY); - ct.scale(scaleX, scaleY); +// ct.scale(scaleX, scaleY); No scaling should be done Geom::IntRect render_rect = area.roundOutwards(); ct.translate(render_rect.min()); @@ -113,6 +123,7 @@ void FilterImage::render_cairo(FilterSlot &slot) return; } + // External image, like if (!image && !broken_ref) { broken_ref = true; try { @@ -158,9 +169,9 @@ void FilterImage::render_cairo(FilterSlot &slot) } // Native size of image - //width = image->get_width(); - //height = image->get_height(); - //rowstride = image->get_rowstride(); + // width = image->get_width(); + // height = image->get_height(); + // rowstride = image->get_rowstride(); convert_pixbuf_normal_to_argb32(image->gobj()); @@ -174,11 +185,94 @@ void FilterImage::render_cairo(FilterSlot &slot) cairo_t *ct = cairo_create(out); cairo_translate(ct, -sa.min()[Geom::X], -sa.min()[Geom::Y]); - // now ct is in pb coordinates - ink_cairo_transform(ct, slot.get_units().get_matrix_primitiveunits2pb()); + + // now ct is in pb coordinates, note the feWidth etc. are in user units + ink_cairo_transform(ct, slot.get_units().get_matrix_user2pb()); + // now ct is in the coordinates of feImageX etc. - // TODO: add preserveAspectRatio support here + // Now that we have the viewport, we must map image inside. + // Partially copied from sp-image.cpp. + + // Do nothing if preserveAspectRatio is "none". + if( aspect_align != SP_ASPECT_NONE ) { + + // Check aspect ratio of image vs. viewport + double feAspect = feImageHeight/feImageWidth; + double aspect = (double)image->get_height()/(double)image->get_width(); + bool ratio = (feAspect < aspect); + + double ax, ay; // Align side + switch( aspect_align ) { + case SP_ASPECT_XMIN_YMIN: + ax = 0.0; + ay = 0.0; + break; + case SP_ASPECT_XMID_YMIN: + ax = 0.5; + ay = 0.0; + break; + case SP_ASPECT_XMAX_YMIN: + ax = 1.0; + ay = 0.0; + break; + case SP_ASPECT_XMIN_YMID: + ax = 0.0; + ay = 0.5; + break; + case SP_ASPECT_XMID_YMID: + ax = 0.5; + ay = 0.5; + break; + case SP_ASPECT_XMAX_YMID: + ax = 1.0; + ay = 0.5; + break; + case SP_ASPECT_XMIN_YMAX: + ax = 0.0; + ay = 1.0; + break; + case SP_ASPECT_XMID_YMAX: + ax = 0.5; + ay = 1.0; + break; + case SP_ASPECT_XMAX_YMAX: + ax = 1.0; + ay = 1.0; + break; + default: + ax = 0.0; + ay = 0.0; + break; + } + + if( aspect_clip == SP_ASPECT_SLICE ) { + // image clipped by viewbox + + if( ratio ) { + // clip top/bottom + feImageY -= ay * (feImageWidth * aspect - feImageHeight); + feImageHeight = feImageWidth * aspect; + } else { + // clip sides + feImageX -= ax * (feImageHeight / aspect - feImageWidth); + feImageWidth = feImageHeight / aspect; + } + + } else { + // image fits into viewbox + + if( ratio ) { + // fit to height + feImageX += ax * (feImageWidth - feImageHeight / aspect ); + feImageWidth = feImageHeight / aspect; + } else { + // fit to width + feImageY += ay * (feImageHeight - feImageWidth * aspect); + feImageHeight = feImageWidth * aspect; + } + } + } double scaleX = feImageWidth / image->get_width(); double scaleY = feImageHeight / image->get_height(); @@ -204,6 +298,7 @@ double FilterImage::complexity(Geom::Affine const &) } void FilterImage::set_href(const gchar *href){ + if (feImageHref) g_free (feImageHref); feImageHref = (href) ? g_strdup (href) : NULL; @@ -218,13 +313,6 @@ void FilterImage::set_document(SPDocument *doc){ document = doc; } -void FilterImage::set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height) { - feImageX=x.computed; - feImageY=y.computed; - feImageWidth=width.computed; - feImageHeight=height.computed; -} - void FilterImage::set_align( unsigned int align ) { aspect_align = align; } diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index c0b9d6e81..05b7d65a8 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -35,7 +35,6 @@ public: void set_document( SPDocument *document ); void set_href(const gchar *href); - void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height); void set_align( unsigned int align ); void set_clip( unsigned int clip ); bool from_element; -- cgit v1.2.3 From af8254ef0ce34909183a1a2985572c1f96f2d32d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 15 Oct 2012 15:54:17 +0200 Subject: Better attempt at finding primitive filter region for percent and userSpaceOnUse. (bzr r11804) --- src/display/nr-filter-image.cpp | 4 ++-- src/display/nr-filter-primitive.cpp | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 722a4ed7f..e03a56964 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -52,8 +52,8 @@ void FilterImage::render_cairo(FilterSlot &slot) //cairo_surface_t *input = slot.getcairo(_input); // Viewport is filter primitive area (in user coordinates). - // Note: viewport calculation in non-trivial. Do not use - // rely on get_matrix_primitiveunits2pb(). + // Note: viewport calculation in non-trivial. Do not rely + // on get_matrix_primitiveunits2pb(). Geom::Rect vp = filter_primitive_area( slot.get_units() ); double feImageX = vp.min()[Geom::X]; double feImageY = vp.min()[Geom::Y]; diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index c6bd8a74e..93c6d4d6e 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -15,6 +15,12 @@ #include "display/nr-filter-types.h" #include "svg/svg-length.h" +#include "inkscape.h" +#include "desktop.h" +#include "desktop-handles.h" +#include "document.h" +#include "sp-root.h" + namespace Inkscape { namespace Filters { @@ -103,6 +109,19 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units) Geom::OptRect bb = units.get_item_bbox(); Geom::OptRect fa = units.get_filter_area(); + // This is definitely a hack... but what else to do? + // Current viewport might not be document viewport... but how to find? + SPDesktop* desktop = inkscape_active_desktop(); + SPDocument* document = sp_desktop_document(desktop); + SPRoot* root = document->getRoot(); + Geom::Rect viewport; + if( root->viewBox_set ) { + viewport = root->viewBox; + } else { + // Pick some random values + viewport = Geom::Rect::from_xywh(0,0,480,360); + } + /* Update computed values for ex, em, %. For %, assumes primitive unit is objectBoundingBox. */ /* TODO: fetch somehow the object ex and em lengths; 12, 6 are just dummy values. */ double len_x = bb->width(); @@ -144,11 +163,11 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units) if( _subregion_y._set && _subregion_y.unit != SVGLength::PERCENT ) y = _subregion_y.computed; if( _subregion_width._set && _subregion_width.unit != SVGLength::PERCENT ) width = _subregion_width.computed; if( _subregion_height._set && _subregion_height.unit != SVGLength::PERCENT ) height = _subregion_height.computed; - // TODO: add percent of viewport TEMPORARY HACK FOR TESTING... - if( _subregion_x._set && _subregion_x.unit == SVGLength::PERCENT ) x = _subregion_x.value * 480; // viewport_x - if( _subregion_y._set && _subregion_y.unit == SVGLength::PERCENT ) y = _subregion_y.value * 360; - if( _subregion_width._set && _subregion_width.unit == SVGLength::PERCENT ) width = _subregion_width.value * 480; - if( _subregion_height._set && _subregion_height.unit == SVGLength::PERCENT ) height = _subregion_height.value * 360; + // Percent of viewport + if( _subregion_x._set && _subregion_x.unit == SVGLength::PERCENT ) x = _subregion_x.value * viewport.width(); + if( _subregion_y._set && _subregion_y.unit == SVGLength::PERCENT ) y = _subregion_y.value * viewport.height(); + if( _subregion_width._set && _subregion_width.unit == SVGLength::PERCENT ) width = _subregion_width.value * viewport.width(); + if( _subregion_height._set && _subregion_height.unit == SVGLength::PERCENT ) height = _subregion_height.value * viewport.height(); } Geom::Point minp, maxp; -- cgit v1.2.3 From 8bb515cbaffa18aa2baee841c4ec2269336e39df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Oct 2012 16:53:47 -0500 Subject: Files in /src that no longer exist (bzr r11804.1.2) --- src/2geom/Makefile_insert | 3 --- src/Makefile.am | 4 ---- src/Makefile_insert | 1 - src/display/Makefile_insert | 1 - src/extension/Makefile_insert | 1 - src/extension/internal/Makefile_insert | 2 -- src/helper/Makefile_insert | 1 - src/libgdl/Makefile_insert | 4 ---- src/libnrtype/Makefile_insert | 1 - src/livarot/Makefile_insert | 1 - src/xml/Makefile_insert | 3 +-- 11 files changed, 1 insertion(+), 21 deletions(-) (limited to 'src') diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index e3b6fcdab..fa84a5701 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -47,7 +47,6 @@ 2geom/geom.h \ 2geom/hvlinesegment.h \ 2geom/interval.h \ - 2geom/isnan.h \ 2geom/linear.h \ 2geom/line.cpp \ 2geom/line.h \ @@ -70,7 +69,6 @@ 2geom/piecewise.h \ 2geom/point.cpp \ 2geom/point.h \ - 2geom/point-l.h \ 2geom/point-ops.h \ 2geom/poly.cpp \ 2geom/poly.h \ @@ -101,7 +99,6 @@ 2geom/solve-bezier-one-d.cpp \ 2geom/solve-bezier-parametric.cpp \ 2geom/solver.h \ - 2geom/sturm.h \ 2geom/svg-elliptical-arc.cpp \ 2geom/svg-elliptical-arc.h \ 2geom/svg-path.cpp \ diff --git a/src/Makefile.am b/src/Makefile.am index fc1065b34..a95569db7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -156,7 +156,6 @@ EXTRA_DIST += \ $(top_srcdir)/Doxyfile \ sp-skeleton.cpp sp-skeleton.h \ util/makefile.in \ - application/makefile.in \ bind/makefile.in \ debug/makefile.in \ dialogs/makefile.in \ @@ -171,11 +170,8 @@ EXTRA_DIST += \ io/makefile.in \ io/crystalegg.xml \ io/doc2html.xsl \ - pedro/makefile.in \ - jabber_whiteboard/makefile.in \ libgdl/makefile.in \ libcroco/makefile.in \ - libnr/makefile.in \ libnrtype/makefile.in \ libavoid/makefile.in \ livarot/makefile.in \ diff --git a/src/Makefile_insert b/src/Makefile_insert index 36e05270a..8f6c7277d 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -61,7 +61,6 @@ ink_common_sources += \ filter-enums.cpp filter-enums.h \ fixes.cpp \ flood-context.cpp flood-context.h \ - forward.h \ gc-alloc.h \ gc-anchored.h gc-anchored.cpp \ gc-core.h \ diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index cf211108f..393c79233 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -47,7 +47,6 @@ ink_common_sources += \ display/guideline.h \ display/nr-3dutils.cpp \ display/nr-3dutils.h \ - display/nr-arena-forward.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ display/nr-filter-colormatrix.cpp \ diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert index ffcee5f9a..4e75de13a 100644 --- a/src/extension/Makefile_insert +++ b/src/extension/Makefile_insert @@ -3,7 +3,6 @@ ink_common_sources += \ extension/extension.cpp \ extension/extension.h \ - extension/extension-forward.h \ extension/db.cpp \ extension/db.h \ extension/dependency.cpp \ diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index a0fda8e10..51615f7e7 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -136,8 +136,6 @@ ink_common_sources += \ extension/internal/filter/filter-file.cpp \ extension/internal/filter/filter.cpp \ extension/internal/filter/filter.h \ - extension/internal/filter/drop-shadow.h \ - extension/internal/filter/snow.h \ extension/internal/emf-win32-print.h \ extension/internal/emf-win32-print.cpp \ extension/internal/emf-win32-inout.h \ diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert index 0efb5d6ce..2be40e0e0 100644 --- a/src/helper/Makefile_insert +++ b/src/helper/Makefile_insert @@ -12,7 +12,6 @@ ink_common_sources += \ helper/geom-nodetype.h \ helper/gnome-utils.cpp \ helper/gnome-utils.h \ - helper/helper-forward.h \ helper/png-write.cpp \ helper/png-write.h \ helper/sp-marshal.cpp \ diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert index 788df0673..3f5228a20 100644 --- a/src/libgdl/Makefile_insert +++ b/src/libgdl/Makefile_insert @@ -3,7 +3,6 @@ if WITH_EXT_GDL EXTRA_DIST += \ - libgdl/gdl-tools.h \ libgdl/gdl-dock-object.h \ libgdl/gdl-dock-master.h \ libgdl/gdl-dock.h \ @@ -13,7 +12,6 @@ EXTRA_DIST += \ libgdl/gdl-dock-tablabel.h \ libgdl/gdl-dock-placeholder.h \ libgdl/gdl-dock-bar.h \ - libgdl/gdl-stock-icons.h \ libgdl/gdl-i18n.h \ libgdl/gdl-i18n.c \ libgdl/gdl-dock-object.c \ @@ -47,7 +45,6 @@ libgdl/clean: rm -f libgdl/libgdl.a $(libgdl_gdl_a_OBJECTS) libgdl_libgdl_a_SOURCES = \ - libgdl/gdl-tools.h \ libgdl/gdl-dock-object.h \ libgdl/gdl-dock-master.h \ libgdl/gdl-dock.h \ @@ -57,7 +54,6 @@ libgdl_libgdl_a_SOURCES = \ libgdl/gdl-dock-tablabel.h \ libgdl/gdl-dock-placeholder.h \ libgdl/gdl-dock-bar.h \ - libgdl/gdl-stock-icons.h \ libgdl/gdl-i18n.h \ libgdl/gdl-i18n.c \ libgdl/gdl-dock-object.c \ diff --git a/src/libnrtype/Makefile_insert b/src/libnrtype/Makefile_insert index 7cd99e1a8..0ce8f1fd5 100644 --- a/src/libnrtype/Makefile_insert +++ b/src/libnrtype/Makefile_insert @@ -11,7 +11,6 @@ ink_common_sources += \ libnrtype/nr-type-pos-def.h \ libnrtype/nr-type-primitives.cpp \ libnrtype/nr-type-primitives.h \ - libnrtype/nrtype-forward.h \ libnrtype/FontFactory.cpp \ libnrtype/FontFactory.h \ libnrtype/FontInstance.cpp \ diff --git a/src/livarot/Makefile_insert b/src/livarot/Makefile_insert index e4d88efd5..69078d073 100644 --- a/src/livarot/Makefile_insert +++ b/src/livarot/Makefile_insert @@ -37,6 +37,5 @@ livarot_libvarot_a_SOURCES = \ livarot/sweep-event.cpp \ livarot/sweep-event.h \ livarot/sweep-event-queue.h \ - livarot/livarot-forward.h \ livarot/path-description.h \ livarot/path-description.cpp diff --git a/src/xml/Makefile_insert b/src/xml/Makefile_insert index b10f2448b..da55d7f7e 100644 --- a/src/xml/Makefile_insert +++ b/src/xml/Makefile_insert @@ -40,8 +40,7 @@ ink_common_sources += \ xml/subtree.cpp \ xml/subtree.h \ xml/text-node.h \ - xml/invalid-operation-exception.h \ - xml/xml-forward.h + xml/invalid-operation-exception.h # ###################### # ### CxxTest stuff #### -- cgit v1.2.3 From 7686a704cbf9198ca4420a77ee7a77df9b260040 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Oct 2012 16:58:41 -0500 Subject: Drop some extra inkboard and pedro cruft (bzr r11804.1.4) --- src/Makefile.am | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index a95569db7..46c655f9c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,9 +16,6 @@ bin_PROGRAMS = inkscape inkview # Libraries which should be compiled by "make" but not installed. # Use this only for libraries that are really standalone, rather than for # source tree subdirectories. -#if WITH_INKBOARD -#libpedro = pedro/libpedro.a -#endif if !WITH_EXT_GDL internal_GDL = libgdl/libgdl.a @@ -35,7 +32,6 @@ noinst_LIBRARIES = \ libvpsc/libvpsc.a \ livarot/libvarot.a \ 2geom/lib2geom.a \ - $(libpedro) \ libinkversion.a all_libs = \ @@ -109,11 +105,6 @@ win32ldflags = -lcomdlg32 -lmscms mwindows = -mwindows endif -if INKJAR -inkjar_dir = inkjar -inkjar_libs = inkjar/libinkjar.a -endif - # Include all partial makefiles from subdirectories include Makefile_insert include bind/Makefile_insert @@ -195,7 +186,6 @@ EXTRA_DIST += \ helper/sp-marshal.list \ show-preview.bmp \ winconsole.cpp \ - $(jabber_whiteboard_SOURCES) \ $(CXXTEST_TEMPLATE) # Extra files to remove when doing "make distclean" -- cgit v1.2.3 From 235a08d39fcb7c936f02e201b65a1f7664e55772 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Oct 2012 17:04:36 -0500 Subject: New 2geom files and putting in the same order as 'ls' (bzr r11804.1.5) --- src/2geom/Makefile_insert | 228 +++++++++++++++++++++++++--------------------- 1 file changed, 124 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index fa84a5701..07e066df5 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -6,109 +6,129 @@ rm -f 2geom/lib2geom.a $(2geom_lib2geom_a_OBJECTS) 2geom_lib2geom_a_SOURCES = \ - 2geom/affine.h \ - 2geom/affine.cpp \ - 2geom/angle.h \ - 2geom/basic-intersection.cpp \ - 2geom/basic-intersection.h \ - 2geom/bezier-clipping.cpp \ - 2geom/bezier-curve.cpp \ - 2geom/bezier-curve.h \ - 2geom/bezier.h \ - 2geom/bezier-to-sbasis.h \ - 2geom/bezier-utils.cpp \ - 2geom/bezier-utils.h \ - 2geom/choose.h \ - 2geom/circle-circle.cpp \ - 2geom/circle.cpp \ - 2geom/circle.h \ - 2geom/circulator.h \ - 2geom/concepts.h \ - 2geom/conjugate_gradient.cpp \ - 2geom/conjugate_gradient.h \ - 2geom/convex-cover.cpp \ - 2geom/convex-cover.h \ - 2geom/coord.h \ - 2geom/crossing.cpp \ - 2geom/crossing.h \ + 2geom/2geom.h \ + 2geom/affine.cpp \ + 2geom/affine.h \ + 2geom/angle.h \ + 2geom/basic-intersection.cpp \ + 2geom/basic-intersection.h \ + 2geom/bezier-clipping.cpp \ + 2geom/bezier-curve.cpp \ + 2geom/bezier-curve.h \ + 2geom/bezier.h \ + 2geom/bezier-to-sbasis.h \ + 2geom/bezier-utils.cpp \ + 2geom/bezier-utils.h \ + 2geom/choose.h \ + 2geom/circle-circle.cpp \ + 2geom/circle.cpp \ + 2geom/circle.h \ + 2geom/circulator.h \ + 2geom/CMakeLists.txt \ + 2geom/concepts.h \ + 2geom/conicsec.cpp \ + 2geom/conicsec.h \ + 2geom/conic_section_clipper_cr.h \ + 2geom/conic_section_clipper.h \ + 2geom/conic_section_clipper_impl.cpp \ + 2geom/conic_section_clipper_impl.h \ + 2geom/conjugate_gradient.cpp \ + 2geom/conjugate_gradient.h \ + 2geom/convex-cover.cpp \ + 2geom/convex-cover.h \ + 2geom/coord.h \ + 2geom/crossing.cpp \ + 2geom/crossing.h \ 2geom/curve.cpp \ - 2geom/curve.h \ - 2geom/curves.h \ - 2geom/d2.h \ - 2geom/d2-sbasis.cpp \ - 2geom/d2-sbasis.h \ - 2geom/ellipse.cpp \ - 2geom/ellipse.h \ - 2geom/elliptical-arc.cpp \ - 2geom/elliptical-arc.h \ - 2geom/exception.h \ - 2geom/forward.h \ - 2geom/geom.cpp \ - 2geom/geom.h \ - 2geom/hvlinesegment.h \ - 2geom/interval.h \ - 2geom/linear.h \ - 2geom/line.cpp \ - 2geom/line.h \ - 2geom/nearest-point.cpp \ - 2geom/nearest-point.h \ - 2geom/numeric/fitting-model.h \ - 2geom/numeric/fitting-tool.h \ - 2geom/numeric/linear_system.h \ - 2geom/numeric/matrix.cpp \ - 2geom/numeric/matrix.h \ - 2geom/numeric/vector.h \ - 2geom/ord.h \ - 2geom/path.cpp \ - 2geom/path.h \ - 2geom/path-intersection.cpp \ - 2geom/path-intersection.h \ - 2geom/pathvector.cpp \ - 2geom/pathvector.h \ - 2geom/piecewise.cpp \ - 2geom/piecewise.h \ - 2geom/point.cpp \ - 2geom/point.h \ - 2geom/point-ops.h \ - 2geom/poly.cpp \ - 2geom/poly.h \ - 2geom/quadtree.cpp \ - 2geom/quadtree.h \ - 2geom/ray.h \ - 2geom/rect.cpp \ - 2geom/rect.h \ - 2geom/region.cpp \ - 2geom/region.h \ - 2geom/sbasis-2d.cpp \ - 2geom/sbasis-2d.h \ - 2geom/sbasis.cpp \ - 2geom/sbasis-curve.h \ - 2geom/sbasis-geometric.cpp \ - 2geom/sbasis-geometric.h \ - 2geom/sbasis.h \ - 2geom/sbasis-math.cpp \ - 2geom/sbasis-math.h \ - 2geom/sbasis-poly.cpp \ - 2geom/sbasis-poly.h \ - 2geom/sbasis-roots.cpp \ - 2geom/sbasis-to-bezier.cpp \ - 2geom/sbasis-to-bezier.h \ - 2geom/shape.cpp \ - 2geom/shape.h \ - 2geom/solve-bezier.cpp \ - 2geom/solve-bezier-one-d.cpp \ - 2geom/solve-bezier-parametric.cpp \ - 2geom/solver.h \ - 2geom/svg-elliptical-arc.cpp \ - 2geom/svg-elliptical-arc.h \ - 2geom/svg-path.cpp \ - 2geom/svg-path.h \ - 2geom/svg-path-parser.cpp \ - 2geom/svg-path-parser.h \ - 2geom/sweep.cpp \ - 2geom/sweep.h \ - 2geom/transforms.cpp \ - 2geom/transforms.h \ - 2geom/utils.cpp \ - 2geom/utils.h + 2geom/curve.h \ + 2geom/curves.h \ + 2geom/d2.h \ + 2geom/d2-sbasis.cpp \ + 2geom/d2-sbasis.h \ + 2geom/ellipse.cpp \ + 2geom/ellipse.h \ + 2geom/elliptical-arc.cpp \ + 2geom/elliptical-arc.h \ + 2geom/exception.h \ + 2geom/forward.h \ + 2geom/generic-interval.h \ + 2geom/generic-rect.h \ + 2geom/geom.cpp \ + 2geom/geom.h \ + 2geom/hvlinesegment.h \ + 2geom/interval.h \ + 2geom/int-interval.h \ + 2geom/int-point.h \ + 2geom/int-rect.h \ + 2geom/linear.h \ + 2geom/line.cpp \ + 2geom/line.h \ + 2geom/math-utils.h \ + 2geom/nearest-point.cpp \ + 2geom/nearest-point.h \ + 2geom/ord.h \ + 2geom/path.cpp \ + 2geom/path.h \ + 2geom/path-intersection.cpp \ + 2geom/path-intersection.h \ + 2geom/pathvector.cpp \ + 2geom/pathvector.h \ + 2geom/piecewise.cpp \ + 2geom/piecewise.h \ + 2geom/point.cpp \ + 2geom/point.h \ + 2geom/point-ops.h \ + 2geom/poly.cpp \ + 2geom/poly.h \ + 2geom/quadtree.cpp \ + 2geom/quadtree.h \ + 2geom/ray.h \ + 2geom/rect.cpp \ + 2geom/rect.h \ + 2geom/recursive-bezier-intersection.cpp \ + 2geom/region.cpp \ + 2geom/region.h \ + 2geom/sbasis-2d.cpp \ + 2geom/sbasis-2d.h \ + 2geom/sbasis.cpp \ + 2geom/sbasis-curve.h \ + 2geom/sbasis-geometric.cpp \ + 2geom/sbasis-geometric.h \ + 2geom/sbasis.h \ + 2geom/sbasis-math.cpp \ + 2geom/sbasis-math.h \ + 2geom/sbasis-poly.cpp \ + 2geom/sbasis-poly.h \ + 2geom/sbasis-roots.cpp \ + 2geom/sbasis-to-bezier.cpp \ + 2geom/sbasis-to-bezier.h \ + 2geom/shape.cpp \ + 2geom/shape.h \ + 2geom/solve-bezier.cpp \ + 2geom/solve-bezier-one-d.cpp \ + 2geom/solve-bezier-parametric.cpp \ + 2geom/solver.h \ + 2geom/svg-elliptical-arc.cpp \ + 2geom/svg-elliptical-arc.h \ + 2geom/svg-path.cpp \ + 2geom/svg-path.h \ + 2geom/svg-path-parser.cpp \ + 2geom/svg-path-parser.h \ + 2geom/sweep.cpp \ + 2geom/sweep.h \ + 2geom/toposweep.cpp \ + 2geom/toposweep.h \ + 2geom/transforms.cpp \ + 2geom/transforms.h \ + 2geom/utils.cpp \ + 2geom/utils.h \ + 2geom/numeric/fitting-model.h \ + 2geom/numeric/fitting-tool.h \ + 2geom/numeric/linear_system.h \ + 2geom/numeric/matrix.cpp \ + 2geom/numeric/matrix.h \ + 2geom/numeric/symmetric-matrix-fs.h \ + 2geom/numeric/symmetric-matrix-fs-operation.h \ + 2geom/numeric/symmetric-matrix-fs-trace.h \ + 2geom/numeric/vector.h -- cgit v1.2.3 From af688389733a30f414fbc805d3a0d77d61f234e9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Oct 2012 18:22:11 -0500 Subject: A few more headers (bzr r11804.1.6) --- src/Makefile_insert | 2 +- src/display/Makefile_insert | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index 8f6c7277d..2d557158b 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -40,7 +40,7 @@ ink_common_sources += \ dir-util.cpp dir-util.h \ document.cpp document.h document-private.h \ document-subset.cpp document-subset.h \ - document-undo.cpp \ + document-undo.cpp document-undo.h \ doxygen-main.cpp \ draw-anchor.cpp draw-anchor.h \ draw-context.cpp draw-context.h \ diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 393c79233..abbd89a68 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -106,6 +106,8 @@ ink_common_sources += \ display/sodipodi-ctrlrect.h \ display/sp-canvas.cpp \ display/sp-canvas.h \ + display/sp-canvas-item.h \ + display/sp-canvas-group.h \ display/sp-canvas-util.cpp \ display/sp-canvas-util.h \ display/sp-ctrlcurve.cpp \ -- cgit v1.2.3 From a81c6a9e1d7bea8e1876900540ca9520f8ce015e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Oct 2012 21:15:24 -0500 Subject: Getting all the filter headers (bzr r11804.1.7) --- src/extension/internal/Makefile_insert | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 51615f7e7..1ea6caca9 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -132,6 +132,20 @@ ink_common_sources += \ extension/internal/latex-pstricks.h \ extension/internal/latex-pstricks-out.cpp \ extension/internal/latex-pstricks-out.h \ + extension/internal/filter/bevels.h \ + extension/internal/filter/blurs.h \ + extension/internal/filter/bumps.h \ + extension/internal/filter/color.h \ + extension/internal/filter/distort.h \ + extension/internal/filter/filter.h \ + extension/internal/filter/image.h \ + extension/internal/filter/morphology.h \ + extension/internal/filter/overlays.h \ + extension/internal/filter/paint.h \ + extension/internal/filter/protrusions.h \ + extension/internal/filter/shadows.h \ + extension/internal/filter/textures.h \ + extension/internal/filter/transparency.h \ extension/internal/filter/filter-all.cpp \ extension/internal/filter/filter-file.cpp \ extension/internal/filter/filter.cpp \ -- cgit v1.2.3 From 46eea9b1e2f4bde9e8a4c48c5fbda05531153b6b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 16 Oct 2012 12:38:57 +0200 Subject: Fix crash resulting from r11646. (bzr r11805) --- src/xml/simple-node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index 55bd28afe..4965f81c8 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -346,7 +346,7 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_ // tree (and thus has no parent), default values will not be tested. if( !strcmp( name, "style" ) && (flags >= SP_ATTR_CLEAN_STYLE_WARN) ) { g_free( cleaned_value ); - cleaned_value = const_cast(sp_attribute_clean_style( this, value, flags ).c_str()); + cleaned_value = g_strdup( sp_attribute_clean_style( this, value, flags ).c_str() ); // if( g_strcmp0( value, cleaned_value ) ) { // g_warning( "SimpleNode::setAttribute: %s", id.c_str() ); // g_warning( " original: %s", value); -- cgit v1.2.3 From 87f54097e479b2014eeb7b4458473130379fe529 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 17 Oct 2012 16:31:30 +0900 Subject: Fix for 171333 : Adjust icon for moving guides (bzr r11806) --- src/desktop-events.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 1377fef9d..e0ffe66bf 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -502,7 +502,16 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) guide_cursor = gdk_cursor_new (GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); #if GTK_CHECK_VERSION(3,0,0) - g_object_unref(guide_cursor); + g_object_unref(guide_cursor); +#else + gdk_cursor_unref(guide_cursor); +#endif + } else { + GdkCursor *guide_cursor; + guide_cursor = gdk_cursor_new (GDK_FLEUR); + gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(guide_cursor); #else gdk_cursor_unref(guide_cursor); #endif -- cgit v1.2.3 From 401984634d289610103cf85be19a73712381d785 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 18 Oct 2012 14:21:16 +0900 Subject: Fix for 171333 : Adjust icon for moving guides - Hand icon (bzr r11807) --- src/desktop-events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index e0ffe66bf..1cfe018ce 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -508,7 +508,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) #endif } else { GdkCursor *guide_cursor; - guide_cursor = gdk_cursor_new (GDK_FLEUR); + guide_cursor = gdk_cursor_new (GDK_HAND1); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); #if GTK_CHECK_VERSION(3,0,0) g_object_unref(guide_cursor); -- cgit v1.2.3 From 8e2e7b350b7a48347f1842060431bb9fd7bfa94c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 19 Oct 2012 14:51:28 +0200 Subject: Filters. Fixing filters structure and typo. (bzr r11809) --- src/extension/internal/filter/paint.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index dcc51c815..ad396e08f 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -644,7 +644,6 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" "\n" "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), lightness.str().c_str()); -- cgit v1.2.3 From 8f1beab3df861c270d655c7abcd00a87171cee57 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 20 Oct 2012 09:54:19 +0200 Subject: UI uniformisation (bzr r11811) --- src/live_effects/lpe-angle_bisector.cpp | 4 ++-- src/live_effects/lpe-dynastroke.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 4e6176c92..8aa88f1f0 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -42,8 +42,8 @@ public: LPEAngleBisector::LPEAngleBisector(LivePathEffectObject *lpeobject) : Effect(lpeobject), - length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 0), - length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250) + length_left(_("Length left:"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 0), + length_right(_("Length right:"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250) { show_orig_path = true; _provides_knotholder_entities = true; diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index a3e2073ee..c41041577 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -71,17 +71,17 @@ static const Util::EnumDataConverter DSCTConverter(Dynast LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - method(_("Method"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST), - width(_("Pen width"), _("Maximal stroke width"), "width", &wr, this, 25), - roundness(_("Pen roundness"), _("Min/Max width ratio"), "roundness", &wr, this, .2), - angle(_("angle"), _("direction of thickest strokes (opposite = thinest)"), "angle", &wr, this, 45), + method(_("Method:"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST), + width(_("Pen width:"), _("Maximal stroke width"), "width", &wr, this, 25), + roundness(_("Pen roundness:"), _("Min/Max width ratio"), "roundness", &wr, this, .2), + angle(_("Angle:"), _("direction of thickest strokes (opposite = thinest)"), "angle", &wr, this, 45), // modulo_pi(_("modulo pi"), _("Give forward and backward moves in one direction the same thickness "), "modulo_pi", &wr, this, false), - start_cap(_("Start"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP), - end_cap(_("End"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP), - growfor(_("Grow for"), _("Make the stroke thiner near it's start"), "growfor", &wr, this, 100), - fadefor(_("Fade for"), _("Make the stroke thiner near it's end"), "fadefor", &wr, this, 100), + start_cap(_("Start:"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP), + end_cap(_("End:"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP), + growfor(_("Grow for:"), _("Make the stroke thiner near it's start"), "growfor", &wr, this, 100), + fadefor(_("Fade for:"), _("Make the stroke thiner near it's end"), "fadefor", &wr, this, 100), round_ends(_("Round ends"), _("Strokes end with a round end"), "round_ends", &wr, this, false), - capping(_("Capping"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") + capping(_("Capping:"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") { registerParameter( dynamic_cast(& method) ); -- cgit v1.2.3 From 9be0cfa6a09efbdf5657f512ac8db3ed801b6e28 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 20 Oct 2012 09:59:57 +0200 Subject: Do not show console debug messages for dynastroke lpe (bzr r11813) --- src/live_effects/lpe-dynastroke.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index c41041577..467fdfd9c 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -115,7 +115,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p { using namespace Geom; - std::cout<<"do effect: debut\n"; +// std::cout<<"do effect: debut\n"; Piecewise > output; Piecewise > m = pwd2_in; @@ -156,13 +156,13 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p DynastrokeMethod stroke_method = method.get_value(); if (roundness==1.) { - std::cout<<"round pen.\n"; +// std::cout<<"round pen.\n"; n1 = n*double(width); n2 =-n1; }else{ switch(stroke_method) { case DSM_ELLIPTIC_PEN:{ - std::cout<<"ellptic pen\n"; +// std::cout<<"ellptic pen\n"; //FIXME: roundness=0??? double c = cos(angle_rad), s = sin(angle_rad); Affine rot,slant; @@ -178,7 +178,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p break; } case DSM_THICKTHIN_FAST:{ - std::cout<<"fast thick thin pen\n"; +// std::cout<<"fast thick thin pen\n"; D2 > n_xy = make_cuts_independent(n); w = n_xy[X]*sin(angle_rad) - n_xy[Y]*cos(angle_rad); w = w * ((1 - roundness)*width/2.) + ((1 + roundness)*width/2.); @@ -187,7 +187,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p break; } case DSM_THICKTHIN_SLOW:{ - std::cout<<"slow thick thin pen\n"; +// std::cout<<"slow thick thin pen\n"; D2 > n_xy = make_cuts_independent(n); w = n_xy[X]*cos(angle_rad)+ n_xy[Y]*sin(angle_rad); w = w * ((1 - roundness)*width/2.) + ((1 + roundness)*width/2.); @@ -196,12 +196,12 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p Piecewise dw = derivative(w); Piecewise ncomp = sqrt(dot(v,v)-dw*dw,.1,3); //FIXME: is force continuity usefull? compatible with corners? - std::cout<<"ici\n"; +// std::cout<<"ici\n"; n1 = -dw*v + ncomp*rot90(v); n1 = w*force_continuity(unitVector(n1),.1); n2 = -dw*v - ncomp*rot90(v); n2 = w*force_continuity(unitVector(n2),.1); - std::cout<<"ici2\n"; +// std::cout<<"ici2\n"; break; } default:{ @@ -219,13 +219,13 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p Piecewise > left, right; if ( m.segs.front().at0() == m.segs.back().at1()){ // if closed: - std::cout<<"closed input.\n"; +// std::cout<<"closed input.\n"; left = m + n1;//+ n; right = m + n2;//- n; } else { //if not closed, shape the ends: //TODO: allow fancy ends... - std::cout<<"shaping the ends\n"; +// std::cout<<"shaping the ends\n"; double grow_length = growfor;// * width; double fade_length = fadefor;// * width; Piecewise s = arcLengthSb(m); @@ -240,7 +240,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p factor_in.concat(Piecewise(Linear(1))); factor_in.cuts[2]=totlength; } - std::cout<<"shaping the ends ici\n"; +// std::cout<<"shaping the ends ici\n"; //scale factor for a sharp end join[0] = Linear(1,0); join[1] = Linear(1,1); @@ -254,7 +254,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p factor_out = Piecewise(join); factor_out.setDomain(Interval(totlength-fade_length,totlength)); } - std::cout<<"shaping the ends ici ici\n"; +// std::cout<<"shaping the ends ici ici\n"; Piecewise factor = factor_in*factor_out; n1 = compose(factor,s)*n1; @@ -262,10 +262,10 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p left = m + n1; right = m + n2; - std::cout<<"shaping the ends ici ici ici\n"; +// std::cout<<"shaping the ends ici ici ici\n"; if (start_cap.get_value() == DSCT_ROUND){ - std::cout<<"shaping round start\n"; +// std::cout<<"shaping round start\n"; SBasis tau(2,Linear(0)); tau[1] = Linear(-1,0); Piecewise hbump; @@ -280,7 +280,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p right += - hbump * rot90(n); } if (end_cap.get_value() == DSCT_ROUND){ - std::cout<<"shaping round end\n"; +// std::cout<<"shaping round end\n"; SBasis tau(2,Linear(0)); tau[1] = Linear(0,1); Piecewise hbump; @@ -299,11 +299,11 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p left = force_continuity(left); right = force_continuity(right); - std::cout<<"gathering result: left"; +// std::cout<<"gathering result: left"; output = left; - std::cout<<" + reverse(right)"; +// std::cout<<" + reverse(right)"; output.concat(reverse(right)); - std::cout<<". done\n"; +// std::cout<<". done\n"; //----------- return output; -- cgit v1.2.3 From 91b35886250f10cc7a1c3e7ecdc7ea92e54144cb Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 20 Oct 2012 17:02:25 +0100 Subject: GTK3: Migrate desktop widget to GtkGrid (bzr r11814) --- src/widgets/desktop-widget.cpp | 179 ++++++++++++++++++++++++++++++++--------- 1 file changed, 143 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 9f18cc671..04a6447dd 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -317,17 +317,11 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) */ void SPDesktopWidget::init( SPDesktopWidget *dtw ) { - GtkWidget *widget; - GtkWidget *tbl; - GtkWidget *canvas_tbl; - - GtkWidget *eventbox; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); new (&dtw->modified_connection) sigc::connection(); - widget = GTK_WIDGET (dtw); + GtkWidget *widget = GTK_WIDGET (dtw); dtw->window = 0; dtw->desktop = NULL; @@ -365,6 +359,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #else dtw->hbox = gtk_hbox_new(FALSE, 0); #endif + gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 ); gtk_widget_show(dtw->hbox); @@ -382,24 +377,42 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL ); gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 ); - tbl = gtk_table_new (2, 3, FALSE); - gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 ); - - canvas_tbl = gtk_table_new (3, 3, FALSE); - /* Horizontal ruler */ - eventbox = gtk_event_box_new (); + GtkWidget *eventbox = gtk_event_box_new (); dtw->hruler = sp_ruler_new(GTK_ORIENTATION_HORIZONTAL); dtw->hruler_box = eventbox; sp_ruler_set_metric(SP_RULER(dtw->hruler), SP_PT); gtk_widget_set_tooltip_text (dtw->hruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT)))); gtk_container_add (GTK_CONTAINER (eventbox), dtw->hruler); - gtk_table_attach (GTK_TABLE (canvas_tbl), eventbox, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), - gtk_widget_get_style(widget)->xthickness, 0); + guint xthickness = gtk_widget_get_style(widget)->xthickness; + guint ythickness = gtk_widget_get_style(widget)->ythickness; g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_hruler_event), dtw); g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_hruler_event), dtw); g_signal_connect (G_OBJECT (eventbox), "motion_notify_event", G_CALLBACK (sp_dt_hruler_event), dtw); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *tbl = gtk_grid_new(); + GtkWidget *canvas_tbl = gtk_grid_new(); + + gtk_widget_set_margin_left(eventbox, xthickness); + gtk_widget_set_margin_right(eventbox, xthickness); + + gtk_widget_set_halign(eventbox, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(eventbox, TRUE); + gtk_widget_set_valign(eventbox, GTK_ALIGN_START); + + gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 1, 0, 1, 1); +#else + GtkWidget *tbl = gtk_table_new(2, 3, FALSE); + GtkWidget *canvas_tbl = gtk_table_new(3, 3, FALSE); + + gtk_table_attach(GTK_TABLE (canvas_tbl), eventbox, 1, 2, 0, 1, + GTK_FILL, GTK_FILL, + xthickness, 0); +#endif + + gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 ); + /* Vertical ruler */ eventbox = gtk_event_box_new (); dtw->vruler = sp_ruler_new(GTK_ORIENTATION_VERTICAL); @@ -407,28 +420,46 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) sp_ruler_set_metric (SP_RULER (dtw->vruler), SP_PT); gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT)))); gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler)); - gtk_table_attach (GTK_TABLE (canvas_tbl), eventbox, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, - gtk_widget_get_style(widget)->ythickness); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_top(eventbox, ythickness); + gtk_widget_set_margin_bottom(eventbox, ythickness); + + gtk_widget_set_halign(eventbox, GTK_ALIGN_START); + gtk_widget_set_valign(eventbox, GTK_ALIGN_FILL); + gtk_widget_set_vexpand(eventbox, TRUE); + + gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 0, 1, 1, 1); +#else + gtk_table_attach(GTK_TABLE (canvas_tbl), eventbox, 0, 1, 1, 2, + GTK_FILL, GTK_FILL, + 0, ythickness); +#endif + g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_vruler_event), dtw); g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_vruler_event), dtw); g_signal_connect (G_OBJECT (eventbox), "motion_notify_event", G_CALLBACK (sp_dt_vruler_event), dtw); - /* Horizontal scrollbar */ + // Horizontal scrollbar dtw->hadj = (GtkAdjustment *) gtk_adjustment_new (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0); -#if GTK_CHECK_VERSION(3,0,0) - dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj)); -#else - dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj)); -#endif - gtk_table_attach (GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_SHRINK), 0, 0); - /* Vertical scrollbar and the sticky zoom button */ #if GTK_CHECK_VERSION(3,0,0) + dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj)); + gtk_widget_set_halign(dtw->hscrollbar, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(dtw->hscrollbar, TRUE); + gtk_widget_set_valign(dtw->hscrollbar, GTK_ALIGN_END); + gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(dtw->vscrollbar_box), FALSE); #else + dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj)); + gtk_table_attach(GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, + GTK_FILL, GTK_SHRINK, + 0, 0); dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0); #endif + + // Sticky zoom button dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, @@ -437,15 +468,28 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("/options/stickyzoom/value")); gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (dtw->sticky_zoom), "toggled", G_CALLBACK (sp_dtw_sticky_zoom_toggled), dtw); + + // Vertical scrollbar dtw->vadj = (GtkAdjustment *) gtk_adjustment_new (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0); + #if GTK_CHECK_VERSION(3,0,0) dtw->vscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(dtw->vadj)); #else dtw->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (dtw->vadj)); #endif + gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->vscrollbar, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_FILL), 0, 0); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_valign(dtw->vscrollbar, GTK_ALIGN_FILL); + gtk_widget_set_vexpand(dtw->vscrollbar, TRUE); + gtk_widget_set_halign(dtw->vscrollbar, GTK_ALIGN_END); + gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); +#else + gtk_table_attach(GTK_TABLE(canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, + GTK_SHRINK, GTK_FILL, + 0, 0); +#endif gchar const* tip = ""; Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE ); @@ -476,7 +520,16 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #else cms_adjust_set_sensitive(dtw, FALSE); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_grid_attach( GTK_GRID(canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); +#else + gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, + (GtkAttachOptions)(GTK_SHRINK), + (GtkAttachOptions)(GTK_SHRINK), + 0, 0); +#endif + { if (!watcher) { watcher = new CMSPrefWatcher(); @@ -500,17 +553,24 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) GtkStyle *style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dtw->canvas))); style->bg[GTK_STATE_NORMAL] = style->white; gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style); -#endif - + // TODO: Extension event stuff has been removed from public API in GTK+ 3 // Need to check that this hasn't broken anything -#if !GTK_CHECK_VERSION(3,0,0) if ( prefs->getBool("/options/useextinput/value", true) ) gtk_widget_set_extension_events(GTK_WIDGET (dtw->canvas) , GDK_EXTENSION_EVENTS_ALL); //set extension events for tablets, unless disabled in preferences #endif g_signal_connect (G_OBJECT (dtw->canvas), "event", G_CALLBACK (sp_desktop_widget_event), dtw); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(GTK_WIDGET(dtw->canvas), GTK_ALIGN_FILL); + gtk_widget_set_valign(GTK_WIDGET(dtw->canvas), GTK_ALIGN_FILL); + gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE); + gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE); + gtk_grid_attach(GTK_GRID(canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); +#else gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); +#endif /* Dock */ bool create_dock = @@ -530,12 +590,28 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) paned_class->cycle_handle_focus = NULL; } +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_hexpand(GTK_WIDGET(paned->gobj()), TRUE); + gtk_widget_set_vexpand(GTK_WIDGET(paned->gobj()), TRUE); + gtk_widget_set_halign(GTK_WIDGET(paned->gobj()), GTK_ALIGN_FILL); + gtk_widget_set_valign(GTK_WIDGET(paned->gobj()), GTK_ALIGN_FILL); + gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (paned->gobj()), 1, 1, 1, 1); +#else gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (paned->gobj()), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); +#endif } else { +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_hexpand(GTK_WIDGET(canvas_tbl), TRUE); + gtk_widget_set_vexpand(GTK_WIDGET(canvas_tbl), TRUE); + gtk_widget_set_halign(GTK_WIDGET(canvas_tbl), GTK_ALIGN_FILL); + gtk_widget_set_valign(GTK_WIDGET(canvas_tbl), GTK_ALIGN_FILL); + gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (canvas_tbl), 1, 1, 1, 1); +#else gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); +#endif } dtw->selected_style = new Inkscape::UI::Widget::SelectedStyle(true); @@ -573,35 +649,66 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); // cursor coordinates - dtw->coord_status = gtk_table_new (5, 2, FALSE); +#if GTK_CHECK_VERSION(3,0,0) + dtw->coord_status = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(dtw->coord_status), 0); + gtk_grid_set_column_spacing(GTK_GRID(dtw->coord_status), 2); + GtkWidget* sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL); + gtk_grid_attach(GTK_GRID(dtw->coord_status), + GTK_WIDGET(sep), + 0, 0, 1, 2); +#else + dtw->coord_status = gtk_table_new(5, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(dtw->coord_status), 0); gtk_table_set_col_spacings(GTK_TABLE(dtw->coord_status), 2); gtk_table_attach(GTK_TABLE(dtw->coord_status), -#if GTK_CHECK_VERSION(3,0,0) - gtk_separator_new(GTK_ORIENTATION_VERTICAL), -#else gtk_vseparator_new(), + 0, 1, 0, 2, + GTK_FILL, GTK_FILL, 0, 0); #endif - 0,1, 0,2, GTK_FILL, GTK_FILL, 0, 0); + eventbox = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (eventbox), dtw->coord_status); gtk_widget_set_tooltip_text (eventbox, _("Cursor coordinates")); GtkWidget *label_x = gtk_label_new(_("X:")); gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_grid_attach(GTK_GRID(dtw->coord_status), + label_x, 1, 0, 1, 1); +#else gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0); +#endif + GtkWidget *label_y = gtk_label_new(_("Y:")); gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_grid_attach(GTK_GRID(dtw->coord_status), label_y, 1, 1, 1, 1); +#else gtk_table_attach(GTK_TABLE(dtw->coord_status), label_y, 1,2, 1,2, GTK_FILL, GTK_FILL, 0, 0); +#endif + dtw->coord_status_x = gtk_label_new(NULL); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), " 0.00 " ); gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5); dtw->coord_status_y = gtk_label_new(NULL); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), " 0.00 " ); gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5); + GtkWidget* label_z = gtk_label_new(_("Z:")); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2); +#else gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0); - gtk_table_attach(GTK_TABLE(dtw->coord_status), gtk_label_new(_("Z:")), 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 4,5, 0,2, GTK_FILL, GTK_FILL, 0, 0); +#endif + sp_set_font_size_smaller (dtw->coord_status); gtk_box_pack_end (GTK_BOX (statusbar_tail), eventbox, FALSE, FALSE, 1); -- cgit v1.2.3 From 7169965e82d0da4b76c3b4c7c3483fe2f7826537 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 20 Oct 2012 19:19:03 +0100 Subject: GTK3: Migrate toolbox to GtkGrid API (bzr r11815) --- src/widgets/toolbox.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 6e03c2606..b758e4f0f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1423,8 +1423,13 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) GtkWidget* kludge = dataHolders[aux_toolboxes[i].type_name]; +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget* holder = gtk_grid_new(); + gtk_grid_attach( GTK_GRID(holder), kludge, 2, 0, 1, 1); +#else GtkWidget* holder = gtk_table_new( 1, 3, FALSE ); gtk_table_attach( GTK_TABLE(holder), kludge, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 ); +#endif gchar* tmp = g_strdup_printf( "/ui/%s", aux_toolboxes[i].ui_name ); GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, tmp ); @@ -1438,7 +1443,12 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small"); gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast(toolboxSize) ); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_hexpand(toolBar, TRUE); + gtk_grid_attach( GTK_GRID(holder), toolBar, 0, 0, 1, 1); +#else gtk_table_attach( GTK_TABLE(holder), toolBar, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0 ); +#endif if ( aux_toolboxes[i].swatch_verb_id != SP_VERB_INVALID ) { Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch( NULL, _(aux_toolboxes[i].swatch_tip) ); @@ -1446,7 +1456,16 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) swatch->setClickVerb( aux_toolboxes[i].swatch_verb_id ); swatch->setWatchedTool( aux_toolboxes[i].swatch_tool, true ); GtkWidget *swatch_ = GTK_WIDGET( swatch->gobj() ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(swatch_, AUX_BETWEEN_BUTTON_GROUPS); + gtk_widget_set_margin_right(swatch_, AUX_BETWEEN_BUTTON_GROUPS); + gtk_widget_set_margin_top(swatch_, AUX_SPACING); + gtk_widget_set_margin_bottom(swatch_, AUX_SPACING); + gtk_grid_attach( GTK_GRID(holder), swatch_, 1, 0, 1, 1); +#else gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, AUX_SPACING ); +#endif } gtk_widget_show_all( holder ); -- cgit v1.2.3 From 38ef6c69bb3a0718427d40d6463aee1d0c26d4be Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 21 Oct 2012 12:06:31 +0100 Subject: Fix grid layout in desktop widget (bzr r11816) --- src/widgets/desktop-widget.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 04a6447dd..1d1429c40 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -447,7 +447,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj)); gtk_widget_set_halign(dtw->hscrollbar, GTK_ALIGN_FILL); gtk_widget_set_hexpand(dtw->hscrollbar, TRUE); - gtk_widget_set_valign(dtw->hscrollbar, GTK_ALIGN_END); gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(dtw->vscrollbar_box), FALSE); @@ -483,7 +482,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_valign(dtw->vscrollbar, GTK_ALIGN_FILL); gtk_widget_set_vexpand(dtw->vscrollbar, TRUE); - gtk_widget_set_halign(dtw->vscrollbar, GTK_ALIGN_END); gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); #else gtk_table_attach(GTK_TABLE(canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, -- cgit v1.2.3 From 6e7e20a81f37f1e4b31d69fde6bf48b9f0a2fc92 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 21 Oct 2012 20:04:54 +0200 Subject: UI uniformisation (bzr r11817) --- src/live_effects/lpe-boolops.cpp | 4 ++-- src/live_effects/lpe-copy_rotate.cpp | 6 +++--- src/live_effects/lpe-lattice.cpp | 32 ++++++++++++++-------------- src/live_effects/lpe-line_segment.cpp | 2 +- src/live_effects/lpe-mirror_symmetry.cpp | 2 +- src/live_effects/lpe-parallel.cpp | 4 ++-- src/live_effects/lpe-path_length.cpp | 4 ++-- src/live_effects/lpe-perp_bisector.cpp | 4 ++-- src/live_effects/lpe-recursiveskeleton.cpp | 2 +- src/live_effects/lpe-tangent_to_curve.cpp | 8 +++---- src/live_effects/lpe-test-doEffect-stack.cpp | 6 +++--- src/live_effects/lpe-text_label.cpp | 2 +- 12 files changed, 38 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-boolops.cpp b/src/live_effects/lpe-boolops.cpp index efaca7e8b..641cf5d50 100644 --- a/src/live_effects/lpe-boolops.cpp +++ b/src/live_effects/lpe-boolops.cpp @@ -32,8 +32,8 @@ static const Util::EnumDataConverter BoolopTypeConverter(BoolopTypeDat LPEBoolops::LPEBoolops(LivePathEffectObject *lpeobject) : Effect(lpeobject), - bool_path(_("2nd path"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"), - boolop_type(_("Boolop type"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION) + bool_path(_("2nd path:"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"), + boolop_type(_("Boolop type:"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION) { show_orig_path = true; diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 01c0e550c..9ac553ed5 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -48,9 +48,9 @@ public: LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : Effect(lpeobject), - starting_angle(_("Starting"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0), - rotation_angle(_("Rotation angle"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0), - num_copies(_("Number of copies"), _("Number of copies of the original path"), "num_copies", &wr, this, 5), + starting_angle(_("Starting:"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0), + rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0), + num_copies(_("Number of copies:"), _("Number of copies of the original path"), "num_copies", &wr, this, 5), origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"), dist_angle_handle(100) { diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 473469c8a..2d04c4d41 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -42,22 +42,22 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - grid_point0(_("Control handle 0"), _("Control handle 0"), "gridpoint0", &wr, this), - grid_point1(_("Control handle 1"), _("Control handle 1"), "gridpoint1", &wr, this), - grid_point2(_("Control handle 2"), _("Control handle 2"), "gridpoint2", &wr, this), - grid_point3(_("Control handle 3"), _("Control handle 3"), "gridpoint3", &wr, this), - grid_point4(_("Control handle 4"), _("Control handle 4"), "gridpoint4", &wr, this), - grid_point5(_("Control handle 5"), _("Control handle 5"), "gridpoint5", &wr, this), - grid_point6(_("Control handle 6"), _("Control handle 6"), "gridpoint6", &wr, this), - grid_point7(_("Control handle 7"), _("Control handle 7"), "gridpoint7", &wr, this), - grid_point8(_("Control handle 8"), _("Control handle 8"), "gridpoint8", &wr, this), - grid_point9(_("Control handle 9"), _("Control handle 9"), "gridpoint9", &wr, this), - grid_point10(_("Control handle 10"), _("Control handle 10"), "gridpoint10", &wr, this), - grid_point11(_("Control handle 11"), _("Control handle 11"), "gridpoint11", &wr, this), - grid_point12(_("Control handle 12"), _("Control handle 12"), "gridpoint12", &wr, this), - grid_point13(_("Control handle 13"), _("Control handle 13"), "gridpoint13", &wr, this), - grid_point14(_("Control handle 14"), _("Control handle 14"), "gridpoint14", &wr, this), - grid_point15(_("Control handle 15"), _("Control handle 15"), "gridpoint15", &wr, this) + grid_point0(_("Control handle 0:"), _("Control handle 0"), "gridpoint0", &wr, this), + grid_point1(_("Control handle 1:"), _("Control handle 1"), "gridpoint1", &wr, this), + grid_point2(_("Control handle 2:"), _("Control handle 2"), "gridpoint2", &wr, this), + grid_point3(_("Control handle 3:"), _("Control handle 3"), "gridpoint3", &wr, this), + grid_point4(_("Control handle 4:"), _("Control handle 4"), "gridpoint4", &wr, this), + grid_point5(_("Control handle 5:"), _("Control handle 5"), "gridpoint5", &wr, this), + grid_point6(_("Control handle 6:"), _("Control handle 6"), "gridpoint6", &wr, this), + grid_point7(_("Control handle 7:"), _("Control handle 7"), "gridpoint7", &wr, this), + grid_point8(_("Control handle 8:"), _("Control handle 8"), "gridpoint8", &wr, this), + grid_point9(_("Control handle 9:"), _("Control handle 9"), "gridpoint9", &wr, this), + grid_point10(_("Control handle 10:"), _("Control handle 10"), "gridpoint10", &wr, this), + grid_point11(_("Control handle 11:"), _("Control handle 11"), "gridpoint11", &wr, this), + grid_point12(_("Control handle 12:"), _("Control handle 12"), "gridpoint12", &wr, this), + grid_point13(_("Control handle 13:"), _("Control handle 13"), "gridpoint13", &wr, this), + grid_point14(_("Control handle 14:"), _("Control handle 14"), "gridpoint14", &wr, this), + grid_point15(_("Control handle 15:"), _("Control handle 15"), "gridpoint15", &wr, this) { // register all your parameters here, so Inkscape knows which parameters this effect has: diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp index f0d5bab0a..6619b85ce 100644 --- a/src/live_effects/lpe-line_segment.cpp +++ b/src/live_effects/lpe-line_segment.cpp @@ -31,7 +31,7 @@ static const Util::EnumDataConverter EndTypeConverter(EndTypeData, size LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) : Effect(lpeobject), - end_type(_("End type"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH) + end_type(_("End type:"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH) { /* register all your parameters here, so Inkscape knows which parameters this effect has: */ registerParameter( dynamic_cast(&end_type) ); diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 7bfaf2d99..a56909338 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -30,7 +30,7 @@ namespace LivePathEffect { LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : Effect(lpeobject), discard_orig_path(_("Discard original path?"), _("Check this to only keep the mirrored part of the path"), "discard_orig_path", &wr, this, false), - reflection_line(_("Reflection line"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100") + reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100") { show_orig_path = true; diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 5638bf6de..4d4b0c17d 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -48,8 +48,8 @@ LPEParallel::LPEParallel(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: offset_pt(_("Offset"), _("Adjust the offset"), "offset_pt", &wr, this), - length_left(_("Length left"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150), - length_right(_("Length right"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150) + length_left(_("Length left:"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150), + length_right(_("Length right:"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150) { show_orig_path = true; _provides_knotholder_entities = true; diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp index 1b9e7be48..d3edcda27 100644 --- a/src/live_effects/lpe-path_length.cpp +++ b/src/live_effects/lpe-path_length.cpp @@ -23,9 +23,9 @@ namespace LivePathEffect { LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) : Effect(lpeobject), - scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0), + scale(_("Scale:"), _("Scaling factor"), "scale", &wr, this, 1.0), info_text(this), - unit(_("Unit"), _("Unit"), "unit", &wr, this), + unit(_("Unit:"), _("Unit"), "unit", &wr, this), display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true) { registerParameter(dynamic_cast(&scale)); diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index df7e18dcf..c528ef692 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -94,8 +94,8 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) : Effect(lpeobject), - length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200), - length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200), + length_left(_("Length left:"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200), + length_right(_("Length right:"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200), A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0) { show_orig_path = true; diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index cd1140950..906c430c1 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -27,7 +27,7 @@ namespace LivePathEffect { LPERecursiveSkeleton::LPERecursiveSkeleton(LivePathEffectObject *lpeobject) : Effect(lpeobject), - iterations(_("Iterations"), _("recursivity"), "iterations", &wr, this, 2) + iterations(_("Iterations:"), _("recursivity"), "iterations", &wr, this, 2) { show_orig_path = true; concatenate_before_pwd2 = true; diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index d76675467..b40d404ae 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -58,10 +58,10 @@ public: LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) : Effect(lpeobject), - angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0), - t_attach(_("Location along curve"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5), - length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150), - length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150) + angle(_("Angle:"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0), + t_attach(_("Location along curve:"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5), + length_left(_("Length left:"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150), + length_right(_("Length right:"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150) { show_orig_path = true; _provides_knotholder_entities = true; diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index b678e35c1..03e3e7997 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -19,9 +19,9 @@ namespace LivePathEffect { LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) : Effect(lpeobject), - step(_("Stack step"), ("How deep we should go into the stack"), "step", &wr, this), - point(_("point param"), "tooltip of point parameter", "point_param", &wr, this), - path(_("path param"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0") + step(_("Stack step:"), ("How deep we should go into the stack"), "step", &wr, this), + point(_("Point param:"), "tooltip of point parameter", "point_param", &wr, this), + path(_("Path param:"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0") { registerParameter( dynamic_cast(&step) ); registerParameter( dynamic_cast(&point) ); diff --git a/src/live_effects/lpe-text_label.cpp b/src/live_effects/lpe-text_label.cpp index b59722566..602a6897c 100644 --- a/src/live_effects/lpe-text_label.cpp +++ b/src/live_effects/lpe-text_label.cpp @@ -20,7 +20,7 @@ namespace LivePathEffect { LPETextLabel::LPETextLabel(LivePathEffectObject *lpeobject) : Effect(lpeobject), - label(_("Label"), _("Text label attached to the path"), "label", &wr, this, "This is a label") + label(_("Label:"), _("Text label attached to the path"), "label", &wr, this, "This is a label") { registerParameter( dynamic_cast(&label) ); } -- cgit v1.2.3 From ed87de315e80b0066e2dd74d07ff2ec688592072 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 22 Oct 2012 21:47:12 +0900 Subject: Fix for 1067808 : Focus issues with new gradient (and swatch) manager in Fill&Stroke (trunk) (bzr r11819) --- src/widgets/gradient-selector.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index dffda69e3..65608585b 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -336,6 +336,14 @@ void SPGradientSelector::onTreeSelection() return; } + if (!treeview->has_focus()) { + /* Workaround for GTK bug on Windows/OS X + * When the treeview initially doesn't have focus and is clicked + * sometimes get_selection()->signal_changed() has the wrong selection + */ + treeview->grab_focus(); + } + const Glib::RefPtr sel = treeview->get_selection(); if (!sel) { return; -- cgit v1.2.3 From 9e010c259cfdbeaacd5d519264e1d6ad82c44363 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Oct 2012 03:17:54 +1100 Subject: update cmake files & make function static. (bzr r11821) --- src/live_effects/lpe-powerstroke.cpp | 2 +- src/ui/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 13fea76c5..b042f8d41 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -157,7 +157,7 @@ static int circle_circle_intersection(Circle const &circle0, Circle const &circl * Find circle that touches inside of the curve, with radius matching the curvature, at time value \c t. * Because this method internally uses unitTangentAt, t should be smaller than 1.0 (see unitTangentAt). */ -Circle touching_circle( D2 const &curve, double t, double tol=0.01 ) +static Circle touching_circle( D2 const &curve, double t, double tol=0.01 ) { //Piecewise k = curvature(curve, tol); D2 dM=derivative(curve); diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index ec7782302..8fd8eb4e3 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -60,6 +60,7 @@ set(ui_SRC dialog/print-colors-preview-dialog.cpp dialog/print.cpp dialog/scriptdialog.cpp + dialog/symbols.cpp dialog/xml-tree.cpp # dialog/session-player.cpp dialog/spellcheck.cpp @@ -174,6 +175,7 @@ set(ui_SRC dialog/spellcheck.h dialog/svg-fonts-dialog.h dialog/swatches.h + dialog/symbols.h dialog/text-edit.h dialog/tile.h dialog/tracedialog.h -- cgit v1.2.3 From 3c8f6b5ed34852b06b38b1046d4d9042155c96a2 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 23 Oct 2012 14:43:40 +0900 Subject: Fix for 171890 : Mouse wheel on swatches (bzr r11822) --- src/pixmaps/cursor-adj-a.xpm | 38 ++++++++++++++ src/ui/widget/rotateable.cpp | 31 +++++++++++ src/ui/widget/rotateable.h | 3 ++ src/ui/widget/selected-style.cpp | 109 ++++++++++++++++++++++++--------------- src/ui/widget/selected-style.h | 3 ++ 5 files changed, 143 insertions(+), 41 deletions(-) create mode 100644 src/pixmaps/cursor-adj-a.xpm (limited to 'src') diff --git a/src/pixmaps/cursor-adj-a.xpm b/src/pixmaps/cursor-adj-a.xpm new file mode 100644 index 000000000..7af3d9c12 --- /dev/null +++ b/src/pixmaps/cursor-adj-a.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_adj_a_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" .. ", +" .++. ", +" .++. ", +" .+..+. ", +" .+..+. ", +" .++++. ", +" .+ .+. ", +" .... .+..+. ", +" .++. . ...... ", +" .++. .+. ", +" ....++.... .+. ", +" .++++++++. .+. ", +" .++++++++. .+. ", +" ....++.... .+. ", +" .++. .+. ", +" .++. .+. ", +" .... .+. ", +" .+. ", +" .+. ", +" .+. ", +" .+. .......... ", +" .+. .++++++++. ", +" .+. .++++++++. ", +" .+. .......... ", +" .+. ", +" .+. ", +" .+. ", +" .+. ", +" .+. ", +" . ", +" ", +" "}; diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 7be666843..1d91515e5 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -24,12 +24,15 @@ Rotateable::Rotateable(): { dragging = false; working = false; + scrolling = false; modifier = 0; current_axis = axis; signal_button_press_event().connect(sigc::mem_fun(*this, &Rotateable::on_click)); signal_motion_notify_event().connect(sigc::mem_fun(*this, &Rotateable::on_motion)); signal_button_release_event().connect(sigc::mem_fun(*this, &Rotateable::on_release)); + signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll)); + } bool Rotateable::on_click(GdkEventButton *event) { @@ -124,6 +127,34 @@ bool Rotateable::on_release(GdkEventButton *event) { return false; } +bool Rotateable::on_scroll(GdkEventScroll* event) +{ + double change = 0.0; + + if (event->direction == GDK_SCROLL_UP) { + change = 1.0; + } else if (event->direction == GDK_SCROLL_DOWN) { + change = -1.0; + } else { + return FALSE; + } + + drag_started_x = event->x; + drag_started_y = event->y; + modifier = get_single_modifier(modifier, event->state); + dragging = false; + working = false; + scrolling = true; + current_axis = axis; + + do_scroll(change, modifier); + + dragging = false; + working = false; + scrolling = false; + + return TRUE; +} Rotateable::~Rotateable() { } diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h index 15e0bf71c..52fb5306c 100644 --- a/src/ui/widget/rotateable.h +++ b/src/ui/widget/rotateable.h @@ -31,10 +31,12 @@ public: bool on_click(GdkEventButton *event); bool on_motion(GdkEventMotion *event); bool on_release(GdkEventButton *event); + bool on_scroll(GdkEventScroll* event); double axis; double current_axis; double maxdecl; + bool scrolling; private: double drag_started_x; @@ -47,6 +49,7 @@ private: virtual void do_motion (double /*by*/, guint /*state*/) {} virtual void do_release (double /*by*/, guint /*state*/) {} + virtual void do_scroll (double /*by*/, guint /*state*/) {} }; } // namespace Widget diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index e5992958b..ee835216d 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -47,6 +47,7 @@ #include "pixmaps/cursor-adj-h.xpm" #include "pixmaps/cursor-adj-s.xpm" #include "pixmaps/cursor-adj-l.xpm" +#include "pixmaps/cursor-adj-a.xpm" #include "sp-cursor.h" #include "gradient-chemistry.h" @@ -338,6 +339,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click)); _stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click)); + _opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu)); _opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed)); // Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click @@ -1008,7 +1010,7 @@ SelectedStyle::update() guint32 color = paint->value.color.toRGBA32( SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value)); _lastselected[i] = _thisselected[i]; - _thisselected[i] = color | 0xff; // only color, opacity === 1 + _thisselected[i] = color; // include opacity ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color); _color_preview[i]->show_all(); place->add(*_color_preview[i]); @@ -1211,39 +1213,43 @@ RotateableSwatch::~RotateableSwatch() { } double -RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier) +RotateableSwatch::color_adjust(float *hsla, double by, guint32 cc, guint modifier) { - sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc)); - + sp_color_rgb_to_hsl_floatv (hsla, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc)); + hsla[3] = SP_RGBA32_A_F(cc); double diff = 0; if (modifier == 2) { // saturation - double old = hsl[1]; + double old = hsla[1]; if (by > 0) { - hsl[1] += by * (1 - hsl[1]); + hsla[1] += by * (1 - hsla[1]); } else { - hsl[1] += by * (hsl[1]); + hsla[1] += by * (hsla[1]); } - diff = hsl[1] - old; + diff = hsla[1] - old; } else if (modifier == 1) { // lightness - double old = hsl[2]; + double old = hsla[2]; if (by > 0) { - hsl[2] += by * (1 - hsl[2]); + hsla[2] += by * (1 - hsla[2]); } else { - hsl[2] += by * (hsl[2]); + hsla[2] += by * (hsla[2]); } - diff = hsl[2] - old; + diff = hsla[2] - old; + } else if (modifier == 3) { // alpha + double old = hsla[3]; + hsla[3] += by/2; + diff = hsla[3] - old; } else { // hue - double old = hsl[0]; - hsl[0] += by/2; - while (hsl[0] < 0) - hsl[0] += 1; - while (hsl[0] > 1) - hsl[0] -= 1; - diff = hsl[0] - old; + double old = hsla[0]; + hsla[0] += by/2; + while (hsla[0] < 0) + hsla[0] += 1; + while (hsla[0] > 1) + hsla[0] -= 1; + diff = hsla[0] - old; } float rgb[3]; - sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]); + sp_color_hsl_to_rgb_floatv (rgb, hsla[0], hsla[1], hsla[2]); gchar c[64]; sp_svg_write_color (c, sizeof(c), @@ -1256,10 +1262,14 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier ); SPCSSAttr *css = sp_repr_css_attr_new (); - if (fillstroke == SS_FILL) - sp_repr_css_set_property (css, "fill", c); - else - sp_repr_css_set_property (css, "stroke", c); + + if (modifier == 3) { // alpha + Inkscape::CSSOStringStream osalpha; + osalpha << hsla[3]; + sp_repr_css_set_property(css, (fillstroke == SS_FILL) ? "fill-opacity" : "stroke-opacity", osalpha.str().c_str()); + } else { + sp_repr_css_set_property (css, (fillstroke == SS_FILL) ? "fill" : "stroke", c); + } sp_desktop_set_style (parent->getDesktop(), css); sp_repr_css_attr_unref (css); return diff; @@ -1270,7 +1280,7 @@ RotateableSwatch::do_motion(double by, guint modifier) { if (parent->_mode[fillstroke] != SS_COLOR) return; - if (!cr_set && modifier != 3) { + if (!scrolling && !cr_set) { GtkWidget *w = GTK_WIDGET(gobj()); GdkPixbuf *pixbuf = NULL; @@ -1278,6 +1288,8 @@ RotateableSwatch::do_motion(double by, guint modifier) { pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_s_xpm); } else if (modifier == 1) { // lightness pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_l_xpm); + } else if (modifier == 3) { // alpha + pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_a_xpm); } else { // hue pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_h_xpm); } @@ -1305,43 +1317,51 @@ RotateableSwatch::do_motion(double by, guint modifier) { cc = startcolor; } - float hsl[3]; + float hsla[4]; double diff = 0; - if (modifier != 3) { - diff = color_adjust(hsl, by, cc, modifier); - } - if (modifier == 3) { // Alt, do nothing + diff = color_adjust(hsla, by, cc, modifier); + + if (modifier == 3) { // alpha + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, + SP_VERB_DIALOG_FILL_STROKE, (_("Adjust alpha"))); + double ch = hsla[3]; + parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting alpha: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Shift to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 2) { // saturation DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation"))); - double ch = hsl[1]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff); + double ch = hsla[1]; + parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 1) { // lightness DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness"))); - double ch = hsl[2]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); + double ch = hsla[2]; + parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); } else { // hue DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue"))); - double ch = hsl[0]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Ctrl to adjust lightness"), ch - diff, ch, diff); + double ch = hsla[0]; + parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, with Ctrl to adjust lightness"), ch - diff, ch, diff); } } + +void +RotateableSwatch::do_scroll(double by, guint modifier) { + do_motion(by/30.0, modifier); + do_release(by/30.0, modifier); +} + void RotateableSwatch::do_release(double by, guint modifier) { if (parent->_mode[fillstroke] != SS_COLOR) return; - float hsl[3]; - if (modifier != 3) { - color_adjust(hsl, by, startcolor, modifier); - } + float hsla[4]; + color_adjust(hsla, by, startcolor, modifier); if (cr_set) { GtkWidget *w = GTK_WIDGET(gobj()); @@ -1357,7 +1377,9 @@ RotateableSwatch::do_release(double by, guint modifier) { cr_set = false; } - if (modifier == 3) { // Alt, do nothing + if (modifier == 3) { // alpha + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, + SP_VERB_DIALOG_FILL_STROKE, ("Adjust alpha")); } else if (modifier == 2) { // saturation DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation")); @@ -1467,6 +1489,11 @@ RotateableStrokeWidth::do_release(double by, guint modifier) { parent->getDesktop()->event_context->_message_context->clear(); } +void +RotateableStrokeWidth::do_scroll(double by, guint modifier) { + do_motion(by/10.0, modifier); + startvalue_set = false; +} Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop) { diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index a9e9d7274..fac4f22e6 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -61,8 +61,10 @@ public: ~RotateableSwatch(); double color_adjust (float *hsl, double by, guint32 cc, guint state); + virtual void do_motion (double by, guint state); virtual void do_release (double by, guint state); + virtual void do_scroll (double by, guint state); private: guint fillstroke; @@ -87,6 +89,7 @@ public: double value_adjust(double current, double by, guint modifier, bool final); virtual void do_motion (double by, guint state); virtual void do_release (double by, guint state); + virtual void do_scroll (double by, guint state); private: SelectedStyle *parent; -- cgit v1.2.3 From 092ea6e9a6ca2a4af8b5fd2f54220dfaddeac8d5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 23 Oct 2012 10:07:26 +0100 Subject: Use Gtk::Box to arrange layer dialog buttons. Prevents oversized buttons in GTK+ 3 Fixed bugs: - https://launchpad.net/bugs/1069181 (bzr r11823) --- src/ui/dialog/layers.cpp | 52 ++++++++++++++++++++---------------------------- src/ui/dialog/layers.h | 9 ++++++--- 2 files changed, 28 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 55a2f19a5..f851f72c1 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -838,43 +838,34 @@ LayersPanel::LayersPanel() : SPDesktop* targetDesktop = getDesktop(); -#if !WITH_GTKMM_3_0 - // TODO: This has been removed from Gtkmm 3.0. Check that everything still - // looks OK! - _buttonsRow.set_child_min_width( 16 ); -#endif - - _buttonsRow.set_layout (Gtk::BUTTONBOX_END); - Gtk::Button* btn = manage( new Gtk::Button() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, GTK_STOCK_ADD, C_("Layers", "New") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) ); - _buttonsRow.add( *btn ); - _buttonsRow.set_child_secondary( *btn , true); - - btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") ); - btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) ); - _watchingNonTop.push_back( btn ); - _buttonsRow.add( *btn ); + _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK); btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") ); - btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) ); - _watchingNonTop.push_back( btn ); - _buttonsRow.add( *btn ); - + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_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() ); _styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, C_("Layers", "Dn") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) ); _watchingNonBottom.push_back( btn ); - _buttonsRow.add( *btn ); - + _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK); + btn = manage( new Gtk::Button() ); - _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") ); - btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) ); - _watchingNonBottom.push_back( btn ); - _buttonsRow.add( *btn ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_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() ); + _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_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->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) ); @@ -884,9 +875,10 @@ LayersPanel::LayersPanel() : _styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, GTK_STOCK_REMOVE, _("X") ); btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) ); _watching.push_back( btn ); - _buttonsRow.add( *btn ); - _buttonsRow.set_child_secondary( *btn , true); - + _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK); + + _buttonsRow.pack_start(_buttonsSecondary, Gtk::PACK_EXPAND_WIDGET); + _buttonsRow.pack_end(_buttonsPrimary, Gtk::PACK_EXPAND_WIDGET); diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index 12e5f7986..cbd9515d7 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -13,7 +13,6 @@ #define SEEN_LAYERS_PANEL_H #include -#include #include #include #include @@ -122,9 +121,13 @@ private: Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; #if WITH_GTKMM_3_0 - Gtk::ButtonBox _buttonsRow; + Gtk::Box _buttonsRow; + Gtk::Box _buttonsPrimary; + Gtk::Box _buttonsSecondary; #else - Gtk::HButtonBox _buttonsRow; + Gtk::HBox _buttonsRow; + Gtk::HBox _buttonsPrimary; + Gtk::HBox _buttonsSecondary; #endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; -- cgit v1.2.3 From 7751440fc80831c41fa95035469eeb920fa45625 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 24 Oct 2012 17:48:02 +0900 Subject: Fix for 1067819 : Changing gradient name does not dirty the document (trunk) (bzr r11825) --- src/widgets/gradient-selector.cpp | 9 ++++++--- src/widgets/gradient-selector.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 65608585b..0cf1c2c51 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -19,6 +19,7 @@ #include #include "document.h" +#include "../document-undo.h" #include "../document-private.h" #include "../gradient-chemistry.h" #include "inkscape.h" @@ -169,7 +170,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) count_column->signal_clicked().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeCountColClick) ); gvs->tree_select_connection = sel->treeview->get_selection()->signal_changed().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeSelection) ); - sel->text_renderer->signal_edited().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeEdited) ); + sel->text_renderer->signal_edited().connect( sigc::mem_fun(*sel, &SPGradientSelector::onGradientRename) ); sel->scrolled_window = Gtk::manage(new Gtk::ScrolledWindow()); sel->scrolled_window->add(*sel->treeview); @@ -289,7 +290,7 @@ SPGradientSpread SPGradientSelector::getSpread() return gradientSpread; } -void SPGradientSelector::onTreeEdited( const Glib::ustring& path_string, const Glib::ustring& new_text) +void SPGradientSelector::onGradientRename( const Glib::ustring& path_string, const Glib::ustring& new_text) { Gtk::TreePath path(path_string); Gtk::TreeModel::iterator iter = store->get_iter(path); @@ -300,10 +301,12 @@ void SPGradientSelector::onTreeEdited( const Glib::ustring& path_string, const G if ( row ) { SPObject* obj = row[columns->data]; if ( obj ) { + row[columns->name] = gr_prepare_label(obj); if (!new_text.empty() && new_text != row[columns->name]) { rename_id(obj, new_text ); + Inkscape::DocumentUndo::done(obj->document, SP_VERB_CONTEXT_GRADIENT, + _("Rename gradient")); } - row[columns->name] = gr_prepare_label(obj); } } } diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index f7cc3cc14..01c18a48d 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -61,7 +61,7 @@ struct SPGradientSelector { /* Tree */ bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPGradient *vector); void onTreeSelection(); - void onTreeEdited( const Glib::ustring& path_string, const Glib::ustring& new_text); + void onGradientRename( const Glib::ustring& path_string, const Glib::ustring& new_text); void onTreeNameColClick(); void onTreeColorColClick(); void onTreeCountColClick(); -- cgit v1.2.3 From 4b2c5f1410bce434005641ad6849f2d02a920e82 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 26 Oct 2012 13:39:55 +0200 Subject: Fix for Bug #1070903 (Crash when saving a new document). (bzr r11828) --- src/file.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index a03c459da..cb4ea591c 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -952,7 +952,13 @@ sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc) } } } else { - Glib::ustring msg = Glib::ustring::format(_("No changes need to be saved."), " ", doc->getURI()); + Glib::ustring msg; + if ( doc->getURI() == NULL ) + { + msg = Glib::ustring::format(_("No changes need to be saved.")); + } else { + msg = Glib::ustring::format(_("No changes need to be saved."), " ", doc->getURI()); + } SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg.c_str()); success = TRUE; } -- cgit v1.2.3 From 2fb5e22ef81b21ff477dab54ccd28f0085a84da7 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 26 Oct 2012 23:16:40 +0200 Subject: allow 0 degree angles for axonometric grid's x and z axes Fixed bugs: - https://launchpad.net/bugs/583141 (bzr r11830) --- src/display/canvas-axonomgrid.cpp | 76 +++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index d4e15f475..9e288570f 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -251,7 +251,7 @@ CanvasAxonomGrid::readRepr() if ( (value = repr->attribute("gridanglex")) ) { angle_deg[X] = g_ascii_strtod(value, NULL); - if (angle_deg[X] < 1.0) angle_deg[X] = 1.0; + if (angle_deg[X] < 0.) angle_deg[X] = 0.; if (angle_deg[X] > 89.0) angle_deg[X] = 89.0; angle_rad[X] = deg_to_rad(angle_deg[X]); tan_angle[X] = tan(angle_rad[X]); @@ -259,7 +259,7 @@ CanvasAxonomGrid::readRepr() if ( (value = repr->attribute("gridanglez")) ) { angle_deg[Z] = g_ascii_strtod(value, NULL); - if (angle_deg[Z] < 1.0) angle_deg[Z] = 1.0; + if (angle_deg[Z] < 0.) angle_deg[Z] = 0.; if (angle_deg[Z] > 89.0) angle_deg[Z] = 89.0; angle_rad[Z] = deg_to_rad(angle_deg[Z]); tan_angle[Z] = tan(angle_rad[Z]); @@ -477,8 +477,8 @@ CanvasAxonomGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/) spacing_ylines = sw[Geom::X] /(tan_angle[X] + tan_angle[Z]); lyw = sw[Geom::Y]; - lxw_x = sw[Geom::X] / tan_angle[X]; - lxw_z = sw[Geom::X] / tan_angle[Z]; + lxw_x = Geom::are_near(tan_angle[X],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[X]; + lxw_z = Geom::are_near(tan_angle[Z],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[Z]; if (empspacing == 0) { scaled = true; @@ -526,8 +526,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) for (gdouble y = xstart_y_sc; y < buf->rect.bottom(); y += lyw, xlinenum++) { gint const x0 = buf->rect.left(); gint const y0 = round(y); - gint const x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] ); - gint const y1 = buf->rect.bottom(); + gint x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] ); + gint y1 = buf->rect.bottom(); + if ( Geom::are_near(tan_angle[X],0.) ) { + x1 = buf->rect.right(); + y1 = y0; + } if (!scaled && (xlinenum % empspacing) != 0) { sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); @@ -536,18 +540,21 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } } // lines starting from top side - gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ; - xlinenum = xlinestart-1; - for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) { - gint const y0 = buf->rect.top(); - gint const y1 = buf->rect.bottom(); - gint const x0 = round(x); - gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] ); - - if (!scaled && (xlinenum % empspacing) != 0) { - sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); - } else { - sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor); + if (!Geom::are_near(tan_angle[X],0.)) + { + gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ; + xlinenum = xlinestart-1; + for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) { + gint const y0 = buf->rect.top(); + gint const y1 = buf->rect.bottom(); + gint const x0 = round(x); + gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] ); + + if (!scaled && (xlinenum % empspacing) != 0) { + sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); + } else { + sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor); + } } } @@ -575,8 +582,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) for (gdouble y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++, next_y = y) { gint const x0 = buf->rect.left(); gint const y0 = round(y); - gint const x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] ); - gint const y1 = buf->rect.top(); + gint x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] ); + gint y1 = buf->rect.top(); + if ( Geom::are_near(tan_angle[Z],0.) ) { + x1 = buf->rect.right(); + y1 = y0; + } if (!scaled && (zlinenum % empspacing) != 0) { sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); @@ -585,17 +596,20 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } } // draw lines from bottom-up - gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ; - for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) { - gint const y0 = buf->rect.bottom(); - gint const y1 = buf->rect.top(); - gint const x0 = round(x); - gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] ); - - if (!scaled && (zlinenum % empspacing) != 0) { - sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); - } else { - sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor); + if (!Geom::are_near(tan_angle[Z],0.)) + { + gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ; + for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) { + gint const y0 = buf->rect.bottom(); + gint const y1 = buf->rect.top(); + gint const x0 = round(x); + gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] ); + + if (!scaled && (zlinenum % empspacing) != 0) { + sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); + } else { + sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor); + } } } -- cgit v1.2.3 From d930f05bae1124acde7d5e7b93a1ae922c702539 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 26 Oct 2012 23:19:33 +0200 Subject: include yourself first, then the others (bzr r11831) --- src/display/canvas-axonomgrid.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 9e288570f..2df5102de 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -2,7 +2,7 @@ * Authors: * Johan Engelen * - * Copyright (C) 2006-2011 Authors + * Copyright (C) 2006-2012 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,10 +18,11 @@ * THIS FILE AND THE HEADER FILE NEED CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO. */ +#include "display/canvas-axonomgrid.h" + #include #include "ui/widget/registered-widget.h" -#include "display/canvas-axonomgrid.h" #include "2geom/line.h" #include "desktop.h" #include "canvas-grid.h" -- cgit v1.2.3 From 90dbe10154f75b9f3f5f82f53193e20f01537ac1 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 26 Oct 2012 23:35:20 +0200 Subject: bit of a clean-up (bzr r11832) --- src/display/canvas-axonomgrid.cpp | 30 +++++++++--------------------- src/display/canvas-axonomgrid.h | 15 ++++++++++----- 2 files changed, 19 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 2df5102de..f2a9e38cb 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -12,35 +12,29 @@ * smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending * to the right). The x-axis will always have an angle between 0 and 90 degrees. */ - - /* - * TODO: - * THIS FILE AND THE HEADER FILE NEED CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO. - */ - + #include "display/canvas-axonomgrid.h" #include #include "ui/widget/registered-widget.h" -#include "2geom/line.h" #include "desktop.h" -#include "canvas-grid.h" #include "desktop-handles.h" #include "display/cairo-utils.h" #include "display/canvas-grid.h" #include "display/sp-canvas-util.h" +#include "display/sp-canvas.h" #include "document.h" -#include "helper/units.h" #include "inkscape.h" #include "preferences.h" #include "sp-namedview.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "2geom/line.h" +#include "2geom/angle.h" #include "util/mathfns.h" -#include "xml/node-event-vector.h" #include "round.h" -#include "display/sp-canvas.h" +#include "helper/units.h" #include #include @@ -48,12 +42,6 @@ enum Dim3 { X=0, Y, Z }; -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -static double deg_to_rad(double deg) { return deg*M_PI/180.0;} - /** * This function calls Cairo to render a line on a particular canvas buffer. * Coordinates are interpreted as SCREENcoordinates @@ -139,9 +127,9 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0); angle_deg[Y] = 0; - angle_rad[X] = deg_to_rad(angle_deg[X]); + angle_rad[X] = Geom::deg_to_rad(angle_deg[X]); tan_angle[X] = tan(angle_rad[X]); - angle_rad[Z] = deg_to_rad(angle_deg[Z]); + angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]); tan_angle[Z] = tan(angle_rad[Z]); snapper = new CanvasAxonomGridSnapper(this, &namedview->snap_manager, 0); @@ -254,7 +242,7 @@ CanvasAxonomGrid::readRepr() angle_deg[X] = g_ascii_strtod(value, NULL); if (angle_deg[X] < 0.) angle_deg[X] = 0.; if (angle_deg[X] > 89.0) angle_deg[X] = 89.0; - angle_rad[X] = deg_to_rad(angle_deg[X]); + angle_rad[X] = Geom::deg_to_rad(angle_deg[X]); tan_angle[X] = tan(angle_rad[X]); } @@ -262,7 +250,7 @@ CanvasAxonomGrid::readRepr() angle_deg[Z] = g_ascii_strtod(value, NULL); if (angle_deg[Z] < 0.) angle_deg[Z] = 0.; if (angle_deg[Z] > 89.0) angle_deg[Z] = 89.0; - angle_rad[Z] = deg_to_rad(angle_deg[Z]); + angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]); tan_angle[Z] = tan(angle_rad[Z]); } diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 04919f947..0e24d3f56 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -2,9 +2,12 @@ #define CANVAS_AXONOMGRID_H /* - * Copyright (C) 2006-2007 Johan Engelen + * Authors: + * Johan Engelen * - */ + * Copyright (C) 2006-2012 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ #include "line-snapper.h" #include "canvas-grid.h" @@ -15,7 +18,7 @@ struct SPNamedView; namespace Inkscape { namespace XML { - class Node; + class Node; }; class CanvasAxonomGrid : public CanvasGrid { @@ -36,6 +39,9 @@ public: bool scaled; /**< Whether the grid is in scaled mode */ +protected: + friend class CanvasAxonomGridSnapper; + Geom::Point ow; /**< Transformed origin by the affine for the zoom */ double lyw; /**< Transformed length y by the affine for the zoom */ double lxw_x; @@ -44,7 +50,6 @@ public: Geom::Point sw; /**< the scaling factors of the affine transform */ -protected: virtual Gtk::Widget * newSpecificWidget(); private: @@ -63,7 +68,7 @@ public: bool ThisSnapperMightSnap() const; Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom) - bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance + bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance private: LineList _getSnapLines(Geom::Point const &p) const; -- cgit v1.2.3 From 2c4d1e32801b553e426bdc73f3951cf0ca0dff45 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 11:59:42 +0100 Subject: Fix build error due to bad internal handling of deprecated GTK+ symbols in gtkmm header (bzr r11833) --- src/display/canvas-axonomgrid.cpp | 9 +++++---- src/display/canvas-grid.cpp | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index f2a9e38cb..bfc6f27c4 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -13,10 +13,14 @@ * to the right). The x-axis will always have an angle between 0 and 90 degrees. */ -#include "display/canvas-axonomgrid.h" +#include +#include +#include #include +#include "display/canvas-axonomgrid.h" + #include "ui/widget/registered-widget.h" #include "desktop.h" #include "desktop-handles.h" @@ -36,9 +40,6 @@ #include "round.h" #include "helper/units.h" -#include -#include -#include enum Dim3 { X=0, Y, Z }; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 498958f08..cb33169cd 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include #include "ui/widget/registered-widget.h" #include "desktop.h" @@ -37,10 +40,6 @@ #include "verbs.h" #include "display/sp-canvas.h" -#include -#include -#include - using Inkscape::DocumentUndo; namespace Inkscape { -- cgit v1.2.3 From 5ed9dbd895fa15fa3bb03e8751e834cfa33aa16b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 12:46:53 +0100 Subject: Fix C++11 narrowing conversion errors (bzr r11834) --- src/color-profile.cpp | 6 +++--- src/dom/svgimpl.cpp | 2 +- src/sp-conn-end.cpp | 2 +- src/widgets/eek-preview.cpp | 11 ++++++++--- src/widgets/sp-color-icc-selector.cpp | 6 +++--- 5 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index a1e9dd0f1..981d527f0 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -639,9 +639,9 @@ bool ColorProfile::GamutCheck(SPColor color) cmsUInt8Number outofgamut = 0; guchar check_color[4] = { - SP_RGBA32_R_U(val), - SP_RGBA32_G_U(val), - SP_RGBA32_B_U(val), + static_cast(SP_RGBA32_R_U(val)), + static_cast(SP_RGBA32_G_U(val)), + static_cast(SP_RGBA32_B_U(val)), 255}; cmsDoTransform(ColorProfile::getTransfGamutCheck(), &check_color, &outofgamut, 1); diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp index cf28dfec5..87f43af81 100644 --- a/src/dom/svgimpl.cpp +++ b/src/dom/svgimpl.cpp @@ -119,7 +119,7 @@ SVGTableEntry interfaceTable[] = { "SVGUnitTypes", SVG_UNIT_TYPES }, { "SVGURIReference", SVG_URI_REFERENCE }, { "SVGViewSpec", SVG_VIEW_SPEC }, - { "SVGZoomAndPan", SVG_ZOOM_AND_PAN } + { "SVGZoomAndPan", static_cast(SVG_ZOOM_AND_PAN)} }; diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index f8d5694da..cabda82d3 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -152,7 +152,7 @@ sp_conn_get_route_and_redraw(SPPath *const path, // Set sensible values incase there the connector ends are not // attached to any shapes. Geom::PathVector conn_pv = path->_curve->get_pathvector(); - double endPos[2] = { 0, conn_pv[0].size() }; + double endPos[2] = { 0.0, static_cast(conn_pv[0].size()) }; SPConnEnd** _connEnd = path->connEndPair.getConnEnds(); for (unsigned h = 0; h < 2; ++h) { diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 953beb69d..72db91373 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -229,9 +229,14 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr) GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); EekPreview* preview = EEK_PREVIEW(widget); - GdkColor fg = { 0, preview->_r, preview->_g, preview->_b }; - gint insetTop = 0, insetBottom = 0; - gint insetLeft = 0, insetRight = 0; + + GdkColor fg = { 0, + static_cast(preview->_r), + static_cast(preview->_g), + static_cast(preview->_b)}; + + gint insetTop = 0, insetBottom = 0; + gint insetLeft = 0, insetRight = 0; if (preview->_border == BORDER_SOLID) { insetTop = 1; diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index d04f17a30..b021ac43d 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -510,9 +510,9 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) if ( trans ) { guint32 val = _color.toRGBA32(0); guchar pre[4] = { - SP_RGBA32_R_U(val), - SP_RGBA32_G_U(val), - SP_RGBA32_B_U(val), + static_cast(SP_RGBA32_R_U(val)), + static_cast(SP_RGBA32_G_U(val)), + static_cast(SP_RGBA32_B_U(val)), 255}; #ifdef DEBUG_LCMS g_message("Shoving in [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); -- cgit v1.2.3 From e920c0f97739a936d6e02f4cc6a4feb8486f683e Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Sat, 27 Oct 2012 14:42:19 +0200 Subject: Clamp colour channels in feComposite result to alpha channel, instead of 1, as the channels are premultiplied. (bzr r11835) --- src/display/nr-filter-composite.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index b25ecdf2c..040424cb3 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -48,10 +48,11 @@ struct ComposeArithmetic { gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4; gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4; - ao = (pxclamp(ao, 0, 255*255*255) + (255*255/2)) / (255*255); - ro = (pxclamp(ro, 0, 255*255*255) + (255*255/2)) / (255*255); - go = (pxclamp(go, 0, 255*255*255) + (255*255/2)) / (255*255); - bo = (pxclamp(bo, 0, 255*255*255) + (255*255/2)) / (255*255); + ao = pxclamp(ao, 0, 255*255*255); // r, g and b are premultiplied, so should be clamped to the alpha channel + ro = (pxclamp(ro, 0, ao) + (255*255/2)) / (255*255); + go = (pxclamp(go, 0, ao) + (255*255/2)) / (255*255); + bo = (pxclamp(bo, 0, ao) + (255*255/2)) / (255*255); + ao = (ao + (255*255/2)) / (255*255); ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) return pxout; -- cgit v1.2.3 From 66bb3da3ad2912843de88136dda791a8ef19903b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 18:17:51 +0100 Subject: cppcheck fixes: sp-lpe-item (bzr r11836) --- src/snap-candidate.h | 6 ++-- src/sp-lpe-item.cpp | 81 ++++++++++++++++++++++------------------------------ src/sp-lpe-item.h | 4 +-- 3 files changed, 39 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/snap-candidate.h b/src/snap-candidate.h index db0c3fd67..da65d4ea3 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -39,10 +39,10 @@ public: : _point(point), _source_type(source), _target_type(target), + _target_bbox(Geom::OptRect()), _dist() { _source_num = -1; - _target_bbox = Geom::OptRect(); } SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source) @@ -50,10 +50,10 @@ public: _source_type(source), _target_type(Inkscape::SNAPTARGET_UNDEFINED), _source_num(-1), + _target_bbox(Geom::OptRect()), _dist() { - _target_bbox = Geom::OptRect(); - } + }; inline Geom::Point const & getPoint() const {return _point;} inline Inkscape::SnapSourceType getSourceType() const {return _source_type;} diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index f17422d02..3b8999eda 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -87,18 +87,13 @@ sp_lpe_item_get_type() return lpe_item_type; } -static void -sp_lpe_item_class_init(SPLPEItemClass *klass) +static void sp_lpe_item_class_init(SPLPEItemClass *klass) { - GObjectClass *gobject_class; - SPObjectClass *sp_object_class; - - gobject_class = (GObjectClass *) klass; - sp_object_class = (SPObjectClass *) klass; - parent_class = (SPItemClass *)g_type_class_peek_parent (klass); - + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); + parent_class = SP_ITEM_CLASS(g_type_class_peek_parent(klass)); + gobject_class->finalize = sp_lpe_item_finalize; - sp_object_class->build = sp_lpe_item_build; sp_object_class->release = sp_lpe_item_release; sp_object_class->set = sp_lpe_item_set; @@ -122,8 +117,7 @@ sp_lpe_item_init(SPLPEItem *lpeitem) lpeitem->lpe_modified_connection_list = new std::list(); } -static void -sp_lpe_item_finalize(GObject *object) +static void sp_lpe_item_finalize(GObject *object) { if (((GObjectClass *) (parent_class))->finalize) { (* ((GObjectClass *) (parent_class))->finalize)(object); @@ -135,23 +129,21 @@ sp_lpe_item_finalize(GObject *object) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "inkscape:path-effect" ); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if ((SP_OBJECT_CLASS(parent_class))->build) { + (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); } } /** * Drops any allocated memory. */ -static void -sp_lpe_item_release(SPObject *object) +static void sp_lpe_item_release(SPObject *object) { - SPLPEItem *lpeitem = (SPLPEItem *) object; + SPLPEItem *lpeitem = SP_LPE_ITEM(object); // disconnect all modified listeners: for (std::list::iterator mod_it = lpeitem->lpe_modified_connection_list->begin(); @@ -173,17 +165,16 @@ sp_lpe_item_release(SPObject *object) delete lpeitem->path_effect_list; lpeitem->path_effect_list = NULL; - if (((SPObjectClass *) parent_class)->release) - ((SPObjectClass *) parent_class)->release(object); + if ((SP_OBJECT_CLASS(parent_class))->release) + (SP_OBJECT_CLASS(parent_class))->release(object); } /** * Sets a specific value in the SPLPEItem. */ -static void -sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value) +static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value) { - SPLPEItem *lpeitem = (SPLPEItem *) object; + SPLPEItem *lpeitem = SP_LPE_ITEM(object); switch (key) { case SP_ATTR_INKSCAPE_PATH_EFFECT: @@ -243,8 +234,8 @@ sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if ((SP_OBJECT_CLASS(parent_class))->set) { + (SP_OBJECT_CLASS(parent_class))->set(object, key, value); } break; } @@ -256,8 +247,8 @@ sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value) static void sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags) { - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(parent_class))->update) { + (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags); } // update the helperpaths of all LPEs applied to the item @@ -267,25 +258,23 @@ sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags) /** * Sets modified flag for all sub-item views. */ -static void -sp_lpe_item_modified (SPObject *object, unsigned int flags) +static void sp_lpe_item_modified (SPObject *object, unsigned int flags) { if (SP_IS_GROUP(object) && (flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)) { sp_lpe_item_update_patheffect(SP_LPE_ITEM(object), true, true); } - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + if ((SP_OBJECT_CLASS(parent_class))->modified) { + (* (SP_OBJECT_CLASS(parent_class))->modified) (object, flags); } } /** * Writes its settings to an incoming repr object, if any. */ -static Inkscape::XML::Node * -sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node * sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPLPEItem *lpeitem = (SPLPEItem *) object; + SPLPEItem *lpeitem = SP_LPE_ITEM(object); if (flags & SP_OBJECT_WRITE_EXT) { if ( sp_lpe_item_has_path_effect(lpeitem) ) { @@ -296,8 +285,8 @@ sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: } } - if (((SPObjectClass *)(parent_class))->write) { - ((SPObjectClass *)(parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(parent_class))->write) { + (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -675,11 +664,10 @@ void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt) } } -static void -sp_lpe_item_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void sp_lpe_item_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) - (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref); + if ((SP_OBJECT_CLASS(parent_class))->child_added) + (* (SP_OBJECT_CLASS(parent_class))->child_added) (object, child, ref); if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) { SPObject *ochild = object->get_child_by_repr(child); @@ -689,8 +677,7 @@ sp_lpe_item_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape: } } -static void -sp_lpe_item_remove_child (SPObject * object, Inkscape::XML::Node * child) +static void sp_lpe_item_remove_child(SPObject * object, Inkscape::XML::Node * child) { if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) { SPObject *ochild = object->get_child_by_repr(child); @@ -699,8 +686,8 @@ sp_lpe_item_remove_child (SPObject * object, Inkscape::XML::Node * child) } } - if (((SPObjectClass *) (parent_class))->remove_child) - (* ((SPObjectClass *) (parent_class))->remove_child) (object, child); + if ((SP_OBJECT_CLASS(parent_class))->remove_child) + (* (SP_OBJECT_CLASS(parent_class))->remove_child) (object, child); } static std::string patheffectlist_write_svg(PathEffectList const & list) @@ -782,8 +769,8 @@ bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathE * Writes a new "inkscape:path-effect" string to xml, where the old_lpeobjects are substituted by the new ones. * Note that this method messes up the item's \c PathEffectList. */ -void SPLPEItem::replacePathEffects( std::vector const old_lpeobjs, - std::vector const new_lpeobjs ) +void SPLPEItem::replacePathEffects( std::vector const &old_lpeobjs, + std::vector const &new_lpeobjs ) { HRefList hreflist; for (PathEffectList::const_iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 8f99ae1b0..69fde5d58 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -49,8 +49,8 @@ public: Inkscape::LivePathEffect::LPEObjectReference* current_path_effect; std::vector lpe_helperpaths; - void replacePathEffects( std::vector const old_lpeobjs, - std::vector const new_lpeobjs ); + void replacePathEffects( std::vector const &old_lpeobjs, + std::vector const &new_lpeobjs ); }; struct SPLPEItemClass { -- cgit v1.2.3 From 06acd0033e1476e18f45d7630a766868c932b923 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 18:35:46 +0100 Subject: cppcheck: use gobject casts in sp-item (bzr r11837) --- src/sp-item.cpp | 72 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index a21ff3968..3ca7d5d16 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -103,12 +103,10 @@ SPItem::getType(void) /** * SPItem vtable initialization. */ -void -SPItemClass::sp_item_class_init(SPItemClass *klass) +void SPItemClass::sp_item_class_init(SPItemClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *) klass; - - static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); + static_parent_class = SP_OBJECT_CLASS(g_type_class_ref(SP_TYPE_OBJECT)); sp_object_class->build = SPItem::sp_item_build; sp_object_class->release = SPItem::sp_item_release; @@ -427,14 +425,14 @@ void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); - if (((SPObjectClass *) (SPItemClass::static_parent_class))->build) { - (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr); + if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->build) { + (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->build)(object, document, repr); } } void SPItem::sp_item_release(SPObject *object) { - SPItem *item = (SPItem *) object; + SPItem *item = SP_ITEM(object); // Note: do this here before the clip_ref is deleted, since calling // ensureUpToDate() for triggered routing may reference @@ -447,8 +445,8 @@ void SPItem::sp_item_release(SPObject *object) delete item->clip_ref; delete item->mask_ref; - if (((SPObjectClass *) (SPItemClass::static_parent_class))->release) { - ((SPObjectClass *) SPItemClass::static_parent_class)->release(object); + if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->release) { + (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->release(object); } while (item->display) { @@ -460,7 +458,7 @@ void SPItem::sp_item_release(SPObject *object) void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) { - SPItem *item = (SPItem *) object; + SPItem *item = SP_ITEM(object); switch (key) { case SP_ATTR_TRANSFORM: { @@ -544,8 +542,8 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - if (((SPObjectClass *) (SPItemClass::static_parent_class))->set) { - (* ((SPObjectClass *) (SPItemClass::static_parent_class))->set)(object, key, value); + if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->set) { + (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->set)(object, key, value); } } break; @@ -605,8 +603,8 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) { SPItem *item = SP_ITEM(object); - if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) { - (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags); + if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->update) { + (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->update)(object, ctx, flags); } // any of the modifications defined in sp-object.h might change bbox, @@ -721,8 +719,8 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML } } - if (((SPObjectClass *) (SPItemClass::static_parent_class))->write) { - ((SPObjectClass *) (SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->write) { + (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -737,8 +735,8 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const { Geom::OptRect bbox; // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::GEOMETRIC_BBOX); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox) { + bbox = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox(this, transform, SPItem::GEOMETRIC_BBOX); } return bbox; } @@ -757,8 +755,8 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) { // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox) { + bbox = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX); } SPFilter *filter = SP_FILTER(style->getFilter()); @@ -803,8 +801,8 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const *bbox *= transform; } else { // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::VISUAL_BBOX); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox) { + bbox = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox(this, transform, SPItem::VISUAL_BBOX); } } if (clip_ref->getObject()) { @@ -915,7 +913,7 @@ void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item - SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(this); + SPItemClass const &item_class = *SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)); if (item_class.snappoints) { item_class.snappoints(this, p, snapprefs); } @@ -982,8 +980,8 @@ gchar *SPItem::sp_item_private_description(SPItem */*item*/) */ gchar *SPItem::description() { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { - gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->description(this); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->description) { + gchar *s = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->description(this); if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; clipped"), s); g_free (s); @@ -1019,7 +1017,7 @@ gchar *SPItem::description() int SPItem::ifilt() { int retval=0; - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->description) { if ( style && style->filter.href && style->filter.href->getObject() ) { retval=1; } } return retval; @@ -1043,8 +1041,8 @@ unsigned SPItem::display_key_new(unsigned numkeys) Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { Inkscape::DrawingItem *ai = NULL; - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) { - ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, drawing, key, flags); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->show) { + ai = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->show(this, drawing, key, flags); } if (ai != NULL) { @@ -1096,8 +1094,8 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned void SPItem::invoke_hide(unsigned key) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) { - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide(this, key); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->hide) { + (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->hide(this, key); } SPItemView *ref = NULL; @@ -1388,13 +1386,13 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra gint preserve = prefs->getBool("/options/preservetransform/value", 0); Geom::Affine transform_attr (transform); if ( // run the object's set_transform (i.e. embed transform) only if: - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform && // it does have a set_transform method + (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->set_transform && // it does have a set_transform method !preserve && // user did not chose to preserve all transforms !clip_ref->getObject() && // the object does not have a clippath !mask_ref->getObject() && // the object does not have a mask !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { - transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform); + transform_attr = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->set_transform(this, transform); if (freeze_stroke_width) { freeze_stroke_width_recursive(false); } @@ -1427,8 +1425,8 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra gint SPItem::emitEvent(SPEvent &event) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) { - return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->event) { + return (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->event(this, &event); } return FALSE; @@ -1451,8 +1449,8 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) void SPItem::convert_item_to_guides() { // Use derived method if present ... - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) { - (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this); + if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->convert_to_guides) { + (*(SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->convert_to_guides)(this); } else { // .. otherwise simply place the guides around the item's bounding box -- cgit v1.2.3 From 57bfdfeb32733aafd8d7cd82c676d4a9627e1dee Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 19:15:53 +0100 Subject: cppcheck: use gobject casts in box3d-side and rename NONE to SP_NONE in sp_metric (bzr r11838) --- src/box3d-side.cpp | 21 ++++++++++----------- src/helper/units.cpp | 18 ++++++++---------- src/sp-metric.h | 2 +- src/sp-metrics.cpp | 4 ++-- 4 files changed, 21 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 031b16a7c..42268ec83 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -65,8 +65,7 @@ static void box3d_side_class_init(Box3DSideClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast(klass); SPShapeClass *shape_class = reinterpret_cast(klass); - - parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); + parent_class = SP_SHAPE_CLASS(g_type_class_ref (SP_TYPE_SHAPE)); sp_object_class->build = box3d_side_build; sp_object_class->write = box3d_side_write; @@ -86,8 +85,8 @@ box3d_side_init (Box3DSide * side) static void box3d_side_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if ((SP_OBJECT_CLASS(parent_class))->build) { + (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); } object->readAttr( "inkscape:box3dsidetype" ); @@ -111,7 +110,7 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: static_cast(object)->setShape(); /* Duplicate the path */ - SPCurve const *curve = ((SPShape *) object)->_curve; + SPCurve const *curve = (SP_SHAPE(object))->_curve; //Nulls might be possible if this called iteratively if ( !curve ) { return NULL; @@ -120,8 +119,8 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: repr->setAttribute("d", d); g_free (d); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(parent_class))->write) + (SP_OBJECT_CLASS(parent_class))->write (object, xml_doc, repr, flags); return repr; } @@ -154,8 +153,8 @@ box3d_side_set (SPObject *object, unsigned int key, const gchar *value) } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if ((SP_OBJECT_CLASS(parent_class))->set) + (SP_OBJECT_CLASS(parent_class))->set (object, key, value); break; } } @@ -173,8 +172,8 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) static_cast(object)->setShape (); } - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + if ((SP_OBJECT_CLASS(parent_class))->update) + (SP_OBJECT_CLASS(parent_class))->update (object, ctx, flags); } /* Create a new Box3DSide and append it to the parent box */ diff --git a/src/helper/units.cpp b/src/helper/units.cpp index 4f5443e72..1593fc131 100644 --- a/src/helper/units.cpp +++ b/src/helper/units.cpp @@ -34,12 +34,12 @@ * calls sp_unit_table_sane) to ensure that the two are in sync. */ SPUnit const sp_units[] = { - {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""}, + {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, SP_NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""}, {SP_UNIT_PT, SP_UNIT_ABSOLUTE, PX_PER_PT, SP_PT, SVGLength::PT, N_("Point"), N_("pt"), N_("Points"), N_("Pt")}, {SP_UNIT_PC, SP_UNIT_ABSOLUTE, PX_PER_PC, SP_PC, SVGLength::PC, N_("Pica"), N_("pc"), N_("Picas"), N_("Pc")}, {SP_UNIT_PX, SP_UNIT_DEVICE, PX_PER_PX, SP_PX, SVGLength::PX, N_("Pixel"), N_("px"), N_("Pixels"), N_("Px")}, /* You can add new elements from this point forward */ - {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")}, + {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, SP_NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")}, {SP_UNIT_MM, SP_UNIT_ABSOLUTE, PX_PER_MM, SP_MM, SVGLength::MM, N_("Millimeter"), N_("mm"), N_("Millimeters"), N_("mm")}, {SP_UNIT_CM, SP_UNIT_ABSOLUTE, PX_PER_CM, SP_CM, SVGLength::CM, N_("Centimeter"), N_("cm"), N_("Centimeters"), N_("cm")}, {SP_UNIT_M, SP_UNIT_ABSOLUTE, PX_PER_M, SP_M, SVGLength::NONE, N_("Meter"), N_("m"), N_("Meters"), N_("m")}, // no svg_unit @@ -47,9 +47,9 @@ SPUnit const sp_units[] = { {SP_UNIT_FT, SP_UNIT_ABSOLUTE, PX_PER_FT, SP_FT, SVGLength::FOOT, N_("Foot"), N_("ft"), N_("Feet"), N_("ft")}, /* Volatiles do not have default, so there are none here */ // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units - {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")}, + {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")}, // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units - {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")}, + {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")}, }; #define sp_num_units G_N_ELEMENTS(sp_units) @@ -83,18 +83,16 @@ sp_unit_get_plural (SPUnit const *unit) return unit->plural; } -SPMetric -sp_unit_get_metric(SPUnit const *unit) +SPMetric sp_unit_get_metric(SPUnit const *unit) { - g_return_val_if_fail(unit != NULL, NONE); + g_return_val_if_fail(unit != NULL, SP_NONE); return unit->metric; } -guint -sp_unit_get_svg_unit(SPUnit const *unit) +guint sp_unit_get_svg_unit(SPUnit const *unit) { - g_return_val_if_fail(unit != NULL, NONE); + g_return_val_if_fail(unit != NULL, SP_NONE); return unit->svg_unit; } diff --git a/src/sp-metric.h b/src/sp-metric.h index 5f0e5c8f6..31f3330fa 100644 --- a/src/sp-metric.h +++ b/src/sp-metric.h @@ -3,7 +3,7 @@ /** Known metrics so far. (I don't know why this doesn't include pica.) */ enum SPMetric { - NONE, + SP_NONE, SP_MM, SP_CM, SP_IN, diff --git a/src/sp-metrics.cpp b/src/sp-metrics.cpp index 5e34d9ab9..2b421cf05 100644 --- a/src/sp-metrics.cpp +++ b/src/sp-metrics.cpp @@ -37,7 +37,7 @@ sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, con case SP_PX: src = PX_PER_IN; break; - case NONE: + case SP_NONE: src = 1; break; } @@ -67,7 +67,7 @@ sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, con case SP_PX: dst = PX_PER_IN; break; - case NONE: + case SP_NONE: dst = 1; break; } -- cgit v1.2.3 From daf76804788f89d287fa468b4d35189f4f9e16e2 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 19:57:37 +0100 Subject: cppcheck: use gobject casts in box3d and hide dead code (bzr r11839) --- src/box3d.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index a011b1567..0cb139458 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -82,13 +82,12 @@ box3d_get_type(void) return type; } -static void -box3d_class_init(SPBox3DClass *klass) +static void box3d_class_init(SPBox3DClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *) klass; - SPItemClass *item_class = (SPItemClass *) klass; + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); + SPItemClass *item_class = SP_ITEM_CLASS(klass); - parent_class = (SPGroupClass *) g_type_class_ref(SP_TYPE_GROUP); + parent_class = SP_GROUP_CLASS(g_type_class_ref(SP_TYPE_GROUP)); sp_object_class->build = box3d_build; sp_object_class->release = box3d_release; @@ -110,8 +109,8 @@ box3d_init(SPBox3D *box) static void box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(parent_class))->build) { + (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); } SPBox3D *box = SP_BOX3D (object); @@ -140,7 +139,7 @@ static void box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::N static void box3d_release(SPObject *object) { - SPBox3D *box = (SPBox3D *) object; + SPBox3D *box = SP_BOX3D(object); if (box->persp_href) { g_free(box->persp_href); @@ -173,8 +172,8 @@ box3d_release(SPObject *object) */ } - if (((SPObjectClass *) parent_class)->release) - ((SPObjectClass *) parent_class)->release(object); + if ((SP_OBJECT_CLASS(parent_class))->release) + (SP_OBJECT_CLASS(parent_class))->release(object); } static void @@ -225,8 +224,8 @@ box3d_set(SPObject *object, unsigned int key, const gchar *value) } break; default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if ((SP_OBJECT_CLASS(parent_class))->set) { + (SP_OBJECT_CLASS(parent_class))->set(object, key, value); } break; } @@ -260,8 +259,8 @@ box3d_update(SPObject *object, SPCtx *ctx, guint flags) } // Invoke parent method - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(parent_class))->update) + (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags); } @@ -307,8 +306,8 @@ static Inkscape::XML::Node * box3d_write(SPObject *object, Inkscape::XML::Docume box->save_corner7 = box->orig_corner7; } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(parent_class))->write) { + (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -684,7 +683,7 @@ box3d_half_line_crosses_joining_line (Geom::Point const &A, Geom::Point const &B { inters = Geom::intersection(lineAB, lineCD); } - catch (Geom::InfiniteSolutions e) + catch (Geom::InfiniteSolutions& e) { // We're probably dealing with parallel lines, so they don't really cross return false; @@ -1078,6 +1077,8 @@ box3d_recompute_z_orders (SPBox3D *box) { central_axis = Box3D::Z; } + // FIXME: At present, this is not used. Why is it calculated? + /* unsigned int central_corner = 3 ^ central_axis; if (central_axis == Box3D::Z) { central_corner = central_corner ^ Box3D::XYZ; @@ -1085,6 +1086,7 @@ box3d_recompute_z_orders (SPBox3D *box) { if (box3d_XY_axes_are_swapped(box)) { central_corner = central_corner ^ Box3D::XYZ; } + */ Geom::Point c1(box3d_get_corner_screen(box, 1, false)); Geom::Point c2(box3d_get_corner_screen(box, 2, false)); -- cgit v1.2.3 From fdf3d28700bcaf1bd678b15d2404ea5580302890 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 27 Oct 2012 20:43:56 +0100 Subject: cppcheck: get rid of more C-style pointer casts (bzr r11840) --- src/display/canvas-text.cpp | 4 ++-- src/display/guideline.cpp | 8 ++++---- src/display/sp-canvas.cpp | 10 +++++----- src/display/sp-ctrlpoint.cpp | 4 ++-- src/display/sp-ctrlquadr.cpp | 4 ++-- src/draw-context.cpp | 18 +++++++++--------- src/event-context.h | 1 + src/gradient-drag.h | 9 +++++++-- src/zoom-context.cpp | 16 ++++++++-------- 9 files changed, 40 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index ddc946d5d..fe60d9c65 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -58,9 +58,9 @@ sp_canvastext_get_type (void) static void sp_canvastext_class_init(SPCanvasTextClass *klass) { - SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; + SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); - parent_class_ct = (SPCanvasItemClass*)g_type_class_peek_parent (klass); + parent_class_ct = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass)); item_class->destroy = sp_canvastext_destroy; item_class->update = sp_canvastext_update; diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index d3385978a..f71bc82ef 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -66,9 +66,9 @@ GType sp_guideline_get_type() static void sp_guideline_class_init(SPGuideLineClass *c) { - parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c); + parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c)); - SPCanvasItemClass *item_class = (SPCanvasItemClass *) c; + SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c); item_class->destroy = sp_guideline_destroy; item_class->update = sp_guideline_update; item_class->render = sp_guideline_render; @@ -191,8 +191,8 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, { SPGuideLine *gl = SP_GUIDELINE(item); - if (((SPCanvasItemClass *) parent_class)->update) { - ((SPCanvasItemClass *) parent_class)->update(item, affine, flags); + if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) { + (SP_CANVAS_ITEM_CLASS(parent_class))->update(item, affine, flags); } gl->affine = affine; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 6d4d01e33..536c54609 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1081,7 +1081,7 @@ void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsig Geom::OptRect bounds; for (GList *list = group->items; list; list = list->next) { - SPCanvasItem *i = (SPCanvasItem *)list->data; + SPCanvasItem *i = SP_CANVAS_ITEM(list->data); sp_canvas_item_invoke_update (i, affine, flags); @@ -1118,7 +1118,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac double dist = 0.0; for (GList *list = group->items; list; list = list->next) { - SPCanvasItem *child = (SPCanvasItem *)list->data; + SPCanvasItem *child = SP_CANVAS_ITEM(list->data); if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) { SPCanvasItem *point_item = NULL; // cater for incomplete item implementations @@ -1152,7 +1152,7 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf) SPCanvasGroup const *group = SP_CANVAS_GROUP(item); for (GList *list = group->items; list; list = list->next) { - SPCanvasItem *child = (SPCanvasItem *)list->data; + SPCanvasItem *child = SP_CANVAS_ITEM(list->data); if (child->visible) { if ((child->x1 < buf->rect.right()) && (child->y1 < buf->rect.bottom()) && @@ -1171,7 +1171,7 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_ SPCanvasGroup *group = SP_CANVAS_GROUP(item); for (GList *list = group->items; list; list = list->next) { - SPCanvasItem *child = (SPCanvasItem *)list->data; + SPCanvasItem *child = SP_CANVAS_ITEM(list->data); if (child->visible) { if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) { SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area); @@ -1649,7 +1649,6 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event) { int button_down = 0; - double x, y; if (!canvas->root) // canvas may have already be destroyed by closing desktop durring interrupted display! return FALSE; @@ -1709,6 +1708,7 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event) // LeaveNotify means that there is no current item, so we don't look for one if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) { // these fields don't have the same offsets in both types of events + double x, y; if (canvas->pick_event.type == GDK_ENTER_NOTIFY) { x = canvas->pick_event.crossing.x; diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp index d07e9385b..026cc7589 100644 --- a/src/display/sp-ctrlpoint.cpp +++ b/src/display/sp-ctrlpoint.cpp @@ -52,9 +52,9 @@ sp_ctrlpoint_get_type (void) static void sp_ctrlpoint_class_init(SPCtrlPointClass *klass) { - SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; + SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); - parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); + parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass)); item_class->destroy = sp_ctrlpoint_destroy; item_class->update = sp_ctrlpoint_update; diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index ae15d620a..b6a0da109 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -61,9 +61,9 @@ sp_ctrlquadr_get_type (void) static void sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass) { - SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; + SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); - parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); + parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass)); item_class->destroy = sp_ctrlquadr_destroy; item_class->update = sp_ctrlquadr_update; diff --git a/src/draw-context.cpp b/src/draw-context.cpp index daff0794a..5996d600b 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -104,9 +104,9 @@ static void sp_draw_context_class_init(SPDrawContextClass *klass) SPEventContextClass *ec_class; object_class = (GObjectClass *)klass; - ec_class = (SPEventContextClass *) klass; + ec_class = SP_EVENT_CONTEXT_CLASS(klass); - draw_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); + draw_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); object_class->dispose = sp_draw_context_dispose; @@ -175,8 +175,8 @@ static void sp_draw_context_setup(SPEventContext *ec) SPDrawContext *dc = SP_DRAW_CONTEXT(ec); SPDesktop *dt = ec->desktop; - if (((SPEventContextClass *) draw_parent_class)->setup) { - ((SPEventContextClass *) draw_parent_class)->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(draw_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(draw_parent_class))->setup(ec); } dc->selection = sp_desktop_selection(dt); @@ -261,8 +261,8 @@ gint sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) draw_parent_class)->root_handler) { - ret = ((SPEventContextClass *) draw_parent_class)->root_handler(ec, event); + if ((SP_EVENT_CONTEXT_CLASS(draw_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(draw_parent_class))->root_handler(ec, event); } } @@ -700,7 +700,7 @@ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p) } for (GSList *l = dc->white_anchors; l != NULL; l = l->next) { - SPDrawAnchor *na = sp_draw_anchor_test((SPDrawAnchor *) l->data, p, !active); + SPDrawAnchor *na = sp_draw_anchor_test(static_cast(l->data), p, !active); if ( !active && na ) { active = na; } @@ -720,7 +720,7 @@ static void spdc_reset_white(SPDrawContext *dc) dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data); } while (dc->white_anchors) { - sp_draw_anchor_destroy((SPDrawAnchor *) dc->white_anchors->data); + sp_draw_anchor_destroy(static_cast(dc->white_anchors->data)); dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data); } } @@ -767,7 +767,7 @@ static void spdc_free_colors(SPDrawContext *dc) dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data); } while (dc->white_anchors) { - sp_draw_anchor_destroy((SPDrawAnchor *) dc->white_anchors->data); + sp_draw_anchor_destroy(static_cast(dc->white_anchors->data)); dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data); } } diff --git a/src/event-context.h b/src/event-context.h index 9cd754ffb..9936aa668 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -36,6 +36,7 @@ namespace Inkscape { #define SP_TYPE_EVENT_CONTEXT (sp_event_context_get_type()) #define SP_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_EVENT_CONTEXT, SPEventContext)) +#define SP_EVENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_EVENT_CONTEXT, SPEventContextClass)) #define SP_IS_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_EVENT_CONTEXT)) GType sp_event_context_get_type(); diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 4bab3aeb2..69e76d55f 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -134,8 +134,13 @@ public: // FIXME: make more of this private! bool hasSelection() {return (selected != NULL);} guint numSelected() {return (selected? g_list_length(selected) : 0);} guint numDraggers() {return (draggers? g_list_length(draggers) : 0);} - guint singleSelectedDraggerNumDraggables() {return (selected? g_slist_length(((GrDragger *) selected->data)->draggables) : 0);} - guint singleSelectedDraggerSingleDraggableType() {return (selected? ((GrDraggable *) ((GrDragger *) selected->data)->draggables->data)->point_type : 0);} + + guint singleSelectedDraggerNumDraggables() { + return (selected? g_slist_length(( static_cast(selected->data))->draggables) : 0); + } + + guint singleSelectedDraggerSingleDraggableType() { + return (selected? ((GrDraggable *) ((GrDragger *) selected->data)->draggables->data)->point_type : 0);} // especially the selection must be private, fix gradient-context to remove direct access to it GList *selected; // list of GrDragger* diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 68f58614d..9311901d3 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -64,9 +64,9 @@ GType sp_zoom_context_get_type(void) static void sp_zoom_context_class_init(SPZoomContextClass *klass) { - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; + SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = (SPEventContextClass*) g_type_class_peek_parent(klass); + parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); event_context_class->setup = sp_zoom_context_setup; event_context_class->finish = sp_zoom_context_finish; @@ -107,8 +107,8 @@ static void sp_zoom_context_setup(SPEventContext *ec) ec->enableGrDrag(); } - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); } } @@ -116,8 +116,8 @@ static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem * { gint ret = FALSE; - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler (event_context, item, event); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler (event_context, item, event); } return ret; @@ -264,8 +264,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); } } -- cgit v1.2.3 From 50344eb9b83c7d8935010b9a31f0bc243a7da805 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 28 Oct 2012 12:08:09 +0900 Subject: Fix for 1067808 : Focus issues with new gradient (and swatch) manager in Fill&Stroke - Focus fix (bzr r11842) --- src/widgets/gradient-selector.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 0cf1c2c51..2a651544b 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -374,7 +374,10 @@ bool SPGradientSelector::_checkForSelected(const Gtk::TreePath &path, const Gtk: { treeview->scroll_to_row(path, 0.5); Glib::RefPtr select = treeview->get_selection(); + bool wasBlocked = blocked; + blocked = true; select->select(iter); + blocked = wasBlocked; found = true; } -- cgit v1.2.3 From dd99faf81e392ab6b3f9bccc1d08a69dbc7e1e64 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 28 Oct 2012 12:34:17 +0900 Subject: Fix for 928205 : Do not save viewport metadata option (bzr r11843) --- src/sp-namedview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 9d5821897..2f158df9d 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -790,7 +790,7 @@ void sp_namedview_window_from_document(SPDesktop *desktop) { SPNamedView *nv = desktop->namedview; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool geometry_from_file = prefs->getBool("/options/savewindowgeometry/value"); + bool geometry_from_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0)); bool show_dialogs = TRUE; // restore window size and position stored with the document @@ -888,7 +888,7 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop) void sp_namedview_document_from_window(SPDesktop *desktop) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool save_geometry_in_file = prefs->getBool("/options/savewindowgeometry/value", 0); + bool save_geometry_in_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0)); bool save_viewport_in_file = prefs->getBool("/options/savedocviewport/value", true); Inkscape::XML::Node *view = desktop->namedview->getRepr(); Geom::Rect const r = desktop->get_display_area(); -- cgit v1.2.3 From 1ef13096f6644defa9463a0a3fe7dbbcbc7271f7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 28 Oct 2012 10:25:29 +0000 Subject: cppcheck: More C-style pointer casting (bzr r11844) --- src/display/nr-filter-image.cpp | 2 ++ src/display/nr-filter-skeleton.cpp | 3 ++- src/display/sodipodi-ctrl.cpp | 8 ++++---- src/display/sodipodi-ctrlrect.cpp | 11 +++++------ 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index e03a56964..bc18cbcc6 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -99,8 +99,10 @@ void FilterImage::render_cairo(FilterSlot &slot) Geom::Rect area = *optarea; Geom::Affine user2pb = slot.get_units().get_matrix_user2pb(); + /* FIXME: These variables are currently unused. Why were they calculated? double scaleX = feImageWidth / area.width(); double scaleY = feImageHeight / area.height(); + */ Geom::Rect sa = slot.get_slot_area(); cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp index 0c455a818..86ab8141e 100644 --- a/src/display/nr-filter-skeleton.cpp +++ b/src/display/nr-filter-skeleton.cpp @@ -42,7 +42,8 @@ FilterSkeleton::~FilterSkeleton() void FilterSkeleton::render_cairo(FilterSlot &slot) { cairo_surface_t *in = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_identical(in); - cairo_t *ct = cairo_create(out); + +// cairo_t *ct = cairo_create(out); // cairo_set_source_surface(ct, in, offset[X], offset[Y]); // cairo_paint(ct); diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index e21bdff15..45dc38a37 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -63,10 +63,10 @@ sp_ctrl_get_type (void) static void sp_ctrl_class_init (SPCtrlClass *klass) { - SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; + SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); GObjectClass *g_object_class = (GObjectClass *) klass; - parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass); + parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent (klass)); g_object_class->set_property = sp_ctrl_set_property; g_object_class->get_property = sp_ctrl_get_property; @@ -287,8 +287,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla ctrl = SP_CTRL (item); - if (((SPCanvasItemClass *) parent_class)->update) - (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags); + if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) + (* (SP_CANVAS_ITEM_CLASS(parent_class))->update) (item, affine, flags); sp_canvas_item_reset_bounds (item); diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index b0c997a92..c350e4614 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -61,9 +61,9 @@ GType sp_ctrlrect_get_type() static void sp_ctrlrect_class_init(SPCtrlRectClass *c) { - SPCanvasItemClass *item_class = (SPCanvasItemClass *) c; + SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c); - parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c); + parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c)); item_class->destroy = sp_ctrlrect_destroy; item_class->update = sp_ctrlrect_update; @@ -119,8 +119,6 @@ void CtrlRect::render(SPCanvasBuf *buf) using Geom::X; using Geom::Y; - static double const dashes[2] = {4.0, 4.0}; - if (!_area) { return; } @@ -129,6 +127,7 @@ void CtrlRect::render(SPCanvasBuf *buf) area[X].max() + _shadow_size, area[Y].max() + _shadow_size); if ( area_w_shadow.intersects(buf->rect) ) { + static double const dashes[2] = {4.0, 4.0}; cairo_save(buf->ct); cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top()); cairo_set_line_width(buf->ct, 1); @@ -161,8 +160,8 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags) using Geom::X; using Geom::Y; - if (((SPCanvasItemClass *) parent_class)->update) { - ((SPCanvasItemClass *) parent_class)->update(this, affine, flags); + if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) { + (SP_CANVAS_ITEM_CLASS(parent_class))->update(this, affine, flags); } sp_canvas_item_reset_bounds(this); -- cgit v1.2.3 From 0e9545617810df5b44f04a8e2800c929cda0af89 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 28 Oct 2012 12:13:58 +0000 Subject: cppcheck: Fix a couple of leaks (bzr r11845) --- src/helper/stock-items.cpp | 1 + src/ui/dialog/symbols.cpp | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index a00507330..a12fa377a 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -199,6 +199,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) SPDocument *doc = sp_desktop_document(desktop); SPDefs *defs = doc->getDefs(); if (!defs) { + g_free(base); return NULL; } SPObject *object = NULL; diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 82af60fc2..4e1b82ebe 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -418,6 +418,8 @@ void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) { (*row)[columns->symbol_image] = pixbuf; } } + + delete columns; } /* -- cgit v1.2.3 From b68be517ee0a575965cde90913c349405d3994df Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 28 Oct 2012 15:10:22 +0100 Subject: add bleed/margin to pdf export (bzr r11847) --- src/extension/internal/cairo-png-out.cpp | 2 +- src/extension/internal/cairo-ps-out.cpp | 6 +++--- src/extension/internal/cairo-renderer-pdf-out.cpp | 20 +++++++++++++++----- src/extension/internal/cairo-renderer.cpp | 3 ++- src/extension/internal/cairo-renderer.h | 2 +- src/extension/internal/latex-text-renderer.cpp | 7 ++++--- src/extension/internal/latex-text-renderer.h | 4 ++-- src/ui/dialog/print.cpp | 2 +- 8 files changed, 29 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index 4751a229a..956fcce9a 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -68,7 +68,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) ctx = renderer->createContext(); /* Render document */ - bool ret = renderer->setupDocument(ctx, doc, TRUE, NULL); + bool ret = renderer->setupDocument(ctx, doc, TRUE, 0., NULL); if (ret) { renderer->renderItem(ctx, base); ctx->saveAsPng(filename); diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 605f0237c..8a39f4ea9 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -104,7 +104,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l bool ret = ctx->setPsTarget(filename); if(ret) { /* Render document */ - ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base); + ret = renderer->setupDocument(ctx, doc, pageBoundingBox, 0., base); if (ret) { renderer->renderItem(ctx, base); ret = ctx->finish(); @@ -192,7 +192,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con // Create LaTeX file (if requested) if (new_textToLaTeX) { - ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false); + ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false); if (!ret) throw Inkscape::Extension::Output::save_failed(); @@ -272,7 +272,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co // Create LaTeX file (if requested) if (new_textToLaTeX) { - ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false); + ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false); if (!ret) throw Inkscape::Extension::Output::save_failed(); diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 494ff1e8d..773109c77 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -39,6 +39,8 @@ #include <2geom/affine.h> #include "document.h" +#include "unit-constants.h" + namespace Inkscape { namespace Extension { namespace Internal { @@ -57,7 +59,7 @@ bool CairoRendererPdfOutput::check(Inkscape::Extension::Extension * /*module*/) static bool pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, bool filtertobitmap, int resolution, - const gchar * const exportId, bool exportDrawing, bool exportCanvas) + const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px) { doc->ensureUpToDate(); @@ -99,7 +101,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int bool ret = ctx->setPdfTarget (filename); if(ret) { /* Render document */ - ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base); + ret = renderer->setupDocument(ctx, doc, pageBoundingBox, bleedmargin_px, base); if (ret) { renderer->renderItem(ctx, base); ret = ctx->finish(); @@ -191,16 +193,23 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, } catch(...) { g_warning("Parameter might not exist"); } - bool new_exportDrawing = !new_exportCanvas; + float new_bleedmargin_px = 0.; + try { + new_bleedmargin_px = mod->get_param_float("bleed") * PX_PER_MM; + } + catch(...) { + g_warning("Parameter might not exist"); + } + // Create PDF file { gchar * final_name; final_name = g_strdup_printf("> %s", filename); ret = pdf_render_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution, - new_exportId, new_exportDrawing, new_exportCanvas); + new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px); g_free(final_name); if (!ret) @@ -209,7 +218,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, // Create LaTeX file (if requested) if (new_textToLaTeX) { - ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true); + ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px, true); if (!ret) throw Inkscape::Extension::Output::save_failed(); @@ -246,6 +255,7 @@ CairoRendererPdfOutput::init (void) "" "" "" + "0\n" "\n" "\n" ".pdf\n" diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 09d69becb..aa54979bc 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -604,7 +604,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) } bool -CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base) +CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base) { // PLEASE note when making changes to the boundingbox and transform calculation, corresponding changes should be made to PDFLaTeXRenderer::setupDocument !!! @@ -625,6 +625,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page } d = *bbox; } + d.expandBy(bleedmargin_px); if (ctx->_vector_based_target) { // convert from px to pt diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index 7fa7c7ff5..db3068fed 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -53,7 +53,7 @@ public: /** Initializes the CairoRenderContext according to the specified SPDocument. A set*Target function can only be called on the context before setupDocument. */ - bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base); + bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base); /** Traverses the object tree and invokes the render methods. */ void renderItem(CairoRenderContext *ctx, SPItem *item); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index ebd73a033..ecc201733 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -56,7 +56,7 @@ namespace Internal { */ bool latex_render_document_text_to_file( SPDocument *doc, gchar const *filename, - const gchar * const exportId, bool exportDrawing, bool exportCanvas, + const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px, bool pdflatex) { doc->ensureUpToDate(); @@ -84,7 +84,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename, bool ret = renderer->setTargetFile(filename); if (ret) { /* Render document */ - bool ret = renderer->setupDocument(doc, pageBoundingBox, base); + bool ret = renderer->setupDocument(doc, pageBoundingBox, bleedmargin_px, base); if (ret) { renderer->renderItem(base); } @@ -569,7 +569,7 @@ LaTeXTextRenderer::renderItem(SPItem *item) } bool -LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base) +LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base) { // The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument ! @@ -588,6 +588,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * } d = *bbox; } + d.expandBy(bleedmargin_px); // scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX double scale = 1/(d.width()); diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h index 66055a3bc..0fa94c9e6 100644 --- a/src/extension/internal/latex-text-renderer.h +++ b/src/extension/internal/latex-text-renderer.h @@ -29,7 +29,7 @@ namespace Extension { namespace Internal { bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename, - const gchar * const exportId, bool exportDrawing, bool exportCanvas, + const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px, bool pdflatex); class LaTeXTextRenderer { @@ -41,7 +41,7 @@ public: /** Initializes the LaTeXTextRenderer according to the specified SPDocument. Important to set the boundingbox to the pdf boundingbox */ - bool setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base); + bool setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base); /** Traverses the object tree and invokes the render methods. */ void renderItem(SPItem *item); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index e940a3f55..2ab8cf121 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -138,7 +138,7 @@ static void draw_page( #endif bool ret = ctx->setSurfaceTarget (surface, true, &ctm); if (ret) { - ret = renderer.setupDocument (ctx, junk->_doc, TRUE, NULL); + ret = renderer.setupDocument (ctx, junk->_doc, TRUE, 0., NULL); if (ret) { renderer.renderItem(ctx, junk->_base); ret = ctx->finish(); -- cgit v1.2.3 From 258b9b4a5dd01aceebf244522bab72f47b60ea03 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 28 Oct 2012 18:31:24 +0100 Subject: Fix for Bug #1072391 (Save as copy crash). (bzr r11848) --- src/file.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index cb4ea591c..14f70fc8c 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -675,7 +675,12 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, } SP_ACTIVE_DESKTOP->event_log->rememberFileSave(); - Glib::ustring msg = Glib::ustring::format(_("Document saved."), " ", doc->getURI()); + Glib::ustring msg; + if (doc->getURI() == NULL) { + msg = Glib::ustring::format(_("Document saved.")); + } else { + msg = Glib::ustring::format(_("Document saved."), " ", doc->getURI()); + } SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.c_str()); return true; } -- cgit v1.2.3 From 746790b9b8fefd17bc3bb31557c183c9a8206a61 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 28 Oct 2012 19:19:43 +0100 Subject: fix margin for PDF exporting page area (bzr r11849) --- src/extension/internal/cairo-renderer.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index aa54979bc..0a3cff26a 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -639,16 +639,21 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page bool ret = ctx->setupSurface(ctx->_width, ctx->_height); - if (ret && !pageBoundingBox) - { - double high = doc->getHeight(); - if (ctx->_vector_based_target) - high *= PT_PER_PX; - - /// @fixme hardcoded dt2doc transform? - Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0), - (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); - ctx->transform(tp); + if (ret) { + if (pageBoundingBox) { + // translate to set bleed/margin + Geom::Affine tp( Geom::Translate( bleedmargin_px, bleedmargin_px ) ); + ctx->transform(tp); + } else { + double high = doc->getHeight(); + if (ctx->_vector_based_target) + high *= PT_PER_PX; + + // this transform translates the export drawing to a virtual page (0,0)-(width,height) + Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0), + (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); + ctx->transform(tp); + } } return ret; -- cgit v1.2.3 From 606276db1921c978abaf15d1abeff96ef37dbe2f Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 29 Oct 2012 12:44:15 +0900 Subject: Fix for 165865 : Markers - fix Undo history (bzr r11850) --- src/widgets/stroke-style.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 832865eae..4e8431454 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -434,14 +434,13 @@ StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, SPMa item->requestModified(SP_OBJECT_MODIFIED_FLAG); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + + DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set markers")); } sp_repr_css_attr_unref(css); css = 0; - DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, - _("Set markers")); - spw->update = false; }; -- cgit v1.2.3 From 1df38b62029b7ca6ad6a0861650bcbb5a463b5eb Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 30 Oct 2012 11:59:53 +0900 Subject: Fix for 1071426 : Swatches dialog doesn't update when swatch is renamed (bzr r11852) --- src/ui/dialog/color-item.cpp | 19 +++++++++++++++++++ src/ui/dialog/color-item.h | 1 + 2 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 969aac7ab..0c4fe3686 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -355,6 +355,24 @@ void ColorItem::setGradient(SPGradient *grad) _grad = grad; // TODO regen and push to listeners } + + setName( _grad->defaultLabel() ); +} + +void ColorItem::setName(const Glib::ustring name) +{ + def.descr = name; + + for ( std::vector::iterator it = _previews.begin(); it != _previews.end(); ++it ) { + Gtk::Widget* widget = *it; + if ( IS_EEK_PREVIEW(widget->gobj()) ) { + EekPreview * preview = EEK_PREVIEW(widget->gobj()); + gtk_widget_set_tooltip_text(GTK_WIDGET(preview), def.descr.c_str()); + } + else if ( GTK_IS_LABEL(widget->gobj()) ) { + gtk_label_set_text(GTK_LABEL(widget->gobj()), def.descr.c_str()); + } + } } void ColorItem::setPattern(cairo_pattern_t *pattern) @@ -366,6 +384,7 @@ void ColorItem::setPattern(cairo_pattern_t *pattern) cairo_pattern_destroy(_pattern); } _pattern = pattern; + _updatePreviews(); } diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h index f54586192..3a0b33193 100644 --- a/src/ui/dialog/color-item.h +++ b/src/ui/dialog/color-item.h @@ -60,6 +60,7 @@ public: void setGradient(SPGradient *grad); SPGradient * getGradient() const { return _grad; } void setPattern(cairo_pattern_t *pattern); + void setName(const Glib::ustring name); void setState( bool fill, bool stroke ); bool isFill() { return _isFill; } -- cgit v1.2.3 From eaf3c9f41f5faf2ba693d16abc259a48e8a021b8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 30 Oct 2012 12:03:28 +0900 Subject: Fix for 1071328 : Inkscape encounters internal error when opening a valid SVG file (bzr r11853) --- src/sp-item-group.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index b54ec65e2..de2c79ec6 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -766,7 +766,9 @@ void CGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *a if (SP_IS_ITEM (o)) { child = SP_ITEM (o); ac = child->invoke_show (drawing, key, flags); - ai->appendChild(ac); + if (ac) { + ai->appendChild(ac); + } } l = g_slist_remove (l, o); } -- cgit v1.2.3 From 8a7c5c6939b5403fbeb3b9fd2e6e3f3b4f426925 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 30 Oct 2012 22:28:04 +0900 Subject: Fix for 1071426 : Swatches dialog doesn't update when swatch is renamed - fix indicators (bzr r11854) --- src/ui/dialog/color-item.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 0c4fe3686..97f6cc07f 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -35,6 +35,7 @@ #include "xml/node.h" #include "xml/repr.h" #include "verbs.h" +#include "widgets/gradient-vector.h" #include "color.h" // for SP_RGBA32_U_COMPOSE @@ -356,21 +357,20 @@ void ColorItem::setGradient(SPGradient *grad) // TODO regen and push to listeners } - setName( _grad->defaultLabel() ); + setName( gr_prepare_label(_grad) ); } void ColorItem::setName(const Glib::ustring name) { - def.descr = name; + //def.descr = name; for ( std::vector::iterator it = _previews.begin(); it != _previews.end(); ++it ) { Gtk::Widget* widget = *it; if ( IS_EEK_PREVIEW(widget->gobj()) ) { - EekPreview * preview = EEK_PREVIEW(widget->gobj()); - gtk_widget_set_tooltip_text(GTK_WIDGET(preview), def.descr.c_str()); + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->gobj()), name.c_str()); } else if ( GTK_IS_LABEL(widget->gobj()) ) { - gtk_label_set_text(GTK_LABEL(widget->gobj()), def.descr.c_str()); + gtk_label_set_text(GTK_LABEL(widget->gobj()), name.c_str()); } } } -- cgit v1.2.3 From 3c76aba3f2e1dfe8c0568a7d38a732cd2cf3dd8b Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 31 Oct 2012 09:25:06 +0900 Subject: Fix for 1068763 : Opening 'File > Document Properties' dirties current document (bzr r11855) --- src/display/canvas-grid.cpp | 6 ++++-- src/ui/dialog/document-properties.cpp | 2 ++ src/ui/widget/licensor.cpp | 18 +++++++++--------- src/ui/widget/page-sizer.cpp | 4 ++++ 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index cb33169cd..42a5ceccc 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -350,12 +350,13 @@ CanvasGrid::newWidget() _rcb_enabled->setSlaveWidgets(slaves); // set widget values + _wr.setUpdating (true); _rcb_visible->setActive(visible); if (snapper != NULL) { _rcb_enabled->setActive(snapper->getEnabled()); _rcb_snap_visible_only->setActive(snapper->getSnapVisibleOnly()); } - + _wr.setUpdating (false); return dynamic_cast (vbox); } @@ -734,7 +735,6 @@ _wr.setUpdating (true); new Inkscape::UI::Widget::RegisteredCheckButton( _("_Show dots instead of lines"), _("If set, displays dots at gridpoints instead of gridlines"), "dotted", _wr, false, repr, doc) ); -_wr.setUpdating (false); Gtk::Widget const *const widget_array[] = { 0, _rumg, @@ -774,6 +774,8 @@ _wr.setUpdating (false); _rcb_dotted->setActive(render_dotted); + _wr.setUpdating (false); + _rsu_ox->setProgrammatically = false; _rsu_oy->setProgrammatically = false; _rsu_sx->setProgrammatically = false; diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 7bd1b81c0..4a6429fc5 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -150,6 +150,7 @@ DocumentProperties::DocumentProperties() _notebook.append_page(_page_metadata1, _("Metadata")); _notebook.append_page(_page_metadata2, _("License")); + _wr.setUpdating (true); build_page(); build_guides(); build_gridspage(); @@ -159,6 +160,7 @@ DocumentProperties::DocumentProperties() #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) build_scripting(); build_metadata(); + _wr.setUpdating (false); _grids_button_new.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onNewGrid)); _grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid)); diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index 7fff7d87f..8ecd36af2 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -44,7 +44,7 @@ const struct rdf_license_t _other_license = class LicenseItem : public Gtk::RadioButton { public: - LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr); + LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group); protected: void on_toggled(); struct rdf_license_t const *_lic; @@ -52,13 +52,12 @@ protected: Registry &_wr; }; -LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr) +LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group) : Gtk::RadioButton(_(license->name)), _lic(license), _eep(entity), _wr(wr) { - static Gtk::RadioButtonGroup group = get_group(); - static bool first = true; - if (first) first = false; - else set_group (group); + if (group) { + set_group (*group); + } } /// \pre it is assumed that the license URI entry is a Gtk::Entry @@ -97,18 +96,19 @@ void Licensor::init (Registry& wr) LicenseItem *i; wr.setUpdating (true); - i = manage (new LicenseItem (&_proprietary_license, _eentry, wr)); + i = manage (new LicenseItem (&_proprietary_license, _eentry, wr, NULL)); + Gtk::RadioButtonGroup group = i->get_group(); add (*i); LicenseItem *pd = i; for (struct rdf_license_t * license = rdf_licenses; license && license->name; license++) { - i = manage (new LicenseItem (license, _eentry, wr)); + i = 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)); + LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr, &group)); add (*io); pd->set_active(); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 90eb6a3fd..2ab72d6c7 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -245,12 +245,14 @@ PageSizer::PageSizer(Registry & _wr) _widgetRegistry(&_wr) { // set precision of scalar entry boxes + _wr.setUpdating (true); _dimensionWidth.setDigits(5); _dimensionHeight.setDigits(5); _marginTop.setDigits(5); _marginLeft.setDigits(5); _marginRight.setDigits(5); _marginBottom.setDigits(5); + _wr.setUpdating (false); //# Set up the Paper Size combo box _paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns); @@ -315,11 +317,13 @@ PageSizer::PageSizer(Registry & _wr) // Setting default custom unit to document unit SPDesktop *dt = SP_ACTIVE_DESKTOP; SPNamedView *nv = sp_desktop_namedview(dt); + _wr.setUpdating (true); if (nv->units) { _dimensionUnits.setUnit(nv->units); } else if (nv->doc_units) { _dimensionUnits.setUnit(nv->doc_units); } + _wr.setUpdating (false); //## Set up custom size frame _customFrame.set_label(_("Custom size")); -- cgit v1.2.3 From fae3970752f9c3f710afb6d3627d7402dd0de80f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 31 Oct 2012 06:45:04 +0100 Subject: Fix for Bug #1069806 (Inkscape crash in File>Open). (bzr r11856) --- src/ui/dialog/filedialogimpl-gtkmm.cpp | 11 +++++------ src/ui/dialog/filedialogimpl-gtkmm.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 1663eb0b6..8c2a7e056 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -141,13 +141,12 @@ bool SVGPreview::setDocument(SPDocument *doc) //This should remove it from the box, and free resources if (viewerGtk) - gtk_widget_destroy(viewerGtk); - - viewerGtk = sp_svg_view_widget_new(doc); - GtkWidget *vbox = (GtkWidget *)gobj(); - gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0); - gtk_widget_show(viewerGtk); + Gtk::Container::remove(*viewerGtk); + viewerGtk = Glib::wrap(sp_svg_view_widget_new(doc)); + Gtk::VBox *vbox = Glib::wrap(gobj()); + vbox->pack_start(*viewerGtk, TRUE, TRUE, 0); + viewerGtk->show(); return true; } diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index 2c22e7367..02841a082 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -121,7 +121,7 @@ private: /** * The sp_svg_view widget */ - GtkWidget *viewerGtk; + Gtk::Widget *viewerGtk; /** * are we currently showing the "no preview" image? -- cgit v1.2.3 From 5915945014c543604c92d33ef0088c4fa95cf36a Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 1 Nov 2012 11:11:27 +0900 Subject: Fix for 620568 : Changes to 'Hide all except selected' in Export Bitmap - Revert changes from r11569 (bzr r11857) --- src/ui/dialog/export.cpp | 12 ++++++++---- src/ui/dialog/export.h | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 62dd93126..e6c8ca107 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -296,7 +296,7 @@ Export::Export (void) : batch_box.pack_start(batch_export, false, false); hide_export.set_sensitive(true); - hide_export.set_active (true); + hide_export.set_active (prefs->getBool("/dialogs/export/hideexceptselected/value", false)); hide_box.pack_start(hide_export, false, false); @@ -328,6 +328,7 @@ Export::Export (void) : browse_button.signal_clicked().connect(sigc::mem_fun(*this, &Export::onBrowse)); batch_export.signal_clicked().connect(sigc::mem_fun(*this, &Export::onBatchClicked)); export_button.signal_clicked().connect(sigc::mem_fun(*this, &Export::onExport)); + hide_export.signal_clicked().connect(sigc::mem_fun(*this, &Export::onHideExceptSelected)); desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Export::setTargetDesktop) ); deskTrack.connect(GTK_WIDGET(gobj())); @@ -547,7 +548,7 @@ void Export::updateCheckbuttons () batch_export.set_sensitive(false); } - hide_export.set_sensitive (num > 0 && current_key == SELECTION_SELECTION); + //hide_export.set_sensitive (num > 0); } inline void Export::findDefaultSelection() @@ -786,8 +787,6 @@ void Export::onAreaToggled () } } - hide_export.set_sensitive (key == SELECTION_SELECTION); - return; } // end of sp_export_area_toggled() @@ -919,6 +918,11 @@ Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, c return path; } +void Export::onHideExceptSelected () +{ + prefs->setBool("/dialogs/export/hideexceptselected/value", hide_export.get_active()); +} + /// Called when export button is clicked void Export::onExport () { diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index e899009a7..c8376cdcb 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -177,6 +177,11 @@ private: void areaYChange ( Gtk::Adjustment *adj); #endif + /** + * Hide except selected callback + */ + void onHideExceptSelected (); + /** * Area width value changed callback */ -- cgit v1.2.3 From d64bc939585b99a8a1125097fbc3df7b0a21250e Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 1 Nov 2012 11:15:16 +0900 Subject: Fix for 1006816 : Newly applied filter doesn't show in Filters Editor (bzr r11858) --- src/ui/dialog/filter-effects-dialog.cpp | 11 +++++++++++ src/ui/dialog/filter-effects-dialog.h | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a755cfccd..6fab4c504 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1193,6 +1193,17 @@ void FilterEffectsDialog::FilterModifier::setTargetDesktop(SPDesktop *desktop) } } +// When the document changes, update connection to resources +void FilterEffectsDialog::FilterModifier::on_document_replaced(SPDesktop *desktop, SPDocument *document) +{ + if (_resource_changed) { + _resource_changed.disconnect(); + } + _resource_changed = document->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters)); + + update_filters(); +} + // When the selection changes, show the active filter(s) in the dialog void FilterEffectsDialog::FilterModifier::on_change_selection() { diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index acdeecb71..1652a314f 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -77,12 +77,8 @@ private: }; void setTargetDesktop(SPDesktop *desktop); - - void on_document_replaced(SPDesktop*, SPDocument*) - { - update_filters(); - } + void on_document_replaced(SPDesktop *desktop, SPDocument *document); void on_change_selection(); void on_modified_selection( guint flags ); -- cgit v1.2.3 From 75e147ea084e8589224484ae3a5bcda75cde5fb7 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 2 Nov 2012 00:14:58 +0100 Subject: remove flash path when nodetool eventcontext is destroyed. fixes bug for persistent flashpath when flashtime is set to zero (=infinite) and pressing space to instantly go to select tool while flashpath is still being shown. (bzr r11859) --- src/ui/tool/node-tool.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index b532c8b65..7b6502ec3 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -197,6 +197,10 @@ void ink_node_tool_dispose(GObject *object) nt->enableGrDrag(false); + if (nt->flash_tempitem) { + nt->desktop->remove_temporary_canvasitem(nt->flash_tempitem); + } + nt->_selection_changed_connection.disconnect(); nt->_selection_modified_connection.disconnect(); nt->_mouseover_changed_connection.disconnect(); -- cgit v1.2.3 From 9bffe44ca5eef802c58c1ccf8e41800f987d6697 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 3 Nov 2012 10:21:27 +0100 Subject: Don't remove default css values if element is in or is a . (bzr r11860) --- src/attribute-rel-util.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index cf94c0c1e..38327b413 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -76,7 +76,14 @@ void sp_attribute_clean_recursive(Node *repr, unsigned int flags) { } for(Node *child=repr->firstChild() ; child ; child = child->next()) { - sp_attribute_clean_recursive( child, flags ); + + // Don't remove default css values if element is in or is a + Glib::ustring element = child->name(); + unsigned int flags_temp = flags; + if( element.compare( "svg:defs" ) == 0 || element.compare( "svg:symbol" ) == 0 ) { + flags_temp &= ~(SP_ATTR_CLEAN_DEFAULT_WARN|SP_ATTR_CLEAN_DEFAULT_REMOVE); + } + sp_attribute_clean_recursive( child, flags_temp ); } } -- cgit v1.2.3 From 66f12daab54277b91b8fa44c9b0cc6961f6357b1 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 3 Nov 2012 19:18:09 +0900 Subject: Fix for 1065933 : Better support for sub-layers in 'Show/Hide other layers' (bzr r11861) --- src/desktop.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index fa0c8647f..f10174119 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -549,12 +549,17 @@ void SPDesktop::toggleLayerSolo(SPObject *object) { bool othersShowing = false; std::vector layers; for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { - layers.push_back(obj); - othersShowing |= !SP_ITEM(obj)->isHidden(); + // Don't hide ancestors, since that would in turn hide the layer as well + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersShowing |= !SP_ITEM(obj)->isHidden(); + } } for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { - layers.push_back(obj); - othersShowing |= !SP_ITEM(obj)->isHidden(); + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersShowing |= !SP_ITEM(obj)->isHidden(); + } } -- cgit v1.2.3 From 6ecbc96f5ef1960388e3fa0f42dcceaac1e40d69 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 6 Nov 2012 19:36:17 +0100 Subject: Change outline mode rendering tolerance from 1.25 to 0.5. Fixes disappearing lines in newer versions of Cairo. (bzr r11862) --- src/display/drawing-shape.cpp | 2 +- src/display/drawing-text.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 4ca306092..e80f12486 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -167,7 +167,7 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne { Inkscape::DrawingContext::Save save(ct); ct.setSource(rgba); ct.setLineWidth(0.5); - ct.setTolerance(1.25); + ct.setTolerance(0.5); ct.stroke(); } } else { diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 7f63c555a..2a6505c67 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -162,7 +162,7 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are guint32 rgba = _drawing.outlinecolor; Inkscape::DrawingContext::Save save(ct); ct.setSource(rgba); - ct.setTolerance(1.25); // low quality, but good enough for outline mode + ct.setTolerance(0.5); // low quality, but good enough for outline mode for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { DrawingGlyphs *g = dynamic_cast(&*i); -- cgit v1.2.3 From 03e0575add1aa2830e25176db3fdd950450d8c49 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 7 Nov 2012 21:30:45 +0100 Subject: Fix for Bug #773288 (border options) by demicoder. (bzr r11863) --- src/ui/dialog/document-properties.cpp | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 4a6429fc5..693268b35 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -203,41 +203,36 @@ DocumentProperties::~DocumentProperties() * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. */ -inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0) +inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0) { - for (unsigned i = 0, r = start; i < n; i += 2) - { - if (arr[i] && arr[i+1]) - { - table.attach(*arr[i], 1, 2, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - table.attach(*arr[i+1], 2, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - } - else - { + for (unsigned i = 0, r = start; i < n; i += 2) { + if (arr[i] && arr[i+1]) { + table.attach(*arr[i], 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); + table.attach(*arr[i+1], 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); + } else { if (arr[i+1]) { Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0; if (dynamic_cast(arr[i+1])) { // only the PageSizer in Document Properties|Page should be stretched vertically yoptions = Gtk::FILL|Gtk::EXPAND; } - table.attach(*arr[i+1], 1, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); - } - else if (arr[i]) - { + if (docum_prop_flag) { + if( i==(n-4) || i==(n-6) ) { + table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 20,0); + } else { + table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); + } + } else { + table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); + } + } else if (arr[i]) { Gtk::Label& label = reinterpret_cast(*arr[i]); label.set_alignment (0.0); - table.attach (label, 0, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - } - else - { + table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); + } else { Gtk::HBox *space = manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - table.attach (*space, 0, 1, r, r+1, - (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); + table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); } } ++r; @@ -275,7 +270,12 @@ void DocumentProperties::build_page() _rcp_bord._label, &_rcp_bord, }; - attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array)); + std::list _slaveList; + _slaveList.push_back(&_rcb_bord); + _slaveList.push_back(&_rcb_shad); + _rcb_canb.setSlaveWidgets(_slaveList); + + attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array),0,1); } void DocumentProperties::build_guides() -- cgit v1.2.3 From 6d4a392c8b87a48d596c7c872e95b5d6f6de000c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 10 Nov 2012 23:14:13 +0100 Subject: Build. Fixing win32 build with cairo > 1.11.4 (replacing uint with unsigned int). (bzr r11866) --- src/sp-gradient.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 5efa3c84f..f9f9a5015 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -2104,15 +2104,15 @@ static cairo_pattern_t *sp_meshgradient_create_pattern(SPPaintServer *ps, cp = cairo_pattern_create_mesh(); - for( uint i = 0; i < array->patch_rows(); ++i ) { - for( uint j = 0; j < array->patch_columns(); ++j ) { + for( unsigned int i = 0; i < array->patch_rows(); ++i ) { + for( unsigned int j = 0; j < array->patch_columns(); ++j ) { SPMeshPatchI patch( &(array->nodes), i, j ); cairo_mesh_pattern_begin_patch( cp ); cairo_mesh_pattern_move_to( cp, patch.getPoint( 0, 0 )[X], patch.getPoint( 0, 0 )[Y] ); - for( uint k = 0; k < 4; ++k ) { + for( unsigned int k = 0; k < 4; ++k ) { #ifdef DEBUG_MESH std::cout << i << " " << j << " " << patch.getPathType( k ) << " ("; -- cgit v1.2.3 From f8a5b66bb57495c83274218dc98530a071b10f27 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 11:20:05 +0000 Subject: cppcheck: Convert more C-style pointer casts to GObject or C++ (bzr r11867) --- src/common-context.cpp | 4 +-- src/desktop-handles.cpp | 2 +- src/display/curve.cpp | 2 +- src/display/nr-svgfonts.cpp | 67 ++++++++++++++++++++---------------------- src/event-context.cpp | 28 +++++++++--------- src/extension/internal/odf.cpp | 2 +- src/gradient-drag.h | 2 +- src/selection-chemistry.cpp | 5 +++- 8 files changed, 56 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/common-context.cpp b/src/common-context.cpp index 9ced41a26..9d5dbb048 100644 --- a/src/common-context.cpp +++ b/src/common-context.cpp @@ -56,9 +56,9 @@ GType sp_common_context_get_type(void) static void sp_common_context_class_init(SPCommonContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; + SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - common_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); + common_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); object_class->dispose = sp_common_context_dispose; diff --git a/src/desktop-handles.cpp b/src/desktop-handles.cpp index aed2eec34..f7ffbed70 100644 --- a/src/desktop-handles.cpp +++ b/src/desktop-handles.cpp @@ -44,7 +44,7 @@ sp_desktop_canvas (SPDesktop const * desktop) { g_return_val_if_fail (desktop != NULL, NULL); - return ((SPCanvasItem *) desktop->main)->canvas; + return (SP_CANVAS_ITEM(desktop->main))->canvas; } SPCanvasItem * diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 1a788b59a..ae243853e 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -150,7 +150,7 @@ SPCurve::concat(GSList const *list) SPCurve *new_curve = new SPCurve(); for (GSList const *l = list; l != NULL; l = l->next) { - SPCurve *c = (SPCurve *) l->data; + SPCurve *c = static_cast(l->data); new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() ); } diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index e095fb9a9..d0c6d2d56 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -43,10 +43,9 @@ static cairo_user_data_key_t key; static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font, - cairo_t */*cairo*/, cairo_font_extents_t *metrics){ - cairo_font_face_t* face; - face = cairo_scaled_font_get_font_face(scaled_font); - SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key); + cairo_t * /*cairo*/, cairo_font_extents_t *metrics){ + cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font); + SvgFont* instance = static_cast(cairo_font_face_get_user_data(face, &key)); return instance->scaled_font_init(scaled_font, metrics); } @@ -58,9 +57,8 @@ static cairo_status_t font_text_to_glyphs_cb ( cairo_scaled_font_t *scaled_font cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *flags){ - cairo_font_face_t* face; - face = cairo_scaled_font_get_font_face(scaled_font); - SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key); + cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font); + SvgFont* instance = static_cast(cairo_font_face_get_user_data(face, &key)); return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags); } @@ -68,9 +66,8 @@ static cairo_status_t font_render_glyph_cb (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics){ - cairo_font_face_t* face; - face = cairo_scaled_font_get_font_face(scaled_font); - SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key); + cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font); + SvgFont* instance = static_cast(cairo_font_face_get_user_data(face, &key)); return instance->scaled_font_render_glyph(scaled_font, glyph, cr, metrics); } @@ -116,15 +113,15 @@ unsigned int size_of_substring(const char* substring, gchar* str){ } //TODO: in these macros, verify what happens when using unicode strings. -#define Match_VKerning_Rule (((SPVkern*)node)->u1->contains(previous_unicode[0])\ - || ((SPVkern*)node)->g1->contains(previous_glyph_name)) &&\ - (((SPVkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\ - || ((SPVkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str())) +#define Match_VKerning_Rule ((SP_VKERN(node))->u1->contains(previous_unicode[0])\ + || (SP_VKERN(node))->g1->contains(previous_glyph_name)) &&\ + ((SP_VKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\ + || (SP_VKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str())) -#define Match_HKerning_Rule (((SPHkern*)node)->u1->contains(previous_unicode[0])\ - || ((SPHkern*)node)->g1->contains(previous_glyph_name)) &&\ - (((SPHkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\ - || ((SPHkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str())) +#define Match_HKerning_Rule ((SP_HKERN(node))->u1->contains(previous_unicode[0])\ + || (SP_HKERN(node))->g1->contains(previous_glyph_name)) &&\ + ((SP_HKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\ + || (SP_HKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str())) cairo_status_t SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, @@ -187,14 +184,14 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){ //apply glyph kerning if appropriate if (SP_IS_HKERN(node) && is_horizontal_text && Match_HKerning_Rule ){ - x -= (((SPHkern*)node)->k / 1000.0);//TODO: use here the height of the font + x -= ((SP_HKERN(node))->k / 1000.0);//TODO: use here the height of the font } if (SP_IS_VKERN(node) && !is_horizontal_text && Match_VKerning_Rule ){ - y -= (((SPVkern*)node)->k / 1000.0);//TODO: use here the "height" of the font + y -= ((SP_VKERN(node))->k / 1000.0);//TODO: use here the "height" of the font } } - previous_unicode = (char*) this->glyphs[i]->unicode.c_str();//used for kerning checking - previous_glyph_name = (char*) this->glyphs[i]->glyph_name.c_str();//used for kerning checking + previous_unicode = const_cast(this->glyphs[i]->unicode.c_str());//used for kerning checking + previous_glyph_name = const_cast(this->glyphs[i]->glyph_name.c_str());//used for kerning checking (*glyphs)[count].index = i; (*glyphs)[count].x = x; (*glyphs)[count++].y = y; @@ -251,7 +248,7 @@ Geom::PathVector SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){ double units_per_em = 1000; SPObject* obj; - for (obj = ((SPObject*) spfont)->children; obj; obj=obj->next){ + for (obj = (SP_OBJECT(spfont))->children; obj; obj=obj->next){ if (SP_IS_FONTFACE(obj)){ //XML Tree being directly used here while it shouldn't be. sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em); @@ -282,16 +279,16 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, SPObject* node; if (glyph == this->glyphs.size()){ if (!this->missingglyph) return CAIRO_STATUS_SUCCESS; - node = (SPObject*) this->missingglyph; + node = SP_OBJECT(this->missingglyph); } else { - node = (SPObject*) this->glyphs[glyph]; + node = SP_OBJECT(this->glyphs[glyph]); } if (!SP_IS_GLYPH(node) && !SP_IS_MISSING_GLYPH(node)) { return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return? } - SPFont* spfont = (SPFont*) node->parent; + SPFont* spfont = SP_FONT(node->parent); if (!spfont) { return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return? } @@ -300,12 +297,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, // or using the d attribute of a glyph node. // pathv stores the path description from the d attribute: Geom::PathVector pathv; - if (SP_IS_GLYPH(node) && ((SPGlyph*)node)->d) { - pathv = sp_svg_read_pathv(((SPGlyph*)node)->d); + if (SP_IS_GLYPH(node) && (SP_GLYPH(node))->d) { + pathv = sp_svg_read_pathv((SP_GLYPH(node))->d); pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); - } else if (SP_IS_MISSING_GLYPH(node) && ((SPMissingGlyph*)node)->d) { - pathv = sp_svg_read_pathv(((SPMissingGlyph*)node)->d); + } else if (SP_IS_MISSING_GLYPH(node) && (SP_MISSING_GLYPH(node))->d) { + pathv = sp_svg_read_pathv((SP_MISSING_GLYPH(node))->d); pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); } @@ -314,7 +311,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, //render the SVG described on this glyph's child nodes. for(node = node->children; node; node=node->next){ if (SP_IS_PATH(node)){ - pathv = ((SPShape*)node)->_curve->get_pathvector(); + pathv = (SP_SHAPE(node))->_curve->get_pathvector(); pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); } @@ -324,12 +321,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, if (SP_IS_USE(node)){ SPItem* item = SP_USE(node)->ref->getObject(); if (SP_IS_PATH(item)){ - pathv = ((SPShape*)item)->_curve->get_pathvector(); + pathv = (SP_SHAPE(item))->_curve->get_pathvector(); pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); } - glyph_modified_connection = ((SPObject*) item)->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified)); + glyph_modified_connection = (SP_OBJECT(item))->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified)); } } } @@ -342,10 +339,10 @@ SvgFont::get_font_face(){ if (!this->userfont) { for(SPObject* node = this->font->children;node;node=node->next){ if (SP_IS_GLYPH(node)){ - this->glyphs.push_back((SPGlyph*)node); + this->glyphs.push_back(SP_GLYPH(node)); } if (SP_IS_MISSING_GLYPH(node)){ - this->missingglyph=(SPMissingGlyph*)node; + this->missingglyph=SP_MISSING_GLYPH(node); } } this->userfont = new UserFont(this); diff --git a/src/event-context.cpp b/src/event-context.cpp index 6f89e862e..e9d0aa935 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -845,8 +845,8 @@ public: Inkscape::Preferences::Observer(path), _ec(ec) { } virtual void notify(Inkscape::Preferences::Entry const &val) { - if (((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set) { - ((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set(_ec, + if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set) { + (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set(_ec, const_cast (&val)); } } @@ -879,8 +879,8 @@ sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, prefs->addObserver(*(ec->pref_observer)); } - if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup) - ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup) + (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup(ec); return ec; } @@ -898,8 +898,8 @@ void sp_event_context_finish(SPEventContext *ec) { g_warning("Finishing event context with active link\n"); } - if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish) - ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->finish) + (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->finish(ec); } //-------------------------------member functions @@ -955,11 +955,11 @@ void sp_event_context_read(SPEventContext *ec, gchar const *key) { g_return_if_fail(SP_IS_EVENT_CONTEXT(ec)); g_return_if_fail(key != NULL); - if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) { + if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->set) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Inkscape::Preferences::Entry val = prefs->getEntry( ec->pref_observer->observed_path + '/' + key); - ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, &val); + (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->set(ec, &val); } } @@ -975,8 +975,8 @@ void sp_event_context_activate(SPEventContext *ec) { // context should take care of this by itself. sp_event_context_discard_delayed_snap_event(ec); - if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate) - ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate(ec); + if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->activate) + (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->activate(ec); } /** @@ -986,8 +986,8 @@ void sp_event_context_deactivate(SPEventContext *ec) { g_return_if_fail(ec != NULL); g_return_if_fail(SP_IS_EVENT_CONTEXT(ec)); - if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate) - ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate(ec); + if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->deactivate) + (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->deactivate(ec); } /** @@ -1028,7 +1028,7 @@ gint sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEv gint ret = false; if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash // (see the comment in SPDesktop::set_event_context, and bug LP #622350) - ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event); + ret = (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(event_context)))->root_handler(event_context, event); set_event_location(event_context->desktop, event); } return ret; @@ -1067,7 +1067,7 @@ gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPIte gint ret = false; if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash // (see the comment in SPDesktop::set_event_context, and bug LP #622350) - ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event); + ret = (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(event_context)))->item_handler(event_context, item, event); if (!ret) { ret = sp_event_context_virtual_root_handler(event_context, event); } else { diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index c8c187c77..0639ae8d0 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -969,7 +969,7 @@ static Geom::Affine getODFTransform(const SPItem *item) static Geom::OptRect getODFBoundingBox(const SPItem *item) { // TODO: geometric or visual? - Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds(); + Geom::OptRect bbox = item->documentVisualBounds(); if (bbox) { *bbox *= Geom::Affine(Geom::Scale(pxToCm)); } diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 69e76d55f..c92a5c22f 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -140,7 +140,7 @@ public: // FIXME: make more of this private! } guint singleSelectedDraggerSingleDraggableType() { - return (selected? ((GrDraggable *) ((GrDragger *) selected->data)->draggables->data)->point_type : 0);} + return (selected? (static_cast((static_cast(selected->data))->draggables->data))->point_type : 0);} // especially the selection must be private, fix gradient-context to remove direct access to it GList *selected; // list of GrDragger* diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 904e21960..3b1028ab8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3450,7 +3450,10 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Run filter, if any if (run) { g_print("Running external filter: %s\n", run); - system(run); + int result = system(run); + + if(result == -1) + g_warning("Could not run external filter: %s\n", run); } // Import the image back -- cgit v1.2.3 From 5da5121b9afaa8b2d1f0308dffc7d1e1b225b142 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 12:46:25 +0000 Subject: Replace remaining C-style pointer casts for src/widgets (bzr r11868) --- src/widgets/arc-toolbar.cpp | 10 +- src/widgets/box3d-toolbar.cpp | 4 +- src/widgets/button.cpp | 4 +- src/widgets/calligraphy-toolbar.cpp | 2 +- src/widgets/connector-toolbar.cpp | 16 +-- src/widgets/desktop-widget.cpp | 2 +- src/widgets/erasor-toolbar.cpp | 4 +- src/widgets/font-selector.cpp | 2 +- src/widgets/gradient-image.cpp | 4 +- src/widgets/gradient-selector.cpp | 11 +- src/widgets/gradient-toolbar.cpp | 6 +- src/widgets/icon.cpp | 2 +- src/widgets/lpe-toolbar.cpp | 10 +- src/widgets/measure-toolbar.cpp | 4 +- src/widgets/node-toolbar.cpp | 8 +- src/widgets/pencil-toolbar.cpp | 4 +- src/widgets/rect-toolbar.cpp | 4 +- src/widgets/sp-color-gtkselector.cpp | 4 +- src/widgets/sp-color-notebook.cpp | 31 +++--- src/widgets/sp-color-scales.cpp | 7 +- src/widgets/sp-color-slider.cpp | 7 +- src/widgets/sp-color-wheel-selector.cpp | 7 +- src/widgets/sp-xmlview-attr-list.cpp | 7 +- src/widgets/sp-xmlview-content.cpp | 10 +- src/widgets/sp-xmlview-tree.cpp | 175 ++++++++++++++------------------ src/widgets/sp-xmlview-tree.h | 11 ++ src/widgets/spinbutton-events.cpp | 5 +- src/widgets/spiral-toolbar.cpp | 4 +- src/widgets/star-toolbar.cpp | 12 +-- src/widgets/text-toolbar.cpp | 10 +- 30 files changed, 177 insertions(+), 210 deletions(-) (limited to 'src') diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 84434c88b..e96e4c097 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -92,7 +92,7 @@ static void sp_arctb_sensitivize( GObject *tbl, double v1, double v2 ) static void sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name, gchar const *other_name) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -128,8 +128,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v } sp_genericellipse_normalize(ge); - ((SPObject *)arc)->updateRepr(); - ((SPObject *)arc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + (SP_OBJECT(arc))->updateRepr(); + (SP_OBJECT(arc))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); modmade = true; } @@ -163,7 +163,7 @@ static void sp_arctb_end_value_changed(GtkAdjustment *adj, GObject *tbl) static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0); @@ -419,7 +419,7 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), (GObject *)holder)) + sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), G_OBJECT(holder))) ); g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp index 2192ebfdc..cb4951660 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -227,7 +227,7 @@ static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObj static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis axis) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( dataKludge, "desktop" )); SPDocument *document = sp_desktop_document(desktop); // quit if run by the attr_changed or selection changed listener @@ -431,7 +431,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject } sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), (GObject *)holder)) + sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), G_OBJECT(holder))) ); g_signal_connect(holder, "destroy", G_CALLBACK(delete_connection), connection); g_signal_connect(holder, "destroy", G_CALLBACK(purge_repr_listener), holder); diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 45356601b..1ac083276 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -218,9 +218,7 @@ sp_button_perform_action (SPButton *button, gpointer /*data*/) GtkWidget * sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action ) { - SPButton *button; - - button = (SPButton *)g_object_new (SP_TYPE_BUTTON, NULL); + SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL)); button->type = type; button->lsize = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION ); diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp index a0ae136e8..1c39cd9e5 100644 --- a/src/widgets/calligraphy-toolbar.cpp +++ b/src/widgets/calligraphy-toolbar.cpp @@ -259,7 +259,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) { using Inkscape::UI::Dialog::CalligraphicProfileRename; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop" )); if (! desktop) { return; } diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 2b00856ec..87deffc71 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -98,7 +98,7 @@ static void sp_connector_path_set_ignore(void) static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); Inkscape::Selection * selection = sp_desktop_selection(desktop); SPDocument *doc = sp_desktop_document(desktop); @@ -123,7 +123,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl bool modmade = false; GSList *l = (GSList *) selection->itemList(); while (l) { - SPItem *item = (SPItem *) l->data; + SPItem *item = SP_ITEM(l->data); if (cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-type", @@ -148,7 +148,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); Inkscape::Selection * selection = sp_desktop_selection(desktop); SPDocument *doc = sp_desktop_document(desktop); @@ -172,7 +172,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) bool modmade = false; GSList *l = (GSList *) selection->itemList(); while (l) { - SPItem *item = (SPItem *) l->data; + SPItem *item = SP_ITEM(l->data); if (cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-curvature", @@ -198,7 +198,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); SPDocument *doc = sp_desktop_document(desktop); if (!DocumentUndo::getUndoSensitive(doc)) { @@ -305,7 +305,7 @@ static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr, static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context); if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE) { @@ -315,7 +315,7 @@ static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl) static void sp_connector_remove_connection_point(GtkWidget *, GObject *tbl) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context); if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE) { @@ -461,7 +461,7 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions, gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE )); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_directed_graph_layout_toggled), holder ); - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), (GObject *)holder)); + sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), holder)); } // Avoid overlaps toggle button diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 1d1429c40..05053f6fd 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -301,7 +301,7 @@ GType SPDesktopWidget::getType(void) static void sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) { - dtw_parent_class = (SPViewWidgetClass*)g_type_class_peek_parent (klass); + dtw_parent_class = SP_VIEW_WIDGET_CLASS(g_type_class_peek_parent(klass)); GObjectClass *object_class = (GObjectClass *) klass; GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; diff --git a/src/widgets/erasor-toolbar.cpp b/src/widgets/erasor-toolbar.cpp index 740af6821..14f87c943 100644 --- a/src/widgets/erasor-toolbar.cpp +++ b/src/widgets/erasor-toolbar.cpp @@ -82,7 +82,7 @@ static void sp_erc_width_value_changed( GtkAdjustment *adj, GObject *tbl ) static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); bool eraserMode = ege_select_one_action_get_active( act ) != 0; if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -94,9 +94,11 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) // in turn, prevent listener from responding g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); + /* if ( eraserMode != 0 ) { } else { } + */ // TODO finish implementation g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 1cb94a8e5..6a677307e 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -448,7 +448,7 @@ static void sp_font_selector_emit_set (SPFontSelector *fsel) GtkWidget *sp_font_selector_new() { - SPFontSelector *fsel = (SPFontSelector*) g_object_new(SP_TYPE_FONT_SELECTOR, NULL); + SPFontSelector *fsel = SP_FONT_SELECTOR(g_object_new(SP_TYPE_FONT_SELECTOR, NULL)); return (GtkWidget *) fsel; } diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 94918c614..359a41167 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -192,9 +192,7 @@ static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct) GtkWidget * sp_gradient_image_new (SPGradient *gradient) { - SPGradientImage *image; - - image = (SPGradientImage*)g_object_new (SP_TYPE_GRADIENT_IMAGE, NULL); + SPGradientImage *image = SP_GRADIENT_IMAGE(g_object_new(SP_TYPE_GRADIENT_IMAGE, NULL)); sp_gradient_image_set_gradient (image, gradient); diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 2a651544b..33388a0c1 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -249,12 +249,9 @@ void SPGradientSelector::setSpread(SPGradientSpread spread) } -GtkWidget * -sp_gradient_selector_new (void) +GtkWidget *sp_gradient_selector_new() { - SPGradientSelector *sel; - - sel = (SPGradientSelector*)g_object_new (SP_TYPE_GRADIENT_SELECTOR, NULL); + SPGradientSelector *sel = SP_GRADIENT_SELECTOR(g_object_new (SP_TYPE_GRADIENT_SELECTOR, NULL)); return (GtkWidget *) sel; } @@ -361,7 +358,7 @@ void SPGradientSelector::onTreeSelection() } if (obj) { - sp_gradient_selector_vector_set (NULL, (SPGradient*)obj, this); + sp_gradient_selector_vector_set (NULL, SP_GRADIENT(obj), this); } } @@ -508,7 +505,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s Glib::ustring old_id = gr->getId(); - gr = (SPGradient *) doc->getObjectByRepr(repr); + gr = SP_GRADIENT(doc->getObjectByRepr(repr)); // Rename the new gradients id to be similar to the cloned gradients rename_id(gr, old_id); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index b5fc0a0f2..205f5b8ec 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -123,7 +123,7 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient if (drag && drag->selected) { GrDragger *dragger = static_cast(drag->selected->data); for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger - GrDraggable *draggable = (GrDraggable *) i->data; + GrDraggable *draggable = static_cast(i->data); gr_apply_gradient_to_item(draggable->item, gr, initialType, initialMode, draggable->fill_or_stroke); } return; @@ -675,10 +675,10 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, SPEv // for all selected draggers for (GList *i = drag->selected; i != NULL; i = i->next) { - GrDragger *dragger = (GrDragger *) i->data; + GrDragger *dragger = static_cast(i->data); // for all draggables of dragger for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *draggable = (GrDraggable *) j->data; + GrDraggable *draggable = static_cast(j->data); if (draggable->point_type != POINT_RG_FOCUS) { n++; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index c02f4bceb..c7ddc2352 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -881,7 +881,7 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) if ( !widget ) { //g_message("Creating an SPIcon instance for %s:%d", name, (int)lsize); - SPIcon *icon = (SPIcon *)g_object_new(SP_TYPE_ICON, NULL); + SPIcon *icon = SP_ICON(g_object_new(SP_TYPE_ICON, NULL)); icon->lsize = lsize; icon->name = g_strdup(name); icon->psize = getPhysSize(lsize); diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 673b1588b..3126175b3 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -83,7 +83,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl) { using namespace Inkscape::LivePathEffect; - SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop"); + SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); SPEventContext *ec = desktop->event_context; if (!SP_IS_LPETOOL_CONTEXT(ec)) { return; @@ -199,7 +199,7 @@ static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/tools/lpetool/unitid", unit->unit_id); - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); if (SP_IS_LPETOOL_CONTEXT(desktop->event_context)) { SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context); lpetool_delete_measuring_items(lc); @@ -399,7 +399,7 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO { GtkAction* act = tracker->createAction( "LPEToolUnitsAction", _("Units"), ("") ); gtk_action_group_add_action( mainActions, act ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), (GObject*)holder ); + g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), holder ); g_object_set_data(holder, "lpetool_units_action", act); gtk_action_set_sensitive(act, prefs->getBool("/tools/lpetool/show_measuring_info", true)); } @@ -421,12 +421,12 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO sigc::connection *c_selection_modified = new sigc::connection (sp_desktop_selection (desktop)->connectModified - (sigc::bind (sigc::ptr_fun (sp_lpetool_toolbox_sel_modified), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_lpetool_toolbox_sel_modified), holder))); pool->add_connection ("selection-modified", c_selection_modified); sigc::connection *c_selection_changed = new sigc::connection (sp_desktop_selection (desktop)->connectChanged - (sigc::bind (sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), holder))); pool->add_connection ("selection-changed", c_selection_changed); } diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp index 2153aba51..f556c0c7b 100644 --- a/src/widgets/measure-toolbar.cpp +++ b/src/widgets/measure-toolbar.cpp @@ -72,7 +72,7 @@ using Inkscape::UI::PrefPusher; static void sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -122,7 +122,7 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G // units menu { GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units:"), _("The units to be used for the measurements") ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), (GObject*)holder ); + g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), holder ); gtk_action_group_add_action( mainActions, act ); } } // end of sp_measure_toolbox_prep() diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 7dca63ba2..79cdf8117 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -266,7 +266,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::Dim2 d) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); @@ -632,17 +632,17 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje sigc::connection *c_selection_changed = new sigc::connection (sp_desktop_selection (desktop)->connectChanged - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), holder))); pool->add_connection ("selection-changed", c_selection_changed); sigc::connection *c_selection_modified = new sigc::connection (sp_desktop_selection (desktop)->connectModified - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), holder))); pool->add_connection ("selection-modified", c_selection_modified); sigc::connection *c_subselection_changed = new sigc::connection (desktop->connectToolSubselectionChanged - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), holder))); pool->add_connection ("tool-subselection-changed", c_subselection_changed); Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 73ab4883c..d0e71d2b0 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -91,7 +91,7 @@ using Inkscape::UI::PrefPusher; /* This is used in generic functions below to share large portions of code between pen and pencil tool */ static Glib::ustring const freehand_tool_name(GObject *dataKludge) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data(dataKludge, "desktop"); + SPDesktop *desktop = static_cast(g_object_get_data(dataKludge, "desktop")); return ( tools_isactive(desktop, TOOLS_FREEHAND_PEN) ? "/tools/freehand/pen" : "/tools/freehand/pencil" ); @@ -104,7 +104,7 @@ static void freehand_mode_changed(EgeSelectOneAction* act, GObject* tbl) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt(freehand_tool_name(tbl) + "/freehand-mode", mode); - SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop"); + SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); // in pen tool we have more options than in pencil tool; if one of them was chosen, we do any // preparatory work here diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 8e74ff113..65eebf94b 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -89,7 +89,7 @@ static void sp_rtb_sensitivize( GObject *tbl ) static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name, void (*setter)(SPRect *, gdouble)) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); SPUnit const *unit = tracker->getActiveUnit(); @@ -395,7 +395,7 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje sp_rtb_sensitivize( holder ); sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), (GObject *)holder)) + sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder)) ); g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/sp-color-gtkselector.cpp b/src/widgets/sp-color-gtkselector.cpp index 2e00aca71..b19685c66 100644 --- a/src/widgets/sp-color-gtkselector.cpp +++ b/src/widgets/sp-color-gtkselector.cpp @@ -106,9 +106,7 @@ static void sp_color_gtkselector_hide(GtkWidget *widget) GtkWidget * sp_color_gtkselector_new( GType ) { - SPColorGtkselector *csel; - - csel = (SPColorGtkselector*)g_object_new (SP_TYPE_COLOR_GTKSELECTOR, NULL); + SPColorGtkselector *csel = SP_COLOR_GTKSELECTOR(g_object_new (SP_TYPE_COLOR_GTKSELECTOR, NULL)); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index f2ae0425f..0856fd86b 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -107,7 +107,7 @@ sp_color_notebook_switch_page(GtkNotebook *notebook, { if ( colorbook ) { - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); nb->switchPage( notebook, page, page_num ); // remember the page we switched to @@ -144,7 +144,7 @@ static gint sp_color_notebook_menu_handler( GtkWidget *widget, GdkEvent *event ) if (event->type == GDK_BUTTON_PRESS) { SPColorSelector* csel = SP_COLOR_SELECTOR(widget); - ((ColorNotebook*)(csel->base))->menuHandler( event ); + (dynamic_cast(csel->base))->menuHandler( event ); /* Tell calling code that we have handled this event; the buck * stops here. */ @@ -173,11 +173,11 @@ static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer { if ( active ) { - ((ColorNotebook*)(SP_COLOR_SELECTOR(entry->backPointer)->base))->addPage(entry->type, entry->submode); + (dynamic_cast(SP_COLOR_SELECTOR(entry->backPointer)->base))->addPage(entry->type, entry->submode); } else { - ((ColorNotebook*)(SP_COLOR_SELECTOR(entry->backPointer)->base))->removePage(entry->type, entry->submode); + (dynamic_cast(SP_COLOR_SELECTOR(entry->backPointer)->base))->removePage(entry->type, entry->submode); } } } @@ -467,14 +467,11 @@ static void sp_color_notebook_hide(GtkWidget *widget) gtk_widget_hide(widget); } -GtkWidget * -sp_color_notebook_new (void) +GtkWidget *sp_color_notebook_new() { - SPColorNotebook *colorbook; + SPColorNotebook *colorbook = SP_COLOR_NOTEBOOK(g_object_new (SP_TYPE_COLOR_NOTEBOOK, NULL)); - colorbook = (SPColorNotebook*)g_object_new (SP_TYPE_COLOR_NOTEBOOK, NULL); - - return GTK_WIDGET (colorbook); + return GTK_WIDGET(colorbook); } ColorNotebook::ColorNotebook( SPColorSelector* csel ) @@ -520,7 +517,7 @@ void ColorNotebook::_picker_clicked(GtkWidget *widget, SPColorNotebook *colorboo void ColorNotebook::_rgbaEntryChangedHook(GtkEntry *entry, SPColorNotebook *colorbook) { - ((ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base))->_rgbaEntryChanged( entry ); + (dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base))->_rgbaEntryChanged( entry ); } void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry) @@ -630,7 +627,7 @@ void ColorNotebook::_setCurrentPage(int i) void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorbook) { - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) { return; @@ -645,14 +642,14 @@ void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorboo void ColorNotebook::_entryGrabbed (SPColorSelector *, SPColorNotebook *colorbook) { - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); nb->_grabbed(); } void ColorNotebook::_entryDragged (SPColorSelector *csel, SPColorNotebook *colorbook) { gboolean oldState; - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); oldState = nb->_dragging; @@ -664,14 +661,14 @@ void ColorNotebook::_entryDragged (SPColorSelector *csel, SPColorNotebook *color void ColorNotebook::_entryReleased (SPColorSelector *, SPColorNotebook *colorbook) { - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); nb->_released(); } void ColorNotebook::_entryChanged (SPColorSelector *csel, SPColorNotebook *colorbook) { gboolean oldState; - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); oldState = nb->_dragging; @@ -688,7 +685,7 @@ void ColorNotebook::_entryModified (SPColorSelector *csel, SPColorNotebook *colo g_return_if_fail (csel != NULL); g_return_if_fail (SP_IS_COLOR_SELECTOR (csel)); - ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); + ColorNotebook* nb = dynamic_cast(SP_COLOR_SELECTOR(colorbook)->base); SPColor color; gfloat alpha = 1.0; diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 1af5a1068..159fc96e5 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -198,12 +198,9 @@ static void sp_color_scales_hide(GtkWidget *widget) gtk_widget_hide(widget); } -GtkWidget * -sp_color_scales_new (void) +GtkWidget *sp_color_scales_new() { - SPColorScales *csel; - - csel = (SPColorScales*)g_object_new (SP_TYPE_COLOR_SCALES, NULL); + SPColorScales *csel = SP_COLOR_SCALES(g_object_new (SP_TYPE_COLOR_SCALES, NULL)); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index d58d495bb..37b9e022a 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -373,12 +373,9 @@ sp_color_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event) return FALSE; } -GtkWidget * -sp_color_slider_new (GtkAdjustment *adjustment) +GtkWidget *sp_color_slider_new(GtkAdjustment *adjustment) { - SPColorSlider *slider; - - slider = (SPColorSlider*)g_object_new (SP_TYPE_COLOR_SLIDER, NULL); + SPColorSlider *slider = SP_COLOR_SLIDER(g_object_new(SP_TYPE_COLOR_SLIDER, NULL)); sp_color_slider_set_adjustment (slider, adjustment); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index bb8bba328..fe168b403 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -234,12 +234,9 @@ static void sp_color_wheel_selector_hide(GtkWidget *widget) gtk_widget_hide(widget); } -GtkWidget * -sp_color_wheel_selector_new (void) +GtkWidget *sp_color_wheel_selector_new() { - SPColorWheelSelector *csel; - - csel = (SPColorWheelSelector*)g_object_new (SP_TYPE_COLOR_WHEEL_SELECTOR, NULL); + SPColorWheelSelector *csel = SP_COLOR_WHEEL_SELECTOR(g_object_new (SP_TYPE_COLOR_WHEEL_SELECTOR, NULL)); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index 8e7c94572..1fd120d17 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -41,12 +41,9 @@ static Inkscape::XML::NodeEventVector repr_events = { NULL /* order_changed */ }; -GtkWidget * -sp_xmlview_attr_list_new (Inkscape::XML::Node * repr) +GtkWidget *sp_xmlview_attr_list_new (Inkscape::XML::Node * repr) { - SPXMLViewAttrList * attr_list; - - attr_list = (SPXMLViewAttrList*)g_object_new (SP_TYPE_XMLVIEW_ATTR_LIST, NULL); + SPXMLViewAttrList * attr_list = SP_XMLVIEW_ATTR_LIST(g_object_new(SP_TYPE_XMLVIEW_ATTR_LIST, NULL)); attr_list->store = gtk_list_store_new (ATTR_N_COLS, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING ); gtk_tree_view_set_model (GTK_TREE_VIEW(attr_list), GTK_TREE_MODEL(attr_list->store)); diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index bf740baa0..d31e031c2 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -46,14 +46,10 @@ static Inkscape::XML::NodeEventVector repr_events = { NULL /* order_changed */ }; -GtkWidget * -sp_xmlview_content_new (Inkscape::XML::Node * repr) +GtkWidget *sp_xmlview_content_new(Inkscape::XML::Node * repr) { - GtkTextBuffer *tb; - SPXMLViewContent *text; - - tb = gtk_text_buffer_new (NULL); - text = (SPXMLViewContent*)g_object_new (SP_TYPE_XMLVIEW_CONTENT, NULL); + GtkTextBuffer *tb = gtk_text_buffer_new(NULL); + SPXMLViewContent *text = SP_XMLVIEW_CONTENT(g_object_new(SP_TYPE_XMLVIEW_CONTENT, NULL)); gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), tb); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text), GTK_WRAP_CHAR); diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index 11e6717c1..258cea0b4 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -95,16 +95,13 @@ static const Inkscape::XML::NodeEventVector pi_repr_events = { static GtkTreeViewClass * parent_class = NULL; -GtkWidget * -sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * /*factory*/, void * /*data*/) +GtkWidget *sp_xmlview_tree_new(Inkscape::XML::Node * repr, void * /*factory*/, void * /*data*/) { - SPXMLViewTree * tree; - - tree = (SPXMLViewTree*)g_object_new (SP_TYPE_XMLVIEW_TREE, NULL); + SPXMLViewTree *tree = SP_XMLVIEW_TREE(g_object_new (SP_TYPE_XMLVIEW_TREE, NULL)); - tree->store = gtk_tree_store_new (STORE_N_COLS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); + tree->store = gtk_tree_store_new (STORE_N_COLS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); - // Detach the model from the view until all the data is loaded + // Detach the model from the view until all the data is loaded g_object_ref(tree->store); gtk_tree_view_set_model(GTK_TREE_VIEW(tree), NULL); @@ -125,7 +122,7 @@ sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * /*factory*/, void * /*da g_signal_connect(GTK_TREE_VIEW(tree), "drag_data_received", G_CALLBACK(on_drag_data_received), tree); g_signal_connect(GTK_TREE_VIEW(tree), "drag-motion", G_CALLBACK(do_drag_motion), tree); - return (GtkWidget *) tree; + return (GtkWidget *) tree; } GType @@ -264,93 +261,80 @@ NodeData *node_data_new(SPXMLViewTree * tree, GtkTreeIter * /*node*/, GtkTreeRow return data; } -void -node_data_free (gpointer ptr) { - NodeData * data; - data = (NodeData *) ptr; - sp_repr_remove_listener_by_data (data->repr, data); - g_assert (data->repr != NULL); - Inkscape::GC::release(data->repr); - g_free (data); +void node_data_free(gpointer ptr) +{ + NodeData *data = static_cast(ptr); + sp_repr_remove_listener_by_data (data->repr, data); + g_assert (data->repr != NULL); + Inkscape::GC::release(data->repr); + g_free (data); } -void -element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer ptr) +void element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer ptr) { - NodeData * data; - GtkTreeIter before; + NodeData *data = static_cast(ptr); + GtkTreeIter before; - data = (NodeData *) ptr; + if (data->tree->blocked) return; - if (data->tree->blocked) return; - - if (!ref_to_sibling (data, ref, &before)) { - return; - } + if (!ref_to_sibling (data, ref, &before)) { + return; + } GtkTreeIter data_iter; tree_ref_to_iter(data->tree, &data_iter, data->rowref); - add_node (data->tree, &data_iter, &before, child); + add_node (data->tree, &data_iter, &before, child); } -void -element_attr_changed (Inkscape::XML::Node * repr, const gchar * key, const gchar * /*old_value*/, const gchar * new_value, bool /*is_interactive*/, gpointer ptr) +void element_attr_changed(Inkscape::XML::Node * repr, const gchar * key, const gchar * /*old_value*/, const gchar * new_value, bool /*is_interactive*/, gpointer ptr) { - NodeData * data; - gchar *label; - const gchar *layer; - - data = (NodeData *) ptr; + NodeData *data = static_cast(ptr); + gchar *label; - if (data->tree->blocked) return; + if (data->tree->blocked) return; - if (0 != strcmp (key, "id") && 0 != strcmp (key, "inkscape:label")) - return; + if (0 != strcmp (key, "id") && 0 != strcmp (key, "inkscape:label")) + return; - new_value = repr->attribute("id"); - layer = repr->attribute("inkscape:label"); + new_value = repr->attribute("id"); + const gchar *layer = repr->attribute("inkscape:label"); - if (new_value && layer) { - label = g_strdup_printf ("<%s id=\"%s\" inkscape:label=\"%s\">", repr->name(), new_value, layer); - } else if (new_value) { - label = g_strdup_printf ("<%s id=\"%s\">", repr->name(), new_value); - } else { - label = g_strdup_printf ("<%s>", repr->name()); - } + if (new_value && layer) { + label = g_strdup_printf ("<%s id=\"%s\" inkscape:label=\"%s\">", repr->name(), new_value, layer); + } else if (new_value) { + label = g_strdup_printf ("<%s id=\"%s\">", repr->name(), new_value); + } else { + label = g_strdup_printf ("<%s>", repr->name()); + } - GtkTreeIter iter; - if (tree_ref_to_iter(data->tree, &iter, data->rowref)) { - gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); - } - g_free (label); + GtkTreeIter iter; + if (tree_ref_to_iter(data->tree, &iter, data->rowref)) { + gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); + } + g_free (label); } -void -element_child_removed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*ref*/, gpointer ptr) +void element_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*ref*/, gpointer ptr) { - NodeData * data; - data = (NodeData *) ptr; + NodeData *data = static_cast(ptr); - if (data->tree->blocked) return; + if (data->tree->blocked) return; - GtkTreeIter iter; - if (repr_to_child (data, child, &iter)) { + GtkTreeIter iter; + if (repr_to_child (data, child, &iter)) { gtk_tree_store_remove (GTK_TREE_STORE(data->tree->store), &iter); } - } -void -element_order_changed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*oldref*/, Inkscape::XML::Node * newref, gpointer ptr) +void element_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*oldref*/, Inkscape::XML::Node * newref, gpointer ptr) { - NodeData * data; - GtkTreeIter before, node; - data = (NodeData *) ptr; + NodeData *data = static_cast(ptr); + GtkTreeIter before, node; - if (data->tree->blocked) return; + if (data->tree->blocked) return; - ref_to_sibling (data, newref, &before); - repr_to_child (data, child, &node); + ref_to_sibling (data, newref, &before); + repr_to_child (data, child, &node); if (gtk_tree_store_iter_is_valid(data->tree->store, &before)) { gtk_tree_store_move_before (data->tree->store, &node, &before); @@ -360,59 +344,47 @@ element_order_changed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * chi } } -void -text_content_changed (Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar * new_content, gpointer ptr) +void text_content_changed(Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar * new_content, gpointer ptr) { - NodeData *data; - gchar *label; - - data = (NodeData *) ptr; + NodeData *data = static_cast(ptr); - if (data->tree->blocked) return; + if (data->tree->blocked) return; - label = g_strdup_printf ("\"%s\"", new_content); + gchar *label = g_strdup_printf ("\"%s\"", new_content); GtkTreeIter iter; if (tree_ref_to_iter(data->tree, &iter, data->rowref)) { gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); } - g_free (label); + g_free (label); } -void -comment_content_changed (Inkscape::XML::Node */*repr*/, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr) +void comment_content_changed(Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr) { - NodeData *data; - gchar *label; - - data = (NodeData *) ptr; + NodeData *data = static_cast(ptr); - if (data->tree->blocked) return; + if (data->tree->blocked) return; - label = g_strdup_printf ("", new_content); + gchar *label = g_strdup_printf ("", new_content); GtkTreeIter iter; if (tree_ref_to_iter(data->tree, &iter, data->rowref)) { gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); } - g_free (label); + g_free (label); } -void -pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr) +void pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr) { - NodeData *data; - gchar *label; - - data = (NodeData *) ptr; + NodeData *data = static_cast(ptr); - if (data->tree->blocked) return; + if (data->tree->blocked) return; - label = g_strdup_printf ("", repr->name(), new_content); + gchar *label = g_strdup_printf ("", repr->name(), new_content); GtkTreeIter iter; if (tree_ref_to_iter(data->tree, &iter, data->rowref)) { gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); } - g_free (label); + g_free (label); } /* @@ -454,7 +426,7 @@ void on_drag_data_received(GtkWidget * /*wgt*/, GdkDragContext * /*context*/, in */ void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { - SPXMLViewTree *tree = (SPXMLViewTree *)user_data; + SPXMLViewTree *tree = SP_XMLVIEW_TREE(user_data); if (!tree->dndactive) { return; @@ -634,7 +606,7 @@ gboolean do_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint if (path) { action = GDK_ACTION_MOVE; - SPXMLViewTree *tree = (SPXMLViewTree *)user_data; + SPXMLViewTree *tree = SP_XMLVIEW_TREE(user_data); GtkTreeIter iter; gtk_tree_model_get_iter(GTK_TREE_MODEL(tree->store), &iter, path); if (sp_xmlview_tree_node_get_repr (GTK_TREE_MODEL(tree->store), &iter)->type() != Inkscape::XML::ELEMENT_NODE) { @@ -762,3 +734,14 @@ gboolean search_equal_func(GtkTreeModel *model, gint /*column*/, const gchar *ke return !match; } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index e588e78a7..50fcb3bc8 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -53,3 +53,14 @@ gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Nod #endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp index 444aa278e..c718b6712 100644 --- a/src/widgets/spinbutton-events.cpp +++ b/src/widgets/spinbutton-events.cpp @@ -64,10 +64,9 @@ spinbutton_defocus (GtkWidget *container) } } -gboolean -spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) +gboolean spinbutton_keypress(GtkWidget *w, GdkEventKey *event, gpointer data) { - SPWidget *spw = (SPWidget *) data; + SPWidget *spw = SP_WIDGET(data); gdouble v; gdouble step; gdouble page; diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 34996d24e..c51c8b6cf 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -78,7 +78,7 @@ using Inkscape::UI::PrefPusher; static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustring const &value_name) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -314,7 +314,7 @@ void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), (GObject *)holder)) + sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), holder)) ); g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 61d8e1000..d783e3336 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -74,7 +74,7 @@ using Inkscape::UI::PrefPusher; static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKludge ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( dataKludge, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { // do not remember prefs if this call is initiated by an undo change, because undoing object @@ -120,7 +120,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKludge ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( dataKludge, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { if (!IS_NAN(gtk_adjustment_get_value(adj))) { @@ -173,7 +173,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *dataKludge ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( dataKludge, "desktop" )); bool flat = ege_select_one_action_get_active( act ) == 0; if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { @@ -218,7 +218,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludge ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( dataKludge, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -257,7 +257,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKludge ) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( dataKludge, "desktop" )); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -584,7 +584,7 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje } sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), (GObject *)holder)) + sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), holder)) ); g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 352276b21..e32f5a42a 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -665,7 +665,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) // move the x of all texts to preserve the same bbox Inkscape::Selection *selection = sp_desktop_selection(desktop); for (GSList const *items = selection->itemList(); items != NULL; items = items->next) { - if (SP_IS_TEXT((SPItem *) items->data)) { + if (SP_IS_TEXT(SP_ITEM(items->data))) { SPItem *item = SP_ITEM(items->data); unsigned writing_mode = item->style->writing_mode.value; @@ -1156,7 +1156,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ items = items->next) { // const gchar* id = reinterpret_cast(items->data)->getId(); // std::cout << " " << id << std::endl; - if( SP_IS_FLOWTEXT(( SPItem *) items->data )) { + if( SP_IS_FLOWTEXT(SP_ITEM(items->data))) { isFlow = true; // std::cout << " Found flowed text" << std::endl; break; @@ -1849,17 +1849,17 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje sigc::connection *c_selection_changed = new sigc::connection (sp_desktop_selection (desktop)->connectChanged - (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), holder))); pool->add_connection ("selection-changed", c_selection_changed); sigc::connection *c_selection_modified = new sigc::connection (sp_desktop_selection (desktop)->connectModified - (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), holder))); pool->add_connection ("selection-modified", c_selection_modified); sigc::connection *c_subselection_changed = new sigc::connection (desktop->connectToolSubselectionChanged - (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), holder))); pool->add_connection ("tool-subselection-changed", c_subselection_changed); Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool); -- cgit v1.2.3 From f2907ae896ed8688e800519310b61754550f27f6 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 14:17:53 +0000 Subject: SPObject: drop sp_object_ prefix on class members (bzr r11869) --- src/marker.cpp | 4 +-- src/sp-object.cpp | 71 +++++++++++++++++++++++++--------------------------- src/sp-object.h | 42 +++++++++++++++---------------- src/sp-shape.cpp | 4 +-- src/xml/repr-css.cpp | 2 +- 5 files changed, 60 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/marker.cpp b/src/marker.cpp index 45582caa4..8acac805b 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -119,7 +119,7 @@ sp_marker_init (SPMarker *marker) * parent class' build routine to attach the object to its document and * repr. The result will be creation of the whole document tree. * - * \see sp_object_build() + * \see SPObject::build() */ static void sp_marker_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { @@ -147,7 +147,7 @@ static void sp_marker_build(SPObject *object, SPDocument *document, Inkscape::XM * and release its SPRepr bindings. The result will be the destruction * of the entire document tree. * - * \see sp_object_release() + * \see SPObject::release() */ static void sp_marker_release(SPObject *object) { diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 3e18c0835..2cf28137a 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -64,11 +64,11 @@ using std::strstr; guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { - SPObject::sp_object_repr_child_added, - SPObject::sp_object_repr_child_removed, - SPObject::sp_object_repr_attr_changed, - SPObject::sp_object_repr_content_changed, - SPObject::sp_object_repr_order_changed + SPObject::repr_child_added, + SPObject::repr_child_removed, + SPObject::repr_attr_changed, + SPObject::repr_content_changed, + SPObject::repr_order_changed }; // A friend class used to set internal members on SPObject so as to not expose settors in SPObject's public API @@ -104,18 +104,18 @@ public: GObjectClass * SPObjectClass::static_parent_class = 0; -GType SPObject::sp_object_get_type() +GType SPObject::get_type() { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPObjectClass), NULL, NULL, - (GClassInitFunc) SPObjectClass::sp_object_class_init, + (GClassInitFunc) SPObjectClass::init, NULL, NULL, sizeof(SPObject), 16, - (GInstanceInitFunc) sp_object_init, + (GInstanceInitFunc)init, NULL }; type = g_type_register_static(G_TYPE_OBJECT, "SPObject", &info, (GTypeFlags)0); @@ -123,7 +123,7 @@ GType SPObject::sp_object_get_type() return type; } -void SPObjectClass::sp_object_class_init(SPObjectClass *klass) +void SPObjectClass::init(SPObjectClass *klass) { GObjectClass *object_class; @@ -131,21 +131,18 @@ void SPObjectClass::sp_object_class_init(SPObjectClass *klass) static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); - object_class->finalize = SPObject::sp_object_finalize; + object_class->finalize = SPObject::finalize; - klass->child_added = SPObject::sp_object_child_added; - klass->remove_child = SPObject::sp_object_remove_child; - klass->order_changed = SPObject::sp_object_order_changed; - - klass->release = SPObject::sp_object_release; - - klass->build = SPObject::sp_object_build; - - klass->set = SPObject::sp_object_private_set; - klass->write = SPObject::sp_object_private_write; + klass->child_added = SPObject::child_added; + klass->remove_child = SPObject::remove_child; + klass->order_changed = SPObject::order_changed; + klass->release = SPObject::release; + klass->build = SPObject::build; + klass->set = SPObject::private_set; + klass->write = SPObject::private_write; } -void SPObject::sp_object_init(SPObject *object) +void SPObject::init(SPObject *object) { debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); @@ -178,7 +175,7 @@ void SPObject::sp_object_init(SPObject *object) object->_default_label = NULL; } -void SPObject::sp_object_finalize(GObject *object) +void SPObject::finalize(GObject *object) { SPObject *spobject = (SPObject *)object; @@ -616,7 +613,7 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) return result; } -void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +void SPObject::child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { GType type = sp_repr_type_lookup(child); if (!type) { @@ -630,7 +627,7 @@ void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *chil ochild->invoke_build(object->document, child, object->cloned); } -void SPObject::sp_object_release(SPObject *object) +void SPObject::release(SPObject *object) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); while (object->children) { @@ -638,7 +635,7 @@ void SPObject::sp_object_release(SPObject *object) } } -void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) +void SPObject::remove_child(SPObject *object, Inkscape::XML::Node *child) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); SPObject *ochild = object->get_child_by_repr(child); @@ -648,7 +645,7 @@ void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *chi } } -void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/, +void SPObject::order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node * /*old_ref*/, Inkscape::XML::Node *new_ref) { SPObject *ochild = object->get_child_by_repr(child); @@ -658,7 +655,7 @@ void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *ch ochild->_position_changed_signal.emit(ochild); } -void SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +void SPObject::build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Nothing specific here */ debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); @@ -709,7 +706,7 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns gchar const *id = this->repr->attribute("id"); if (!document->isSeeking()) { { - gchar *realid = sp_object_get_unique_id(this, id); + gchar *realid = get_unique_id(this, id); g_assert(realid != NULL); this->document->bindObjectToId(realid, this); @@ -820,7 +817,7 @@ SPObject *SPObject::getPrev() return prev; } -void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) +void SPObject::repr_child_added(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -829,7 +826,7 @@ void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscap } } -void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) +void SPObject::repr_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node * /*ref*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -838,7 +835,7 @@ void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inksc } } -void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) +void SPObject::repr_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -847,7 +844,7 @@ void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inksc } } -void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) +void SPObject::private_set(SPObject *object, unsigned int key, gchar const *value) { g_assert(key != SP_ATTR_INVALID); @@ -869,7 +866,7 @@ void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar c if (!document->isSeeking()) { sp_object_ref(conflict, NULL); // give the conflicting object a new ID - gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL); + gchar *new_conflict_id = get_unique_id(conflict, NULL); conflict->getRepr()->setAttribute("id", new_conflict_id); g_free(new_conflict_id); sp_object_unref(conflict, NULL); @@ -960,7 +957,7 @@ void SPObject::readAttr(gchar const *key) } } -void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) +void SPObject::repr_attr_changed(Inkscape::XML::Node * /*repr*/, gchar const *key, gchar const * /*oldval*/, gchar const * /*newval*/, bool is_interactive, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -973,7 +970,7 @@ void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar } } -void SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) +void SPObject::repr_content_changed(Inkscape::XML::Node * /*repr*/, gchar const * /*oldcontent*/, gchar const * /*newcontent*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -997,7 +994,7 @@ static gchar const *sp_xml_get_space_string(unsigned int space) } } -Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * SPObject::private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { repr = object->getRepr()->duplicate(doc); @@ -1302,7 +1299,7 @@ bool SPObject::storeAsDouble( gchar const *key, double *val ) const /* Helper */ -gchar * SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id) +gchar * SPObject::get_unique_id(SPObject *object, gchar const *id) { static unsigned long count = 0; diff --git a/src/sp-object.h b/src/sp-object.h index b08706b0b..d9ddb17bb 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -18,7 +18,7 @@ class SPObject; class SPObjectClass; -#define SP_TYPE_OBJECT (SPObject::sp_object_get_type ()) +#define SP_TYPE_OBJECT (SPObject::get_type ()) #define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) #define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) #define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) @@ -260,7 +260,7 @@ public: * Represents the style properties, whether from presentation attributes, the style * attribute, or inherited. * - * sp_object_private_set doesn't handle SP_ATTR_STYLE or any presentation attributes at the + * private_set() doesn't handle SP_ATTR_STYLE or any presentation attributes at the * time of writing, so this is probably NULL for all SPObject's that aren't an SPItem. * * However, this gives rise to the bugs mentioned in sp_object_get_style_property. @@ -801,18 +801,18 @@ private: /** * Callback to initialize the SPObject object. */ - static void sp_object_init(SPObject *object); + static void init(SPObject *object); /** * Callback to destroy all members and connections of object and itself. */ - static void sp_object_finalize(GObject *object); + static void finalize(GObject *object); /** * Callback for child_added event. * Invoked whenever the given mutation event happens in the XML tree. */ - static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); + static void child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); /** * Remove object's child whose node equals repr, release and @@ -822,7 +822,7 @@ private: * tree, BEFORE removal from the XML tree happens, so grouping * objects can safely release the child data. */ - static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child); + static void remove_child(SPObject *object, Inkscape::XML::Node *child); /** * Move object corresponding to child after sibling object corresponding @@ -830,7 +830,7 @@ private: * Invoked whenever the given mutation event happens in the XML tree. * @param old_ref Ignored */ - static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); + static void order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); /** * Removes, releases and unrefs all children of object. @@ -841,9 +841,9 @@ private: * document and releases the SPRepr bindings; implementations should free * state data and release all child objects. Invoking release on * SPRoot destroys the whole document tree. - * @see sp_object_build() + * @see build() */ - static void sp_object_release(SPObject *object); + static void release(SPObject *object); /** * Virtual build callback. @@ -854,21 +854,21 @@ private: * generate the children objects and so on. Invoking build on the SPRoot * object results in creation of the whole document tree (this is, what * SPDocument does after the creation of the XML tree). - * @see sp_object_release() + * @see release() */ - static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); + static void build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); /** * Callback for set event. */ - static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); + static void private_set(SPObject *object, unsigned int key, gchar const *value); /** * Callback for write event. */ - static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + static Inkscape::XML::Node *private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); + static gchar *get_unique_id(SPObject *object, gchar const *defid); /* Real handlers of repr signals */ @@ -877,34 +877,34 @@ public: /** * Registers the SPObject class with Gdk and returns its type number. */ - static GType sp_object_get_type(); + static GType get_type(); /** * Callback for attr_changed node event. */ - static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); + static void repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); /** * Callback for content_changed node event. */ - static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); + static void repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); /** * Callback for child_added node event. */ - static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); + static void repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); /** * Callback for remove_child node event. */ - static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); + static void repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); /** * Callback for order_changed node event. * * \todo fixme: */ - static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); + static void repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); friend class SPObjectClass; @@ -942,7 +942,7 @@ private: /** * Initializes the SPObject vtable. */ - static void sp_object_class_init(SPObjectClass *klass); + static void init(SPObjectClass *klass); friend class SPObject; }; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index a9a9c7781..ad73f226c 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -146,7 +146,7 @@ void SPShape::sp_shape_finalize(GObject *object) * * This is to be invoked immediately after creation of an SPShape. * - * \see sp_object_build() + * \see SPObject::build() */ void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { @@ -167,7 +167,7 @@ void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::X * by other objects. This routine also disconnects/unrefs markers and * curves attached to it. * - * \see sp_object_release() + * \see SPObject::release() */ void SPShape::sp_shape_release(SPObject *object) { diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index f554d314d..4c339ad5a 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -312,7 +312,7 @@ void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr) /* * If the new value is different from the old value, this will sometimes send a signal via * CompositeNodeObserver::notiftyAttributeChanged() which results in calling - * SPObject::sp_object_repr_attr_changed and thus updates the object's SPStyle. This update + * SPObject::repr_attr_changed and thus updates the object's SPStyle. This update * results in another call to repr->setAttribute(). */ repr->setAttribute(attr, value.c_str()); -- cgit v1.2.3 From 53404b40617ef88ed21ae476968c1d71bd64675b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 14:30:26 +0000 Subject: SPObject: Remove todo note (bzr r11870) --- src/sp-object.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/sp-object.h b/src/sp-object.h index d9ddb17bb..0c4429a74 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -193,8 +193,6 @@ SPObject *sp_object_hunref(SPObject *object, gpointer owner); * SPObjects are bound to the higher-level container SPDocument, which * provides document level functionality such as the undo stack, * dictionary and so on. Source: doc/architecture.txt - * - * @todo need to remove redundant sp_object_... prefixing on methods. */ class SPObject : public GObject { public: -- cgit v1.2.3 From 0516dc2e3b182eead7fc62a0190043724f6bf2f7 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 11 Nov 2012 17:57:22 -0500 Subject: emf import. modify sequence of operations to load file EMF_Illustrator_a4.emf (Bug 988601) (bzr r11871) --- src/extension/internal/emf-win32-inout.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 872de045a..e9360a0ea 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -61,6 +61,8 @@ namespace Extension { namespace Internal { static float device_scale = DEVICESCALE; +static float device_x; +static float device_y; static RECTL rc_old; static bool clipset = false; @@ -322,11 +324,11 @@ _pix_y_to_point(PEMF_CALLBACK_DATA d, double px) static double pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py) { - double ppx = _pix_x_to_point(d, px); - double ppy = _pix_y_to_point(d, py); + double ppx = px * d->dc[d->level].worldTransform.eM11 + py * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx; + double x = _pix_x_to_point(d, ppx); - double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx; x *= device_scale; + x -= device_x; return x; } @@ -334,11 +336,11 @@ pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py) static double pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py) { - double ppx = _pix_x_to_point(d, px); - double ppy = _pix_y_to_point(d, py); + double ppy = px * d->dc[d->level].worldTransform.eM12 + py * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy; + double y = _pix_y_to_point(d, ppy); - double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy; y *= device_scale; + y -= device_y; return y; } @@ -773,8 +775,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * d->xDPI = 2540; d->yDPI = 2540; - d->dc[d->level].PixelsInX = pEmr->rclFrame.right; // - pEmr->rclFrame.left; - d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom; // - pEmr->rclFrame.top; + d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left; + d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top; + device_x = pEmr->rclFrame.left/100.0*PX_PER_MM; + device_y = pEmr->rclFrame.top/100.0*PX_PER_MM; d->MMX = d->dc[d->level].PixelsInX / 100.0; d->MMY = d->dc[d->level].PixelsInY / 100.0; @@ -2464,9 +2468,10 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) DWORD dwNeeded = GetEnhMetaFileDescriptionA( hemf, 0, NULL ); if ( dwNeeded > 0 ) { d.pDesc = (CHAR *) malloc( dwNeeded + 1 ); + d.pDesc[dwNeeded] = 0; if ( GetEnhMetaFileDescription( hemf, dwNeeded, d.pDesc ) == 0 ) lstrcpy( d.pDesc, "" ); - if ( lstrlen( d.pDesc ) > 1 ) + if ((lstrlen(d.pDesc) > 1) && (lstrlen(d.pDesc) < dwNeeded)) d.pDesc[lstrlen(d.pDesc)] = '#'; } -- cgit v1.2.3 From 20df6e1067d73cca6336f55ee699dbde406312c0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 15 Nov 2012 11:00:36 +0000 Subject: cppcheck: Fix a couple more C-style pointer casts and inefficient vector-emptiness checking (bzr r11872) --- src/display/canvas-grid.cpp | 6 +++--- src/display/nr-filter-merge.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 42a5ceccc..329b621ae 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -274,9 +274,9 @@ CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * repr, SPDocument * d switch (gridtype) { case GRID_RECTANGULAR: - return (CanvasGrid*) new CanvasXYGrid(nv, repr, doc); + return dynamic_cast(new CanvasXYGrid(nv, repr, doc)); case GRID_AXONOMETRIC: - return (CanvasGrid*) new CanvasAxonomGrid(nv, repr, doc); + return dynamic_cast(new CanvasAxonomGrid(nv, repr, doc)); } return NULL; @@ -366,7 +366,7 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc if (!data) return; - ((CanvasGrid*) data)->onReprAttrChanged(repr, key, oldval, newval, is_interactive); + (static_cast(data))->onReprAttrChanged(repr, key, oldval, newval, is_interactive); } bool CanvasGrid::isEnabled() diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index f1fbd7d33..759d7d6d1 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -31,7 +31,7 @@ FilterMerge::~FilterMerge() void FilterMerge::render_cairo(FilterSlot &slot) { - if (_input_image.size() == 0) return; + if (_input_image.empty()) return; // output is RGBA if at least one input is RGBA bool rgba32 = false; -- cgit v1.2.3 From f02cd4f80de3b2d54d62958c3f4747908d43eecd Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 15 Nov 2012 11:19:41 +0000 Subject: cppcheck: Simple fixes for src/ui/widget (bzr r11873) --- src/ui/widget/color-picker.cpp | 2 +- src/ui/widget/preferences-widget.cpp | 2 +- src/ui/widget/selected-style.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index e5c542a7c..31fb3096c 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -55,7 +55,7 @@ void ColorPicker::setupDialog(const Glib::ustring &title) _colorSelectorDialog.hide(); _colorSelectorDialog.set_title (title); _colorSelectorDialog.set_border_width (4); - _colorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK); + _colorSelector = SP_COLOR_SELECTOR(sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK)); _colorSelectorDialog.get_vbox()->pack_start ( *Glib::wrap(&_colorSelector->vbox), true, true, 0); diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 07145f5f3..b793893c7 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -640,7 +640,7 @@ void PrefCombo::on_changed() if (this->get_visible()) //only take action if user changed value { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if(_values.size() > 0) + if(!_values.empty()) { prefs->setInt(_prefs_path, _values[this->get_active_row_number()]); } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index ee835216d..41d7c8be2 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -300,7 +300,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) // List of units should match with Fill/Stroke dialog stroke style width list for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) { - SPUnit const *u = (SPUnit*)l->data; + SPUnit const *u = static_cast(l->data); Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); @@ -451,7 +451,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); @@ -988,13 +988,13 @@ SelectedStyle::update() if (SP_IS_LINEARGRADIENT (server)) { SPGradient *vector = SP_GRADIENT(server)->getVector(); - sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_l[i], vector); + sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_l[i]), vector); place->add(_gradient_box_l[i]); place->set_tooltip_text(__lgradient[i]); _mode[i] = SS_LGRADIENT; } else if (SP_IS_RADIALGRADIENT (server)) { SPGradient *vector = SP_GRADIENT(server)->getVector(); - sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_r[i], vector); + sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_r[i]), vector); place->add(_gradient_box_r[i]); place->set_tooltip_text(__rgradient[i]); _mode[i] = SS_RGRADIENT; -- cgit v1.2.3 From 15f08c37a261583b138f9cbecd6c271921f4e514 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 15 Nov 2012 11:42:04 +0000 Subject: cppcheck: Simple fixes for src/ui/dialog (bzr r11874) --- src/trace/trace.h | 11 +++++------ src/ui/dialog/align-and-distribute.cpp | 2 -- src/ui/dialog/align-and-distribute.h | 2 +- src/ui/dialog/clonetiler.cpp | 20 ++++++++++---------- src/ui/dialog/color-item.cpp | 2 +- src/ui/dialog/document-properties.cpp | 4 ++-- src/ui/dialog/export.cpp | 14 +++++++------- src/ui/dialog/filter-effects-dialog.cpp | 7 +++---- src/ui/dialog/font-substitution.cpp | 4 ++-- src/ui/dialog/layer-properties.cpp | 2 +- src/ui/dialog/object-attributes.cpp | 2 +- src/ui/dialog/ocaldialogs.h | 2 +- src/ui/dialog/spellcheck.cpp | 8 ++++---- src/ui/dialog/svg-fonts-dialog.cpp | 4 ++-- 14 files changed, 40 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/trace/trace.h b/src/trace/trace.h index f811f4891..9f9f44b14 100644 --- a/src/trace/trace.h +++ b/src/trace/trace.h @@ -48,12 +48,11 @@ public: */ TracingEngineResult(const std::string &theStyle, const std::string &thePathData, - long theNodeCount) - { - style = theStyle; - pathData = thePathData; - nodeCount = theNodeCount; - } + long theNodeCount) : + style(theStyle), + pathData(thePathData), + nodeCount(theNodeCount) + {} TracingEngineResult(const TracingEngineResult &other) { assign(other); } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 4b0f773b5..cd1ce1471 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1314,7 +1314,6 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator AlignAndDistribute::find_master( std::listisEmpty()) { gtk_widget_set_sensitive (buttons, FALSE); @@ -2204,7 +2204,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) desktop->setWaitingCursor(); // set statusbar text - GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status"); + GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); gtk_label_set_markup (GTK_LABEL(status), _("Creating tiled clones...")); gtk_widget_queue_draw(GTK_WIDGET(status)); gdk_window_process_all_updates(); @@ -2870,10 +2870,10 @@ void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data } -void CloneTiler::clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg) +void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) { - GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols"); - GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight"); + GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); + GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); if (rowscols) { gtk_widget_set_sensitive (rowscols, TRUE); @@ -2887,10 +2887,10 @@ void CloneTiler::clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget } -void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg) +void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) { - GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols"); - GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight"); + GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); + GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); if (rowscols) { gtk_widget_set_sensitive (rowscols, FALSE); @@ -2929,7 +2929,7 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) { - GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace"); + GtkWidget *vvb = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "dotrace")); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb)); diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 97f6cc07f..e370a0342 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -144,7 +144,7 @@ static void dieDieDie( GObject *obj, gpointer user_data ) g_message("die die die %p %p", obj, user_data ); } -static bool getBlock( std::string& dst, guchar ch, std::string const str ) +static bool getBlock( std::string& dst, guchar ch, std::string const & str ) { bool good = false; std::string::size_type pos = str.find(ch); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 693268b35..e681147aa 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -928,7 +928,7 @@ void DocumentProperties::removeExternalScript(){ while ( current ) { if (current->data && SP_IS_OBJECT(current->data)) { SPObject* obj = SP_OBJECT(current->data); - SPScript* script = (SPScript*) obj; + SPScript* script = SP_SCRIPT(obj); if (name == script->xlinkhref){ //XML Tree being used directly here while it shouldn't be. @@ -1085,7 +1085,7 @@ void DocumentProperties::populate_script_lists(){ if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); - SPScript* script = (SPScript*) obj; + SPScript* script = SP_SCRIPT(obj); if (script->xlinkhref) { Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append()); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index e6c8ca107..c073375a2 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1438,7 +1438,7 @@ void Export::areaXChange (Gtk::Adjustment *adj) return; } - if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) { + if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { return; } @@ -1485,7 +1485,7 @@ void Export::areaYChange (Gtk::Adjustment *adj) return; } - if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) { + if (sp_unit_selector_update_test (SP_UNIT_SELECTOR(unit_selector->gobj()))) { return; } @@ -1640,7 +1640,7 @@ void Export::onBitmapWidthChange () return; } - if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) { + if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { return; } @@ -1674,7 +1674,7 @@ void Export::onBitmapHeightChange () return; } - if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) { + if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { return; } @@ -1734,7 +1734,7 @@ void Export::onExportXdpiChange() return; } - if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) { + if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { return; } @@ -1836,7 +1836,7 @@ void Export::setValuePx(Glib::RefPtr& adj, double val) void Export::setValuePx( Gtk::Adjustment *adj, double val) #endif { - const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)unit_selector->gobj() ); + const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj()) ); setValue(adj, sp_pixels_get_units (val, *unit)); @@ -1886,7 +1886,7 @@ float Export::getValuePx( Gtk::Adjustment *adj ) #endif { float value = getValue( adj); - const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)unit_selector->gobj()); + const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj())); return sp_units_get_pixels (value, *unit); } // end of sp_export_value_get_px() diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 6fab4c504..87b3e3f1a 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1327,7 +1327,7 @@ void FilterEffectsDialog::FilterModifier::update_filters() for(const GSList *l = filters; l; l = l->next) { Gtk::TreeModel::Row row = *_model->append(); - SPFilter* f = (SPFilter*)l->data; + SPFilter* f = SP_FILTER(l->data); row[_columns.filter] = f; const gchar* lbl = f->label(); const gchar* id = f->getId(); @@ -1454,7 +1454,7 @@ void FilterEffectsDialog::CellRendererConnection::get_size_vfunc( if(height) { // Scale the height depending on the number of inputs, unless it's // the first primitive, in which case there are no connections - SPFilterPrimitive* prim = (SPFilterPrimitive*)_primitive.get_value(); + SPFilterPrimitive* prim = SP_FILTER_PRIMITIVE(_primitive.get_value()); (*height) = size * input_count(prim); } } @@ -1536,11 +1536,10 @@ void FilterEffectsDialog::PrimitiveList::update() { SPFilter* f = _dialog._filter_modifier.get_selected_filter(); const SPFilterPrimitive* active_prim = get_selected(); - bool active_found = false; - _model->clear(); if(f) { + bool active_found = false; _dialog._primitive_box.set_sensitive(true); _dialog.update_filter_general_settings_view(); for(SPObject *prim_obj = f->children; diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index d449bad67..24588946e 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -207,7 +207,7 @@ GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring * // Check if any document styles are not in the actual layout std::map::const_iterator mapIter; - for (mapIter = mapFontStyles.begin(); mapIter != mapFontStyles.end(); mapIter++) { + for (mapIter = mapFontStyles.begin(); mapIter != mapFontStyles.end(); ++mapIter) { SPItem *item = mapIter->first; Glib::ustring fonts = mapIter->second; @@ -241,7 +241,7 @@ GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring * } std::set::const_iterator setIter; - for (setIter = setErrors.begin(); setIter != setErrors.end(); setIter++) { + for (setIter = setErrors.begin(); setIter != setErrors.end(); ++setIter) { Glib::ustring err = (*setIter); out->append(err + "\n"); g_warning("%s", err.c_str()); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 4f9edf774..245dac5e0 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -216,7 +216,7 @@ LayerPropertiesDialog::_setup_layers_controls() { if ( root ) { SPObject* target = _desktop->currentLayer(); _store->clear(); - _addLayer( document, (SPObject *)root, 0, target, 0 ); + _addLayer( document, SP_OBJECT(root), 0, target, 0 ); } _layout_table.remove(_layer_name_entry); diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp index f67c4db21..1ae9730d5 100644 --- a/src/ui/dialog/object-attributes.cpp +++ b/src/ui/dialog/object-attributes.cpp @@ -123,7 +123,7 @@ void ObjectAttributes::widget_setup (void) } blocked = true; - SPObject *obj = (SPObject*)item; //to get the selected item + SPObject *obj = SP_OBJECT(item); //to get the selected item GObjectClass *klass = G_OBJECT_GET_CLASS(obj); //to deduce the object's type GType type = G_TYPE_FROM_CLASS(klass); const SPAttrDesc *desc; diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 0dc61abb3..1cdfa15bb 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -64,7 +64,7 @@ public: FileDialogBase(const Glib::ustring &title, Gtk::Window& /*parent*/) : Gtk::Window(Gtk::WINDOW_TOPLEVEL) { set_title(title); - sp_transientize((GtkWidget*) gobj()); + sp_transientize(GTK_WIDGET(gobj())); // Allow shrinking of window so labels wrap correctly set_resizable(true); diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 0da28061e..0f2c53f99 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -219,8 +219,8 @@ void SpellCheck::setTargetDesktop(SPDesktop *desktop) void SpellCheck::clearRects() { for (GSList *it = _rects; it; it = it->next) { - sp_canvas_item_hide((SPCanvasItem*) it->data); - sp_canvas_item_destroy((SPCanvasItem*) it->data); + sp_canvas_item_hide(SP_CANVAS_ITEM(it->data)); + sp_canvas_item_destroy(SP_CANVAS_ITEM(it->data)); } g_slist_free(_rects); _rects = NULL; @@ -330,8 +330,8 @@ SpellCheck::nextText() _text = getText(_root); if (_text) { - _modified_connection = ((SPObject*) _text)->connectModified(sigc::mem_fun(*this, &SpellCheck::onObjModified)); - _release_connection = ((SPObject*) _text)->connectRelease(sigc::mem_fun(*this, &SpellCheck::onObjReleased)); + _modified_connection = (SP_OBJECT(_text))->connectModified(sigc::mem_fun(*this, &SpellCheck::onObjModified)); + _release_connection = (SP_OBJECT(_text))->connectRelease(sigc::mem_fun(*this, &SpellCheck::onObjReleased)); _layout = te_get_layout (_text); _begin_w = _layout->begin(); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 16bb8222a..f296ad030 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -278,7 +278,7 @@ void SvgFontsDialog::update_fonts() _model->clear(); for(const GSList *l = fonts; l; l = l->next) { Gtk::TreeModel::Row row = *_model->append(); - SPFont* f = (SPFont*)l->data; + SPFont* f = SP_FONT(l->data); row[_columns.spfont] = f; row[_columns.svgfont] = new SvgFont(f); const gchar* lbl = f->label(); @@ -318,7 +318,7 @@ void SvgFontsDialog::update_global_settings_tab(){ SPObject* obj; for (obj=font->children; obj; obj=obj->next){ if (SP_IS_FONTFACE(obj)){ - _familyname_entry->set_text(((SPFontFace*) obj)->font_family); + _familyname_entry->set_text((SP_FONTFACE(obj))->font_family); } } } -- cgit v1.2.3 From ba3802c42dbf90ec56b235d96b9ab0a7736ae290 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 18 Nov 2012 10:39:47 +0900 Subject: Fix for 177931 : Layer dialog toggle solo mode with Shift/Alt click (bzr r11879) --- src/ui/dialog/layers.cpp | 57 +++++++++++++++++++++++++++++++++++++++--------- src/ui/dialog/layers.h | 2 +- 2 files changed, 48 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index f851f72c1..ffdf27b62 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -558,7 +558,8 @@ bool LayersPanel::_handleKeyEvent(GdkEventKey *event) } return false; } -void LayersPanel::_handleButtonEvent(GdkEventButton* event) + +bool LayersPanel::_handleButtonEvent(GdkEventButton* event) { static unsigned doubleclick = 0; @@ -573,9 +574,9 @@ void LayersPanel::_handleButtonEvent(GdkEventButton* event) } } - if ( event->type == GDK_BUTTON_RELEASE && (event->button == 1) - && (event->state & GDK_SHIFT_MASK)) { - // Shift left click on the visible/lock columns toggles "solo" mode + if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) + && (event->state & GDK_MOD1_MASK)) { + // Alt left click on the visible/lock columns - eat this event to keep row selection Gtk::TreeModel::Path path; Gtk::TreeViewColumn* col = 0; int x = static_cast(event->x); @@ -583,10 +584,45 @@ void LayersPanel::_handleButtonEvent(GdkEventButton* event) int x2 = 0; int y2 = 0; if ( _tree.get_path_at_pos( x, y, path, col, x2, y2 ) ) { - if (col == _tree.get_column(COL_VISIBLE-1)) { - _takeAction(BUTTON_SOLO); - } else if (col == _tree.get_column(COL_LOCKED-1)) { - _takeAction(BUTTON_LOCK_OTHERS); + if (col == _tree.get_column(COL_VISIBLE-1) || + col == _tree.get_column(COL_LOCKED-1)) { + return true; + } + } + } + + // TODO - ImageToggler doesn't seem to handle Shift/Alt clicks - so we deal with them here. + if ( (event->type == GDK_BUTTON_RELEASE) && (event->button == 1) + && (event->state & (GDK_SHIFT_MASK | GDK_MOD1_MASK))) { + + Gtk::TreeModel::Path path; + Gtk::TreeViewColumn* col = 0; + int x = static_cast(event->x); + int y = static_cast(event->y); + int x2 = 0; + int y2 = 0; + if ( _tree.get_path_at_pos( x, y, path, col, x2, y2 ) ) { + if (event->state & GDK_SHIFT_MASK) { + // Shift left click on the visible/lock columns toggles "solo" mode + if (col == _tree.get_column(COL_VISIBLE - 1)) { + _takeAction(BUTTON_SOLO); + } else if (col == _tree.get_column(COL_LOCKED - 1)) { + _takeAction(BUTTON_LOCK_OTHERS); + } + } else if (event->state & GDK_MOD1_MASK) { + // Alt+left click on the visible/lock columns toggles "solo" mode and preserves selection + Gtk::TreeModel::iterator iter = _store->get_iter(path); + if (_store->iter_is_valid(iter)) { + Gtk::TreeModel::Row row = *iter; + SPObject *obj = row[_model->_colObject]; + if (col == _tree.get_column(COL_VISIBLE - 1)) { + _desktop->toggleLayerSolo( obj ); + DocumentUndo::maybeDone(_desktop->doc(), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo")); + } else if (col == _tree.get_column(COL_LOCKED - 1)) { + _desktop->toggleLockOtherLayers( obj ); + DocumentUndo::maybeDone(_desktop->doc(), "layer:lockothers", SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers")); + } + } } } } @@ -612,6 +648,7 @@ void LayersPanel::_handleButtonEvent(GdkEventButton* event) } } + return false; } /* @@ -808,8 +845,8 @@ LayersPanel::LayersPanel() : _text_renderer->signal_edited().connect( sigc::mem_fun(*this, &LayersPanel::_handleEdited) ); _text_renderer->signal_editing_canceled().connect( sigc::mem_fun(*this, &LayersPanel::_handleEditingCancelled) ); - _tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) ); - _tree.signal_button_release_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) ); + _tree.signal_button_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent), false ); + _tree.signal_button_release_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent), false ); _tree.signal_key_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleKeyEvent), false ); _scroller.add( _tree ); diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index cbd9515d7..e9fd9ebc6 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -64,7 +64,7 @@ private: void _preToggle( GdkEvent const *event ); void _toggled( Glib::ustring const& str, int targetCol ); - void _handleButtonEvent(GdkEventButton *event); + bool _handleButtonEvent(GdkEventButton *event); bool _handleKeyEvent(GdkEventKey *event); bool _handleDragDrop(const Glib::RefPtr& context, int x, int y, guint time); void _handleEdited(const Glib::ustring& path, const Glib::ustring& new_text); -- cgit v1.2.3 From f1a9fc07d9f4cfa94da390247c25ce4ba693a34e Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 18 Nov 2012 21:33:53 +0900 Subject: Fix for 1079971 : Symbol dialog : Drag & Drop to the canvas (bzr r11880) --- src/desktop.cpp | 1 + src/interface.cpp | 12 +++++++++++- src/ui/dialog/symbols.cpp | 27 +++++++++++++++++++++++++++ src/ui/dialog/symbols.h | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index f10174119..2f8f3e4b6 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1903,6 +1903,7 @@ SPDesktop::show_dialogs() mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_CLONETILER, "/dialogs/clonetiler") ); mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_ITEM, "/dialogs/object") ); mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SPELLCHECK, "/dialogs/spellcheck") ); + mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SYMBOLS, "/dialogs/symbols") ); for (iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); iter++) { int verbId = iter->first; diff --git a/src/interface.cpp b/src/interface.cpp index bad95adc6..823119953 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -59,6 +59,7 @@ #include "dialogs/dialog-events.h" #include "message-context.h" #include "ui/uxmanager.h" +#include "ui/clipboard.h" #include "display/sp-canvas.h" #include "color.h" @@ -97,6 +98,7 @@ typedef enum { APP_X_INKY_COLOR, APP_X_COLOR, APP_OSWB_COLOR, + APP_X_INK_PASTE } ui_drop_target_info; static GtkTargetEntry ui_drop_target_entries [] = { @@ -109,7 +111,8 @@ static GtkTargetEntry ui_drop_target_entries [] = { {(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR}, #endif // ENABLE_MAGIC_COLORS {(gchar *)"application/x-oswb-color", 0, APP_OSWB_COLOR }, - {(gchar *)"application/x-color", 0, APP_X_COLOR } + {(gchar *)"application/x-color", 0, APP_X_COLOR }, + {(gchar *)"application/x-inkscape-paste", 0, APP_X_INK_PASTE } }; static GtkTargetEntry *completeDropTargets = 0; @@ -1430,6 +1433,13 @@ sp_ui_drag_data_received(GtkWidget *widget, break; } + case APP_X_INK_PASTE: { + Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); + cm->paste(desktop); + DocumentUndo::done( doc, SP_VERB_NONE, _("Drop Symbol") ); + break; + } + case PNG_DATA: case JPEG_DATA: case IMAGE_DATA: { diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 4e1b82ebe..8cf48f827 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -123,6 +123,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : iconView->set_tooltip_column( 1 ); iconView->set_pixbuf_column( columns->symbol_image ); + std::vector< Gtk::TargetEntry > targets; + targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste")); + + iconView->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY); + iconView->signal_drag_data_get().connect(sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet)); + sigc::connection connIconChanged; connIconChanged = iconView->signal_selection_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); @@ -228,6 +234,27 @@ void SymbolsDialog::rebuild() { draw_symbols( symbolDocument ); } +void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& data, guint info, guint time) { + +#if WITH_GTKMM_3_0 + std::vector iconArray = iconView->get_selected_items(); +#else + Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); +#endif + + if( iconArray.empty() ) { + //std::cout << " iconArray empty: huh? " << std::endl; + } else { + Gtk::TreeModel::Path const & path = *iconArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + Glib::ustring symbol_id = (*row)[getColumns()->symbol_id]; + + GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE ); + gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() ); + } + +} + void SymbolsDialog::iconChanged() { #if WITH_GTKMM_3_0 std::vector iconArray = iconView->get_selected_items(); diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index c2bb4448e..5486ff546 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -54,6 +54,7 @@ private: void rebuild(); void iconChanged(); + void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); void draw_symbols( SPDocument* symbol_document ); -- cgit v1.2.3 From 945ff336805b151f03399f01c819c40f481fd45c Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 18 Nov 2012 21:43:37 +0900 Subject: Fix for 275662 : Filter stays in object's css property after Filter Effect dialog removal (bzr r11881) --- src/ui/dialog/filter-effects-dialog.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 87b3e3f1a..b00dd042f 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -62,6 +62,7 @@ #include "io/sys.h" #include +#include "selection-chemistry.h" #include #include @@ -1398,6 +1399,29 @@ void FilterEffectsDialog::FilterModifier::remove_filter() if(filter) { SPDocument* doc = filter->document; + // Delete all references to this filter + GSList *all = get_all_items(NULL, _desktop->currentRoot(), _desktop, false, false, true, NULL); + for (GSList *i = all; i != NULL; i = i->next) { + if (!SP_IS_ITEM(i->data)) { + continue; + } + SPItem *item = SP_ITEM(i->data); + if (!item->style) { + continue; + } + + const SPIFilter *ifilter = &(item->style->filter); + if (ifilter && ifilter->href) { + const SPObject *obj = ifilter->href->getObject(); + if (obj && obj == (SPObject *)filter) { + ::remove_filter(item, false); + } + } + } + if (all) { + g_slist_free(all); + } + //XML Tree being used directly here while it shouldn't be. sp_repr_unparent(filter->getRepr()); -- cgit v1.2.3 From b2103acf1da407e1bef705d9f6ee26cb896c43a2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 18 Nov 2012 14:08:41 +0100 Subject: UI. Fix for Bug #1071104 (Failure to open a browse window when choosing Export As...). (bzr r11882) --- src/ui/dialog/export.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index c073375a2..f267c5ae9 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1260,6 +1260,14 @@ void Export::onBrowse () WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL); WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 + std::string dirname = Glib::path_get_dirname(filename.raw()); + if ( !Glib::file_test(dirname, Glib::FILE_TEST_EXISTS) || + Glib::file_test(filename, Glib::FILE_TEST_IS_DIR) || + dirname.empty() ) + { + Glib::ustring tmp; + filename = create_filepath_from_id(tmp, tmp); + } WCHAR _filename[_MAX_PATH + 1]; memset(_filename, 0, sizeof(_filename)); gunichar2* utf16_path_string = g_utf8_to_utf16(filename.c_str(), -1, NULL, NULL, NULL); -- cgit v1.2.3 From d6ac14202d3983a8bb19d66c6a599f9b77f464bc Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 19 Nov 2012 13:05:55 +0900 Subject: Revert for 166691 : Changing layer order does not update layer selector - Revert change to performance issues (bzr r11883) --- src/ui/widget/layer-selector.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index c06f70185..fbb9c0e24 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -241,7 +241,11 @@ private: void LayerSelector::_layersChanged() { if (_desktop) { - _selectLayer(_desktop->currentLayer()); + /* + * This code fixes #166691 but causes issues #1066543 and #1080378. + * Comment out until solution found. + */ + //_selectLayer(_desktop->currentLayer()); } } -- cgit v1.2.3 From f37e1310a960f5472325c7aac47d44c197916adb Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 20 Nov 2012 06:30:33 +0100 Subject: Fix for Bug #768149 (Incorrect Image URL can cause Loop) by Kris. (bzr r11885) --- src/sp-image.cpp | 44 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index aa16bcdd4..7293c49fa 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -433,10 +433,16 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& modTime = 0; if ( pixPath ) { g_free(pixPath); - pixPath = 0; + pixPath = NULL; + } + + struct stat stdir; + g_stat(filename, &stdir); + if (stdir.st_mode & S_IFDIR){ + //filename is not correct: it is a directory name and hence further code can not return valid results + return NULL; } - //buf = gdk_pixbuf_new_from_file( filename, error ); dump_fopen_call( filename, "pixbuf_new_from_file" ); FILE* fp = fopen_utf8name( filename, "r" ); if ( fp ) @@ -479,7 +485,6 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& } } else if ( !latter ) { latter = TRUE; - //g_message(" READing latter"); } // Now clear out the buffer so we can read more. // (dumping out unused) @@ -492,23 +497,6 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& buf = gdk_pixbuf_loader_get_pixbuf( loader ); if ( buf ) { g_object_ref(buf); - - if ( dpiX ) { - gchar *tmp = g_strdup_printf( "%d", dpiX ); - if ( tmp ) { - //g_message("Need to set DpiX: %s", tmp); - //gdk_pixbuf_set_option( buf, "Inkscape::DpiX", tmp ); - g_free( tmp ); - } - } - if ( dpiY ) { - gchar *tmp = g_strdup_printf( "%d", dpiY ); - if ( tmp ) { - //g_message("Need to set DpiY: %s", tmp); - //gdk_pixbuf_set_option( buf, "Inkscape::DpiY", tmp ); - g_free( tmp ); - } - } } } else { // do something @@ -525,22 +513,6 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& g_warning ("Unable to open linked file: %s", filename); } -/* - if ( buf ) - { - const gchar* bloop = gdk_pixbuf_get_option( buf, "Inkscape::DpiX" ); - if ( bloop ) - { - g_message("DPI X is [%s]", bloop); - } - bloop = gdk_pixbuf_get_option( buf, "Inkscape::DpiY" ); - if ( bloop ) - { - g_message("DPI Y is [%s]", bloop); - } - } -*/ - return buf; } -- cgit v1.2.3 From 8af73b0d457e33172951f97c01d523bcd31d89cb Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 20 Nov 2012 21:17:26 +0100 Subject: Fix for #970355, radial gradient using object bounding box. (bzr r11887) --- src/sp-gradient.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index f9f9a5015..d7add805d 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -2051,13 +2051,32 @@ sp_radialgradient_create_pattern(SPPaintServer *ps, double scale = 1.0; double tolerance = cairo_get_tolerance(ct); + // NOTE: SVG2 will allow the use of a focus circle which can + // have its center outside the first circle. + // code below suggested by Cairo devs to overcome tolerance problems // more: https://bugs.freedesktop.org/show_bug.cgi?id=40918 + + // Corrected for + // https://bugs.launchpad.net/inkscape/+bug/970355 + + Geom::Affine gs2user = gr->gradientTransform; + Geom::Scale gs2user_scale; + + if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX && bbox) { + Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top()); + gs2user *= bbox2user; + gs2user_scale = Geom::Scale( gs2user[0], gs2user[3] ); + } + Geom::Point d = focus - center; - if (d.length() + tolerance > radius) { - scale = radius / d.length(); + Geom::Point d_user = d * gs2user_scale; + Geom::Point r_user( radius, 0 ); + r_user *= gs2user_scale; - double dx = d.x(), dy = d.y(); + if (d_user.length() + tolerance > r_user.length()) { + scale = r_user.length() / d_user.length(); + double dx = d_user.x(), dy = d_user.y(); cairo_user_to_device_distance(ct, &dx, &dy); if (!Geom::are_near(dx, 0, tolerance) || !Geom::are_near(dy, 0, tolerance)) -- cgit v1.2.3 From d463240d8fd961d45b47ba96e0d93c37e1719da7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Nov 2012 09:55:55 +1100 Subject: code cleanup: quiet warnings with gcc. (bzr r11888) --- src/libavoid/makepath.cpp | 2 +- src/libavoid/orthogonal.cpp | 4 ++-- src/libcola/connected_components.cpp | 2 +- src/libcola/shortest_paths.cpp | 4 ++-- src/libcola/straightener.cpp | 2 +- src/libnrtype/FontFactory.cpp | 4 ++-- src/libvpsc/csolve_VPSC.h | 2 ++ src/libvpsc/generate-constraints.cpp | 6 +++--- src/libvpsc/remove_rectangle_overlap.cpp | 1 + src/livarot/PathSimplify.cpp | 10 +++++----- src/livarot/PathStroke.cpp | 4 ++-- src/livarot/ShapeMisc.cpp | 4 ++-- src/svg/itos.cpp | 2 ++ src/svg/round.cpp | 1 + src/util/expression-evaluator.cpp | 2 +- 15 files changed, 28 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/libavoid/makepath.cpp b/src/libavoid/makepath.cpp index 4e15dbca9..774e0d7f5 100644 --- a/src/libavoid/makepath.cpp +++ b/src/libavoid/makepath.cpp @@ -82,7 +82,7 @@ class ANode // it back into a heap) when getting the next node to examine. This way we // get better complexity -- logarithmic pushs and pops to the heap. // -bool operator<(const ANode &a, const ANode &b) +static bool operator<(const ANode &a, const ANode &b) { if (a.f != b.f) { diff --git a/src/libavoid/orthogonal.cpp b/src/libavoid/orthogonal.cpp index e0a30b246..772fc9668 100644 --- a/src/libavoid/orthogonal.cpp +++ b/src/libavoid/orthogonal.cpp @@ -204,7 +204,7 @@ class ShiftSegment }; typedef std::list ShiftSegmentList; -bool cmpShiftSegment(const ShiftSegment& u, const ShiftSegment& v) +static bool cmpShiftSegment(const ShiftSegment& u, const ShiftSegment& v) { return u < v; } @@ -488,7 +488,7 @@ Event **events; // Used for quicksort. Must return <0, 0, or >0. -int compare_events(const void *a, const void *b) +static int compare_events(const void *a, const void *b) { Event *ea = *(Event**) a; Event *eb = *(Event**) b; diff --git a/src/libcola/connected_components.cpp b/src/libcola/connected_components.cpp index 0cf6ee45a..1afec55b4 100644 --- a/src/libcola/connected_components.cpp +++ b/src/libcola/connected_components.cpp @@ -39,7 +39,7 @@ namespace cola { Rectangle* r; }; // Depth first search traversal of graph to find connected component - void dfs(Node* v, + static void dfs(Node* v, list& remaining, Component* component, map > &cmap) { diff --git a/src/libcola/shortest_paths.cpp b/src/libcola/shortest_paths.cpp index ebc2c93de..514721fb5 100644 --- a/src/libcola/shortest_paths.cpp +++ b/src/libcola/shortest_paths.cpp @@ -33,7 +33,7 @@ void floyd_warshall( } } } -void dijkstra_init(Node* vs, vector& es, double* eweights) { +static void dijkstra_init(Node* vs, vector& es, double* eweights) { for(unsigned i=0;i& es, double* eweights) { vs[v].nweights.push_back(eweights[i]); } } -void dijkstra( +static void dijkstra( unsigned s, unsigned n, Node* vs, diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index 0ecd82faa..650f41aac 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -109,7 +109,7 @@ namespace straightener { Event(EventType t, Edge *e, double p) : type(t),v(NULL),e(e),pos(p) {}; }; Event **events; - int compare_events(const void *a, const void *b) { + static int compare_events(const void *a, const void *b) { Event *ea=*(Event**)a; Event *eb=*(Event**)b; if((ea->v!=NULL&&ea->v==eb->v)||(ea->e!=NULL&&ea->e==eb->e)) { diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 8de9d4795..76a3df0e8 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -276,7 +276,7 @@ family_name_compare(char const *a, char const *b) #endif } -void noop(...) {} +static void noop(...) {} //#define PANGO_DEBUG g_print #define PANGO_DEBUG noop @@ -285,7 +285,7 @@ void noop(...) {} ///////////////////// FontFactory #ifndef USE_PANGO_WIN32 // the substitute function to tell fontconfig to enforce outline fonts -void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/) +static void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/) { FcPatternAddBool(pattern, "FC_OUTLINE",FcTrue); //char *fam = NULL; diff --git a/src/libvpsc/csolve_VPSC.h b/src/libvpsc/csolve_VPSC.h index b0d01e763..edfd16657 100644 --- a/src/libvpsc/csolve_VPSC.h +++ b/src/libvpsc/csolve_VPSC.h @@ -60,7 +60,9 @@ int genXConstraints(int n, boxf[], Variable** vs, Constraint*** cs, int genYConstraints(int n, boxf[], Variable** vs, Constraint*** cs); void satisfyVPSC(Solver*); +void deleteVPSC(Solver*); void solveVPSC(Solver*); +void splitIncVPSC(IncSolver*); Solver* newIncSolver(int n, Variable* vs[], int m, Constraint* cs[]); void splitIncSolver(IncSolver*); int getSplitCnt(IncSolver *vpsc); diff --git a/src/libvpsc/generate-constraints.cpp b/src/libvpsc/generate-constraints.cpp index 8dd2d9331..fabe5217f 100644 --- a/src/libvpsc/generate-constraints.cpp +++ b/src/libvpsc/generate-constraints.cpp @@ -105,7 +105,7 @@ bool CmpNodePos::operator() (const Node* u, const Node* v) const { */ } -NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) { +static NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) { NodeSet *leftv = new NodeSet; NodeSet::iterator i=scanline.find(v); while(i--!=scanline.begin()) { @@ -120,7 +120,7 @@ NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) { } return leftv; } -NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) { +static NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) { NodeSet *rightv = new NodeSet; NodeSet::iterator i=scanline.find(v); for(++i;i!=scanline.end(); ++i) { @@ -144,7 +144,7 @@ struct Event { Event(EventType t, Node *v, double p) : type(t),v(v),pos(p) {}; }; Event **events; -int compare_events(const void *a, const void *b) { +static int compare_events(const void *a, const void *b) { Event *ea=*(Event**)a; Event *eb=*(Event**)b; if(ea->v->r==eb->v->r) { diff --git a/src/libvpsc/remove_rectangle_overlap.cpp b/src/libvpsc/remove_rectangle_overlap.cpp index 381759f3c..d667ffb1e 100644 --- a/src/libvpsc/remove_rectangle_overlap.cpp +++ b/src/libvpsc/remove_rectangle_overlap.cpp @@ -15,6 +15,7 @@ #include "solve_VPSC.h" #include "variable.h" #include "constraint.h" +#include "remove_rectangle_overlap.h" /* own include */ #ifdef RECTANGLE_OVERLAP_LOGGING #include #include "blocks.h" diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index d6e916197..d9f609e87 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -70,10 +70,10 @@ void Path::Simplify(double treshhold) // dichomtomic method to get distance to curve approximation // a real polynomial solver would get the minimum more efficiently, but since the polynom // would likely be of degree >= 5, that would imply using some generic solver, liek using the sturm metod -double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD, - Geom::Point const &iE, Geom::Point const &ieD, - Geom::Point &pt, double current, int lev, double st, double et) -{ +static double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD, + Geom::Point const &iE, Geom::Point const &ieD, + Geom::Point &pt, double current, int lev, double st, double et) +{ if ( lev <= 0 ) { return current; } @@ -116,7 +116,7 @@ double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD, } -double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Geom::Point &pt) +static double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Geom::Point &pt) { Geom::Point const sp = pt - start; Geom::Point const ep = pt - res.p; diff --git a/src/livarot/PathStroke.cpp b/src/livarot/PathStroke.cpp index 93280d794..cdd5cae6d 100644 --- a/src/livarot/PathStroke.cpp +++ b/src/livarot/PathStroke.cpp @@ -20,7 +20,7 @@ */ // until i find something better -Geom::Point StrokeNormalize(const Geom::Point value) { +static Geom::Point StrokeNormalize(const Geom::Point value) { double length = L2(value); if ( length < 0.0000001 ) { return Geom::Point(0, 0); @@ -30,7 +30,7 @@ Geom::Point StrokeNormalize(const Geom::Point value) { } // faster version if length is known -Geom::Point StrokeNormalize(const Geom::Point value, double length) { +static Geom::Point StrokeNormalize(const Geom::Point value, double length) { if ( length < 0.0000001 ) { return Geom::Point(0, 0); } else { diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index 7b170e8a0..a7e5a6cdc 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -406,7 +406,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in if (startBord >= 0) { // parcours en profondeur pour mettre les leF et riF a leurs valeurs - swdData[startBord].misc = (void *) (1+nbNest); + swdData[startBord].misc = (void *)(intptr_t)(1 + nbNest); //printf("part de %d\n",startBord); int curBord = startBord; bool back = false; @@ -507,7 +507,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in startBord=nb; } } - swdData[nb].misc = (void *) (1+nbNest); + swdData[nb].misc = (void *)(intptr_t)(1 + nbNest); swdData[nb].ind = searchInd++; swdData[nb].precParc = curBord; swdData[curBord].suivParc = nb; diff --git a/src/svg/itos.cpp b/src/svg/itos.cpp index ff7ca516c..78726d068 100644 --- a/src/svg/itos.cpp +++ b/src/svg/itos.cpp @@ -18,6 +18,8 @@ #include // for string #include +#include "../io/ftos.h" /* own include */ /* note - why in different dirs? */ + using std::string; string itos(int n) diff --git a/src/svg/round.cpp b/src/svg/round.cpp index 9e7b91e4e..0a4ca9d05 100644 --- a/src/svg/round.cpp +++ b/src/svg/round.cpp @@ -26,6 +26,7 @@ // on the average. /////////////////////////////////////////////////////////////////////// #include +#include "../io/ftos.h" /* own include */ /* note - why in different dirs? */ double rround(double x) { diff --git a/src/util/expression-evaluator.cpp b/src/util/expression-evaluator.cpp index 37e9d6cc1..3e1bab6bc 100644 --- a/src/util/expression-evaluator.cpp +++ b/src/util/expression-evaluator.cpp @@ -75,7 +75,7 @@ typedef struct /** Unit Resolver... */ -bool unitresolverproc (const gchar* identifier, GimpEevlQuantity *result, Unit* unit) +static bool unitresolverproc (const gchar* identifier, GimpEevlQuantity *result, Unit* unit) { static UnitTable unit_table; -- cgit v1.2.3 From f36cbed4b3f685a59f69dfd7b4534fe5a8da4bcf Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 23 Nov 2012 20:46:45 +0100 Subject: UI. Fix for Bug #1072007 (Mouse scroll zoom depends on if the cursor is over an object). (bzr r11893) --- src/display/canvas-arena.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 809f14500..8e25c1843 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -316,13 +316,17 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) ret = sp_canvas_arena_send_event (arena, event); break; - case GDK_SCROLL: - if (event->scroll.state & GDK_CONTROL_MASK) { + case GDK_SCROLL: { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); + bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); + if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { /* Zoom is emitted by the canvas as well, ignore here */ return FALSE; } ret = sp_canvas_arena_send_event (arena, event); break; + } default: /* Just send event */ -- cgit v1.2.3 From d6a0a9aad6bc34cb5c2fac14bd6c046b480e85ab Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 24 Nov 2012 17:20:08 +0900 Subject: Fix for 172236 : Dropper pixmaps and onetime fix (bzr r11894) --- src/dropper-context.cpp | 105 +++++++++++++++++++++++++++++++------- src/pixmaps/cursor-dropper-f.xpm | 38 ++++++++++++++ src/pixmaps/cursor-dropper-s.xpm | 38 ++++++++++++++ src/ui/dialog/fill-and-stroke.cpp | 25 +++++++++ src/ui/dialog/fill-and-stroke.h | 6 +++ 5 files changed, 194 insertions(+), 18 deletions(-) create mode 100644 src/pixmaps/cursor-dropper-f.xpm create mode 100644 src/pixmaps/cursor-dropper-s.xpm (limited to 'src') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 4742f5cff..8b293a9d9 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -32,6 +32,7 @@ #include "desktop-style.h" #include "preferences.h" #include "sp-namedview.h" +#include "sp-cursor.h" #include "desktop.h" #include "desktop-handles.h" #include "selection.h" @@ -39,6 +40,8 @@ #include "document-undo.h" #include "pixmaps/cursor-dropper.xpm" +#include "pixmaps/cursor-dropper-f.xpm" +#include "pixmaps/cursor-dropper-s.xpm" #include "dropper-context.h" #include "message-context.h" @@ -57,6 +60,9 @@ static gint sp_dropper_context_root_handler(SPEventContext *ec, GdkEvent * event static SPEventContextClass *parent_class; +static GdkCursor *cursor_dropper_fill = NULL; +static GdkCursor *cursor_dropper_stroke = NULL; + GType sp_dropper_context_get_type() { static GType type = 0; @@ -90,9 +96,13 @@ static void sp_dropper_context_class_init(SPDropperContextClass *klass) static void sp_dropper_context_init(SPDropperContext *dc) { SPEventContext *event_context = SP_EVENT_CONTEXT(dc); - event_context->cursor_shape = cursor_dropper_xpm; + event_context->cursor_shape = cursor_dropper_f_xpm; event_context->hot_x = 7; event_context->hot_y = 7; + + cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 7, 7); + cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7); + } static void sp_dropper_context_setup(SPEventContext *ec) @@ -143,6 +153,27 @@ static void sp_dropper_context_finish(SPEventContext *ec) sp_canvas_item_destroy(dc->area); dc->area = NULL; } + + if (cursor_dropper_fill) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor_dropper_fill); +#else + gdk_cursor_unref (cursor_dropper_fill); +#endif + cursor_dropper_fill = NULL; + } + if (cursor_dropper_stroke) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor_dropper_stroke); +#else + gdk_cursor_unref (cursor_dropper_stroke); +#endif + cursor_dropper_fill = NULL; + } + + //Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + //prefs->setBool("/tools/dropper/onetimepick", false); + } @@ -205,6 +236,13 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv } else if (!event_context->space_panning) { // otherwise, constantly calculate color no matter is any button pressed or not + // If one time pick with stroke set the pixmap + if (prefs->getBool("/tools/dropper/onetimepick", false) && prefs->getInt("/dialogs/fillstroke/page", 0) == 1) { + //TODO Only set when not set already + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop))); + gdk_window_set_cursor(window, cursor_dropper_stroke); + } + double rw = 0.0; double R(0), G(0), B(0), A(0); @@ -310,14 +348,24 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv double alpha_to_set = setalpha? dc->alpha : 1.0; + bool fill = !(event->button.state & GDK_SHIFT_MASK); // Stroke if Shift key held + if (prefs->getBool("/tools/dropper/onetimepick", false)) { + // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore key) + fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false; + } + // do the actual color setting sp_desktop_set_color(desktop, (event->button.state & GDK_MOD1_MASK)? ColorRGBA(1 - dc->R, 1 - dc->G, 1 - dc->B, alpha_to_set) : ColorRGBA(dc->R, dc->G, dc->B, alpha_to_set), - false, !(event->button.state & GDK_SHIFT_MASK)); + false, fill); // REJON: set aux. toolbar input to hex color! + if (event->button.state & GDK_SHIFT_MASK) { + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop))); + gdk_window_set_cursor(window, cursor_dropper_stroke); + } if (!(sp_desktop_selection(desktop)->isEmpty())) { DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER, @@ -332,25 +380,46 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv ret = TRUE; } break; - case GDK_KEY_PRESS: - switch (get_group0_keyval(&event->key)) { - case GDK_KEY_Up: - case GDK_KEY_Down: - case GDK_KEY_KP_Up: - case GDK_KEY_KP_Down: - // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) { - ret = TRUE; - } - break; - case GDK_KEY_Escape: - sp_desktop_selection(desktop)->clear(); - default: - break; + case GDK_KEY_PRESS: + switch (get_group0_keyval(&event->key)) { + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: + // prevent the zoom field from activation + if (!MOD__CTRL_ONLY) { + ret = TRUE; } break; - default: + case GDK_KEY_Escape: + sp_desktop_selection(desktop)->clear(); + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) { + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop))); + gdk_window_set_cursor(window, cursor_dropper_stroke); + } + break; + default: + break; + } + break; + case GDK_KEY_RELEASE: + switch (get_group0_keyval(&event->key)) { + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) { + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop))); + gdk_window_set_cursor(window, cursor_dropper_fill); + } + break; + default: + break; + } + break; + default: + break; } if (!ret) { diff --git a/src/pixmaps/cursor-dropper-f.xpm b/src/pixmaps/cursor-dropper-f.xpm new file mode 100644 index 000000000..3bf1e80e1 --- /dev/null +++ b/src/pixmaps/cursor-dropper-f.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_dropper_f_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ............", +" .+. .++++++++++.", +" .+. .+........+.", +" .+. .+........+.", +".... .... .+........+.", +".+++ +++. .+........+.", +".... .... .+........+.", +" .+. .+........+.", +" .+. .... .+........+.", +" .+. .+++. .+........+.", +" ... .+..+. .++++++++++.", +" .++..+. ............", +" .++..+. ", +" .++..+. ", +" .++..+. . ", +" .++..+.+. ", +" .++..+++. ", +" .++++.+. ", +" .++++.+.. ", +" .++++++.++. ", +" .++++++..+. ", +" ..+++++.+. ", +" .++++++. ", +" .+++++. ", +" .+++. ", +" ... ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/pixmaps/cursor-dropper-s.xpm b/src/pixmaps/cursor-dropper-s.xpm new file mode 100644 index 000000000..1a12934d8 --- /dev/null +++ b/src/pixmaps/cursor-dropper-s.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_dropper_s_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ............", +" .+. .+++.++.+++.", +" .+. .+........+.", +" .+. .+. .+.", +".... .... ... ...", +".+++ +++. .+. .+.", +".... .... .+. .+.", +" .+. ... ...", +" .+. .... .+. .+.", +" .+. .+++. .+........+.", +" ... .+..+. .+++.++.+++.", +" .++..+. ............", +" .++..+. ", +" .++..+. ", +" .++..+. . ", +" .++..+.+. ", +" .++..+++. ", +" .++++.+. ", +" .++++.+.. ", +" .++++++.++. ", +" .++++++..+. ", +" ..+++++.+. ", +" .++++++. ", +" .+++++. ", +" .+++. ", +" ... ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index c7efd3bf2..5ba4e7e39 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -22,6 +22,7 @@ #include "filter-chemistry.h" #include "inkscape.h" #include "selection.h" +#include "preferences.h" #include "style.h" #include "svg/css-ostringstream.h" #include "ui/icon-names.h" @@ -59,6 +60,8 @@ FillAndStroke::FillAndStroke() _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON("object-stroke"))); _notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON("object-stroke-style"))); + _notebook.signal_switch_page().connect(sigc::mem_fun(this, &FillAndStroke::_onSwitchPage)); + _layoutPageFill(); _layoutPageStrokePaint(); _layoutPageStrokeStyle(); @@ -105,6 +108,23 @@ void FillAndStroke::setTargetDesktop(SPDesktop *desktop) } } +#if WITH_GTKMM_3_0 +void FillAndStroke::_onSwitchPage(Gtk::Widget * /*page*/, guint pagenum) +#else +void FillAndStroke::_onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum) +#endif +{ + _savePagePref(pagenum); +} + +void +FillAndStroke::_savePagePref(guint page_num) +{ + // remember the current page + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/dialogs/fillstroke/page", page_num); +} + void FillAndStroke::_layoutPageFill() { @@ -133,6 +153,8 @@ FillAndStroke::showPageFill() { present(); _notebook.set_current_page(0); + _savePagePref(0); + } void @@ -140,6 +162,7 @@ FillAndStroke::showPageStrokePaint() { present(); _notebook.set_current_page(1); + _savePagePref(1); } void @@ -147,6 +170,8 @@ FillAndStroke::showPageStrokeStyle() { present(); _notebook.set_current_page(2); + _savePagePref(2); + } Gtk::HBox& diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index 596205c58..255cea89a 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -60,6 +60,12 @@ protected: void _layoutPageFill(); void _layoutPageStrokePaint(); void _layoutPageStrokeStyle(); + void _savePagePref(guint page_num); +#if WITH_GTKMM_3_0 + void _onSwitchPage(Gtk::Widget *page, guint pagenum); +#else + void _onSwitchPage(GtkNotebookPage *page, guint pagenum); +#endif private: FillAndStroke(FillAndStroke const &d); -- cgit v1.2.3 From 60141f6bdf22a0efad3baff5a944d15a2b28f728 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 25 Nov 2012 13:53:29 +0900 Subject: Fix for 1036059 : Keyboard shortcut editor (bzr r11895) --- src/extension/effect.h | 2 +- src/shortcuts.cpp | 524 ++++++++++++++++++++++++++++++++- src/shortcuts.h | 16 + src/ui/dialog/filedialog.cpp | 3 + src/ui/dialog/filedialog.h | 2 + src/ui/dialog/filedialogimpl-gtkmm.cpp | 21 +- src/ui/dialog/filedialogimpl-gtkmm.h | 1 + src/ui/dialog/filedialogimpl-win32.cpp | 72 ++++- src/ui/dialog/filedialogimpl-win32.h | 2 + src/ui/dialog/inkscape-preferences.cpp | 319 +++++++++++++++++++- src/ui/dialog/inkscape-preferences.h | 62 +++- src/verbs.cpp | 59 ++-- src/verbs.h | 19 +- 13 files changed, 1060 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/extension/effect.h b/src/extension/effect.h index bb36b9238..6616a23ec 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -67,7 +67,7 @@ class Effect : public Extension { gchar const * image, Effect * effect, bool showPrefs) : - Verb(id, _(name), _(tip), image), + Verb(id, _(name), _(tip), image, _("Extensions")), _effect(effect), _showPrefs(showPrefs), _elip_name(NULL) { diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index 796962b11..9ececbb3b 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "helper/action.h" #include "io/sys.h" @@ -36,12 +37,24 @@ #include "verbs.h" #include "xml/node-iterators.h" #include "xml/repr.h" +#include "document.h" +#include "preferences.h" +#include "event-context.h" +#include "inkscape.h" +#include "desktop.h" +#include "path-prefix.h" +#include "ui/dialog/filedialog.h" using namespace Inkscape; -static void sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary); +using Inkscape::IO::Resource::get_path; +using Inkscape::IO::Resource::SYSTEM; +using Inkscape::IO::Resource::USER; +using Inkscape::IO::Resource::KEYS; + + static void try_shortcuts_file(char const *filename); -static void read_shortcuts_file(char const *filename); +static void read_shortcuts_file(char const *filename, bool const is_user_set=false); /* Returns true if action was performed */ @@ -61,19 +74,22 @@ sp_shortcut_invoke(unsigned int shortcut, Inkscape::UI::View::View *view) static std::map *verbs = NULL; static std::map *primary_shortcuts = NULL; +static std::map *user_shortcuts = NULL; -static void -sp_shortcut_init() +void sp_shortcut_init() { - using Inkscape::IO::Resource::get_path; - using Inkscape::IO::Resource::SYSTEM; - using Inkscape::IO::Resource::USER; - using Inkscape::IO::Resource::KEYS; verbs = new std::map(); primary_shortcuts = new std::map(); + user_shortcuts = new std::map(); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring shortcutfile = prefs->getString("/options/kbshortcuts/shortcutfile"); + if (shortcutfile.empty()) { + shortcutfile = Glib::ustring(get_path(SYSTEM, KEYS, "default.xml")); + } - read_shortcuts_file(get_path(SYSTEM, KEYS, "default.xml")); + read_shortcuts_file(shortcutfile.c_str()); try_shortcuts_file(get_path(USER, KEYS, "default.xml")); } @@ -82,11 +98,451 @@ static void try_shortcuts_file(char const *filename) { /* ah, if only we had an exception to catch... (permission, forgiveness) */ if (file_test(filename, G_FILE_TEST_EXISTS)) { - read_shortcuts_file(filename); + read_shortcuts_file(filename, true); } } -static void read_shortcuts_file(char const *filename) { +/* + * Inkscape expects to add the Shift modifier to any accel_keys create with Shift + * For exmaple on en_US keyboard +6 = "&" - in this case return +& + * See get_group0_keyval() for explanation on why + */ +unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmodifier, guint hardware_keycode) { + + + unsigned int shortcut = 0; + GdkEventKey event; + event.state = gdkmodifier; + event.keyval = accel_key; + event.hardware_keycode = hardware_keycode; + guint keyval = get_group0_keyval (&event); + + shortcut = accel_key | + ( (gdkmodifier & GDK_SHIFT_MASK) || ( accel_key != keyval) ? + SP_SHORTCUT_SHIFT_MASK : 0 ) | + ( gdkmodifier & GDK_CONTROL_MASK ? + SP_SHORTCUT_CONTROL_MASK : 0 ) | + ( gdkmodifier & GDK_MOD1_MASK ? + SP_SHORTCUT_ALT_MASK : 0 ); + + return shortcut; +} + +Glib::ustring sp_shortcut_to_label(unsigned int const shortcut) { + + Glib::ustring modifiers = ""; + + if (shortcut & SP_SHORTCUT_CONTROL_MASK) + modifiers += "Ctrl,"; + if (shortcut & SP_SHORTCUT_SHIFT_MASK) + modifiers += "Shift,"; + if (shortcut & SP_SHORTCUT_ALT_MASK) + modifiers += "Alt,"; + + if(modifiers.length() > 0 && + modifiers.find(',',modifiers.length()-1)!=modifiers.npos) { + modifiers.erase(modifiers.length()-1, 1); + } + + return modifiers; +} + +/* + * REmove all shortucts from the users file + */ + +void sp_shortcuts_delete_all_from_file() { + + + char const *filename = get_path(USER, KEYS, "default.xml"); + + XML::Document *doc=sp_repr_read_file(filename, NULL); + if (!doc) { + g_warning("Unable to read keys file %s", filename); + return; + } + + XML::Node *root=doc->root(); + g_return_if_fail(!strcmp(root->name(), "keys")); + + XML::Node *iter=root->firstChild(); + while (iter) { + + if (strcmp(iter->name(), "bind")) { + // some unknown element, do not complain + iter = iter->next(); + continue; + } + + // Delete node + sp_repr_unparent(iter); + iter=root->firstChild(); + } + + + sp_repr_save_file(doc, filename, NULL); + + GC::release(doc); +} + +Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename) { + + gchar const *buffer = + " " + "" + ""; + + Inkscape::XML::Document *doc = sp_repr_read_mem(buffer, strlen(buffer), NULL); + sp_repr_save_file(doc, filename, NULL); + + return sp_repr_read_file(filename, NULL); +} + +/* + * Get a list of keyboard shortcut files names and paths from the system and users paths + * Dont add the users custom keyboards file + */ +void sp_shortcut_get_file_names(std::vector *names, std::vector *paths) { + + std::list sources; + sources.push_back( profile_path("keys") ); + sources.push_back( g_strdup(INKSCAPE_KEYSDIR) ); + + // loop through possible keyboard shortcut file locations. + while (!sources.empty()) { + gchar *dirname = sources.front(); + if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS ) + && Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) { + GError *err = 0; + GDir *directory = g_dir_open(dirname, 0, &err); + if (!directory) { + gchar *safeDir = Inkscape::IO::sanitizeString(dirname); + g_warning(_("Keyboard directory (%s) is unavailable."), safeDir); + g_free(safeDir); + } else { + gchar *filename = 0; + while ((filename = (gchar *) g_dir_read_name(directory)) != NULL) { + gchar* lower = g_ascii_strdown(filename, -1); + if (!strcmp(dirname, profile_path("keys")) && + !strcmp(lower, "default.xml")) { + // Dont add the users custom keys file + continue; + } + if (!strcmp(dirname, INKSCAPE_KEYSDIR) && + !strcmp(lower, "inkscape.xml")) { + // Dont add system inkscape.xml (since its a duplicate? of dfefault.xml) + continue; + } + if (g_str_has_suffix(lower, ".xml")) { + gchar* full = g_build_filename(dirname, filename, NULL); + if (!Inkscape::IO::file_test(full, G_FILE_TEST_IS_DIR)) { + + // Get the "key name" from the root element of each file + XML::Document *doc=sp_repr_read_file(full, NULL); + if (!doc) { + g_warning("Unable to read keyboard shortcut file %s", full); + continue; + } + XML::Node *root=doc->root(); + if (strcmp(root->name(), "keys")) { + g_warning("Not a shortcut keys file %s", full); + Inkscape::GC::release(doc); + continue; + } + + gchar const *name=root->attribute("name"); + Glib::ustring label(filename); + if (name) { + label = Glib::ustring(name)+ " (" + filename + ")"; + } + + if (!strcmp(filename, "default.xml")) { + paths->insert(paths->begin(), full); + names->insert(names->begin(), label.c_str()); + } else { + paths->push_back(full); + names->push_back(label.c_str()); + } + + Inkscape::GC::release(doc); + } + g_free(full); + } + g_free(lower); + } + g_dir_close(directory); + } + } + + g_free(dirname); + sources.pop_front(); + } + +} + +Glib::ustring sp_shortcut_get_file_path() +{ + //# Get the current directory for finding files + Glib::ustring open_path; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + Glib::ustring attr = prefs->getString("/dialogs/save_export/path"); + if (!attr.empty()) open_path = attr; + + //# Test if the open_path directory exists + if (!Inkscape::IO::file_test(open_path.c_str(), + (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + open_path = ""; + + if (open_path.empty()) { + /* Grab document directory */ + const gchar* docURI = SP_ACTIVE_DOCUMENT->getURI(); + if (docURI) { + open_path = Glib::path_get_dirname(docURI); + open_path.append(G_DIR_SEPARATOR_S); + } + } + + //# If no open path, default to our home directory + if (open_path.empty()) + { + open_path = g_get_home_dir(); + open_path.append(G_DIR_SEPARATOR_S); + } + + return open_path; +} + +//static Inkscape::UI::Dialog::FileSaveDialog * saveDialog = NULL; + +void sp_shortcut_file_export() +{ + Glib::ustring open_path = sp_shortcut_get_file_path(); + open_path.append("shortcut_keys.xml"); + + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + Glib::ustring filename; + + Inkscape::UI::Dialog::FileSaveDialog *saveDialog = + Inkscape::UI::Dialog::FileSaveDialog::create( + *(desktop->getToplevel()), + open_path, + Inkscape::UI::Dialog::CUSTOM_TYPE, + _("Select a filename for exporting"), + "", + "", + Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS + ); + saveDialog->addFileType("All Files", "*"); + + bool success = saveDialog->show(); + if (!success) { + delete saveDialog; + return; + } + + Glib::ustring fileName = saveDialog->getFilename(); + if (fileName.size() > 0) { + Glib::ustring newFileName = Glib::filename_to_utf8(fileName); + sp_shortcut_file_export_do(newFileName.c_str()); + } + + delete saveDialog; +} + +bool sp_shortcut_file_import() { + + Glib::ustring open_path = sp_shortcut_get_file_path(); + + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + + Inkscape::UI::Dialog::FileOpenDialog *importFileDialog = + Inkscape::UI::Dialog::FileOpenDialog::create( + *desktop->getToplevel(), + open_path, + Inkscape::UI::Dialog::CUSTOM_TYPE, + _("Select a file to import")); + importFileDialog->addFilterMenu("All Files", "*"); + + //# Show the dialog + bool const success = importFileDialog->show(); + + if (!success) { + delete importFileDialog; + return false; + } + + Glib::ustring fileName = importFileDialog->getFilename(); + sp_shortcut_file_import_do(fileName.c_str()); + + delete importFileDialog; + + return true; +} + +void sp_shortcut_file_import_do(char const *importname) { + + XML::Document *doc=sp_repr_read_file(importname, NULL); + if (!doc) { + g_warning("Unable to read keyboard shortcut file %s", importname); + return; + } + + char const *filename = get_path(USER, KEYS, "default.xml"); + sp_repr_save_file(doc, filename, NULL); + + GC::release(doc); + + sp_shortcut_init(); +} + +void sp_shortcut_file_export_do(char const *exportname) { + + char const *filename = get_path(USER, KEYS, "default.xml"); + + XML::Document *doc=sp_repr_read_file(filename, NULL); + if (!doc) { + g_warning("Unable to read keyboard shortcut file %s", filename); + return; + } + + sp_repr_save_file(doc, exportname, NULL); + + GC::release(doc); +} +/* + * Add or delete a shortcut to the users default.xml keys file + * @param addremove - when true add/override a shortcut, when false remove shortcut + * @param addshift - when true addthe Shifg modifier to the non-display element + * + * Shortcut file consists of pairs of bind elements : + * Element (a) is used for shortcut display in menus (display="True") and contains the gdk_keyval_name of the shortcut key + * Element (b) is used in shortcut lookup and contains an uppercase version of the gdk_keyval_name, + * or a gdk_keyval_name name and the "Shift" modifier for Shift altered hardware code keys (see get_group0_keyval() for explanation) + */ +void sp_shortcut_delete_from_file(char const *action, unsigned int const shortcut) { + + char const *filename = get_path(USER, KEYS, "default.xml"); + + XML::Document *doc=sp_repr_read_file(filename, NULL); + if (!doc) { + g_warning("Unable to read keyboard shortcut file %s", filename); + return; + } + + gchar *key = gdk_keyval_name (shortcut & (~SP_SHORTCUT_MODIFIER_MASK)); + std::string modifiers = sp_shortcut_to_label(shortcut & (SP_SHORTCUT_MODIFIER_MASK)); + + if (!key) { + g_warning("Unknown key for shortcut %u", shortcut); + return; + } + + //g_message("Removing key %s, mods %s action %s", key, modifiers.c_str(), action); + + XML::Node *root=doc->root(); + g_return_if_fail(!strcmp(root->name(), "keys")); + XML::Node *iter=root->firstChild(); + while (iter) { + + if (strcmp(iter->name(), "bind")) { + // some unknown element, do not complain + iter = iter->next(); + continue; + } + + gchar const *verb_name=iter->attribute("action"); + if (!verb_name) { + iter = iter->next(); + continue; + } + + gchar const *keyval_name = iter->attribute("key"); + if (!keyval_name || !*keyval_name) { + // that's ok, it's just listed for reference without assignment, skip it + iter = iter->next(); + continue; + } + + if (Glib::ustring(key).lowercase() != Glib::ustring(keyval_name).lowercase()) { + // If deleting, then delete both the upper and lower case versions + iter = iter->next(); + continue; + } + + gchar const *modifiers_string = iter->attribute("modifiers"); + if ((modifiers_string && !strcmp(modifiers.c_str(), modifiers_string)) || + (!modifiers_string && modifiers.empty())) { + //Looks like a match + // Delete node + sp_repr_unparent(iter); + iter = root->firstChild(); + continue; + } + iter = iter->next(); + } + + sp_repr_save_file(doc, filename, NULL); + + GC::release(doc); + +} + +void sp_shortcut_add_to_file(char const *action, unsigned int const shortcut) { + + char const *filename = get_path(USER, KEYS, "default.xml"); + + XML::Document *doc=sp_repr_read_file(filename, NULL); + if (!doc) { + g_warning("Unable to read keyboard shortcut file %s, creating ....", filename); + doc = sp_shortcut_create_template_file(filename); + if (!doc) { + g_warning("Unable to create keyboard shortcut file %s", filename); + return; + } + } + + gchar *key = gdk_keyval_name (shortcut & (~SP_SHORTCUT_MODIFIER_MASK)); + std::string modifiers = sp_shortcut_to_label(shortcut & (SP_SHORTCUT_MODIFIER_MASK)); + + if (!key) { + g_warning("Unknown key for shortcut %u", shortcut); + return; + } + + //g_message("Adding key %s, mods %s action %s", key, modifiers.c_str(), action); + + // Add node + Inkscape::XML::Node *newnode; + newnode = doc->createElement("bind"); + newnode->setAttribute("key", key); + if (!modifiers.empty()) { + newnode->setAttribute("modifiers", modifiers.c_str()); + } + newnode->setAttribute("action", action); + newnode->setAttribute("display", "true"); + + doc->root()->appendChild(newnode); + + if (strlen(key) == 1) { + // Add another uppercase version if a character + Inkscape::XML::Node *newnode; + newnode = doc->createElement("bind"); + newnode->setAttribute("key", Glib::ustring(key).uppercase().c_str()); + if (!modifiers.empty()) { + newnode->setAttribute("modifiers", modifiers.c_str()); + } + + newnode->setAttribute("action", action); + doc->root()->appendChild(newnode); + } + + sp_repr_save_file(doc, filename, NULL); + + GC::release(doc); + +} +static void read_shortcuts_file(char const *filename, bool const is_user_set) { XML::Document *doc=sp_repr_read_file(filename, NULL); if (!doc) { g_warning("Unable to read keys file %s", filename); @@ -153,12 +609,36 @@ static void read_shortcuts_file(char const *filename) { } } - sp_shortcut_set(keyval | modifiers, verb, is_primary); + sp_shortcut_set(keyval | modifiers, verb, is_primary, is_user_set); } GC::release(doc); } +/** + * Removes a keyboard shortcut for the given verb. + * (Removes any existing binding for the given shortcut, including appropriately + * adjusting sp_shortcut_get_primary if necessary.)* + */ +void +sp_shortcut_unset(unsigned int const shortcut) +{ + if (!verbs) sp_shortcut_init(); + + Inkscape::Verb *verb = (*verbs)[shortcut]; + + /* Maintain the invariant that sp_shortcut_get_primary(v) returns either 0 or a valid shortcut for v. */ + if (verb) { + + (*verbs)[shortcut] = 0; + + unsigned int const old_primary = (*primary_shortcuts)[verb]; + if (old_primary == shortcut) { + (*primary_shortcuts)[verb] = 0; + } + + } +} /** * Adds a keyboard shortcut for the given verb. * (Removes any existing binding for the given shortcut, including appropriately @@ -169,8 +649,8 @@ static void read_shortcuts_file(char const *filename) { * \post sp_shortcut_get_verb(shortcut) == verb. * \post !is_primary or sp_shortcut_get_primary(verb) == shortcut. */ -static void -sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary) +void +sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary, bool const is_user_set) { if (!verbs) sp_shortcut_init(); @@ -183,11 +663,13 @@ sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool co if (old_primary == shortcut) { (*primary_shortcuts)[old_verb] = 0; + (*user_shortcuts)[old_verb] = 0; } } if (is_primary) { (*primary_shortcuts)[verb] = shortcut; + (*user_shortcuts)[verb] = is_user_set; } } @@ -211,6 +693,20 @@ unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) return result; } +bool sp_shortcut_is_user_set(Inkscape::Verb *verb) +{ + unsigned int result = false; + if (!primary_shortcuts) { + sp_shortcut_init(); + } + + if (primary_shortcuts->count(verb)) { + result = (*user_shortcuts)[verb]; + } + return result; +} + + gchar *sp_shortcut_get_label(unsigned int shortcut) { // The comment below was copied from the function sp_ui_shortcut_string in interface.cpp (which was subsequently removed) diff --git a/src/shortcuts.h b/src/shortcuts.h index 9d84aa6d1..118909bd3 100644 --- a/src/shortcuts.h +++ b/src/shortcuts.h @@ -1,6 +1,8 @@ #ifndef __SP_SHORTCUTS_H__ #define __SP_SHORTCUTS_H__ +#include + /* * Keyboard shortcut processing * @@ -29,9 +31,23 @@ namespace Inkscape { /* Returns true if action was performed */ bool sp_shortcut_invoke (unsigned int shortcut, Inkscape::UI::View::View *view); +void sp_shortcut_init(); Inkscape::Verb * sp_shortcut_get_verb (unsigned int shortcut); unsigned int sp_shortcut_get_primary (Inkscape::Verb * verb); // Returns GDK_VoidSymbol if no shortcut is found. char* sp_shortcut_get_label (unsigned int shortcut); // Returns the human readable form of the shortcut (or NULL), for example Shift+Ctrl+F. Free the returned string with g_free. +void sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary, bool const is_user_set=false); +void sp_shortcut_unset(unsigned int const shortcut); +void sp_shortcut_add_to_file(char const *action, unsigned int const shortcut); +void sp_shortcut_delete_from_file(char const *action, unsigned int const shortcut); +void sp_shortcuts_delete_all_from_file(); +Glib::ustring sp_shortcut_to_label(unsigned int const shortcut); +unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmodifier, guint hardware_keycode); +void sp_shortcut_get_file_names(std::vector *names, std::vector *paths); +bool sp_shortcut_is_user_set(Inkscape::Verb *verb); +void sp_shortcut_file_export(); +bool sp_shortcut_file_import(); +void sp_shortcut_file_import_do(char const *importname); +void sp_shortcut_file_export_do(char const *exportname); #endif diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 47ba6c748..b3af6fc00 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -152,6 +152,9 @@ Glib::ustring FileSaveDialog::getDocTitle() void FileSaveDialog::appendExtension(Glib::ustring& path, Inkscape::Extension::Output* outputExtension) { + if (!outputExtension) + return; + try { bool appendExtension = true; Glib::ustring utf8Name = Glib::filename_to_utf8( path ); diff --git a/src/ui/dialog/filedialog.h b/src/ui/dialog/filedialog.h index 6a3436aea..63cee6bdc 100644 --- a/src/ui/dialog/filedialog.h +++ b/src/ui/dialog/filedialog.h @@ -208,6 +208,8 @@ public: virtual Glib::ustring getCurrentDirectory() = 0; + virtual void addFileType(Glib::ustring name, Glib::ustring pattern) = 0; + protected: /** diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 8c2a7e056..90d9855ec 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1047,7 +1047,9 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, fileTypeCheckbox.set_active(prefs->getBool("/dialogs/save_as/append_extension", true)); } - createFileTypeMenu(); + if (_dialogType != CUSTOM_TYPE) + createFileTypeMenu(); + fileTypeComboBox.set_size_request(200,40); fileTypeComboBox.signal_changed().connect( sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileTypeChangedCallback) ); @@ -1174,7 +1176,24 @@ void FileSaveDialogImplGtk::fileTypeChangedCallback() updateNameAndExtension(); } +void FileSaveDialogImplGtk::addFileType(Glib::ustring name, Glib::ustring pattern) +{ + //#Let user choose + FileType guessType; + guessType.name = name; + guessType.pattern = pattern; + guessType.extension = NULL; + #if WITH_GTKMM_2_24 + fileTypeComboBox.append(guessType.name); + #else + fileTypeComboBox.append_text(guessType.name); + #endif + fileTypes.push_back(guessType); + + fileTypeComboBox.set_active(0); + fileTypeChangedCallback(); //call at least once to set the filter +} void FileSaveDialogImplGtk::createFileTypeMenu() { diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index 02841a082..7501b5e14 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -291,6 +291,7 @@ public: virtual void setSelectionType( Inkscape::Extension::Extension * key ); Glib::ustring getCurrentDirectory(); + void addFileType(Glib::ustring name, Glib::ustring pattern); private: //void change_title(const Glib::ustring& title); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 5891f25ac..6425d9fee 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -188,7 +188,8 @@ FileOpenDialogImplWin32::FileOpenDialogImplWin32(Gtk::Window &parent, _mutex = NULL; - createFilterMenu(); + if (dialogType != CUSTOM_TYPE) + createFilterMenu(); } @@ -1748,6 +1749,72 @@ void FileSaveDialogImplWin32::createFilterMenu() _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd } + +void FileSaveDialogImplWin32::addFileType(Glib::ustring name, Glib::ustring pattern) +{ + list filter_list; + + knownExtensions.clear(); + + int extension_index = 0; + int filter_length = 1; + + ustring all_exe_files_filter = pattern; + Filter all_exe_files; + + const gchar *all_exe_files_filter_name = name.data(); + + // Calculate the amount of memory required + int filter_count = 1; + + + // Filter Executable Files + all_exe_files.name = g_utf8_to_utf16(all_exe_files_filter_name, + -1, NULL, &all_exe_files.name_length, NULL); + all_exe_files.filter = g_utf8_to_utf16(all_exe_files_filter.data(), + -1, NULL, &all_exe_files.filter_length, NULL); + all_exe_files.mod = NULL; + filter_list.push_front(all_exe_files); + + knownExtensions.insert( Glib::ustring(all_exe_files_filter).casefold() ); + + _extension_map = new Inkscape::Extension::Extension*[filter_count]; + + _filter = new wchar_t[filter_length]; + wchar_t *filterptr = _filter; + + for(list::iterator filter_iterator = filter_list.begin(); + filter_iterator != filter_list.end(); ++filter_iterator) + { + const Filter &filter = *filter_iterator; + + wcsncpy(filterptr, (wchar_t*)filter.name, filter.name_length); + filterptr += filter.name_length; + g_free(filter.name); + + *(filterptr++) = L'\0'; + *(filterptr++) = L'*'; + + if(filter.filter != NULL) + { + wcsncpy(filterptr, (wchar_t*)filter.filter, filter.filter_length); + filterptr += filter.filter_length; + g_free(filter.filter); + } + + *(filterptr++) = L'\0'; + + // Associate this input extension with the file type name + _extension_map[extension_index++] = filter.mod; + } + *(filterptr++) = L'\0'; + + _filter_count = extension_index; + _filter_index = 1; // Select the 1st filter in the list + + +} + void FileSaveDialogImplWin32::GetSaveFileName_thread() { OPENFILENAMEEXW ofn; @@ -1814,7 +1881,7 @@ FileSaveDialogImplWin32::show() if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) g_main_loop_run(_main_loop); - if(_result) + if(_result && _extension) appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); } @@ -1827,6 +1894,7 @@ void FileSaveDialogImplWin32::setSelectionType( Inkscape::Extension::Extension * } + UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc( HWND hdlg, UINT uiMsg, WPARAM, LPARAM lParam) { diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index d016b0a24..15953f9d8 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -343,6 +343,8 @@ public: virtual void setSelectionType( Inkscape::Extension::Extension *key ); + virtual void addFileType(Glib::ustring name, Glib::ustring pattern); + private: /// A handle to the title label and edit box HWND _title_label; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2731b6174..03366a0c3 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -47,7 +47,11 @@ #include "display/canvas-grid.h" #include "path-prefix.h" #include "io/resource.h" +#include "io/sys.h" #include "inkscape.h" +#include "shortcuts.h" +#include "document.h" + #ifdef HAVE_ASPELL # include @@ -137,6 +141,7 @@ InkscapePreferences::InkscapePreferences() initPageRendering(); initPageSpellcheck(); + signalPresent().connect(sigc::mem_fun(*this, &InkscapePreferences::_presentPages)); //calculate the size request for this dialog @@ -741,6 +746,8 @@ void InkscapePreferences::initPageUI() _grids_axonom.add_line( false, _("Major grid line every:"), _grids_axonom_empspacing, "", "", false); this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS); + + initKeyboardShortcuts(iter_ui); } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -1405,6 +1412,316 @@ void InkscapePreferences::initPageBitmaps() this->AddPage(_page_bitmaps, _("Bitmaps"), PREFS_PAGE_BITMAPS); } +void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui) +{ + std::vector fileNames; + std::vector fileLabels; + + sp_shortcut_get_file_names(&fileLabels, &fileNames); + + _kb_filelist.init( "/options/kbshortcuts/shortcutfile", &fileLabels[0], &fileNames[0], fileLabels.size(), fileNames[0]); + + Glib::ustring tooltip(_("Select a file of predefined shortcuts to use. Any customized shortcuts you create will be added seperately to ")); + tooltip += Glib::ustring(IO::Resource::get_path(IO::Resource::USER, IO::Resource::KEYS, "default.xml")); + + _page_keyshortcuts.add_line( false, _("Shortcut file:"), _kb_filelist, "", tooltip.c_str(), false); + + _kb_search.init("/options/kbshortcuts/value", true); + _page_keyshortcuts.add_line( false, _("Search:"), _kb_search, "", "", true); + + _kb_store = Gtk::TreeStore::create( _kb_columns ); + _kb_store->set_sort_column (_kb_columns.id, Gtk::SORT_ASCENDING ); + + _kb_filter = Gtk::TreeModelFilter::create(_kb_store); + _kb_filter->set_visible_func (sigc::mem_fun(*this, &InkscapePreferences::onKBSearchFilter)); + + _kb_shortcut_renderer.property_editable() = true; + + _kb_tree.set_model(_kb_filter); + _kb_tree.append_column(_("Name"), _kb_columns.name); + _kb_tree.append_column(_("Shortcut"), _kb_shortcut_renderer); + _kb_tree.append_column(_("Description"), _kb_columns.description); + _kb_tree.append_column(_("ID"), _kb_columns.id); + + _kb_tree.set_expander_column(*_kb_tree.get_column(0)); + + _kb_tree.get_column(0)->set_resizable(true); + _kb_tree.get_column(0)->set_clickable(true); + _kb_tree.get_column(0)->set_fixed_width (200); + + _kb_tree.get_column(1)->set_resizable(true); + _kb_tree.get_column(1)->set_clickable(true); + _kb_tree.get_column(1)->set_fixed_width (150); + //_kb_tree.get_column(1)->add_attribute(_kb_shortcut_renderer.property_text(), _kb_columns.shortcut); + _kb_tree.get_column(1)->set_cell_data_func(_kb_shortcut_renderer, sigc::ptr_fun(InkscapePreferences::onKBShortcutRenderer)); + + _kb_tree.get_column(2)->set_resizable(true); + _kb_tree.get_column(2)->set_clickable(true); + + _kb_tree.get_column(3)->set_resizable(true); + _kb_tree.get_column(3)->set_clickable(true); + + _kb_shortcut_renderer.signal_accel_edited().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBTreeEdited) ); + _kb_shortcut_renderer.signal_accel_cleared().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBTreeCleared) ); + + Gtk::ScrolledWindow* scroller = new Gtk::ScrolledWindow(); + scroller->add(_kb_tree); + + int row = 3; + _page_keyshortcuts.attach(*scroller, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL); + row++; + + Gtk::HButtonBox *box_buttons = manage (new Gtk::HButtonBox); + box_buttons->set_layout(Gtk::BUTTONBOX_END); + box_buttons->set_spacing(4); + _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); + + 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"))); + 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"))); + 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"))); + box_buttons->pack_end(*kb_export, true, true, 6); + + kb_reset->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBReset) ); + kb_import->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBImport) ); + kb_export->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBExport) ); + _kb_search.signal_key_release_event().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBSearchKeyEvent) ); + _kb_filelist.signal_changed().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBList) ); + _page_keyshortcuts.signal_realize().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBRealize) ); + + this->AddPage(_page_keyshortcuts, _("Keyboard Shortcuts"), iter_ui, PREFS_PAGE_UI_KEYBOARD_SHORTCUTS); + + _kb_shortcuts_loaded = false; + Gtk::TreeStore::iterator iter_group = _kb_store->append(); + (*iter_group)[_kb_columns.name] = "Loading ..."; + (*iter_group)[_kb_columns.shortcut] = ""; + (*iter_group)[_kb_columns.id] = ""; + (*iter_group)[_kb_columns.description] = ""; + (*iter_group)[_kb_columns.shortcutid] = 0; + (*iter_group)[_kb_columns.user_set] = 0; + +} + +void InkscapePreferences::onKBList() +{ + sp_shortcut_init(); + onKBListKeyboardShortcuts(); +} + +void InkscapePreferences::onKBReset() +{ + sp_shortcuts_delete_all_from_file(); + sp_shortcut_init(); + onKBListKeyboardShortcuts(); +} + +void InkscapePreferences::onKBImport() +{ + if (sp_shortcut_file_import()) { + onKBListKeyboardShortcuts(); + } +} + +void InkscapePreferences::onKBExport() +{ + sp_shortcut_file_export(); +} + +bool InkscapePreferences::onKBSearchKeyEvent(GdkEventKey *event) +{ + _kb_filter->refilter(); + return FALSE; +} + +void InkscapePreferences::onKBTreeCleared(const Glib::ustring& path) +{ + Gtk::TreeModel::iterator iter = _kb_filter->get_iter(path); + Glib::ustring id = (*iter)[_kb_columns.id]; + unsigned int const current_shortcut_id = (*iter)[_kb_columns.shortcutid]; + + // Remove current shortcut from file + sp_shortcut_delete_from_file(id.c_str(), current_shortcut_id); + + sp_shortcut_init(); + onKBListKeyboardShortcuts(); + +} + +void InkscapePreferences::onKBTreeEdited (const Glib::ustring& path, guint accel_key, Gdk::ModifierType accel_mods, guint hardware_keycode) +{ + Gtk::TreeModel::iterator iter = _kb_filter->get_iter(path); + + Glib::ustring id = (*iter)[_kb_columns.id]; + Glib::ustring current_shortcut = (*iter)[_kb_columns.shortcut]; + unsigned int const current_shortcut_id = (*iter)[_kb_columns.shortcutid]; + + Inkscape::Verb *const verb = Inkscape::Verb::getbyid(id.c_str()); + if (!verb) { + return; + } + + unsigned int const new_shortcut_id = sp_gdkmodifier_to_shortcut(accel_key, accel_mods, hardware_keycode); + if (new_shortcut_id) { + + // Delete current shortcut if it existed + sp_shortcut_delete_from_file(id.c_str(), current_shortcut_id); + // Delete any references to the new shortcut + sp_shortcut_delete_from_file(id.c_str(), new_shortcut_id); + // Add the new shortcut + sp_shortcut_add_to_file(id.c_str(), new_shortcut_id); + + sp_shortcut_init(); + onKBListKeyboardShortcuts(); + } +} + +bool InkscapePreferences::onKBSearchFilter(const Gtk::TreeModel::const_iterator& iter) +{ + Glib::ustring search = _kb_search.get_text().lowercase(); + if (search.empty()) { + return TRUE; + } + + Glib::ustring name = (*iter)[_kb_columns.name]; + Glib::ustring desc = (*iter)[_kb_columns.description]; + Glib::ustring shortcut = (*iter)[_kb_columns.shortcut]; + Glib::ustring id = (*iter)[_kb_columns.id]; + + if (id.empty()) { + return TRUE; // Keep all group nodes visible + } + + return (name.lowercase().find(search) != name.npos + || shortcut.lowercase().find(search) != name.npos + || desc.lowercase().find(search) != name.npos + || id.lowercase().find(search) != name.npos); +} + +void InkscapePreferences::onKBRealize() +{ + if (!_kb_shortcuts_loaded /*&& _current_page == &_page_keyshortcuts*/) { + _kb_shortcuts_loaded = true; + onKBListKeyboardShortcuts(); + } +} + +InkscapePreferences::ModelColumns &InkscapePreferences::onKBGetCols() +{ + static InkscapePreferences::ModelColumns cols; + return cols; +} + +void InkscapePreferences::onKBShortcutRenderer(Gtk::CellRenderer *renderer, Gtk::TreeIter const &iter) { + + Glib::ustring shortcut = (*iter)[onKBGetCols().shortcut]; + unsigned int user_set = (*iter)[onKBGetCols().user_set]; + Gtk::CellRendererAccel *accel = dynamic_cast(renderer); + if (user_set) { + accel->property_markup() = Glib::ustring(" " + shortcut + " ").c_str(); + } else { + accel->property_markup() = Glib::ustring(" " + shortcut + " ").c_str(); + } +} + +void InkscapePreferences::onKBListKeyboardShortcuts() +{ + // Save the current selection + Gtk::TreeStore::iterator iter = _kb_tree.get_selection()->get_selected(); + Glib::ustring selected_id = ""; + if (iter) { + selected_id = (*iter)[_kb_columns.id]; + } + + _kb_store->clear(); + + std::vectorverbs = Inkscape::Verb::getList(); + + for (unsigned int i = 0; i < verbs.size(); i++) { + + Inkscape::Verb* verb = verbs[i]; + if (!verb) { + continue; + } + if (!verb->get_name()){ + continue; + } + + Gtk::TreeStore::Path path; + if (_kb_store->iter_is_valid(_kb_store->get_iter("0"))) { + path = _kb_store->get_path(_kb_store->get_iter("0")); + } + + // Find this group in the tree + Glib::ustring group = verb->get_group() ? verb->get_group() : "Misc"; + Gtk::TreeStore::iterator iter_group; + bool found = false; + while (path) { + iter_group = _kb_store->get_iter(path); + if (!_kb_store->iter_is_valid(iter_group)) { + break; + } + Glib::ustring name = (*iter_group)[_kb_columns.name]; + if ((*iter_group)[_kb_columns.name] == group) { + found = true; + break; + } + path.next(); + } + + if (!found) { + // Add the group if not there + iter_group = _kb_store->append(); + (*iter_group)[_kb_columns.name] = group; + (*iter_group)[_kb_columns.shortcut] = ""; + (*iter_group)[_kb_columns.id] = ""; + (*iter_group)[_kb_columns.description] = ""; + (*iter_group)[_kb_columns.shortcutid] = 0; + (*iter_group)[_kb_columns.user_set] = 0; + } + + // Remove the key accelerators from the verb name + Glib::ustring name = verb->get_name(); + std::string::size_type k = 0; + while((k=name.find('_',k))!=name.npos) { + name.erase(k, 1); + } + + // Get the shortcut label + unsigned int shortcut_id = sp_shortcut_get_primary(verb); + Glib::ustring shortcut_label = ""; + if (shortcut_id != GDK_KEY_VoidSymbol) { + gchar* str = sp_shortcut_get_label(shortcut_id); + if (str) { + shortcut_label = str; + g_free(str); + str = 0; + } + } + // Add the verb to the group + Gtk::TreeStore::iterator row = _kb_store->append(iter_group->children()); + (*row)[_kb_columns.name] = name; + (*row)[_kb_columns.shortcut] = shortcut_label; + (*row)[_kb_columns.description] = verb->get_short_tip() ? verb->get_short_tip() : ""; + (*row)[_kb_columns.shortcutid] = shortcut_id; + (*row)[_kb_columns.id] = verb->get_id(); + (*row)[_kb_columns.user_set] = sp_shortcut_is_user_set(verb); + + if (selected_id == verb->get_id()) { + Gtk::TreeStore::Path sel_path = _kb_filter->convert_child_path_to_path(_kb_store->get_path(row)); + _kb_tree.expand_to_path(sel_path); + _kb_tree.get_selection()->select(sel_path); + } + } + + if (selected_id.empty()) { + _kb_tree.expand_to_path(_kb_store->get_path(_kb_store->get_iter("0:1"))); + } + +} void InkscapePreferences::initPageSpellcheck() { @@ -1609,7 +1926,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) _page_list.expand_row(_path_tools, false); if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL) _page_list.expand_row(_path_shapes, false); - if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_GRIDS) + if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_KEYBOARD_SHORTCUTS) _page_list.expand_row(_path_ui, false); if (desired_page >= PREFS_PAGE_BEHAVIOR && desired_page <= PREFS_PAGE_BEHAVIOR_MASKS) _page_list.expand_row(_path_behavior, false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index d60035515..690016556 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -18,15 +18,19 @@ #include #include #include "ui/widget/preferences-widget.h" +#include "ui/widget/button.h" +#include #include #include #include #include #include #include -#include #include #include +#include +#include +#include #include "ui/widget/panel.h" @@ -60,6 +64,7 @@ enum { PREFS_PAGE_UI, PREFS_PAGE_UI_WINDOWS, PREFS_PAGE_UI_GRIDS, + PREFS_PAGE_UI_KEYBOARD_SHORTCUTS, PREFS_PAGE_BEHAVIOR, PREFS_PAGE_BEHAVIOR_SELECTING, PREFS_PAGE_BEHAVIOR_TRANSFORMS, @@ -79,6 +84,7 @@ enum { PREFS_PAGE_BITMAPS, PREFS_PAGE_RENDERING, PREFS_PAGE_SPELLCHECK + }; namespace Inkscape { @@ -166,6 +172,8 @@ protected: UI::Widget::DialogPage _page_bitmaps; UI::Widget::DialogPage _page_spellcheck; + UI::Widget::DialogPage _page_keyshortcuts; + UI::Widget::PrefSpinButton _mouse_sens; UI::Widget::PrefSpinButton _mouse_thres; UI::Widget::PrefSlider _mouse_grabsize; @@ -337,12 +345,16 @@ protected: UI::Widget::PrefCheckButton _spell_ignorenumbers; UI::Widget::PrefCheckButton _spell_ignoreallcaps; + UI::Widget::PrefCombo _misc_overs_bitmap; UI::Widget::PrefEntryFileButtonHBox _misc_bitmap_editor; UI::Widget::PrefCheckButton _misc_bitmap_autoreload; UI::Widget::PrefSpinButton _bitmap_copy_res; UI::Widget::PrefCombo _bitmap_import; + UI::Widget::PrefEntry _kb_search; + UI::Widget::PrefCombo _kb_filelist; + UI::Widget::PrefCheckButton _save_use_current_dir; UI::Widget::PrefCheckButton _save_autosave_enable; UI::Widget::PrefSpinButton _save_autosave_interval; @@ -411,6 +423,37 @@ protected: UI::Widget::PrefEntry _importexport_ocal_username; UI::Widget::PrefEntry _importexport_ocal_password; + /* + * Keyboard shortcut members + */ + class ModelColumns: public Gtk::TreeModel::ColumnRecord { + public: + ModelColumns() { + add(name); + add(id); + add(shortcut); + add(description); + add(shortcutid); + add(user_set); + } + virtual ~ModelColumns() { + } + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn id; + Gtk::TreeModelColumn shortcut; + Gtk::TreeModelColumn description; + Gtk::TreeModelColumn shortcutid; + Gtk::TreeModelColumn user_set; + }; + ModelColumns _kb_columns; + static ModelColumns &onKBGetCols(); + Glib::RefPtr _kb_store; + Gtk::TreeView _kb_tree; + Gtk::CellRendererAccel _kb_shortcut_renderer; + Glib::RefPtr _kb_filter; + gboolean _kb_shortcuts_loaded; + int _max_dialog_width; int _max_dialog_height; int _sb_width; @@ -441,9 +484,26 @@ protected: void initPageBitmaps(); void initPageSystem(); void initPageI18n(); // Do we still need it? + void initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui); void _presentPages(); + /* + * Functions for the Keyboard shortcut editor panel + */ + void onKBReset(); + void onKBImport(); + void onKBExport(); + void onKBList(); + void onKBRealize(); + void onKBListKeyboardShortcuts(); + void onKBTreeEdited (const Glib::ustring& path, guint accel_key, Gdk::ModifierType accel_mods, guint hardware_keycode); + void onKBTreeCleared(const Glib::ustring& path_string); + bool onKBSearchKeyEvent(GdkEventKey *event); + bool onKBSearchFilter(const Gtk::TreeModel::const_iterator& iter); + static void onKBShortcutRenderer(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter); + + private: InkscapePreferences(); InkscapePreferences(InkscapePreferences const &d); diff --git a/src/verbs.cpp b/src/verbs.cpp index 8c45ce665..bbadb1a25 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -133,7 +133,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("File")) { } }; // FileVerb class @@ -152,7 +152,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Edit")) { } }; // EditVerb class @@ -171,7 +171,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Selection")) { } }; // SelectionVerb class @@ -190,7 +190,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Layer")) { } }; // LayerVerb class @@ -209,7 +209,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Object")) { } }; // ObjectVerb class @@ -228,7 +228,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Context")) { } }; // ContextVerb class @@ -247,7 +247,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("View")) { } }; // ZoomVerb class @@ -267,7 +267,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Dialog")) { } }; // DialogVerb class @@ -286,7 +286,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Help")) { } }; // HelpVerb class @@ -305,7 +305,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Help")) { } }; // TutorialVerb class @@ -324,7 +324,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Text")) { } }; //TextVerb : public Verb @@ -341,7 +341,7 @@ Verb::VerbIDTable Verb::_verb_ids; * each call it is incremented. The list of allocated verbs is kept * in the \c _verbs hashtable which is indexed by the \c code. */ -Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) : +Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image, gchar const *group) : _actions(0), _id(id), _name(name), @@ -350,6 +350,7 @@ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *im _shortcut(0), _image(image), _code(0), + _group(group), _default_sensitive(false) { static int count = SP_VERB_LAST; @@ -2002,6 +2003,7 @@ void DialogVerb::perform(SPAction *action, void *data) case SP_VERB_DIALOG_PRINT_COLORS_PREVIEW: dt->_dlg_mgr->showDialog("PrintColorsPreviewDialog"); break; + default: break; } @@ -2104,7 +2106,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Extensions")) { set_default_sensitive(false); } @@ -2169,7 +2171,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("View")) { set_default_sensitive(false); } @@ -2235,7 +2237,7 @@ public: gchar const *name, gchar const *tip, gchar const *image) : - Verb(code, id, name, tip, image) + Verb(code, id, name, tip, image, _("Layer")) { set_default_sensitive(true); } @@ -2294,8 +2296,8 @@ void LockAndHideVerb::perform(SPAction *action, void *data) // these must be in the same order as the SP_VERB_* enum in "verbs.h" Verb *Verb::_base_verbs[] = { // Header - new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL), - new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL), + new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL, NULL), + new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL, NULL), // File new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"), @@ -2707,7 +2709,7 @@ Verb *Verb::_base_verbs[] = { #ifdef HAVE_GTK_WINDOW_FULLSCREEN new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"), INKSCAPE_ICON("view-fullscreen")), - new ZoomVerb(SP_VERB_FULLSCREENFOCUS, "FullScreenFocus", N_("Fullscreen & Focus Mode"), Glib::ustring::format(N_("Stretch this document window to full screen"), N_(" and "), N_("Remove excess toolbars to focus on drawing")).c_str(), + new ZoomVerb(SP_VERB_FULLSCREENFOCUS, "FullScreenFocus", N_("Fullscreen & Focus Mode"), N_("Stretch this document window to full screen"), INKSCAPE_ICON("view-fullscreen")), #endif // HAVE_GTK_WINDOW_FULLSCREEN new ZoomVerb(SP_VERB_FOCUSTOGGLE, "FocusToggle", N_("Toggle _Focus Mode"), N_("Remove excess toolbars to focus on drawing"), @@ -2814,7 +2816,6 @@ Verb *Verb::_base_verbs[] = { N_("Select which color separations to render in Print Colors Preview rendermode"), NULL), new DialogVerb(SP_VERB_DIALOG_EXPORT, "DialogExport", N_("_Export PNG Image..."), N_("Export this document or a selection as a PNG image"), INKSCAPE_ICON("document-export")), - // Help new HelpVerb(SP_VERB_HELP_ABOUT_EXTENSIONS, "HelpAboutExtensions", N_("About E_xtensions"), N_("Information on Inkscape extensions"), NULL), @@ -2898,9 +2899,27 @@ Verb *Verb::_base_verbs[] = { // Footer - new Verb(SP_VERB_LAST, " '\"invalid id", NULL, NULL, NULL) + new Verb(SP_VERB_LAST, " '\"invalid id", NULL, NULL, NULL, NULL) }; +std::vector +Verb::getList (void) { + + std::vector verbs; + // Go through the dynamic verb table + for (VerbTable::iterator iter = _verbs.begin(); iter != _verbs.end(); ++iter) { + Verb * verb = iter->second; + if (verb->get_code() == SP_VERB_INVALID || + verb->get_code() == SP_VERB_NONE || + verb->get_code() == SP_VERB_LAST) { + continue; + } + + verbs.push_back(verb); + } + + return verbs; +}; void Verb::list (void) { diff --git a/src/verbs.h b/src/verbs.h index c47d3ae16..c4a7b67e0 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -348,6 +348,7 @@ enum { gchar *sp_action_get_title (const SPAction *action); #include +#include namespace Inkscape { @@ -418,6 +419,9 @@ private: */ unsigned int _code; + /** Name of the group the verb belongs to. */ + gchar const * _group; + /** * Whether this verb is set to default to sensitive or * insensitive when new actions are created. @@ -451,18 +455,25 @@ public: /** Accessor to get the internal variable. */ gchar const * get_name (void) { return _name; } + /** Accessor to get the internal variable. */ + gchar const * get_short_tip (void) { return _tip; }; + /** Accessor to get the internal variable. */ gchar const * get_tip (void) ; /** Accessor to get the internal variable. */ gchar const * get_image (void) { return _image; } + /** Get the verbs group */ + gchar const * get_group (void) { return _group; } + /** Set the name after initialization. */ gchar const * set_name (gchar const * name) { _name = name; return _name; } /** Set the tooltip after initialization. */ gchar const * set_tip (gchar const * tip) { _tip = tip; return _tip; } + protected: SPAction *make_action_helper (Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL); virtual SPAction *make_action (Inkscape::UI::View::View *view); @@ -494,7 +505,8 @@ public: gchar const * id, gchar const * name, gchar const * tip, - gchar const * image) : + gchar const * image, + gchar const * group) : _actions(0), _id(id), _name(name), @@ -503,12 +515,13 @@ public: _shortcut(0), _image(image), _code(code), + _group(group), _default_sensitive(true) { _verbs.insert(VerbTable::value_type(_code, this)); _verb_ids.insert(VerbIDTable::value_type(_id, this)); } - Verb (gchar const * id, gchar const * name, gchar const * tip, gchar const * image); + Verb (gchar const * id, gchar const * name, gchar const * tip, gchar const * image, gchar const * group); virtual ~Verb (void); SPAction * get_action(Inkscape::UI::View::View * view); @@ -560,6 +573,8 @@ protected: public: static void list (void); + static std::vectorgetList (void); + }; /* Verb class */ -- cgit v1.2.3 From 06bd90e7b1f3cbf7f15cf9a10961218d02da853f Mon Sep 17 00:00:00 2001 From: Alexandre Prokoudine Date: Mon, 26 Nov 2012 06:52:34 +0400 Subject: Made a few user-visible messages translatable (bzr r11899) --- src/widgets/font-selector.cpp | 2 +- src/widgets/text-toolbar.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 6a677307e..c7f28fb9c 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -133,7 +133,7 @@ static void sp_font_selector_set_size_tooltip(SPFontSelector *fsel) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); - Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")"); + Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")"); gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str())); } diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index e32f5a42a..9e0977d51 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1233,7 +1233,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ sp_text_set_sizes(GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontSizeAction)), unit); ink_comboboxentry_action_set_active_text( fontSizeAction, os.str().c_str() ); - Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")"); + Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")"); ink_comboboxentry_action_set_tooltip ( fontSizeAction, tooltip.c_str()); // Font styles @@ -1492,7 +1492,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje sp_text_set_sizes(model_size, unit); - Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")"); + Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")"); Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontSizeAction", _("Font Size"), -- cgit v1.2.3 From 98e8bcc657ebe691185e787f8ddab7e17a02962a Mon Sep 17 00:00:00 2001 From: Alexandre Prokoudine Date: Mon, 26 Nov 2012 07:34:49 +0400 Subject: Marked even more user visible messages for translation (bzr r11900) --- src/widgets/desktop-widget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 05053f6fd..cc441cc1c 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -817,10 +817,10 @@ SPDesktopWidget::updateTitle(gchar const* uri) gchar const *fname = uri; GString *name = g_string_new (""); - gchar const *grayscalename = "(grayscale) "; - gchar const *grayscalenamecomma = ", grayscale"; - gchar const *printcolorsname = "(print colors preview) "; - gchar const *printcolorsnamecomma = ", print colors preview"; + gchar const *grayscalename = _("(grayscale) "); + gchar const *grayscalenamecomma = _(", grayscale"); + gchar const *printcolorsname = _("(print colors preview) "); + gchar const *printcolorsnamecomma = _(", print colors preview"); gchar const *colormodename = ""; gchar const *colormodenamecomma = ""; gchar const *modifiedname = ""; -- cgit v1.2.3 From d67c51b26a7c267d4f1294f03c475a824c6a3ccb Mon Sep 17 00:00:00 2001 From: Alexandre Prokoudine Date: Mon, 26 Nov 2012 08:41:42 +0400 Subject: Marked another user-visible message for translation, fixed text case for combo items (bzr r11901) --- src/widgets/gradient-toolbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 205f5b8ec..55f102898 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -1109,7 +1109,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); - EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectGradientAction", _("Select"), ("Choose a gradient"), NULL, GTK_TREE_MODEL(store) ); + EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectGradientAction", _("Select"), (_("Choose a gradient")), NULL, GTK_TREE_MODEL(store) ); g_object_set( act1, "short_label", _("Select:"), NULL ); ege_select_one_action_set_appearance( act1, "compact" ); gtk_action_set_sensitive( GTK_ACTION(act1), FALSE ); @@ -1125,13 +1125,13 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GtkTreeIter iter; gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, 0, _("none"), 1, SP_GRADIENT_SPREAD_PAD, -1 ); + gtk_list_store_set( model, &iter, 0, _("None"), 1, SP_GRADIENT_SPREAD_PAD, -1 ); gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, 0, _("reflected"), 1, SP_GRADIENT_SPREAD_REFLECT, -1 ); + gtk_list_store_set( model, &iter, 0, _("Reflected"), 1, SP_GRADIENT_SPREAD_REFLECT, -1 ); gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, 0, _("direct"), 1, SP_GRADIENT_SPREAD_REPEAT, -1 ); + gtk_list_store_set( model, &iter, 0, _("Direct"), 1, SP_GRADIENT_SPREAD_REPEAT, -1 ); EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectRepeatAction", _("Repeat"), (// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute -- cgit v1.2.3 From 887adad175d68ddb148ab129c5c7436794b15627 Mon Sep 17 00:00:00 2001 From: Alexandre Prokoudine Date: Mon, 26 Nov 2012 08:45:55 +0400 Subject: The label should really say "Stops:", just like its verb. The former "Edit:" label text is just confusing. (bzr r11902) --- src/widgets/gradient-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 55f102898..ea125a380 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -1157,7 +1157,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientEditStopsAction", _("Stops"), _("Select a stop for the current gradient"), NULL, GTK_TREE_MODEL(store) ); - g_object_set( act1, "short_label", _("Edit:"), NULL ); + g_object_set( act1, "short_label", _("Stops:"), NULL ); ege_select_one_action_set_appearance( act1, "compact" ); gtk_action_set_sensitive( GTK_ACTION(act1), FALSE ); g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(gr_stop_combo_changed), holder ); -- cgit v1.2.3 From ab63da7c5449a97ca9eb698b0d461184464c26c8 Mon Sep 17 00:00:00 2001 From: su_v Date: Mon, 26 Nov 2012 07:29:21 +0100 Subject: Fix undo history entry for layer renaming to be consistent with 'Rename Layer' dialog (bzr r11903) --- src/ui/dialog/layers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index ffdf27b62..4f7b8f27c 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -743,7 +743,7 @@ void LayersPanel::_renameLayer(Gtk::TreeModel::Row row, const Glib::ustring& nam if ( !name.empty() && (!oldLabel || name != oldLabel) ) { _desktop->layer_manager->renameLayer( obj, name.c_str(), FALSE ); DocumentUndo::done( _desktop->doc() , SP_VERB_NONE, - _("Renamed layer")); + _("Rename layer")); } } -- cgit v1.2.3 From 97ef01fe17c522cbe313add9f7136aa09ad0350d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 26 Nov 2012 08:04:44 +0100 Subject: i18n. Fix for Bug #1083043 (Symbols dialog isn't translatable). (bzr r11904) --- src/ui/dialog/symbols.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 8cf48f827..4c3a406f0 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -97,16 +99,16 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : guint row = 0; /******************** Symbol Sets *************************/ - Gtk::Label* labelSet = new Gtk::Label("Symbol set: "); + Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: ")); table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); symbolSet = new Gtk::ComboBoxText(); // Fill in later #if WITH_GTKMM_2_24 - symbolSet->append("Current Document"); + symbolSet->append(_("Current Document")); #else - symbolSet->append_text("Current Document"); + symbolSet->append_text(_("Current Document")); #endif - symbolSet->set_active_text("Current Document"); + symbolSet->set_active_text(_("Current Document")); table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); sigc::connection connSet = @@ -142,12 +144,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; /******************** Preview Scale ***********************/ - Gtk::Label* labelScale = new Gtk::Label("Preview scale: "); + Gtk::Label* labelScale = new Gtk::Label(_("Preview scale: ")); table->attach(*Gtk::manage(labelScale),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); previewScale = new Gtk::ComboBoxText(); const gchar *scales[] = - {"Fit", "Fit to width", "Fit to height", "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL}; + {_("Fit"), _("Fit to width"), _("Fit to height"), "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL}; for( int i = 0; scales[i]; ++i ) { #if WITH_GTKMM_2_24 previewScale->append(scales[i]); @@ -165,7 +167,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; /******************** Preview Size ************************/ - Gtk::Label* labelSize = new Gtk::Label("Preview size: "); + Gtk::Label* labelSize = new Gtk::Label(_("Preview size: ")); table->attach(*Gtk::manage(labelSize),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); previewSize = new Gtk::ComboBoxText(); -- cgit v1.2.3 From 4af19c56cf90e31a0d800821e8daf7fb08108e94 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 26 Nov 2012 10:33:19 +0000 Subject: Drop support for GTK+ < 2.24 Fixed bugs: - https://launchpad.net/bugs/1069024 (bzr r11907) --- src/device-manager.cpp | 9 +-------- src/extension/internal/pdf-input-cairo.cpp | 8 -------- src/extension/internal/pdfinput/pdf-input.cpp | 8 -------- src/extension/param/enum.cpp | 4 ---- src/extension/param/radiobutton.cpp | 4 ---- src/ui/dialog/align-and-distribute.cpp | 19 ------------------- src/ui/dialog/document-properties.cpp | 12 ------------ src/ui/dialog/filedialogimpl-gtkmm.cpp | 12 ------------ src/ui/dialog/filter-effects-dialog.cpp | 23 +---------------------- src/ui/dialog/glyphs.cpp | 8 -------- src/ui/dialog/inkscape-preferences.cpp | 12 ------------ src/ui/dialog/input.cpp | 21 --------------------- src/ui/dialog/ocaldialogs.cpp | 4 ---- src/ui/dialog/spellcheck.cpp | 14 -------------- src/ui/dialog/svg-fonts-dialog.cpp | 11 +---------- src/ui/dialog/symbols.cpp | 17 ----------------- src/ui/dialog/text-edit.cpp | 27 --------------------------- src/ui/widget/frame.cpp | 2 -- src/ui/widget/gimpspinscale.c | 10 ---------- src/ui/widget/preferences-widget.cpp | 13 ------------- src/ui/widget/unit-menu.cpp | 14 +------------- src/widgets/eek-preview.cpp | 7 ------- src/widgets/font-selector.cpp | 17 ----------------- 23 files changed, 4 insertions(+), 272 deletions(-) (limited to 'src') diff --git a/src/device-manager.cpp b/src/device-manager.cpp index 5c7048613..29efa2627 100644 --- a/src/device-manager.cpp +++ b/src/device-manager.cpp @@ -173,14 +173,7 @@ public: virtual bool hasCursor() const {return gdk_device_get_has_cursor (device);} virtual gint getNumKeys() const { -// Backward-compatibility: The GSEAL-compliant -// gdk_device_get_n_keys function was only introduced -// with GTK 2.24 -#if GTK_CHECK_VERSION(2, 24, 0) - return gdk_device_get_n_keys (device); -#else - return device->num_keys; -#endif // GTK_CHECK_VERSION + return gdk_device_get_n_keys (device); } virtual Glib::ustring getLink() const {return link;} virtual void setLink( Glib::ustring const& link ) {this->link = link;} diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index eee1b43bf..03b7c0a90 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -95,11 +95,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) _cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText()); int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]); for ( int i = 0 ; i < num_crop_choices ; i++ ) { -#if WITH_GTKMM_2_24 _cropTypeCombo->append(_(crop_setting_choices[i])); -#else - _cropTypeCombo->append_text(_(crop_setting_choices[i])); -#endif } _cropTypeCombo->set_active_text(_(crop_setting_choices[0])); _cropTypeCombo->set_sensitive(false); @@ -124,11 +120,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) // Text options _labelText = Gtk::manage(new class Gtk::Label(_("Text handling:"))); _textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText()); -#if WITH_GTKMM_2_24 _textHandlingCombo->append(_("Import text as text")); -#else - _textHandlingCombo->append_text(_("Import text as text")); -#endif _textHandlingCombo->set_active_text(_("Import text as text")); _localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts"))); diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index d2d594017..688e3f612 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -111,11 +111,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText()); int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]); for ( int i = 0 ; i < num_crop_choices ; i++ ) { -#if WITH_GTKMM_2_24 _cropTypeCombo->append(_(crop_setting_choices[i])); -#else - _cropTypeCombo->append_text(_(crop_setting_choices[i])); -#endif } _cropTypeCombo->set_active_text(_(crop_setting_choices[0])); _cropTypeCombo->set_sensitive(false); @@ -140,11 +136,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) // Text options _labelText = Gtk::manage(new class Gtk::Label(_("Text handling:"))); _textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText()); -#if WITH_GTKMM_2_24 _textHandlingCombo->append(_("Import text as text")); -#else - _textHandlingCombo->append_text(_("Import text as text")); -#endif _textHandlingCombo->set_active_text(_("Import text as text")); _localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts"))); diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index b1968a4d6..18a73beb6 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -242,11 +242,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { enumentry * entr = reinterpret_cast(list->data); Glib::ustring text = entr->guitext; -#if WITH_GTKMM_2_24 combo->append(text); -#else - combo->append_text(text); -#endif if ( _value && !entr->value.compare(_value) ) { settext = entr->guitext; diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 5b5e179d2..921c322b6 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -305,11 +305,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node switch ( _mode ) { case MINIMAL: { -#if WITH_GTKMM_2_24 cbt->append(*text); -#else - cbt->append_text(*text); -#endif if (!entr->value->compare(_value)) { cbt->set_active_text(*text); comboSet = true; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index cd1ce1471..dbd06d9e8 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1040,7 +1040,6 @@ AlignAndDistribute::AlignAndDistribute() //Rest of the widgetry -#if WITH_GTKMM_2_24 _combo.append(_("Last selected")); _combo.append(_("First selected")); _combo.append(_("Biggest object")); @@ -1048,15 +1047,6 @@ AlignAndDistribute::AlignAndDistribute() _combo.append(_("Page")); _combo.append(_("Drawing")); _combo.append(_("Selection")); -#else - _combo.append_text(_("Last selected")); - _combo.append_text(_("First selected")); - _combo.append_text(_("Biggest object")); - _combo.append_text(_("Smallest object")); - _combo.append_text(_("Page")); - _combo.append_text(_("Drawing")); - _combo.append_text(_("Selection")); -#endif _combo.set_active(prefs->getInt("/dialogs/align/align-to", 6)); _combo.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_ref_change)); @@ -1154,21 +1144,12 @@ void AlignAndDistribute::on_selgrp_toggled(){ void AlignAndDistribute::setMode(bool nodeEdit) { //Act on widgets used in node mode -#if WITH_GTKMM_2_24 void ( Gtk::Widget::*mNode) () = nodeEdit ? &Gtk::Widget::show_all : &Gtk::Widget::hide; //Act on widgets used in selection mode void ( Gtk::Widget::*mSel) () = nodeEdit ? &Gtk::Widget::hide : &Gtk::Widget::show_all; -#else - void ( Gtk::Widget::*mNode) () = nodeEdit ? - &Gtk::Widget::show_all : &Gtk::Widget::hide_all; - - //Act on widgets used in selection mode - void ( Gtk::Widget::*mSel) () = nodeEdit ? - &Gtk::Widget::hide_all : &Gtk::Widget::show_all; -#endif ((_alignFrame).*(mSel))(); ((_distributeFrame).*(mSel))(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index e681147aa..ab1e8fbd8 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -333,21 +333,13 @@ void DocumentProperties::build_snap() #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) /// Populates the available color profiles combo box void DocumentProperties::populate_available_profiles(){ -#if WITH_GTKMM_2_24 _combo_avail.remove_all(); // Clear any existing items in the combo box -#else - _combo_avail.clear_items(); // Clear any existing items in the combo box -#endif // Iterate through the list of profiles and add the name to the combo box. std::vector > pairs = ColorProfile::getProfileFilesWithNames(); for ( std::vector >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) { Glib::ustring name = it->second; -#if WITH_GTKMM_2_24 _combo_avail.append(name); -#else - _combo_avail.append_text(name); -#endif } } @@ -1160,11 +1152,7 @@ void DocumentProperties::build_gridspage() _grids_hbox_crea.pack_start(_grids_button_new, true, true); for (gint t = 0; t <= GRID_MAXTYPENR; t++) { -#if WITH_GTKMM_2_24 _grids_combo_gridtype.append( CanvasGrid::getName( (GridType) t ) ); -#else - _grids_combo_gridtype.append_text( CanvasGrid::getName( (GridType) t ) ); -#endif } _grids_combo_gridtype.set_active_text( CanvasGrid::getName(GRID_RECTANGULAR) ); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 90d9855ec..553acac84 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1183,11 +1183,7 @@ void FileSaveDialogImplGtk::addFileType(Glib::ustring name, Glib::ustring patter guessType.name = name; guessType.pattern = pattern; guessType.extension = NULL; - #if WITH_GTKMM_2_24 fileTypeComboBox.append(guessType.name); - #else - fileTypeComboBox.append_text(guessType.name); - #endif fileTypes.push_back(guessType); @@ -1216,11 +1212,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() knownExtensions.insert( extension.casefold() ); fileDialogExtensionToPattern (type.pattern, extension); type.extension= omod; -#if WITH_GTKMM_2_24 fileTypeComboBox.append(type.name); -#else - fileTypeComboBox.append_text(type.name); -#endif fileTypes.push_back(type); } @@ -1229,11 +1221,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() guessType.name = _("Guess from extension"); guessType.pattern = "*"; guessType.extension = NULL; -#if WITH_GTKMM_2_24 fileTypeComboBox.append(guessType.name); -#else - fileTypeComboBox.append_text(guessType.name); -#endif fileTypes.push_back(guessType); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index b00dd042f..9a430114d 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1058,11 +1058,7 @@ private: void update() { -#if WITH_GTKMM_2_24 - _box.hide(); -#else - _box.hide_all(); -#endif + _box.hide(); _box.show(); _light_box.show_all(); @@ -1128,13 +1124,8 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) if(col) col->add_attribute(_cell_toggle.property_active(), _columns.sel); _list.append_column_editable(_("_Filter"), _columns.label); -#if WITH_GTKMM_2_24 ((Gtk::CellRendererText*)_list.get_column(1)->get_first_cell())-> signal_edited().connect(sigc::mem_fun(*this, &FilterEffectsDialog::FilterModifier::on_name_edited)); -#else - ((Gtk::CellRendererText*)_list.get_column(1)->get_first_cell_renderer())-> - signal_edited().connect(sigc::mem_fun(*this, &FilterEffectsDialog::FilterModifier::on_name_edited)); -#endif sw->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); sw->set_shadow_type(Gtk::SHADOW_IN); @@ -2648,11 +2639,7 @@ void FilterEffectsDialog::update_filter_general_settings_view() } else { std::vector vect = _settings_tab2.get_children(); -#if WITH_GTKMM_2_24 vect[0]->hide(); -#else - vect[0]->hide_all(); -#endif _no_filter_selected.show(); } @@ -2671,11 +2658,7 @@ void FilterEffectsDialog::update_settings_view() std::vector vect1 = _settings_tab1.get_children(); for(unsigned int i=0; ihide(); -#else - vect1[i]->hide_all(); -#endif _empty_settings.show(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2699,11 +2682,7 @@ void FilterEffectsDialog::update_settings_view() //Second Tab std::vector vect2 = _settings_tab2.get_children(); -#if WITH_GTKMM_2_24 vect2[0]->hide(); -#else - vect2[0]->hide_all(); -#endif _no_filter_selected.show(); SPFilter* filter = _filter_modifier.get_selected_filter(); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 1eed8d804..eec904ee4 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -364,11 +364,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : scriptCombo = new Gtk::ComboBoxText(); for (std::map::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) { -#if WITH_GTKMM_2_24 scriptCombo->append(it->second); -#else - scriptCombo->append_text(it->second); -#endif } scriptCombo->set_active_text(getScriptToName()[G_UNICODE_SCRIPT_INVALID_CODE]); @@ -393,11 +389,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : rangeCombo = new Gtk::ComboBoxText(); for ( std::vector::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { -#if WITH_GTKMM_2_24 rangeCombo->append(it->second); -#else - rangeCombo->append_text(it->second); -#endif } rangeCombo->set_active_text(getRanges()[1].second); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 03366a0c3..291059999 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -986,18 +986,10 @@ void InkscapePreferences::initPageIO() Glib::ustring current = prefs->getString( "/options/displayprofile/uri" ); gint index = 0; -#if WITH_GTKMM_2_24 _cms_display_profile.append(_("")); -#else - _cms_display_profile.append_text(_("")); -#endif index++; for ( std::vector::iterator it = names.begin(); it != names.end(); ++it ) { -#if WITH_GTKMM_2_24 _cms_display_profile.append( *it ); -#else - _cms_display_profile.append_text( *it ); -#endif Glib::ustring path = CMSSystem::getPathForProfile(*it); if ( !path.empty() && path == current ) { _cms_display_profile.set_active(index); @@ -1012,11 +1004,7 @@ void InkscapePreferences::initPageIO() current = prefs->getString("/options/softproof/uri"); index = 0; for ( std::vector::iterator it = names.begin(); it != names.end(); ++it ) { -#if WITH_GTKMM_2_24 _cms_proof_profile.append( *it ); -#else - _cms_proof_profile.append_text( *it ); -#endif Glib::ustring path = CMSSystem::getPathForProfile(*it); if ( !path.empty() && path == current ) { _cms_proof_profile.set_active(index); diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index b3c1bddfd..7e2b0a1e1 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -609,11 +609,7 @@ InputDialogImpl::InputDialogImpl() : ::Gtk::FILL, ::Gtk::SHRINK); -#if WITH_GTKMM_2_24 linkCombo.append(_("None")); -#else - linkCombo.append_text(_("None")); -#endif linkCombo.set_active_text(_("None")); linkCombo.set_sensitive(false); linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged)); @@ -1282,24 +1278,15 @@ void InputDialogImpl::resyncToSelection() { devDetails.set_sensitive(true); linkConnection.block(); -#if WITH_GTKMM_2_24 linkCombo.remove_all(); linkCombo.append(_("None")); -#else - linkCombo.clear_items(); - linkCombo.append_text(_("None")); -#endif linkCombo.set_active(0); if ( dev->getSource() != Gdk::SOURCE_MOUSE ) { Glib::ustring linked = dev->getLink(); std::list > devList = Inkscape::DeviceManager::getManager().getDevices(); for ( std::list >::const_iterator it = devList.begin(); it != devList.end(); ++it ) { if ( ((*it)->getSource() != Gdk::SOURCE_MOUSE) && ((*it) != dev) ) { -#if WITH_GTKMM_2_24 linkCombo.append((*it)->getName().c_str()); -#else - linkCombo.append_text((*it)->getName().c_str()); -#endif if ( (linked.length() > 0) && (linked == (*it)->getId()) ) { linkCombo.set_active_text((*it)->getName().c_str()); } @@ -1334,18 +1321,10 @@ void InputDialogImpl::setupValueAndCombo( gint reported, gint actual, Gtk::Label label.set_label(tmp); g_free(tmp); -#if WITH_GTKMM_2_24 combo.remove_all(); -#else - combo.clear_items(); -#endif for ( gint i = 1; i <= reported; ++i ) { tmp = g_strdup_printf("%d", i); -#if WITH_GTKMM_2_24 combo.append(tmp); -#else - combo.append_text(tmp); -#endif g_free(tmp); } diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index bb06e3e79..174f361fd 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -963,11 +963,7 @@ void SearchResultList::populate_from_xml(xmlNode * a_node) { if (!strcmp((const char*)cur_node->name, "title")) { -#if WITH_GTKMM_2_24 row_num = append(""); -#else - row_num = append_text(""); -#endif xmlChar *xml_title = xmlNodeGetContent(cur_node); char* title = (char*) xml_title; diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 0f2c53f99..9cc18c02c 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -109,10 +109,6 @@ SpellCheck::SpellCheck (void) : tree_view.append_column(_("Suggestions:"), tree_columns.suggestions); { -// Backward compatibility fix: The GtkComboBoxText API was introduced with -// GTK+ 2.24. This check should eventually be dropped when we bump our -// GTK dependency. -#if GTK_CHECK_VERSION(2, 24, 0) dictionary_combo = gtk_combo_box_text_new(); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dictionary_combo), _lang.c_str()); if (_lang2 != "") { @@ -121,16 +117,6 @@ SpellCheck::SpellCheck (void) : if (_lang3 != "") { gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dictionary_combo), _lang3.c_str()); } -#else - dictionary_combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text (GTK_COMBO_BOX (dictionary_combo), _lang.c_str()); - if (_lang2 != "") { - gtk_combo_box_append_text (GTK_COMBO_BOX (dictionary_combo), _lang2.c_str()); - } - if (_lang3 != "") { - gtk_combo_box_append_text (GTK_COMBO_BOX (dictionary_combo), _lang3.c_str()); - } -#endif gtk_combo_box_set_active (GTK_COMBO_BOX (dictionary_combo), 0); gtk_widget_show_all (dictionary_combo); } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index f296ad030..be69635e8 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -163,23 +163,14 @@ GlyphComboBox::GlyphComboBox(){ void GlyphComboBox::update(SPFont* spfont){ if (!spfont) return -//TODO: figure out why do we need to append_text("") before clearing items properly... +//TODO: figure out why do we need to append("") before clearing items properly... -#if WITH_GTKMM_2_24 this->append(""); //Gtk is refusing to clear the combobox when I comment out this line this->remove_all(); -#else - this->append_text(""); //Gtk is refusing to clear the combobox when I comment out this line - this->clear_items(); -#endif for(SPObject* node = spfont->children; node; node=node->next){ if (SP_IS_GLYPH(node)){ -#if WITH_GTKMM_2_24 this->append((static_cast(node))->unicode); -#else - this->append_text((static_cast(node))->unicode); -#endif } } } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 4c3a406f0..9d4ab5d8a 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -103,11 +103,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); symbolSet = new Gtk::ComboBoxText(); // Fill in later -#if WITH_GTKMM_2_24 symbolSet->append(_("Current Document")); -#else - symbolSet->append_text(_("Current Document")); -#endif symbolSet->set_active_text(_("Current Document")); table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); @@ -151,11 +147,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : const gchar *scales[] = {_("Fit"), _("Fit to width"), _("Fit to height"), "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL}; for( int i = 0; scales[i]; ++i ) { -#if WITH_GTKMM_2_24 previewScale->append(scales[i]); -#else - previewScale->append_text(scales[i]); -#endif } previewScale->set_active_text(scales[0]); table->attach(*Gtk::manage(previewScale),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); @@ -173,12 +165,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : previewSize = new Gtk::ComboBoxText(); const gchar *sizes[] = {"16", "24", "32", "48", "64", NULL}; for( int i = 0; sizes[i]; ++i ) { -#if WITH_GTKMM_2_24 previewSize->append(sizes[i]); -#else - previewSize->append_text(sizes[i]); -#endif - } previewSize->set_active_text(sizes[2]); table->attach(*Gtk::manage(previewSize),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); @@ -333,11 +320,7 @@ void SymbolsDialog::get_symbols() { SPDocument* symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { symbolSets[Glib::ustring(filename)]= symbol_doc; -#if WITH_GTKMM_2_24 symbolSet->append(filename); -#else - symbolSet->append_text(filename); -#endif } } g_free( fullname ); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 033571bb4..6696db083 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -106,30 +106,12 @@ TextEdit::TextEdit() GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") ); layout_hbox.pack_start(*Gtk::manage(Glib::wrap(px)), false, false); -/* -This would introduce dependency on gtk version 2.24 which is currently not available in -Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) -This conditional and its #else block can be deleted in the future. -*/ -#if GTK_CHECK_VERSION(2, 24,0) spacing_combo = gtk_combo_box_text_new_with_entry (); -#else - spacing_combo = gtk_combo_box_entry_new_text (); -#endif gtk_widget_set_size_request (spacing_combo, 90, -1); const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL}; for (int i = 0; spacings[i]; i++) { -/* -This would introduce dependency on gtk version 2.24 which is currently not available in -Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) -This conditional and its #else block can be deleted in the future. -*/ -#if GTK_CHECK_VERSION(2, 24,0) gtk_combo_box_text_append_text((GtkComboBoxText *) spacing_combo, spacings[i]); -#else - gtk_combo_box_append_text((GtkComboBox *) spacing_combo, spacings[i]); -#endif } gtk_widget_set_tooltip_text (px, _("Spacing between lines (percent of font size)")); @@ -505,16 +487,7 @@ SPCSSAttr *TextEdit::getTextStyle () // Note that CSS 1.1 does not support line-height; we set it for consistency, but also set // sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext -/* -This would introduce dependency on gtk version 2.24 which is currently not available in -Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) -This conditional and its #else block can be deleted in the future. -*/ -#if GTK_CHECK_VERSION(2, 24,0) const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo); -#else - const gchar *sstr = gtk_entry_get_text ((GtkEntry *) (gtk_bin_get_child (GTK_BIN (spacing_combo)))); -#endif sp_repr_css_set_property (css, "line-height", sstr); return css; diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp index b2968f806..eaa4336bb 100644 --- a/src/ui/widget/frame.cpp +++ b/src/ui/widget/frame.cpp @@ -56,9 +56,7 @@ Frame::set_label(const Glib::ustring &label_text, gboolean label_bold /*= TRUE*/ void Frame::set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right) { -#if WITH_GTKMM_2_24 _alignment.set_padding(padding_top, padding_bottom, padding_left, padding_right); -#endif } Gtk::Label const * diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c index df39b9644..222a8aa1d 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/ui/widget/gimpspinscale.c @@ -432,12 +432,7 @@ static gboolean gdk_cairo_region (cr, event->region); cairo_clip (cr); -#if GTK_CHECK_VERSION(2, 24,0) w = gdk_window_get_width (event->window); -#else - gdk_drawable_get_size (event->window, &w, NULL); -#endif - #endif cairo_set_line_width (cr, 1.0); @@ -687,12 +682,7 @@ gimp_spin_scale_change_value (GtkWidget *widget, gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); -#if GTK_CHECK_VERSION(2, 24,0) width = gdk_window_get_width (text_window); -#else - gdk_drawable_get_size (text_window, &width, NULL); -#endif - #endif diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index b793893c7..e7e317d11 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -378,12 +378,7 @@ ZoomCorrRuler::redraw() { Glib::RefPtr window = get_window(); Cairo::RefPtr cr = window->create_cairo_context(); -#if WITH_GTKMM_2_24 int w = window->get_width(); -#else - int w, h; - window->get_size(w, h); -#endif _drawing_width = w - _border * 2; cr->set_source_rgb(1.0, 1.0, 1.0); @@ -597,11 +592,7 @@ void PrefCombo::init(Glib::ustring const &prefs_path, for (int i = 0 ; i < num_items; ++i) { -#if WITH_GTKMM_2_24 this->append(labels[i]); -#else - this->append_text(labels[i]); -#endif _values.push_back(values[i]); if (value == values[i]) row = i; @@ -623,11 +614,7 @@ void PrefCombo::init(Glib::ustring const &prefs_path, for (int i = 0 ; i < num_items; ++i) { -#if WITH_GTKMM_2_24 this->append(labels[i]); -#else - this->append_text(labels[i]); -#endif _ustr_values.push_back(values[i]); if (value == values[i]) row = i; diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 86e8c9e58..18b7bcab9 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -34,11 +34,7 @@ bool UnitMenu::setUnitType(UnitType unit_type) UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { Glib::ustring text = (*iter).first; -#if WITH_GTKMM_2_24 append(text); -#else - append_text(text); -#endif ++iter; } _type = unit_type; @@ -49,11 +45,7 @@ bool UnitMenu::setUnitType(UnitType unit_type) bool UnitMenu::resetUnitType(UnitType unit_type) { -#if WITH_GTKMM_2_24 - remove_all(); -#else - clear_items(); -#endif + remove_all(); return setUnitType(unit_type); } @@ -61,11 +53,7 @@ bool UnitMenu::resetUnitType(UnitType unit_type) void UnitMenu::addUnit(Unit const& u) { _unit_table.addUnit(u, false); -#if WITH_GTKMM_2_24 append(u.abbr); -#else - append_text(u.abbr); -#endif } Unit UnitMenu::getUnit() const diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 72db91373..535a5d101 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -296,15 +296,8 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr) GdkWindow *da_window = gtk_widget_get_window(GTK_WIDGET(da)); cairo_t *cr = gdk_cairo_create(da_window); -#if GTK_CHECK_VERSION(2,24,0) gint w = gdk_window_get_width(da_window); gint h = gdk_window_get_height(da_window); -#else - gint w = 0; - gint h = 0; - gdk_drawable_get_size(da_window, &w, &h); -#endif - if ((w != preview->_scaledW) || (h != preview->_scaledH)) { if (preview->_scaled) { diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index c7f28fb9c..dde511612 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -218,16 +218,7 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_widget_show(hb); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0); -/* -This would introduce dependency on gtk version 2.24 which is currently not available in -Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) -This conditional and its #else block can be deleted in the future. -*/ -#if GTK_CHECK_VERSION(2, 24,0) fsel->size = gtk_combo_box_text_new_with_entry (); -#else - fsel->size = gtk_combo_box_entry_new_text (); -#endif sp_font_selector_set_size_tooltip(fsel); gtk_widget_set_size_request(fsel->size, 90, -1); @@ -346,11 +337,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel ) { double size = sizes[n] / ratios[unit]; -#if GTK_CHECK_VERSION(2, 24,0) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), Glib::ustring::format(size).c_str()); -#else - gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), Glib::ustring::format(size).c_str()); -#endif } } @@ -358,11 +345,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel ) static void sp_font_selector_size_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel ) { char *text = NULL; -#if GTK_CHECK_VERSION(2, 24,0) text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (fsel->size)); -#else - text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size)); -#endif gfloat old_size = fsel->fontsize; gchar *endptr; -- cgit v1.2.3 From edd8b70486b32a27c4fcdf2ac0e7230086e0b551 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 26 Nov 2012 10:56:42 +0000 Subject: Drop support for Glib < 2.28 (bzr r11908) --- src/widgets/icon.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index c7ddc2352..d3b7e2dbb 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -40,15 +40,6 @@ #include "icon.h" -// Bring in work-around for Glib versions missing GStatBuf -#if !GLIB_CHECK_VERSION(2,25,0) -#if defined (_MSC_VER) && !defined(_WIN64) -typedef struct _stat32 GStatBuf; -#else //defined (_MSC_VER) && !defined(_WIN64) -typedef struct stat GStatBuf; -#endif //defined (_MSC_VER) && !defined(_WIN64) -#endif //!GLIB_CHECK_VERSION(2,25,0) - struct IconImpl { static void classInit(SPIconClass *klass); static void init(SPIcon *icon); -- cgit v1.2.3 From 083e48b0f1e09b0f9056c6cda5a6f344a457583b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 27 Nov 2012 23:31:10 +0000 Subject: GTK+ 3: Migrate to GdkRGBA (bzr r11910) --- src/ui/dialog/filter-effects-dialog.cpp | 94 ++++++++++++++++++++++++++++++++- src/ui/widget/gimpspinscale.c | 18 ++++--- src/widgets/ruler.cpp | 7 +++ src/widgets/sp-color-slider.cpp | 13 +++++ 4 files changed, 123 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 9a430114d..ddafcd481 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1660,8 +1660,30 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrset_line_width(1.0); - // TODO: Use Gtk::StyleContext instead +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); + GdkRGBA bg_color, fg_color; + gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); + gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); + + GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0, + (bg_color.green + fg_color.green)/2.0, + (bg_color.blue + fg_color.blue)/2.0, + (bg_color.alpha + fg_color.alpha)/2.0}; + + GdkRGBA bg_color_active, fg_color_active; + gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_ACTIVE, &bg_color_active); + gtk_style_context_get_color(sc, GTK_STATE_FLAG_ACTIVE, &fg_color_active); + + GdkRGBA mid_color_active = {(bg_color_active.red + fg_color_active.red)/2.0, + (bg_color_active.green + fg_color_active.green)/2.0, + (bg_color_active.blue + fg_color_active.blue)/2.0, + (bg_color_active.alpha + fg_color_active.alpha)/2.0}; + + GdkRGBA black = {0,0,0,1}; +#else GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); +#endif SPFilterPrimitive* prim = get_selected(); int row_count = get_model()->children().size(); @@ -1680,13 +1702,25 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrsave(); cr->rectangle(x, 0, get_input_type_width(), vis.get_height()); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), &bg_color); + cr->fill_preserve(); + + gdk_cairo_set_source_rgba(cr->cobj(), &fg_color); +#else gdk_cairo_set_source_color(cr->cobj(), &(style->bg[GTK_STATE_NORMAL])); cr->fill_preserve(); gdk_cairo_set_source_color(cr->cobj(), &(style->text[GTK_STATE_NORMAL])); +#endif cr->move_to(x+get_input_type_width(), 0); cr->rotate_degrees(90); _vertical_layout->show_in_cairo_context(cr); + +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); +#else gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); +#endif cr->move_to(x, 0); cr->line_to(x, vis.get_height()); cr->stroke(); @@ -1707,7 +1741,13 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrsave(); + +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); +#else gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); +#endif + cr->move_to(x, y + h); cr->line_to(outline_x, y + h); // Side outline @@ -1728,10 +1768,17 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrsave(); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), + inside && mask & GDK_BUTTON1_MASK ? + &mid_color : + &mid_color_active); +#else gdk_cairo_set_source_color(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &(style->dark[GTK_STATE_NORMAL]) : &(style->dark[GTK_STATE_ACTIVE])); +#endif draw_connection_node(cr, con_poly, inside); @@ -1751,10 +1798,17 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrsave(); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), + inside && mask & GDK_BUTTON1_MASK ? + &mid_color : + &mid_color_active); +#else gdk_cairo_set_source_color(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &(style->dark[GTK_STATE_NORMAL]) : &(style->dark[GTK_STATE_ACTIVE])); +#endif draw_connection_node(cr, con_poly, inside); @@ -1772,10 +1826,17 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrsave(); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), + inside && mask & GDK_BUTTON1_MASK ? + &mid_color : + &mid_color_active); +#else gdk_cairo_set_source_color(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &(style->dark[GTK_STATE_NORMAL]) : &(style->dark[GTK_STATE_ACTIVE])); +#endif draw_connection_node(cr, con_poly, inside); @@ -1790,7 +1851,11 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtrsave(); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), &black); +#else gdk_cairo_set_source_color(cr->cobj(), &(style->black)); +#endif cr->move_to(outline_x, con_drag_y); cr->line_to(mx, con_drag_y); cr->line_to(mx, my); @@ -1809,8 +1874,22 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtrsave(); - // TODO: Use Gtk::StyleContext instead +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); + + GdkRGBA bg_color, fg_color; + gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); + gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); + + GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0, + (bg_color.green + fg_color.green)/2.0, + (bg_color.blue + fg_color.blue)/2.0, + (bg_color.alpha + fg_color.alpha)/2.0}; + + GdkRGBA black = {0,0,0,1}; +#else GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); +#endif int src_id = 0; Gtk::TreeIter res = find_result(input, attr, src_id); @@ -1825,10 +1904,17 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtrcobj(), &mid_color); + else + gdk_cairo_set_source_rgba(cr->cobj(), &black); +#else if(use_default && is_first) gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); else gdk_cairo_set_source_color(cr->cobj(), &(style->black)); +#endif cr->rectangle(end_x-2, y1-2, 5, 5); cr->fill_preserve(); @@ -1856,7 +1942,11 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtrcobj(), &black); +#else gdk_cairo_set_source_color(cr->cobj(), &(style->black)); +#endif cr->move_to(x1, y1); cr->line_to(x2-fheight/4, y1); cr->line_to(x2, y1-fheight/4); diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c index 222a8aa1d..f9f9a3807 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/ui/widget/gimpspinscale.c @@ -408,21 +408,20 @@ static gboolean gimp_spin_scale_expose (GtkWidget *widget, GdkEventExpose *event) #endif { - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - GtkStyle *style = gtk_widget_get_style (widget); - + GimpSpinScalePrivate *private = GET_PRIVATE (widget); #if WITH_GTKMM_3_0 + GtkStyleContext *style = gtk_widget_get_style_context(widget); GtkAllocation allocation; + GdkRGBA color; cairo_save (cr); GTK_WIDGET_CLASS (parent_class)->draw (widget, cr); cairo_restore (cr); gtk_widget_get_allocation (widget, &allocation); - - #else + GtkStyle *style = gtk_widget_get_style (widget); cairo_t *cr; gint w; @@ -499,12 +498,17 @@ static gboolean #if WITH_GTKMM_3_0 cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); + + gtk_style_context_get_color (style, gtk_widget_get_state_flags (widget), + &color); + + gdk_cairo_set_source_rgba (cr, &color); #else cairo_move_to (cr, layout_offset_x, layout_offset_y-3); -#endif - + gdk_cairo_set_source_color (cr, &style->text[gtk_widget_get_state (widget)]); +#endif pango_cairo_show_layout (cr, private->layout); } diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index 72c839b19..5104d5a9d 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -690,7 +690,14 @@ static void sp_ruler_real_draw_pos(SPRuler *ruler, y = ROUND ((priv->position - priv->lower) * increment) + (ythickness - bs_height) / 2 - 1; } +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *sc = gtk_widget_get_style_context(widget); + GdkRGBA color; + gtk_style_context_get_color(sc, gtk_widget_get_state_flags(widget), &color); + gdk_cairo_set_source_rgba(cr, &color); +#else gdk_cairo_set_source_color(cr, &style->fg[gtk_widget_get_state(widget)]); +#endif cairo_move_to (cr, x, y); diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 37b9e022a..3ba748f2b 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -648,13 +648,22 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr) gint w = ARROW_SIZE; cairo_set_line_width(cr, 1.0); +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA white = {1,1,1,1}; + GdkRGBA black = {0,0,0,1}; +#else GdkColor white, black; gdk_color_parse("#fff", &white); gdk_color_parse("#000", &black); +#endif while ( w > 0 ) { +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr, &white); +#else gdk_cairo_set_source_color(cr, &white); +#endif cairo_move_to(cr, x - 0.5, y1 + 0.5); cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); cairo_move_to(cr, x - 0.5, y2 + 0.5); @@ -664,7 +673,11 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr) x++; if ( w > 0 ) { +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr, &black); +#else gdk_cairo_set_source_color(cr, &black); +#endif cairo_move_to(cr, x - 0.5, y1 + 0.5); cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); cairo_move_to(cr, x - 0.5, y2 + 0.5); -- cgit v1.2.3 From c31f12ada683e302beb99dbc6eaea5d6d1205ab2 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 28 Nov 2012 09:44:24 +0900 Subject: Fix for 1071421 : Setting swatch as fill/stroke creates new swatches which never go away (bzr r11911) --- src/gradient-chemistry.cpp | 18 ++++++++++ src/gradient-chemistry.h | 2 ++ src/ui/dialog/swatches.cpp | 34 ++++++++++--------- src/widgets/gradient-selector.cpp | 70 ++++++++++++++++++++++++++++++++++++++- src/widgets/gradient-selector.h | 2 ++ 5 files changed, 109 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 0038e9325..6b019ad2a 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -27,6 +27,7 @@ #include "style.h" #include "document-private.h" #include "document-undo.h" +#include "desktop.h" #include "desktop-style.h" #include "desktop-handles.h" #include "event-context.h" @@ -1592,6 +1593,23 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) _("Reverse gradient")); } +void sp_gradient_unset_swatch(SPDesktop *desktop, std::string id) +{ + SPDocument *doc = desktop ? desktop->doc() : 0; + + if (doc) { + const GSList *gradients = doc->getResourceList("gradient"); + for (const GSList *item = gradients; item; item = item->next) { + SPGradient* grad = SP_GRADIENT(item->data); + if ( id == grad->getId() ) { + grad->setSwatch(false); + DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, + _("Delete swatch")); + break; + } + } + } +} /* Local Variables: mode:c++ diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h index 50422458c..66a8e5281 100644 --- a/src/gradient-chemistry.h +++ b/src/gradient-chemistry.h @@ -74,6 +74,8 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop); void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke); +void sp_gradient_unset_swatch(SPDesktop *desktop, std::string id); + /** * Fetches either the fill or the stroke gradient from the given item. * diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 9d5a2ac28..43b88e5c6 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -54,6 +54,8 @@ #include "dialog-manager.h" #include "selection.h" #include "verbs.h" +#include "gradient-chemistry.h" +#include "helper/action.h" namespace Inkscape { namespace UI { @@ -142,8 +144,21 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) } if (!shown) { - GtkWidget *dialog = sp_gradient_vector_editor_new( gr ); - gtk_widget_show( dialog ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/dialogs/gradienteditor/showlegacy", false)) { + // Legacy gradient dialog + GtkWidget *dialog = sp_gradient_vector_editor_new( gr ); + gtk_widget_show( dialog ); + } else { + // Invoke the gradient tool + Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_CONTEXT_GRADIENT ); + if ( verb ) { + SPAction *action = verb->get_action( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP); + if ( action ) { + sp_action_perform( action, NULL ); + } + } + } } } } @@ -197,20 +212,7 @@ void SwatchesPanelHook::deleteGradient( GtkMenuItem */*menuitem*/, gpointer /*us if ( bounceTarget ) { SwatchesPanel* swp = bouncePanel; SPDesktop* desktop = swp ? swp->getDesktop() : 0; - SPDocument *doc = desktop ? desktop->doc() : 0; - if (doc) { - std::string targetName(bounceTarget->def.descr); - const GSList *gradients = doc->getResourceList("gradient"); - for (const GSList *item = gradients; item; item = item->next) { - SPGradient* grad = SP_GRADIENT(item->data); - if ( targetName == grad->getId() ) { - grad->setSwatch(false); - DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, - _("Delete")); - break; - } - } - } + sp_gradient_unset_swatch(desktop, bounceTarget->def.descr); } } diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 33388a0c1..a900a0d10 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -53,6 +53,8 @@ static void sp_gradient_selector_dispose(GObject *object); static void sp_gradient_selector_vector_set (SPGradientVectorSelector *gvs, SPGradient *gr, SPGradientSelector *sel); static void sp_gradient_selector_edit_vector_clicked (GtkWidget *w, SPGradientSelector *sel); static void sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel); +static void sp_gradient_selector_delete_vector_clicked (GtkWidget *w, SPGradientSelector *sel); + static GtkVBoxClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; @@ -125,6 +127,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) sel->safelyInit = true; sel->blocked = false; new (&sel->nonsolid) std::vector(); + new (&sel->swatch_widgets) std::vector(); sel->mode = SPGradientSelector::MODE_LINEAR; @@ -189,7 +192,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) #else GtkWidget *hb = gtk_hbox_new( FALSE, 2 ); #endif - sel->nonsolid.push_back(hb); + //sel->nonsolid.push_back(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); sel->add = gtk_button_new (); @@ -213,6 +216,16 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) gtk_button_set_relief(GTK_BUTTON(sel->edit), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text( sel->edit, _("Edit gradient")); + sel->del = gtk_button_new (); + gtk_button_set_image((GtkButton*)sel->del , gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); + + sel->swatch_widgets.push_back(sel->del); + gtk_box_pack_start (GTK_BOX (hb), sel->del, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (sel->del), "clicked", G_CALLBACK (sp_gradient_selector_delete_vector_clicked), sel); + gtk_widget_set_sensitive (sel->del, FALSE); + gtk_button_set_relief(GTK_BUTTON(sel->del), GTK_RELIEF_NONE); + gtk_widget_set_tooltip_text( sel->del, _("Delete swatch")); + gtk_widget_show_all(hb); @@ -226,6 +239,7 @@ static void sp_gradient_selector_dispose(GObject *object) sel->safelyInit = false; using std::vector; sel->nonsolid.~vector(); + sel->swatch_widgets.~vector(); } if (sel->icon_renderer) { @@ -265,9 +279,23 @@ void SPGradientSelector::setMode(SelectorMode mode) { gtk_widget_hide(*it); } + for (std::vector::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it) + { + gtk_widget_show_all(*it); + } SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors); vs->setSwatched(); + } else { + for (std::vector::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it) + { + gtk_widget_show_all(*it); + } + for (std::vector::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it) + { + gtk_widget_hide(*it); + } + } } } @@ -412,6 +440,17 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector) gtk_widget_show_all(*it); } } + } else if (mode != MODE_SWATCH) { + + for (std::vector::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it) + { + gtk_widget_hide(*it); + } + for (std::vector::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it) + { + gtk_widget_show_all(*it); + } + } if (edit) { @@ -420,6 +459,9 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector) if (add) { gtk_widget_set_sensitive(add, TRUE); } + if (del) { + gtk_widget_set_sensitive(del, TRUE); + } } else { if (edit) { gtk_widget_set_sensitive(edit, FALSE); @@ -427,6 +469,9 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector) if (add) { gtk_widget_set_sensitive(add, (doc != NULL)); } + if (del) { + gtk_widget_set_sensitive(del, FALSE); + } } } @@ -451,6 +496,29 @@ sp_gradient_selector_vector_set (SPGradientVectorSelector *gvs, SPGradient *gr, } } + +static void +sp_gradient_selector_delete_vector_clicked (GtkWidget */*w*/, SPGradientSelector *sel) +{ + const Glib::RefPtr selection = sel->treeview->get_selection(); + if (!selection) { + return; + } + + SPGradient *obj = NULL; + /* Single selection */ + Gtk::TreeModel::iterator iter = selection->get_selected(); + if ( iter ) { + Gtk::TreeModel::Row row = *iter; + obj = row[sel->columns->data]; + } + + if (obj) { + sp_gradient_unset_swatch(SP_ACTIVE_DESKTOP, obj->getId()); + } + +} + static void sp_gradient_selector_edit_vector_clicked (GtkWidget */*w*/, SPGradientSelector *sel) { diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index 01c18a48d..ea83ff819 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -97,6 +97,7 @@ struct SPGradientSelector { /* Editing buttons */ GtkWidget *edit; GtkWidget *add; + GtkWidget *del; GtkWidget *merge; /* Position widget */ @@ -106,6 +107,7 @@ struct SPGradientSelector { bool blocked; std::vector nonsolid; + std::vector swatch_widgets; void setMode(SelectorMode mode); void setUnits(SPGradientUnits units); -- cgit v1.2.3 From 7d0688dffd46de8bd6defea214606ab1ad417595 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 29 Nov 2012 09:32:43 +0900 Subject: Fix for 171466 : F/S set swatch preview column name (bzr r11912) --- src/widgets/gradient-selector.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index a900a0d10..89a891284 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -284,6 +284,9 @@ void SPGradientSelector::setMode(SelectorMode mode) gtk_widget_show_all(*it); } + Gtk::TreeView::Column* icon_column = treeview->get_column(0); + icon_column->set_title(_("Swatch")); + SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors); vs->setSwatched(); } else { @@ -295,6 +298,8 @@ void SPGradientSelector::setMode(SelectorMode mode) { gtk_widget_hide(*it); } + Gtk::TreeView::Column* icon_column = treeview->get_column(0); + icon_column->set_title(_("Gradient")); } } -- cgit v1.2.3 From 32598fdd4d1e85228e46242d37f83c739591a078 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 29 Nov 2012 09:37:30 +0900 Subject: Fix for 1073128 : Command line PNG export fails if FeFlood filter primitive is present (bzr r11913) --- src/display/nr-filter-primitive.cpp | 3 +-- src/inkscape.cpp | 4 ++++ src/main.cpp | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index 93c6d4d6e..ce562668a 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -111,8 +111,7 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units) // This is definitely a hack... but what else to do? // Current viewport might not be document viewport... but how to find? - SPDesktop* desktop = inkscape_active_desktop(); - SPDocument* document = sp_desktop_document(desktop); + SPDocument* document = inkscape_active_document(); SPRoot* root = document->getRoot(); Geom::Rect viewport; if( root->viewBox_set ) { diff --git a/src/inkscape.cpp b/src/inkscape.cpp index fc9a9783f..fc823f8b7 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1270,6 +1270,10 @@ inkscape_active_document (void) { if (SP_ACTIVE_DESKTOP) { return sp_desktop_document (SP_ACTIVE_DESKTOP); + } else if (!inkscape->document_set.empty()) { + // If called from the command line there will be no desktop + // So 'fall back' to take the first listed document in the Inkscape instance + return inkscape->document_set.begin()->first; } return NULL; diff --git a/src/main.cpp b/src/main.cpp index 844aded56..be8049cf5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1032,6 +1032,9 @@ static int sp_process_file_list(GSList *fl) g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename); retVal++; } else { + + inkscape_add_document(doc); + if (sp_vacuum_defs) { doc->vacuumDocument(); } @@ -1099,6 +1102,8 @@ static int sp_process_file_list(GSList *fl) do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id); } + inkscape_remove_document(doc); + delete doc; } fl = g_slist_remove(fl, fl->data); -- cgit v1.2.3 From 773355863afe9b5ddb1afad277fe795b0d5d70b6 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 29 Nov 2012 10:15:34 +0100 Subject: Fix for #955141: Converting clipped object to pattern produces rasterised pattern. (bzr r11914) --- src/display/drawing-context.h | 2 ++ src/display/drawing-item.cpp | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index fb6662202..b8c4667c2 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -101,6 +101,8 @@ public: cairo_t *raw() { return _ct; } cairo_surface_t *rawTarget() { return cairo_get_group_target(_ct); } + DrawingSurface *surface() { return _surface; } // Needed to find scale in drawing-item.cpp + private: DrawingContext(cairo_t *ct, DrawingSurface *surface, bool destroy); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 0fb1f0018..b443ad22a 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -20,6 +20,7 @@ #include "nr-filter.h" #include "preferences.h" #include "style.h" +#include "2geom/rect.h" namespace Inkscape { @@ -540,8 +541,17 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag iarea.intersectWith(_drawbox); } - DrawingSurface intermediate(*iarea); + // Must use same scale factor between "logical space" (coordinates in the + // rendering) and "physical space" (surface pixels). See drawing-surface.cpp. + // See bug 955141. + // There must be a better lib2geom way of finding sarea. + DrawingSurface* ds = ct.surface(); + Geom::Scale scale = ds->scale(); + Geom::Rect rarea( *iarea ); + Geom::Point sarea( rarea.dimensions() * scale ); + DrawingSurface intermediate( *iarea, sarea.ceil() ); DrawingContext ict(intermediate); + unsigned render_result = RENDER_OK; // 1. Render clipping path with alpha = opacity. @@ -614,9 +624,24 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag cachect.fill(); _cache->markClean(*carea); } - ct.rectangle(*carea); + + ct.rectangle(*carea); // Area to be filled + + // Account for difference between logical and physical spaces. + ct.scale( intermediate.scale().inverse() ); + + // Must shift origin to compensate for scaling. + Geom::Point factor( Geom::Point(1,1) - intermediate.scale().vector() ); + Geom::Point origin( intermediate.origin() ); + Geom::Point shift( origin[Geom::X] * factor[Geom::X], origin[Geom::Y] * factor[Geom::Y] ); + ct.translate( -shift ); + ct.setSource(&intermediate); ct.fill(); + + ct.translate( shift ); + ct.scale( intermediate.scale() ); + ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct -- cgit v1.2.3 From 91276e1763b33970684e93ef6a20cd2134a5be57 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 30 Nov 2012 11:05:35 +0900 Subject: Fix for 430301 : core dump exporting to non existing folder (bzr r11915) --- src/io/sys.cpp | 34 ++++++++++++++++++++++++ src/io/sys.h | 2 ++ src/main.cpp | 82 +++++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 89 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/io/sys.cpp b/src/io/sys.cpp index 5f19ee5db..26c1993a7 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -239,6 +239,40 @@ bool Inkscape::IO::file_is_writable( char const *utf8name) return success; } +/**Checks if directory of file exists, useful + * because inkscape doesn't create directories.*/ +bool Inkscape::IO::file_directory_exists( char const *utf8name ){ + bool exists = true; + + if ( utf8name) { + gchar *filename = NULL; + if (utf8name && !g_utf8_validate(utf8name, -1, NULL)) { + /* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable. + If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to + use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false) + to beginning of this function. */ + filename = g_strdup(utf8name); + // Looks like g_get_home_dir isn't safe. + //g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!"); + } else { + filename = g_filename_from_utf8 ( utf8name, -1, NULL, NULL, NULL ); + } + if ( filename ) { + gchar *dirname = g_path_get_dirname(filename); + exists = Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS); + g_free(filename); + g_free(dirname); + filename = NULL; + dirname = NULL; + } else { + g_warning( "Unable to convert filename in IO:file_test" ); + } + } + + return exists; + +} + /** Wrapper around g_dir_open, but taking a utf8name as first argument. */ GDir * Inkscape::IO::dir_open(gchar const *const utf8name, guint const flags, GError **const error) diff --git a/src/io/sys.h b/src/io/sys.h index fbfe4d4c4..78d25afa3 100644 --- a/src/io/sys.h +++ b/src/io/sys.h @@ -36,6 +36,8 @@ int file_open_tmp( std::string& name_used, const std::string& prefix ); bool file_test( char const *utf8name, GFileTest test ); +bool file_directory_exists( char const *utf8name ); + bool file_is_writable( char const *utf8name); GDir *dir_open(gchar const *utf8name, guint flags, GError **error); diff --git a/src/main.cpp b/src/main.cpp index be8049cf5..20330edbb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -169,10 +169,10 @@ enum { int sp_main_gui(int argc, char const **argv); int sp_main_console(int argc, char const **argv); -static void sp_do_export_png(SPDocument *doc); -static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime); +static int sp_do_export_png(SPDocument *doc); +static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime); #ifdef WIN32 -static void do_export_emf(SPDocument* doc, gchar const* uri, char const *mime); +static int do_export_emf(SPDocument* doc, gchar const* uri, char const *mime); #endif //WIN32 static void do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id); static void do_query_all (SPDocument *doc); @@ -1046,7 +1046,7 @@ static int sp_process_file_list(GSList *fl) sp_print_document_to_file(doc, sp_global_printer); } if (sp_export_png || (sp_export_id && sp_export_use_hints)) { - sp_do_export_png(doc); + retVal |= sp_do_export_png(doc); } if (sp_export_svg) { if (sp_export_text_to_path) { @@ -1081,17 +1081,17 @@ static int sp_process_file_list(GSList *fl) doc->getBase(), sp_export_svg); } if (sp_export_ps) { - do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript"); + retVal |= do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript"); } if (sp_export_eps) { - do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript"); + retVal |= do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript"); } if (sp_export_pdf) { - do_export_ps_pdf(doc, sp_export_pdf, "application/pdf"); + retVal |= do_export_ps_pdf(doc, sp_export_pdf, "application/pdf"); } #ifdef WIN32 if (sp_export_emf) { - do_export_emf(doc, sp_export_emf, "image/x-emf"); + retVal |= do_export_emf(doc, sp_export_emf, "image/x-emf"); } #endif //WIN32 if (sp_query_all) { @@ -1299,7 +1299,7 @@ do_query_all_recurse (SPObject *o) } -static void sp_do_export_png(SPDocument *doc) +static int sp_do_export_png(SPDocument *doc) { Glib::ustring filename; bool filename_from_hint = false; @@ -1330,7 +1330,7 @@ static void sp_do_export_png(SPDocument *doc) if (o) { if (!SP_IS_ITEM (o)) { g_warning("Object with id=\"%s\" is not a visible item. Nothing exported.", sp_export_id); - return; + return 1; } items = g_slist_prepend (items, SP_ITEM(o)); @@ -1377,11 +1377,11 @@ static void sp_do_export_png(SPDocument *doc) area = *areaMaybe; } else { g_warning("Unable to determine a valid bounding box. Nothing exported."); - return; + return 1; } } else { g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id); - return; + return 1; } } @@ -1390,7 +1390,7 @@ static void sp_do_export_png(SPDocument *doc) gdouble x0,y0,x1,y1; if (sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &x0, &y0, &x1, &y1) != 4) { g_warning("Cannot parse export area '%s'; use 'x0:y0:x1:y1'. Nothing exported.", sp_export_area); - return; + return 1; } area = Geom::Rect(Geom::Interval(x0,x1), Geom::Interval(y0,y1)); } else if (sp_export_area_page || !(sp_export_id || sp_export_area_drawing)) { @@ -1404,7 +1404,7 @@ static void sp_do_export_png(SPDocument *doc) if (filename.empty()) { if (!sp_export_png) { g_warning ("No export filename given and no filename hint. Nothing exported."); - return; + return 1; } filename = sp_export_png; } @@ -1413,7 +1413,7 @@ static void sp_do_export_png(SPDocument *doc) dpi = atof(sp_export_dpi); if ((dpi < 0.1) || (dpi > 10000.0)) { g_warning("DPI value %s out of range [0.1 - 10000.0]. Nothing exported.", sp_export_dpi); - return; + return 1; } g_print("DPI: %g\n", dpi); } @@ -1435,7 +1435,7 @@ static void sp_do_export_png(SPDocument *doc) width = strtoul(sp_export_width, NULL, 0); if ((width < 1) || (width > PNG_UINT_31_MAX) || (errno == ERANGE) ) { g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX); - return; + return 1; } dpi = (gdouble) width * PX_PER_IN / area.width(); } @@ -1445,7 +1445,7 @@ static void sp_do_export_png(SPDocument *doc) height = strtoul(sp_export_height, NULL, 0); if ((height < 1) || (height > PNG_UINT_31_MAX)) { g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX); - return; + return 1; } dpi = (gdouble) height * PX_PER_IN / area.height(); } @@ -1508,19 +1508,28 @@ static void sp_do_export_png(SPDocument *doc) path = filename; } - g_print("Background RRGGBBAA: %08x\n", bgcolor); + int retcode = 0; + //check if specified directory exists - g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); + if (!Inkscape::IO::file_directory_exists(filename.c_str())) { + g_warning("File path \"%s\" includes directory that doesn't exist.\n", filename.c_str()); + retcode = 1; + } else { + g_print("Background RRGGBBAA: %08x\n", bgcolor); - g_print("Bitmap saved as: %s\n", filename.c_str()); + g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); - if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { - sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); - } else { - g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); + g_print("Bitmap saved as: %s\n", filename.c_str()); + + if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { + sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); + } else { + g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); + } } g_slist_free (items); + return retcode; } @@ -1532,7 +1541,7 @@ static void sp_do_export_png(SPDocument *doc) * \param mime MIME type to export as. */ -static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) +static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) { Inkscape::Extension::DB::OutputList o; Inkscape::Extension::db.get_output_list(o); @@ -1544,14 +1553,14 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime if (i == o.end()) { g_warning ("Could not find an extension to export to MIME type %s.", mime); - return; + return 1; } if (sp_export_id) { SPObject *o = doc->getObjectById(sp_export_id); if (o == NULL) { g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id); - return; + return 1; } (*i)->set_param_string ("exportId", sp_export_id); } else { @@ -1612,7 +1621,14 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime (*i)->set_param_int("resolution", (int) dpi); } + //check if specified directory exists + if (!Inkscape::IO::file_directory_exists(uri)) { + g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); + return 1; + } + (*i)->save(doc, uri); + return 0; } #ifdef WIN32 @@ -1624,7 +1640,7 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime * \param mime MIME type to export as (should be "image/x-emf") */ -static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) +static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) { Inkscape::Extension::DB::OutputList o; Inkscape::Extension::db.get_output_list(o); @@ -1636,10 +1652,18 @@ static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) if (i == o.end()) { g_warning ("Could not find an extension to export to MIME type %s.", mime); - return; + return 1; + } + + //check if specified directory exists + if (!Inkscape::IO::file_directory_exists(uri)){ + g_warning("File path \"%s\" includes directory that doesn't exist.\n", + uri); + return 1; } (*i)->save(doc, uri); + return 0; } #endif //WIN32 -- cgit v1.2.3 From b2b5252360d16fa3a1dd8cc172a2b7a09ba716e4 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 30 Nov 2012 21:11:42 +0900 Subject: Fix for 255792 : Calligraphy tool presets management (bzr r11916) --- src/preferences.cpp | 11 ++++ src/preferences.h | 7 +++ src/ui/dialog/calligraphic-profile-rename.cpp | 39 +++++++++++- src/ui/dialog/calligraphic-profile-rename.h | 8 ++- src/widgets/calligraphy-toolbar.cpp | 85 ++++++++++++++++++++++----- src/widgets/toolbox.cpp | 1 + 6 files changed, 132 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/preferences.cpp b/src/preferences.cpp index 1f985a629..3f12c4f64 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -504,6 +504,17 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) sp_repr_css_attr_unref(current); } +/** + * Remove an entry + * Make sure observers have been removed before calling + */ +void Preferences::remove(Glib::ustring const &pref_path) +{ + Inkscape::XML::Node *node = _getNode(pref_path, false); + if (node && node->parent()) { + node->parent()->removeChild(node); + } +} /** * Class that holds additional information for registered Observers. diff --git a/src/preferences.h b/src/preferences.h index 5dcf4524d..66fa11542 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -503,6 +503,13 @@ public: static void unload(bool save=true); /*@}*/ + /** + * Remove a node from prefs + * @param pref_path Path to entry + * + */ + void remove(Glib::ustring const &pref_path); + protected: /* helper methods used by Entry * This will enable using the same Entry class with different backends. diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index c6633df0b..77a4f4f03 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -30,6 +30,8 @@ namespace Dialog { CalligraphicProfileRename::CalligraphicProfileRename() : _applied(false) { + set_title(_("Edit profile")); + Gtk::Box *mainVBox = get_vbox(); _layout_table.set_spacings(4); _layout_table.resize (1, 2); @@ -49,19 +51,27 @@ CalligraphicProfileRename::CalligraphicProfileRename() : _close_button.set_label(Gtk::Stock::CANCEL.id); _close_button.set_can_default(); + _delete_button.set_use_underline(true); + _delete_button.set_label(_("Delete")); + _delete_button.set_can_default(); + _delete_button.set_visible(false); + _apply_button.set_use_underline(true); _apply_button.set_label(_("Save")); _apply_button.set_can_default(); _close_button.signal_clicked() - .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_close)); + .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_close)); + _delete_button.signal_clicked() + .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_delete)); _apply_button.signal_clicked() - .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_apply)); + .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_apply)); signal_delete_event().connect( sigc::bind_return( sigc::hide(sigc::mem_fun(*this, &CalligraphicProfileRename::_close)), true ) ); add_action_widget(_close_button, Gtk::RESPONSE_CLOSE); + add_action_widget(_delete_button, Gtk::RESPONSE_DELETE_EVENT); add_action_widget(_apply_button, Gtk::RESPONSE_APPLY); _apply_button.grab_default(); @@ -73,6 +83,15 @@ void CalligraphicProfileRename::_apply() { _profile_name = _profile_name_entry.get_text(); _applied = true; + _deleted = false; + _close(); +} + +void CalligraphicProfileRename::_delete() +{ + _profile_name = _profile_name_entry.get_text(); + _applied = true; + _deleted = true; _close(); } @@ -81,11 +100,25 @@ void CalligraphicProfileRename::_close() this->Gtk::Dialog::hide(); } -void CalligraphicProfileRename::show(SPDesktop *desktop) +void CalligraphicProfileRename::show(SPDesktop *desktop, const Glib::ustring profile_name) { CalligraphicProfileRename &dial = instance(); dial._applied=false; + dial._deleted=false; dial.set_modal(true); + + dial._profile_name = profile_name; + dial._profile_name_entry.set_text(profile_name); + + if (profile_name.empty()) { + dial.set_title(_("Add profile")); + dial._delete_button.set_visible(false); + + } else { + dial.set_title(_("Edit profile")); + dial._delete_button.set_visible(true); + } + desktop->setWindowTransient (dial.gobj()); dial.property_destroy_with_parent() = true; // dial.Gtk::Dialog::show(); diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index f0eb0b491..8fe82d7bb 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -29,10 +29,13 @@ public: return "CalligraphicProfileRename"; } - static void show(SPDesktop *desktop); + static void show(SPDesktop *desktop, const Glib::ustring profile_name); static bool applied() { return instance()._applied; } + static bool deleted() { + return instance()._deleted; + } static Glib::ustring getProfileName() { return instance()._profile_name; } @@ -40,14 +43,17 @@ public: protected: void _close(); void _apply(); + void _delete(); Gtk::Label _profile_name_label; Gtk::Entry _profile_name_entry; Gtk::Table _layout_table; Gtk::Button _close_button; + Gtk::Button _delete_button; Gtk::Button _apply_button; Glib::ustring _profile_name; bool _applied; + bool _deleted; private: static CalligraphicProfileRename &instance() { static CalligraphicProfileRename instance_; diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp index 1c39cd9e5..287deb815 100644 --- a/src/widgets/calligraphy-toolbar.cpp +++ b/src/widgets/calligraphy-toolbar.cpp @@ -74,6 +74,16 @@ using Inkscape::UI::PrefPusher; //######################## //## Calligraphy ## //######################## + +std::vector get_presets_list() { + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); + + return presets; +} + void update_presets_list(GObject *tbl) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -88,7 +98,7 @@ void update_presets_list(GObject *tbl) return; } - std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); + std::vector presets = get_presets_list(); int ege_index = 1; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) { @@ -233,22 +243,24 @@ static void sp_dcc_build_presets_list(GObject *tbl) // iterate over all presets to populate the list Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); + std::vector presets = get_presets_list(); int ii=1; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i) { GtkTreeIter iter; Glib::ustring preset_name = prefs->getString(*i + "/name"); - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, 0, _(preset_name.data()), 1, ii++, -1 ); + if (!preset_name.empty()) { + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, 0, _(preset_name.data()), 1, ii++, -1 ); + } } - { +/* { GtkTreeIter iter; gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Save..."), 1, ii, -1 ); g_object_set_data(tbl, "save_presets_index", GINT_TO_POINTER(ii)); - } + }*/ g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE)); @@ -268,15 +280,25 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) return; } - CalligraphicProfileRename::show(desktop); + EgeSelectOneAction *sel = static_cast(g_object_get_data(tbl, "profile_selector")); + //gint preset_index = ege_select_one_action_get_active( sel ); + Glib::ustring current_profile_name = _("No preset"); + if (ege_select_one_action_get_active_text( sel )) { + current_profile_name = ege_select_one_action_get_active_text( sel ); + } + + if (current_profile_name == _("No preset")) { + current_profile_name = ""; + } + CalligraphicProfileRename::show(desktop, current_profile_name); if ( !CalligraphicProfileRename::applied()) { // dialog cancelled update_presets_list (tbl); return; } - Glib::ustring profile_name = CalligraphicProfileRename::getProfileName(); + Glib::ustring new_profile_name = CalligraphicProfileRename::getProfileName(); - if (profile_name.empty()) { + if (new_profile_name.empty()) { // empty name entered update_presets_list (tbl); return; @@ -285,7 +307,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); // If there's a preset with the given name, find it and set save_path appropriately - std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); + std::vector presets = get_presets_list(); int total_presets = presets.size(); int new_index = -1; Glib::ustring save_path; // profile pref path without a trailing slash @@ -293,13 +315,21 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) int temp_index = 0; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) { Glib::ustring name = prefs->getString(*i + "/name"); - if (!name.empty() && profile_name == name) { + if (!name.empty() && (new_profile_name == name || current_profile_name == name)) { new_index = temp_index; save_path = *i; break; } } + + if ( CalligraphicProfileRename::deleted() && new_index != -1) { + prefs->remove(save_path); + g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE)); + sp_dcc_build_presets_list (tbl); + return; + } + if (new_index == -1) { // no preset with this name, create new_index = total_presets + 1; @@ -327,7 +357,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) g_warning("Bad key when writing preset: %s\n", widget_name); } } - prefs->setString(save_path + "/name", profile_name); + prefs->setString(save_path + "/name", new_profile_name); g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE)); sp_dcc_build_presets_list (tbl); @@ -338,7 +368,7 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint preset_index = ege_select_one_action_get_active( act ); + guint preset_index = ege_select_one_action_get_active( act ); // This is necessary because EgeSelectOneAction spams us with GObject "changed" signal calls // even when the preset is not changed. It would be good to replace it with something more // modern. Index 0 means "No preset", so we don't do anything. @@ -346,6 +376,7 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) return; } +/* gint save_presets_index = GPOINTER_TO_INT(g_object_get_data(tbl, "save_presets_index")); if (preset_index == save_presets_index) { @@ -353,14 +384,19 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) sp_dcc_save_profile(NULL, tbl); return; } +*/ if (g_object_get_data(tbl, "presets_blocked")) { return; } // preset_index is one-based so we subtract 1 - std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); - Glib::ustring preset_path = presets.at(preset_index - 1); + std::vector presets = get_presets_list(); + + Glib::ustring preset_path = ""; + if (preset_index - 1 < presets.size()) { + preset_path = presets.at(preset_index - 1); + } if (!preset_path.empty()) { g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it @@ -391,9 +427,16 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) } } g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE)); + } else { + ege_select_one_action_set_active(act, 0); } } +static void sp_ddc_edit_profile(GtkAction * /*act*/, GObject* tbl) +{ + sp_dcc_save_profile(NULL, tbl); +} + void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -595,6 +638,18 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions g_signal_connect(G_OBJECT(act1), "changed", G_CALLBACK(sp_ddc_change_profile), holder); gtk_action_group_add_action(mainActions, GTK_ACTION(act1)); } + + /*calligraphic profile editor */ + { + InkAction* inky = ink_action_new( "ProfileEditAction", + _("Add/Edit Profile"), + _("Add or edit calligraphic profile"), + GTK_STOCK_PROPERTIES, + Inkscape::ICON_SIZE_DECORATION ); + g_object_set( inky, "short_label", _("Edit"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_ddc_edit_profile), (GObject*)holder ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } } } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index b758e4f0f..a5e929c7d 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -407,6 +407,7 @@ static gchar const * ui_descr = " " " " " " + " " " " " " " " -- cgit v1.2.3 From 4b3c78c2b08883810527be30f9ba9937d6a8dc5a Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 30 Nov 2012 21:35:42 +0900 Subject: Fix for 1084341 : Gradient Tool : Hide gradient handles on a solid color swatch (bzr r11917) --- src/gradient-drag.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index c775a19d7..69b9db92d 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2080,7 +2080,7 @@ void GrDrag::updateDraggers() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = style->getFillPaintServer(); - if ( server && server->isSolid() ) { + if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL ); @@ -2094,7 +2094,7 @@ void GrDrag::updateDraggers() if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = style->getStrokePaintServer(); - if ( server && server->isSolid() ) { + if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE ); @@ -2145,7 +2145,7 @@ void GrDrag::updateLines() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( server && server->isSolid() ) { + if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); @@ -2204,7 +2204,7 @@ void GrDrag::updateLines() if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( server && server->isSolid() ) { + if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); -- cgit v1.2.3 From 3758aabe9c73e3afc8b070c652a77fd749509ece Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 1 Dec 2012 19:23:24 +0000 Subject: Migrate inkview buttons from deprecated GtkTable layout to GtkButtonBox (bzr r11918) --- src/inkview.cpp | 63 +++++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/inkview.cpp b/src/inkview.cpp index 3831cab95..ee93b4134 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -337,44 +337,37 @@ sp_svgview_ctrlwin_delete (GtkWidget */*widget*/, GdkEvent */*event*/, void */*d return FALSE; } -static GtkWidget * -sp_svgview_control_show (struct SPSlideShow *ss) +static GtkWidget* sp_svgview_control_show(struct SPSlideShow *ss) { if (!ctrlwin) { - GtkWidget *t, *b; - ctrlwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_transient_for (GTK_WINDOW(ctrlwin), GTK_WINDOW(ss->window)); - g_signal_connect (G_OBJECT (ctrlwin), "key_press_event", (GCallback) sp_svgview_main_key_press, ss); - g_signal_connect (G_OBJECT (ctrlwin), "delete_event", (GCallback) sp_svgview_ctrlwin_delete, NULL); - t = gtk_table_new (1, 4, TRUE); - gtk_container_add ((GtkContainer *) ctrlwin, t); - b = gtk_button_new_from_stock (GTK_STOCK_GOTO_FIRST); - gtk_table_attach ((GtkTable *) t, b, 0, 1, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - 0, 0); - g_signal_connect ((GObject *) b, "clicked", (GCallback) sp_svgview_goto_first_cb, ss); - b = gtk_button_new_from_stock (GTK_STOCK_GO_BACK); - gtk_table_attach ((GtkTable *) t, b, 1, 2, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - 0, 0); - g_signal_connect (G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss); - b = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD); - gtk_table_attach ((GtkTable *) t, b, 2, 3, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - 0, 0); - g_signal_connect (G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss); - b = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST); - gtk_table_attach ((GtkTable *) t, b, 3, 4, 0, 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - 0, 0); - g_signal_connect (G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss); - gtk_widget_show_all (ctrlwin); + ctrlwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_resizable(GTK_WINDOW(ctrlwin), FALSE); + gtk_window_set_transient_for(GTK_WINDOW(ctrlwin), GTK_WINDOW(ss->window)); + g_signal_connect(G_OBJECT (ctrlwin), "key_press_event", (GCallback) sp_svgview_main_key_press, ss); + g_signal_connect(G_OBJECT (ctrlwin), "delete_event", (GCallback) sp_svgview_ctrlwin_delete, NULL); + +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *t = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); +#else + GtkWidget *t = gtk_hbutton_box_new(); +#endif + + gtk_container_add(GTK_CONTAINER(ctrlwin), t); + GtkWidget *b = gtk_button_new_from_stock(GTK_STOCK_GOTO_FIRST); + gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss); + b = gtk_button_new_from_stock(GTK_STOCK_GO_BACK); + gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss); + b = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); + gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss); + b = gtk_button_new_from_stock(GTK_STOCK_GOTO_LAST); + gtk_container_add(GTK_CONTAINER(t), b); + g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss); + gtk_widget_show_all(ctrlwin); } else { - gtk_window_present ((GtkWindow *) ctrlwin); + gtk_window_present(GTK_WINDOW(ctrlwin)); } return NULL; -- cgit v1.2.3 From 5bb969ec0bffe89d0a49ae7906da35de75a2328f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 1 Dec 2012 19:42:24 +0000 Subject: Drop unused sp-color-gtkselector code (bzr r11919) --- src/widgets/CMakeLists.txt | 2 - src/widgets/Makefile_insert | 2 - src/widgets/sp-color-gtkselector.cpp | 153 ----------------------------------- src/widgets/sp-color-gtkselector.h | 55 ------------- 4 files changed, 212 deletions(-) delete mode 100644 src/widgets/sp-color-gtkselector.cpp delete mode 100644 src/widgets/sp-color-gtkselector.h (limited to 'src') diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 38180bd69..19410ee1d 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -36,7 +36,6 @@ set(widgets_SRC select-toolbar.cpp shrink-wrap-button.cpp sp-attribute-widget.cpp - sp-color-gtkselector.cpp sp-color-icc-selector.cpp sp-color-notebook.cpp sp-color-scales.cpp @@ -94,7 +93,6 @@ set(widgets_SRC select-toolbar.h shrink-wrap-button.h sp-attribute-widget.h - sp-color-gtkselector.h sp-color-icc-selector.h sp-color-notebook.h sp-color-scales.h diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert index 7d6b413bd..46f0bd645 100644 --- a/src/widgets/Makefile_insert +++ b/src/widgets/Makefile_insert @@ -66,8 +66,6 @@ ink_common_sources += \ widgets/spiral-toolbar.h \ widgets/sp-attribute-widget.cpp \ widgets/sp-attribute-widget.h \ - widgets/sp-color-gtkselector.cpp \ - widgets/sp-color-gtkselector.h \ widgets/sp-color-icc-selector.cpp \ widgets/sp-color-icc-selector.h \ widgets/sp-color-notebook.cpp \ diff --git a/src/widgets/sp-color-gtkselector.cpp b/src/widgets/sp-color-gtkselector.cpp deleted file mode 100644 index b19685c66..000000000 --- a/src/widgets/sp-color-gtkselector.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include -#include "sp-color-gtkselector.h" - - -static void sp_color_gtkselector_class_init (SPColorGtkselectorClass *klass); -static void sp_color_gtkselector_init (SPColorGtkselector *csel); -static void sp_color_gtkselector_dispose(GObject *object); - -static void sp_color_gtkselector_show_all (GtkWidget *widget); -static void sp_color_gtkselector_hide(GtkWidget *widget); - - -static SPColorSelectorClass *parent_class; - -#define XPAD 4 -#define YPAD 1 - -GType -sp_color_gtkselector_get_type (void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof (SPColorGtkselectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_color_gtkselector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPColorGtkselector), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_color_gtkselector_init, - NULL, - }; - - type = g_type_register_static (SP_TYPE_COLOR_SELECTOR, - "SPColorGtkselector", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; -} - -static void -sp_color_gtkselector_class_init (SPColorGtkselectorClass *klass) -{ - static const gchar* nameset[] = {N_("System"), 0}; - GObjectClass *object_class = (GObjectClass *) klass; - GtkWidgetClass *widget_class; - SPColorSelectorClass *selector_class; - - widget_class = (GtkWidgetClass *) klass; - selector_class = SP_COLOR_SELECTOR_CLASS (klass); - - parent_class = SP_COLOR_SELECTOR_CLASS (g_type_class_peek_parent (klass)); - - selector_class->name = nameset; - selector_class->submode_count = 1; - - object_class->dispose = sp_color_gtkselector_dispose; - - widget_class->show_all = sp_color_gtkselector_show_all; - widget_class->hide = sp_color_gtkselector_hide; -} - -void sp_color_gtkselector_init (SPColorGtkselector *csel) -{ - SP_COLOR_SELECTOR(csel)->base = new ColorGtkselector( SP_COLOR_SELECTOR(csel) ); - - if ( SP_COLOR_SELECTOR(csel)->base ) - { - SP_COLOR_SELECTOR(csel)->base->init(); - } -} - -void ColorGtkselector::init() -{ - GtkWidget *gtksel = gtk_color_selection_new(); - gtk_widget_show (gtksel); - _gtkThing = GTK_COLOR_SELECTION (gtksel); - gtk_box_pack_start (GTK_BOX (_csel), gtksel, TRUE, TRUE, 0); - - _sigId = g_signal_connect(gtksel, "color-changed", G_CALLBACK( _gtkChanged ), _csel); -} - -static void sp_color_gtkselector_dispose(GObject *object) -{ - if (((GObjectClass *) (parent_class))->dispose) - (* ((GObjectClass *) (parent_class))->dispose) (object); -} - -static void -sp_color_gtkselector_show_all (GtkWidget *widget) -{ - gtk_widget_show (widget); -} - -static void sp_color_gtkselector_hide(GtkWidget *widget) -{ - gtk_widget_hide(widget); -} - -GtkWidget * -sp_color_gtkselector_new( GType ) -{ - SPColorGtkselector *csel = SP_COLOR_GTKSELECTOR(g_object_new (SP_TYPE_COLOR_GTKSELECTOR, NULL)); - - return GTK_WIDGET (csel); -} - -ColorGtkselector::ColorGtkselector( SPColorSelector* csel ) - : ColorSelector( csel ), - _gtkThing(0) -{ -} - -ColorGtkselector::~ColorGtkselector() -{ -} - -void ColorGtkselector::_colorChanged() -{ - GdkColor gcolor; - - gcolor.pixel = 0; - gcolor.red = static_cast< guint16 >(_color.v.c[0] * 65535); - gcolor.green = static_cast< guint16 >(_color.v.c[1] * 65535); - gcolor.blue = static_cast< guint16 >(_color.v.c[2] * 65535); - -// g_message( "***** _colorChanged %04x %04x %04x", gcolor.red, gcolor.green, gcolor.blue ); - g_signal_handler_block( _gtkThing, _sigId ); - gtk_color_selection_set_current_alpha( _gtkThing, static_cast(65535 * _alpha) ); - gtk_color_selection_set_current_color( _gtkThing, &gcolor ); - g_signal_handler_unblock(_gtkThing, _sigId ); -} - -void ColorGtkselector::_gtkChanged( GtkColorSelection *colorselection, SPColorGtkselector *gtksel ) -{ - GdkColor color; - gtk_color_selection_get_current_color (colorselection, &color); - - guint16 alpha = gtk_color_selection_get_current_alpha (colorselection); - - SPColor ourColor( (color.red / 65535.0), (color.green / 65535.0), (color.blue / 65535.0) ); - -// g_message( "***** _gtkChanged %04x %04x %04x", color.red, color.green, color.blue ); - - ColorGtkselector* gtkInst = static_cast(SP_COLOR_SELECTOR(gtksel)->base); - gtkInst->_updateInternals( ourColor, static_cast< gfloat > (alpha) / 65535.0, gtk_color_selection_is_adjusting(colorselection) ); -} diff --git a/src/widgets/sp-color-gtkselector.h b/src/widgets/sp-color-gtkselector.h deleted file mode 100644 index 3142406c1..000000000 --- a/src/widgets/sp-color-gtkselector.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SEEN_SP_COLOR_GTKSELECTOR_H -#define SEEN_SP_COLOR_GTKSELECTOR_H - -#include -#include "../color.h" -#include "sp-color-selector.h" - -#include - - - -struct SPColorGtkselector; - - - -class ColorGtkselector: public ColorSelector -{ -public: - ColorGtkselector( SPColorSelector* csel ); - virtual ~ColorGtkselector(); - - virtual void init(); - -protected: - static void _gtkChanged( GtkColorSelection *colorselection, SPColorGtkselector *gtksel ); - - virtual void _colorChanged(); - - GtkColorSelection* _gtkThing; - gulong _sigId; -}; - - - -#define SP_TYPE_COLOR_GTKSELECTOR (sp_color_gtkselector_get_type ()) -#define SP_COLOR_GTKSELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselector)) -#define SP_COLOR_GTKSELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselectorClass)) -#define SP_IS_COLOR_GTKSELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_GTKSELECTOR)) -#define SP_IS_COLOR_GTKSELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_GTKSELECTOR)) - -struct SPColorGtkselector { - SPColorSelector base; -}; - -struct SPColorGtkselectorClass { - SPColorSelectorClass parent_class; -}; - -GType sp_color_gtkselector_get_type (void); - -GtkWidget *sp_color_gtkselector_new( GType selector_type ); - - - -#endif // SEEN_SP_COLOR_GTKSELECTOR_H -- cgit v1.2.3 From 2695bd6b9b38afcebaae0a7235111fa5534e85f3 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 1 Dec 2012 20:10:26 +0000 Subject: Migrate sp-color-wheel-selector to GtkGrid (bzr r11920) --- src/widgets/sp-color-wheel-selector.cpp | 55 ++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index fe168b403..57b762d0e 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -146,13 +146,17 @@ static void handleWheelAllocation(GtkHSV *hsv, GtkAllocation *allocation, gpoint void ColorWheelSelector::init() { - GtkWidget *t; gint row = 0; _updating = FALSE; _dragging = FALSE; - t = gtk_table_new (5, 3, FALSE); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *t = gtk_grid_new(); +#else + GtkWidget *t = gtk_table_new (5, 3, FALSE); +#endif + gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 0); @@ -162,7 +166,16 @@ void ColorWheelSelector::init() _wheel = gtk_hsv_new(); gtk_hsv_set_metrics( GTK_HSV(_wheel), 48, 8 ); gtk_widget_show( _wheel ); - gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(_wheel, GTK_ALIGN_FILL); + gtk_widget_set_valign(_wheel, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(_wheel, TRUE); + gtk_widget_set_vexpand(_wheel, TRUE); + gtk_grid_attach(GTK_GRID(t), _wheel, 0, row, 3, 1); +#else + gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); +#endif row++; @@ -170,7 +183,18 @@ void ColorWheelSelector::init() _label = gtk_label_new_with_mnemonic (_("_A:")); gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); gtk_widget_show (_label); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_label, XPAD); + gtk_widget_set_margin_right(_label, XPAD); + gtk_widget_set_margin_top(_label, YPAD); + gtk_widget_set_margin_bottom(_label, YPAD); + gtk_widget_set_halign(_label, GTK_ALIGN_FILL); + gtk_widget_set_valign(_label, GTK_ALIGN_FILL); + gtk_grid_attach(GTK_GRID(t), _label, 0, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); +#endif /* Adjustment */ _adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 10.0, 10.0); @@ -179,7 +203,19 @@ void ColorWheelSelector::init() _slider = sp_color_slider_new (_adj); gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); gtk_widget_show (_slider); - gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_slider, XPAD); + gtk_widget_set_margin_right(_slider, XPAD); + gtk_widget_set_margin_top(_slider, YPAD); + gtk_widget_set_margin_bottom(_slider, YPAD); + gtk_widget_set_hexpand(_slider, TRUE); + gtk_widget_set_halign(_slider, GTK_ALIGN_FILL); + gtk_widget_set_valign(_slider, GTK_ALIGN_FILL); + gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1); +#else + gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, XPAD, YPAD); +#endif sp_color_slider_set_colors (SP_COLOR_SLIDER (_slider), SP_RGBA32_F_COMPOSE (1.0, 1.0, 1.0, 0.0), @@ -193,7 +229,16 @@ void ColorWheelSelector::init() sp_dialog_defocus_on_enter (_sbtn); gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); gtk_widget_show (_sbtn); - gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_sbtn, XPAD); + gtk_widget_set_margin_right(_sbtn, XPAD); + gtk_widget_set_margin_top(_sbtn, YPAD); + gtk_widget_set_margin_bottom(_sbtn, YPAD); + gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1); +#else + gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, 0, 0, XPAD, YPAD); +#endif /* Signals */ g_signal_connect (G_OBJECT (_adj), "value_changed", -- cgit v1.2.3 From dc005b16ba5f51e635231787ec2733db244309ef Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 2 Dec 2012 11:37:57 +0000 Subject: Fix permissive casting in sp-color-wheel-selector (bzr r11921) --- src/widgets/sp-color-wheel-selector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 57b762d0e..57ce86ff6 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -174,7 +174,7 @@ void ColorWheelSelector::init() gtk_widget_set_vexpand(_wheel, TRUE); gtk_grid_attach(GTK_GRID(t), _wheel, 0, row, 3, 1); #else - gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); #endif row++; @@ -214,7 +214,7 @@ void ColorWheelSelector::init() gtk_widget_set_valign(_slider, GTK_ALIGN_FILL); gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1); #else - gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, XPAD, YPAD); + gtk_table_attach(GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); #endif sp_color_slider_set_colors (SP_COLOR_SLIDER (_slider), @@ -237,7 +237,7 @@ void ColorWheelSelector::init() gtk_widget_set_margin_bottom(_sbtn, YPAD); gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1); #else - gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, 0, 0, XPAD, YPAD); + gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); #endif /* Signals */ -- cgit v1.2.3 From b04301b979000497c3e4d7b799044b6964ad9a66 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 2 Dec 2012 18:53:59 +0000 Subject: Migrate sp-color-scales to GtkGrid and fix alignment in sp-color-wheel-selector (bzr r11922) --- src/widgets/sp-color-scales.cpp | 40 ++++++++++++++++++++++++++++++--- src/widgets/sp-color-wheel-selector.cpp | 2 ++ 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 159fc96e5..95c6d341d 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -133,13 +133,16 @@ void sp_color_scales_init (SPColorScales *cs) void ColorScales::init() { - GtkWidget *t; gint i; _updating = FALSE; _dragging = FALSE; - t = gtk_table_new (5, 3, FALSE); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *t = gtk_grid_new(); +#else + GtkWidget *t = gtk_table_new (5, 3, FALSE); +#endif gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4); @@ -149,20 +152,51 @@ void ColorScales::init() _l[i] = gtk_label_new(""); gtk_misc_set_alignment (GTK_MISC (_l[i]), 1.0, 0.5); gtk_widget_show (_l[i]); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_l[i], XPAD); + gtk_widget_set_margin_right(_l[i], XPAD); + gtk_widget_set_margin_top(_l[i], YPAD); + gtk_widget_set_margin_bottom(_l[i], YPAD); + gtk_grid_attach(GTK_GRID(t), _l[i], 0, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (t), _l[i], 0, 1, i, i + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); +#endif + /* Adjustment */ _a[i] = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, _rangeLimit, 1.0, 10.0, 10.0); /* Slider */ _s[i] = sp_color_slider_new (_a[i]); gtk_widget_show (_s[i]); - gtk_table_attach (GTK_TABLE (t), _s[i], 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_s[i], XPAD); + gtk_widget_set_margin_right(_s[i], XPAD); + gtk_widget_set_margin_top(_s[i], YPAD); + gtk_widget_set_margin_bottom(_s[i], YPAD); + gtk_widget_set_hexpand(_s[i], TRUE); + gtk_grid_attach(GTK_GRID(t), _s[i], 1, i, 1, 1); +#else + gtk_table_attach (GTK_TABLE (t), _s[i], 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); +#endif /* Spinbutton */ _b[i] = gtk_spin_button_new (GTK_ADJUSTMENT (_a[i]), 1.0, 0); sp_dialog_defocus_on_enter (_b[i]); gtk_label_set_mnemonic_widget (GTK_LABEL(_l[i]), _b[i]); gtk_widget_show (_b[i]); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_b[i], XPAD); + gtk_widget_set_margin_right(_b[i], XPAD); + gtk_widget_set_margin_top(_b[i], YPAD); + gtk_widget_set_margin_bottom(_b[i], YPAD); + gtk_widget_set_halign(_b[i], GTK_ALIGN_CENTER); + gtk_widget_set_valign(_b[i], GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(t), _b[i], 2, i, 1, 1); +#else gtk_table_attach (GTK_TABLE (t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); +#endif /* Attach channel value to adjustment */ g_object_set_data (G_OBJECT (_a[i]), "channel", GINT_TO_POINTER (i)); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 57ce86ff6..a979a168a 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -235,6 +235,8 @@ void ColorWheelSelector::init() gtk_widget_set_margin_right(_sbtn, XPAD); gtk_widget_set_margin_top(_sbtn, YPAD); gtk_widget_set_margin_bottom(_sbtn, YPAD); + gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER); + gtk_widget_set_valign(_sbtn, GTK_ALIGN_CENTER); gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1); #else gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); -- cgit v1.2.3 From 052562da2ea30ec0ca7dba92dddf6ca6cee6e998 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 2 Dec 2012 23:23:08 +0000 Subject: Migrate remaining color widgets to GtkGrid (bzr r11923) --- src/widgets/sp-color-icc-selector.cpp | 90 +++++++++++++++++++++++++++++++++-- src/widgets/sp-color-notebook.cpp | 40 ++++++++++++++-- 2 files changed, 122 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index b021ac43d..80974c2e4 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -272,13 +272,17 @@ void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const void ColorICCSelector::init() { - GtkWidget *t; gint row = 0; _updating = FALSE; _dragging = FALSE; - t = gtk_table_new (5, 3, FALSE); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *t = gtk_grid_new(); +#else + GtkWidget *t = gtk_table_new(5, 3, FALSE); +#endif + gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4); @@ -299,7 +303,16 @@ void ColorICCSelector::init() gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); //gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 ); gtk_widget_show( _fixupBtn ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_fixupBtn, XPAD); + gtk_widget_set_margin_right(_fixupBtn, XPAD); + gtk_widget_set_margin_top(_fixupBtn, YPAD); + gtk_widget_set_margin_bottom(_fixupBtn, YPAD); + gtk_grid_attach(GTK_GRID(t), _fixupBtn, 0, row, 1, 1); +#else gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); +#endif // Combobox and store with 2 columns : label (0) and full name (1) GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); @@ -315,7 +328,16 @@ void ColorICCSelector::init() gtk_widget_show( _profileSel ); gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_profileSel, XPAD); + gtk_widget_set_margin_right(_profileSel, XPAD); + gtk_widget_set_margin_top(_profileSel, YPAD); + gtk_widget_set_margin_bottom(_profileSel, YPAD); + gtk_grid_attach(GTK_GRID(t), _profileSel, 1, row, 1, 1); +#else gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); +#endif #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) _profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this ); @@ -342,7 +364,16 @@ void ColorICCSelector::init() #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_misc_set_alignment( GTK_MISC (_fooLabel[i]), 1.0, 0.5 ); gtk_widget_show( _fooLabel[i] ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_fooLabel[i], XPAD); + gtk_widget_set_margin_right(_fooLabel[i], XPAD); + gtk_widget_set_margin_top(_fooLabel[i], YPAD); + gtk_widget_set_margin_bottom(_fooLabel[i], YPAD); + gtk_grid_attach(GTK_GRID(t), _fooLabel[i], 0, row, 1, 1); +#else gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); +#endif /* Adjustment */ gdouble step = static_cast(_fooScales[i]) / 100.0; @@ -358,7 +389,17 @@ void ColorICCSelector::init() gtk_widget_set_tooltip_text( _fooSlider[i], "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_show( _fooSlider[i] ); - gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_fooSlider[i], XPAD); + gtk_widget_set_margin_right(_fooSlider[i], XPAD); + gtk_widget_set_margin_top(_fooSlider[i], YPAD); + gtk_widget_set_margin_bottom(_fooSlider[i], YPAD); + gtk_widget_set_hexpand(_fooSlider[i], TRUE); + gtk_grid_attach(GTK_GRID(t), _fooSlider[i], 1, row, 1, 1); +#else + gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); +#endif _fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -369,7 +410,18 @@ void ColorICCSelector::init() sp_dialog_defocus_on_enter( _fooBtn[i] ); gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] ); gtk_widget_show( _fooBtn[i] ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_fooBtn[i], XPAD); + gtk_widget_set_margin_right(_fooBtn[i], XPAD); + gtk_widget_set_margin_top(_fooBtn[i], YPAD); + gtk_widget_set_margin_bottom(_fooBtn[i], YPAD); + gtk_widget_set_halign(_fooBtn[i], GTK_ALIGN_CENTER); + gtk_widget_set_valign(_fooBtn[i], GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(t), _fooBtn[i], 2, row, 1, 1); +#else gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); +#endif _fooMap[i] = g_new( guchar, 4 * 1024 ); memset( _fooMap[i], 0x0ff, 1024 * 4 ); @@ -389,7 +441,16 @@ void ColorICCSelector::init() _label = gtk_label_new_with_mnemonic (_("_A:")); gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); gtk_widget_show (_label); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_label, XPAD); + gtk_widget_set_margin_right(_label, XPAD); + gtk_widget_set_margin_top(_label, YPAD); + gtk_widget_set_margin_bottom(_label, YPAD); + gtk_grid_attach(GTK_GRID(t), _label, 0, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); +#endif /* Adjustment */ _adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 10.0, 10.0); @@ -398,7 +459,17 @@ void ColorICCSelector::init() _slider = sp_color_slider_new (_adj); gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); gtk_widget_show (_slider); - gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_slider, XPAD); + gtk_widget_set_margin_right(_slider, XPAD); + gtk_widget_set_margin_top(_slider, YPAD); + gtk_widget_set_margin_bottom(_slider, YPAD); + gtk_widget_set_hexpand(_slider, TRUE); + gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1); +#else + gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); +#endif sp_color_slider_set_colors( SP_COLOR_SLIDER( _slider ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ), @@ -412,7 +483,18 @@ void ColorICCSelector::init() sp_dialog_defocus_on_enter (_sbtn); gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); gtk_widget_show (_sbtn); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_sbtn, XPAD); + gtk_widget_set_margin_right(_sbtn, XPAD); + gtk_widget_set_margin_top(_sbtn, YPAD); + gtk_widget_set_margin_bottom(_sbtn, YPAD); + gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER); + gtk_widget_set_valign(_sbtn, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); +#endif /* Signals */ g_signal_connect (G_OBJECT (_adj), "value_changed", diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 0856fd86b..fa586ce5f 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -195,7 +195,6 @@ sp_color_notebook_init (SPColorNotebook *colorbook) void ColorNotebook::init() { - GtkWidget* table = 0; guint row = 0; guint i = 0; guint j = 0; @@ -279,22 +278,49 @@ void ColorNotebook::init() } } - table = gtk_table_new (2, 3, FALSE); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget* table = gtk_grid_new(); +#else + GtkWidget* table = gtk_table_new(2, 3, FALSE); +#endif + gtk_widget_show (table); gtk_box_pack_start (GTK_BOX (_csel), table, TRUE, TRUE, 0); sp_set_font_size_smaller (_buttonbox); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_buttonbox, XPAD); + gtk_widget_set_margin_right(_buttonbox, XPAD); + gtk_widget_set_margin_top(_buttonbox, YPAD); + gtk_widget_set_margin_bottom(_buttonbox, YPAD); + gtk_widget_set_hexpand(_buttonbox, TRUE); + gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), _buttonbox, 0, row, 2, 1); +#else gtk_table_attach (GTK_TABLE (table), _buttonbox, 0, 2, row, row + 1, static_cast(GTK_EXPAND|GTK_FILL), static_cast(0), XPAD, YPAD); +#endif + row++; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(_book, XPAD*2); + gtk_widget_set_margin_right(_book, XPAD*2); + gtk_widget_set_margin_top(_book, YPAD); + gtk_widget_set_margin_bottom(_book, YPAD); + gtk_widget_set_hexpand(_book, TRUE); + gtk_widget_set_vexpand(_book, TRUE); + gtk_grid_attach(GTK_GRID(table), _book, 0, row, 2, 1); +#else gtk_table_attach (GTK_TABLE (table), _book, 0, 2, row, row + 1, static_cast(GTK_EXPAND|GTK_FILL), static_cast(GTK_EXPAND|GTK_FILL), XPAD*2, YPAD); +#endif // restore the last active page Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -349,7 +375,6 @@ void ColorNotebook::init() #if GTK_CHECK_VERSION(3,0,0) GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_set_homogeneous(GTK_BOX(rgbabox), FALSE); #else GtkWidget *rgbabox = gtk_hbox_new (FALSE, 0); #endif @@ -376,7 +401,6 @@ void ColorNotebook::init() gtk_widget_set_tooltip_text (_box_toomuchink, _("Too much ink!")); gtk_widget_set_sensitive (_box_toomuchink, false); gtk_box_pack_start(GTK_BOX(rgbabox), _box_toomuchink, FALSE, FALSE, 2); - #endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -411,7 +435,15 @@ void ColorNotebook::init() gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); #endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(rgbabox, XPAD); + gtk_widget_set_margin_right(rgbabox, XPAD); + gtk_widget_set_margin_top(rgbabox, YPAD); + gtk_widget_set_margin_bottom(rgbabox, YPAD); + gtk_grid_attach(GTK_GRID(table), rgbabox, 0, row, 2, 1); +#else gtk_table_attach (GTK_TABLE (table), rgbabox, 0, 2, row, row + 1, GTK_FILL, GTK_SHRINK, XPAD, YPAD); +#endif #ifdef SPCS_PREVIEW _p = sp_color_preview_new (0xffffffff); -- cgit v1.2.3 From 9cffd82661a0aa17fdb4f6333b8a45ee896901b0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 3 Dec 2012 15:10:10 +0100 Subject: Translations. Removing sp-color-gtkselector.cpp from translatable files. UI. Fix for Bug #836477 (Spray Tool: Descriptions in status bar "... scroll to spray something" need more words). Translations. Translation template update. (bzr r11926) --- src/spray-context.cpp | 6 +++--- src/tools-switch.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/spray-context.cpp b/src/spray-context.cpp index fe478583c..07539a080 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -232,13 +232,13 @@ static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) switch (tc->mode) { case SPRAY_MODE_COPY: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray copies of the initial selection."), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray copies of the initial selection."), sel_message); break; case SPRAY_MODE_CLONE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray clones of the initial selection."), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray clones of the initial selection."), sel_message); break; case SPRAY_MODE_SINGLE_PATH: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a single path of the initial selection."), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a single path of the initial selection."), sel_message); break; default: break; diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index cbf269387..f0535e2ff 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -144,7 +144,7 @@ tools_switch(SPDesktop *dt, int num) dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]); dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag, click or scroll to spray the selected objects.")); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag, click or click and scroll to spray the selected objects.")); break; case TOOLS_SHAPES_RECT: dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); -- cgit v1.2.3 From fa850419ea4a516f68bd32d57af09972c670c774 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 3 Dec 2012 15:29:05 +0100 Subject: UI. Fix for bug #959202 (Spiral Tool: Alt+drag on outside handle isn't described). (bzr r11927) --- src/object-edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 989d84c7f..1c7f76a7f 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -1305,7 +1305,7 @@ SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde entity_outer->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Roll/unroll the spiral from outside; with Ctrl to snap angle; " - "with Shift to scale/rotate")); + "with Shift to scale/rotate; with Alt to lock radius")); entity.push_back(entity_inner); entity.push_back(entity_outer); -- cgit v1.2.3 From 7ddd6c9285357f54ff0dd0547d414972fb34cb82 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 3 Dec 2012 11:49:35 -0500 Subject: win32 registry. set value for inkscape location (Bug 644185) Fixed bugs: - https://launchpad.net/bugs/644185 (bzr r11928) --- src/registrytool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/registrytool.cpp b/src/registrytool.cpp index d2cec0080..72b53821e 100644 --- a/src/registrytool.cpp +++ b/src/registrytool.cpp @@ -70,6 +70,7 @@ bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg, //Get or create the key gunichar2 *keyw = g_utf8_to_utf16(keyName.data(), -1, 0,0,0); gunichar2 *valuenamew = g_utf8_to_utf16(valueName.data(), -1, 0,0,0); + gunichar2 *valuew = g_utf8_to_utf16(value.data(), -1, 0,0,0); HKEY key; if (RegCreateKeyExW(rootKey, (WCHAR*) keyw, @@ -82,7 +83,7 @@ bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg, // Set the value if (RegSetValueExW(key, (WCHAR*) valuenamew, - 0, REG_SZ, (LPBYTE) value.data(), (DWORD) (value.size() + 1))) + 0, REG_SZ, (LPBYTE) valuew, (DWORD) (2*value.size() + 2))) { fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str()); goto failkey; -- cgit v1.2.3 From ebeba56ed8fbc614b48315dd24c2660ffe92dfd7 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 5 Dec 2012 23:21:14 +0100 Subject: i18n. Improving windows's title internationalization (color mode wasn't correctly handled). Translations. Translation template and French translation update. (bzr r11930) --- src/widgets/desktop-widget.cpp | 49 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index cc441cc1c..9cd93a871 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -817,12 +817,15 @@ SPDesktopWidget::updateTitle(gchar const* uri) gchar const *fname = uri; GString *name = g_string_new (""); - gchar const *grayscalename = _("(grayscale) "); - gchar const *grayscalenamecomma = _(", grayscale"); - gchar const *printcolorsname = _("(print colors preview) "); - gchar const *printcolorsnamecomma = _(", print colors preview"); + gchar const *grayscalename = N_("grayscale"); + gchar const *grayscalenamecomma = N_(", grayscale"); + gchar const *printcolorsname = N_("print colors preview"); + gchar const *printcolorsnamecomma = N_(", print colors preview"); + gchar const *outlinename = N_("outline"); + gchar const *nofiltersname = N_("no filters"); gchar const *colormodename = ""; gchar const *colormodenamecomma = ""; + gchar const *rendermodename = ""; gchar const *modifiedname = ""; SPDocument *doc = this->desktop->doc(); if (doc->isModifiedSinceSave()) { @@ -836,22 +839,40 @@ SPDesktopWidget::updateTitle(gchar const* uri) colormodename = printcolorsname; colormodenamecomma = printcolorsnamecomma; } + if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) { + rendermodename = outlinename; + } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) { + rendermodename = nofiltersname; + } + if (this->desktop->number > 1) { - if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) { - g_string_printf (name, _("%s%s: %d (outline%s) - Inkscape"), modifiedname, fname, this->desktop->number, colormodenamecomma); - } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) { - g_string_printf (name, _("%s%s: %d (no filters%s) - Inkscape"), modifiedname, fname, this->desktop->number, colormodenamecomma); + if (rendermodename != "") { + if (colormodenamecomma != "") { + g_string_printf (name, _("%s%s: %d (%s%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename), _(colormodenamecomma)); + } else { + g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename)); + } } else { - g_string_printf (name, _("%s%s: %d %s- Inkscape"), modifiedname, fname, this->desktop->number, colormodename); + if (colormodename != "") { + g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(colormodename)); + } else { + g_string_printf (name, _("%s%s: %d - Inkscape"), modifiedname, fname, this->desktop->number); + } } } else { - if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) { - g_string_printf (name, _("%s%s (outline%s) - Inkscape"), modifiedname, fname, colormodenamecomma); - } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) { - g_string_printf (name, _("%s%s (no filters%s) - Inkscape"), modifiedname, fname, colormodenamecomma); + if (rendermodename != "") { + if (colormodenamecomma != "") { + g_string_printf (name, _("%s%s (%s%s) - Inkscape"), modifiedname, fname, _(rendermodename), _(colormodenamecomma)); + } else { + g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(rendermodename)); + } } else { - g_string_printf (name, _("%s%s %s- Inkscape"), modifiedname, fname, colormodename); + if (colormodename != "") { + g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(colormodename)); + } else { + g_string_printf (name, _("%s%s - Inkscape"), modifiedname, fname); + } } } window->set_title (name->str); -- cgit v1.2.3 From bc29141167ff3df4b92d85edae209d3fb9ffab93 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 5 Dec 2012 23:39:22 +0100 Subject: - fix security bug lp:1025185 - make network access optional for XML loading Fixed bugs: - https://launchpad.net/bugs/1025185 (bzr r11931) --- src/preferences-skeleton.h | 4 ++++ src/ui/dialog/ocaldialogs.cpp | 10 ++++++++-- src/xml/repr-io.cpp | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 2cd391150..77ffe429a 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -337,6 +337,10 @@ static char const preferences_skeleton[] = " check_on_reading=\"0\" " " check_on_editing=\"0\" " " check_on_writing=\"0\"/>\n" +" \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 174f361fd..c7bff185c 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1112,8 +1112,14 @@ void ImportDialog::on_xml_file_read(const Glib::RefPtr& result xmlDoc *doc = NULL; xmlNode *root_element = NULL; - doc = xmlReadMemory(data, (int) length, xml_uri.c_str(), NULL, - XML_PARSE_RECOVER + XML_PARSE_NOWARNING + XML_PARSE_NOERROR); + int parse_options = XML_PARSE_RECOVER + XML_PARSE_NOWARNING + XML_PARSE_NOERROR; // do not use XML_PARSE_NOENT ! see bug lp:1025185 + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool allowNetAccess = prefs->getBool("/options/externalresources/xml/allow_net_access", false); + if (!allowNetAccess) { + parse_options |= XML_PARSE_NONET; + } + + doc = xmlReadMemory(data, (int) length, xml_uri.c_str(), NULL, parse_options); if (doc == NULL) { // If nothing is returned, no results could be found diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 29a5b4a78..1258617c7 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -297,12 +297,18 @@ Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns) XmlSource src; if ( (src.setFile(filename) == 0) ) { + int parse_options = XML_PARSE_HUGE; // do not use XML_PARSE_NOENT ! see bug lp:1025185 + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool allowNetAccess = prefs->getBool("/options/externalresources/xml/allow_net_access", false); + if (!allowNetAccess) { + parse_options |= XML_PARSE_NONET; + } doc = xmlReadIO( XmlSource::readCb, XmlSource::closeCb, &src, localFilename, src.getEncoding(), - XML_PARSE_NOENT | XML_PARSE_HUGE); + parse_options); } } -- cgit v1.2.3 From 56255864c99b77e4c72916c61e783f332e429ba7 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 6 Dec 2012 00:32:43 +0100 Subject: can't do a string comparison like that! (bzr r11932) --- src/widgets/desktop-widget.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 9cd93a871..3791ec73c 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -823,9 +823,9 @@ SPDesktopWidget::updateTitle(gchar const* uri) gchar const *printcolorsnamecomma = N_(", print colors preview"); gchar const *outlinename = N_("outline"); gchar const *nofiltersname = N_("no filters"); - gchar const *colormodename = ""; - gchar const *colormodenamecomma = ""; - gchar const *rendermodename = ""; + gchar const *colormodename = NULL; + gchar const *colormodenamecomma = NULL; + gchar const *rendermodename = NULL; gchar const *modifiedname = ""; SPDocument *doc = this->desktop->doc(); if (doc->isModifiedSinceSave()) { @@ -847,28 +847,28 @@ SPDesktopWidget::updateTitle(gchar const* uri) if (this->desktop->number > 1) { - if (rendermodename != "") { - if (colormodenamecomma != "") { + if (rendermodename) { + if (colormodenamecomma) { g_string_printf (name, _("%s%s: %d (%s%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename), _(colormodenamecomma)); } else { g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename)); } } else { - if (colormodename != "") { + if (colormodename) { g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(colormodename)); } else { g_string_printf (name, _("%s%s: %d - Inkscape"), modifiedname, fname, this->desktop->number); } } } else { - if (rendermodename != "") { - if (colormodenamecomma != "") { + if (rendermodename) { + if (colormodenamecomma) { g_string_printf (name, _("%s%s (%s%s) - Inkscape"), modifiedname, fname, _(rendermodename), _(colormodenamecomma)); } else { g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(rendermodename)); } } else { - if (colormodename != "") { + if (colormodename) { g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(colormodename)); } else { g_string_printf (name, _("%s%s - Inkscape"), modifiedname, fname); -- cgit v1.2.3 From 233f55ac655ada4bd00578fc4610688583530adb Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 6 Dec 2012 10:07:41 +0900 Subject: Fix for 1086881 : Regression editing patterns with node tool (bzr r11933) --- src/gradient-drag.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 69b9db92d..3611eac80 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2080,7 +2080,8 @@ void GrDrag::updateDraggers() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = style->getFillPaintServer(); - if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { + if ( server && (server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL ); @@ -2094,7 +2095,8 @@ void GrDrag::updateDraggers() if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = style->getStrokePaintServer(); - if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { + if ( server && (server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE ); @@ -2145,7 +2147,8 @@ void GrDrag::updateLines() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { + if ( server && (server->isSolid() || + (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); @@ -2204,7 +2207,8 @@ void GrDrag::updateLines() if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( server && (server->isSolid() || SP_GRADIENT(server)->getVector()->isSolid()) ) { + if ( server && (server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { // Suppress "gradientness" of solid paint } else if ( SP_IS_LINEARGRADIENT(server) ) { addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); -- cgit v1.2.3 From 34a8850a7c0df3f4c35863e2621db100153c4a41 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 6 Dec 2012 12:51:51 +0100 Subject: Check that server is gradient before calling getVector(). (bzr r11934) --- src/gradient-drag.cpp | 223 ++++++++++++++++++++++++++------------------------ 1 file changed, 115 insertions(+), 108 deletions(-) (limited to 'src') diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 3611eac80..904c3b349 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2080,30 +2080,33 @@ void GrDrag::updateDraggers() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = style->getFillPaintServer(); - if ( server && (server->isSolid() - || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL ); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_FILL ); - } else if ( SP_IS_MESHGRADIENT(server) ) { - addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL ); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_FILL ); + } else if ( SP_IS_MESHGRADIENT(server) ) { + addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL ); + } } - } if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = style->getStrokePaintServer(); - if ( server && (server->isSolid() - || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE ); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_STROKE ); - } else if ( SP_IS_MESHGRADIENT(server) ) { - addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE ); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_STROKE ); + } else if ( SP_IS_MESHGRADIENT(server) ) { + addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE ); + } } } } @@ -2147,59 +2150,61 @@ void GrDrag::updateLines() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( server && (server->isSolid() || - (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_FILL); - addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); - addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); - } else if ( SP_IS_MESHGRADIENT(server) ) { - - SPMeshGradient *mg = SP_MESHGRADIENT(server); - - guint rows = mg->array.patch_rows(); - guint columns = mg->array.patch_columns(); - for ( guint i = 0; i < rows; ++i ) { - for ( guint j = 0; j < columns; ++j ) { - - std::vector h; - - SPMeshPatchI patch( &(mg->array.nodes), i, j ); - - // Top line - h = patch.getPointsForSide( 0 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); - - // Right line - if( j == columns - 1 ) { - h = patch.getPointsForSide( 1 ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_FILL); + addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); + addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); + } else if ( SP_IS_MESHGRADIENT(server) ) { + + SPMeshGradient *mg = SP_MESHGRADIENT(server); + + guint rows = mg->array.patch_rows(); + guint columns = mg->array.patch_columns(); + for ( guint i = 0; i < rows; ++i ) { + for ( guint j = 0; j < columns; ++j ) { + + std::vector h; + + SPMeshPatchI patch( &(mg->array.nodes), i, j ); + + // Top line + h = patch.getPointsForSide( 0 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); - } - // Bottom line - if( i == rows - 1 ) { - h = patch.getPointsForSide( 2 ); + // Right line + if( j == columns - 1 ) { + h = patch.getPointsForSide( 1 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); + } + + // Bottom line + if( i == rows - 1 ) { + h = patch.getPointsForSide( 2 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); + } + + // Left line + h = patch.getPointsForSide( 3 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); } - - // Left line - h = patch.getPointsForSide( 3 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); } } } @@ -2207,62 +2212,64 @@ void GrDrag::updateLines() if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( server && (server->isSolid() - || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_STROKE); - addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); - addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); - } else if ( SP_IS_MESHGRADIENT(server) ) { - - // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE. - SPMeshGradient *mg = SP_MESHGRADIENT(server); - - guint rows = mg->array.patch_rows(); - guint columns = mg->array.patch_columns(); - for ( guint i = 0; i < rows; ++i ) { - for ( guint j = 0; j < columns; ++j ) { - - std::vector h; - - SPMeshPatchI patch( &(mg->array.nodes), i, j ); - - // Top line - h = patch.getPointsForSide( 0 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); - - // Right line - if( j == columns - 1 ) { - h = patch.getPointsForSide( 1 ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_STROKE); + addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); + addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); + } else if ( SP_IS_MESHGRADIENT(server) ) { + + // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE. + SPMeshGradient *mg = SP_MESHGRADIENT(server); + + guint rows = mg->array.patch_rows(); + guint columns = mg->array.patch_columns(); + for ( guint i = 0; i < rows; ++i ) { + for ( guint j = 0; j < columns; ++j ) { + + std::vector h; + + SPMeshPatchI patch( &(mg->array.nodes), i, j ); + + // Top line + h = patch.getPointsForSide( 0 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); - } - // Bottom line - if( i == rows - 1 ) { - h = patch.getPointsForSide( 2 ); + // Right line + if( j == columns - 1 ) { + h = patch.getPointsForSide( 1 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); + } + + // Bottom line + if( i == rows - 1 ) { + h = patch.getPointsForSide( 2 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); + } + + // Left line + h = patch.getPointsForSide( 3 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); } - - // Left line - h = patch.getPointsForSide( 3 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); - } - } + } + } } } } -- cgit v1.2.3 From 2454948ceada44bb6e90d1470d04e0b01695ca99 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Thu, 6 Dec 2012 21:01:07 +0100 Subject: Fix for bug #790192, the unclipped alpha component was used for clipping the colour components. (bzr r11935) --- src/display/nr-filter-gaussian.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 390021712..6ef321992 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -102,15 +102,16 @@ static inline Tt clip_round_cast(Ts const v) { Ts const minval = std::numeric_limits::min(); Ts const maxval = std::numeric_limits::max(); Tt const minval_rounded = std::numeric_limits::min(); - Ts const maxval_rounded = std::numeric_limits::max(); + Tt const maxval_rounded = std::numeric_limits::max(); if ( v < minval ) return minval_rounded; if ( v > maxval ) return maxval_rounded; return round_cast(v); } template -static inline Tt clip_round_cast_varmax(Ts const v, Ts const maxval, Tt const maxval_rounded) { +static inline Tt clip_round_cast_varmax(Ts const v, Tt const maxval_rounded) { Ts const minval = std::numeric_limits::min(); + Tt const maxval = maxval_rounded; Tt const minval_rounded = std::numeric_limits::min(); if ( v < minval ) return minval_rounded; if ( v > maxval ) return maxval_rounded; @@ -339,7 +340,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { dstimg[alpha_PC] = clip_round_cast(v[0][alpha_PC]); - PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax(v[0][c], v[0][alpha_PC], dstimg[alpha_PC]); + PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax(v[0][c], dstimg[alpha_PC]); } else { for(unsigned int c=0; c(v[0][c]); } @@ -354,7 +355,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { dstimg[alpha_PC] = clip_round_cast(v[0][alpha_PC]); - PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax(v[0][c], v[0][alpha_PC], dstimg[alpha_PC]); + PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax(v[0][c], dstimg[alpha_PC]); } else { for(unsigned int c=0; c(v[0][c]); } -- cgit v1.2.3 From d0d3e7f80dafc80e47c9a95bf31c14283010a2c2 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 8 Dec 2012 21:29:18 +0100 Subject: Selector tool: improve responsiveness for snapping a path's internal intersections (was unbearable already for paths having 20+ segments) (bzr r11937) --- src/selection.cpp | 34 +--------------------------------- src/selection.h | 6 ------ src/seltrans.cpp | 34 +++++++++++++--------------------- src/snap-candidate.h | 6 ++++-- src/snap.cpp | 9 +++++++-- src/snap.h | 2 +- src/sp-shape.cpp | 4 ++-- 7 files changed, 28 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/selection.cpp b/src/selection.cpp index d769b402c..72f50137c 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -443,15 +443,13 @@ std::vector Selection::getSnapPoints(SnapPreferenc SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center - //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source - //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { SPItem *this_item = SP_ITEM(iter->data); this_item->getSnappoints(p, &snapprefs_dummy); //Include the transformation origin for snapping - //For a selection or group only the overall origin is considered + //For a selection or group only the overall center is considered, not for each item individually if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { p.push_back(Inkscape::SnapCandidatePoint(this_item->getCenter(), SNAPSOURCE_ROTATION_CENTER)); } @@ -460,36 +458,6 @@ std::vector Selection::getSnapPoints(SnapPreferenc return p; } -// TODO: both getSnapPoints and getSnapPointsConvexHull are called, subsequently. Can we do this more efficient? -// Why do we need to include the transformation center in one case and not the other? -std::vector Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const { - GSList const *items = const_cast(this)->itemList(); - - SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs - snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source - snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference - - std::vector p; - for (GSList const *iter = items; iter != NULL; iter = iter->next) { - SP_ITEM(iter->data)->getSnappoints(p, &snapprefs_dummy); - } - - std::vector pHull; - if (!p.empty()) { - Geom::Rect cvh((p.front()).getPoint(), (p.front()).getPoint()); - for (std::vector::iterator i = p.begin(); i != p.end(); ++i) { - // these are the points we get back - cvh.expandTo((*i).getPoint()); - } - - for ( unsigned i = 0 ; i < 4 ; ++i ) { - pHull.push_back(Inkscape::SnapCandidatePoint(cvh.corner(i), SNAPSOURCE_CONVEX_HULL_CORNER)); - } - } - - return pHull; -} - void Selection::_removeObjectDescendants(SPObject *obj) { GSList *iter, *next; for ( iter = _objs ; iter ; iter = next ) { diff --git a/src/selection.h b/src/selection.h index 168c70dd4..85e06a5c6 100644 --- a/src/selection.h +++ b/src/selection.h @@ -266,12 +266,6 @@ public: */ std::vector getSnapPoints(SnapPreferences const *snapprefs) const; - /** - * Gets the snap points of a selection that form a convex hull. - * @return Selection's convex hull points - */ - std::vector getSnapPointsConvexHull(SnapPreferences const *snapprefs) const; - /** * Connects a slot to be notified of selection changes. * diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 15cea9198..64bb95508 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -298,30 +298,21 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // Next, get all points to consider for snapping SnapManager const &m = _desktop->namedview->snap_manager; _snap_points.clear(); - _snap_points = selection->getSnapPoints(&m.snapprefs); - std::vector snap_points_hull = selection->getSnapPointsConvexHull(&m.snapprefs); + if (m.someSnapperMightSnap(false)) { // Only search for snap sources when really needed, to avoid unnecessary delays + _snap_points = selection->getSnapPoints(&m.snapprefs); // This might take some time! + } if (_snap_points.size() > 200 && !(prefs->getBool("/options/snapclosestonly/value", false))) { /* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes A typical user would rarely ever try to snap such a large number of nodes anyway, because (s)he would hardly be able to discern which node would be snapping */ - _snap_points = snap_points_hull; - //} + _snap_points.resize(200); // Unfortunately, by now we will have lost the font-baseline snappoints :-( } // Find bbox hulling all special points, which excludes stroke width. Here we need to include the // path nodes, for example because a rectangle which has been converted to a path doesn't have // any other special points - Geom::Rect snap_points_bbox; - if ( snap_points_hull.empty() == false ) { - std::vector::iterator i = snap_points_hull.begin(); - snap_points_bbox = Geom::Rect((*i).getPoint(), (*i).getPoint()); - i++; - while (i != snap_points_hull.end()) { - snap_points_bbox.expandTo((*i).getPoint()); - i++; - } - } + Geom::OptRect snap_points_bbox = selection->bounds(SPItem::GEOMETRIC_BBOX); _bbox_points.clear(); // Collect the bounding box's corners and midpoints for each selected item @@ -329,11 +320,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER); bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT); bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); - // 1) Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations - // this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the - // stroke width. (see get_scale_transform_for_stroke()). This however is currently only implemented for a single bbox. - // 2) More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl - // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole + // Preferably we'd use the bbox of each selected item, but for example 50 items will produce at least 200 bbox points, + // which might make Inkscape crawl(see the comment a few lines above). In that case we will use the bbox of the selection as a whole bool c1 = (_items.size() > 0) && (_items.size() < 50); bool c2 = prefs->getBool("/options/snapclosestonly/value", false); if (translating && (c1 || c2)) { @@ -353,10 +341,14 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // - one for snapping the boundingbox, which can be either visual or geometric // - one for snapping the special points // The "opposite" in case of a geometric boundingbox always coincides with the "opposite" for the special points - // These distinct "opposites" are needed in the snapmanager to avoid bugs such as #sf1540195 (in which + // These distinct "opposites" are needed in the snapmanager to avoid bugs such as LP167905 (in which // a box is caught between two guides) _opposite_for_bboxpoints = _bbox->min() + _bbox->dimensions() * Geom::Scale(1-x, 1-y); - _opposite_for_specpoints = snap_points_bbox.min() + snap_points_bbox.dimensions() * Geom::Scale(1-x, 1-y); + if (snap_points_bbox) { + _opposite_for_specpoints = (*snap_points_bbox).min() + (*snap_points_bbox).dimensions() * Geom::Scale(1-x, 1-y); + } else { + _opposite_for_specpoints = _opposite_for_bboxpoints; + } _opposite = _opposite_for_bboxpoints; } diff --git a/src/snap-candidate.h b/src/snap-candidate.h index da65d4ea3..8bb7cb52f 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -25,6 +25,8 @@ namespace Inkscape { class SnapCandidatePoint { public: + SnapCandidatePoint() {}; // only needed / used for resizing() of a vector in seltrans.cpp; do not use uninitialized instances! + SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num, Inkscape::SnapTargetType const target, Geom::OptRect const &bbox) : _point(point), _source_type(source), @@ -39,7 +41,7 @@ public: : _point(point), _source_type(source), _target_type(target), - _target_bbox(Geom::OptRect()), + _target_bbox(Geom::OptRect()), _dist() { _source_num = -1; @@ -50,7 +52,7 @@ public: _source_type(source), _target_type(Inkscape::SNAPTARGET_UNDEFINED), _source_num(-1), - _target_bbox(Geom::OptRect()), + _target_bbox(Geom::OptRect()), _dist() { }; diff --git a/src/snap.cpp b/src/snap.cpp index 1ee55fcf8..695424194 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -77,9 +77,14 @@ SnapManager::SnapperList SnapManager::getGridSnappers() const return s; } -bool SnapManager::someSnapperMightSnap() const +bool SnapManager::someSnapperMightSnap(bool immediately) const { - if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) { + if ( !snapprefs.getSnapEnabledGlobally() ) { + return false; + } + + // If we're asking if some snapper might snap RIGHT NOW (without the snap being postponed)... + if ( immediately && snapprefs.getSnapPostponedGlobally() ) { return false; } diff --git a/src/snap.h b/src/snap.h index 3a8e18ad3..67af20063 100644 --- a/src/snap.h +++ b/src/snap.h @@ -93,7 +93,7 @@ public: * * @return true if one of the snappers will try to snap to something. */ - bool someSnapperMightSnap() const; + bool someSnapperMightSnap(bool immediately = true) const; /** * @return true if one of the grids might be snapped to. diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index ad73f226c..d5556ba9e 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1193,10 +1193,10 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorisTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION) || snapprefs->isSourceSnappable(Inkscape::SNAPSOURCE_PATH_INTERSECTION)) { Geom::Crossings cs; try { - cs = self_crossings(*path_it); + cs = self_crossings(*path_it); // This can be slow! if (!cs.empty()) { // There might be multiple intersections... for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) { Geom::Point p_ix = (*path_it).pointAt((*i).ta); -- cgit v1.2.3 From 4a76e2728f29933fece00149b2edc86c48f119ae Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 9 Dec 2012 11:35:25 +0000 Subject: Tidy up GTK/Glib deprecation flags and drop ancient pango support (<1.24) Fixed bugs: - https://launchpad.net/bugs/1088134 (bzr r11938) --- src/libnrtype/FontFactory.cpp | 7 ------- src/libnrtype/FontInstance.cpp | 7 ------- src/libnrtype/Layout-TNG-Input.cpp | 6 ------ src/libnrtype/Layout-TNG-Output.cpp | 6 ------ 4 files changed, 26 deletions(-) (limited to 'src') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 76a3df0e8..ed1e1dc5c 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -22,13 +22,6 @@ #include "libnrtype/font-instance.h" #include "util/unordered-containers.h" -#if !PANGO_VERSION_CHECK(1,24,0) -#define PANGO_WEIGHT_THIN static_cast(100) -#define PANGO_WEIGHT_BOOK static_cast(380) -#define PANGO_WEIGHT_MEDIUM static_cast(500) -#define PANGO_WEIGHT_ULTRAHEAVY static_cast(1000) -#endif - typedef INK_UNORDERED_MAP FaceMapType; // need to avoid using the size field diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index f8b2c3b9d..4ca8bf2a0 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -27,13 +27,6 @@ #include "livarot/Path.h" #include "util/unordered-containers.h" -#if !PANGO_VERSION_CHECK(1,24,0) -#define PANGO_WEIGHT_THIN static_cast(100) -#define PANGO_WEIGHT_BOOK static_cast(380) -#define PANGO_WEIGHT_MEDIUM static_cast(500) -#define PANGO_WEIGHT_ULTRAHEAVY static_cast(1000) -#endif - struct font_style_hash : public std::unary_function { size_t operator()(font_style const &x) const; diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index 07bf207c8..10310b4aa 100644 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -19,12 +19,6 @@ #include "sp-string.h" #include "FontFactory.h" -#if !PANGO_VERSION_CHECK(1,24,0) -#define PANGO_WEIGHT_THIN static_cast(100) -#define PANGO_WEIGHT_BOOK static_cast(380) -#define PANGO_WEIGHT_MEDIUM static_cast(500) -#define PANGO_WEIGHT_ULTRAHEAVY static_cast(1000) -#endif namespace Inkscape { namespace Text { diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 4bdd2c6cb..bf746b41f 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -21,12 +21,6 @@ #include "display/curve.h" #include <2geom/pathvector.h> -#if !PANGO_VERSION_CHECK(1,24,0) -#define PANGO_WEIGHT_THIN static_cast(100) -#define PANGO_WEIGHT_BOOK static_cast(380) -#define PANGO_WEIGHT_MEDIUM static_cast(500) -#define PANGO_WEIGHT_ULTRAHEAVY static_cast(1000) -#endif namespace Inkscape { namespace Extension { -- cgit v1.2.3 From 73186b30e90fdca666af811ee63b385eeb9740b1 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 9 Dec 2012 13:57:31 +0000 Subject: Migrate remaining stuff from GtkTable to GtkGrid (bzr r11939) --- src/ui/dialog/clonetiler.cpp | 47 ++++++++++++++++++++-- src/widgets/spw-utilities.cpp | 93 +++++++++++++++++++++++++++++++++++++++---- src/widgets/spw-utilities.h | 20 +++++++--- src/widgets/stroke-style.cpp | 45 ++++++++++++++++++++- src/widgets/stroke-style.h | 13 +++++- 5 files changed, 198 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index f51470826..e971cfb09 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -815,9 +815,15 @@ CloneTiler::CloneTiler (void) : GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *table = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(table), 4); + gtk_grid_set_column_spacing(GTK_GRID(table), 6); +#else GtkWidget *table = gtk_table_new (3, 3, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 6); +#endif gtk_container_add(GTK_CONTAINER(frame), table); @@ -893,9 +899,16 @@ CloneTiler::CloneTiler (void) : GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *table = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(table), 4); + gtk_grid_set_column_spacing(GTK_GRID(table), 6); +#else GtkWidget *table = gtk_table_new (4, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 6); +#endif + gtk_container_add(GTK_CONTAINER(frame), table); { @@ -935,10 +948,15 @@ CloneTiler::CloneTiler (void) : GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); - +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *table = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(table), 4); + gtk_grid_set_column_spacing(GTK_GRID(table), 6); +#else GtkWidget *table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 6); +#endif gtk_container_add(GTK_CONTAINER(frame), table); { @@ -987,10 +1005,17 @@ CloneTiler::CloneTiler (void) : // Rows/columns, width/height { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *table = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(table), 4); + gtk_grid_set_column_spacing(GTK_GRID(table), 6); +#else GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 6); +#endif + + gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { @@ -2807,15 +2832,29 @@ void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, fl { GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); gtk_container_add(GTK_CONTAINER(a), widget); - gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(table, GTK_ALIGN_FILL); + gtk_widget_set_valign(table, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), a, col, row, 1, 1); +#else + gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 ); +#endif } GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *table = gtk_grid_new(); + gtk_grid_set_row_spacing(GTK_GRID(table), 6); + gtk_grid_set_column_spacing(GTK_GRID(table), 8); +#else GtkWidget *table = gtk_table_new (values + 2, 5, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 8); +#endif + + gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); { #if GTK_CHECK_VERSION(3,0,0) diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 8adc72cd7..ce8ce388d 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -19,7 +19,12 @@ #include #include + +#if GTK_CHECK_VERSION(3,0,0) +#include +#else #include +#endif #include "selection.h" @@ -32,8 +37,11 @@ * Creates a label widget with the given text, at the given col, row * position in the table. */ -Gtk::Label * -spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target) +#if GTK_CHECK_VERSION(3,0,0) +Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int row, Gtk::Widget* target) +#else +Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target) +#endif { Gtk::Label *label_widget = new Gtk::Label(); g_assert(label_widget != NULL); @@ -48,7 +56,18 @@ spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Wid } label_widget->set_alignment(1.0, 0.5); label_widget->show(); + +#if GTK_CHECK_VERSION(3,0,0) + label_widget->set_hexpand(); + label_widget->set_halign(Gtk::ALIGN_FILL); + label_widget->set_valign(Gtk::ALIGN_CENTER); + label_widget->set_margin_left(4); + label_widget->set_margin_right(4); + table->attach(*label_widget, col, row, 1, 1); +#else table->attach(*label_widget, col, col+1, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast(0), 4, 0); +#endif + return label_widget; } @@ -61,8 +80,19 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) g_assert(label_widget != NULL); gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5); gtk_widget_show (label_widget); - gtk_table_attach (GTK_TABLE (table), label_widget, col, col+1, row, row+1, + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left(label_widget, 4); + gtk_widget_set_margin_right(label_widget, 4); + gtk_widget_set_hexpand(label_widget, TRUE); + gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL); + gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1); +#else + gtk_table_attach(GTK_TABLE (table), label_widget, col, col+1, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 0); +#endif + return label_widget; } @@ -70,14 +100,26 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) * Creates a horizontal layout manager with 4-pixel spacing between children * and space for 'width' columns. */ -Gtk::HBox * -spw_hbox(Gtk::Table * table, int width, int col, int row) +#if GTK_CHECK_VERSION(3,0,0) +Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row) +#else +Gtk::HBox * spw_hbox(Gtk::Table * table, int width, int col, int row) +#endif { /* Create a new hbox with a 4-pixel spacing between children */ Gtk::HBox *hb = new Gtk::HBox(false, 4); g_assert(hb != NULL); hb->show(); + +#if GTK_CHECK_VERSION(3,0,0) + hb->set_hexpand(); + hb->set_halign(Gtk::ALIGN_FILL); + hb->set_valign(Gtk::ALIGN_CENTER); + table->attach(*hb, col, row, width, 1); +#else table->attach(*hb, col, col+width, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast(0), 0, 0); +#endif + return hb; } @@ -117,16 +159,33 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table, g_assert(dialog != NULL); g_assert(table != NULL); - GtkWidget *l = gtk_label_new (label); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_widget_show (l); + GtkWidget *l = gtk_label_new (label); + gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); + gtk_widget_show (l); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(l, TRUE); + gtk_widget_set_valign(l, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), l, 0, 1, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif b = gtk_check_button_new (); gtk_widget_show (b); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(b, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(b, TRUE); + gtk_widget_set_valign(b, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), b, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif + g_object_set_data (G_OBJECT (b), "key", key); g_object_set_data (G_OBJECT (dialog), key, b); g_signal_connect (G_OBJECT (b), "toggled", cb, dialog); @@ -153,8 +212,17 @@ spw_dropdown(GtkWidget * dialog, GtkWidget * table, spw_label_old(table, label_text, 0, row); gtk_widget_show (selector); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(selector, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(selector, TRUE); + gtk_widget_set_valign(selector, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), selector, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif + g_object_set_data (G_OBJECT (dialog), key, selector); return selector; } @@ -189,8 +257,17 @@ spw_unit_selector(GtkWidget * dialog, GtkWidget * table, GtkWidget * sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 4); g_assert(sb != NULL); gtk_widget_show (sb); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(sb, GTK_ALIGN_FILL); + gtk_widget_set_hexpand(sb, TRUE); + gtk_widget_set_valign(sb, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(table), sb, 1, row, 1, 1); +#else gtk_table_attach (GTK_TABLE (table), sb, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); +#endif + g_signal_connect (G_OBJECT (a), "value_changed", cb, dialog); return sb; } diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h index 263abbcaf..fb8c04ebf 100644 --- a/src/widgets/spw-utilities.h +++ b/src/widgets/spw-utilities.h @@ -20,18 +20,26 @@ namespace Gtk { class Label; + +#if GTK_CHECK_VERSION(3,0,0) + class Grid; +#else class Table; +#endif + class HBox; class Widget; } -Gtk::Label * -spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target); -GtkWidget * -spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row); +#if GTK_CHECK_VERSION(3,0,0) +Gtk::Label * spw_label(Gtk::Grid *table, gchar const *label_text, int col, int row, Gtk::Widget *target); +Gtk::HBox * spw_hbox(Gtk::Grid *table, int width, int col, int row); +#else +Gtk::Label * spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target); +Gtk::HBox * spw_hbox(Gtk::Table *table, int width, int col, int row); +#endif -Gtk::HBox * -spw_hbox(Gtk::Table *table, int width, int col, int row); +GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row); GtkWidget * spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *table, diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 4e8431454..7912b654a 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -122,10 +122,17 @@ StrokeStyle::StrokeStyle() : f->show(); add(*f); +#if WITH_GTKMM_3_0 + table = new Gtk::Grid(); + table->set_border_width(4); + table->set_row_spacing(4); +#else table = new Gtk::Table(3, 6, false); - table->show(); table->set_border_width(4); table->set_row_spacings(4); +#endif + + table->show(); f->add(*table); gint i = 0; @@ -282,7 +289,16 @@ StrokeStyle::StrokeStyle() : dashSelector = manage(new SPDashSelector); dashSelector->show(); + +#if WITH_GTKMM_3_0 + dashSelector->set_hexpand(); + dashSelector->set_halign(Gtk::ALIGN_FILL); + dashSelector->set_valign(Gtk::ALIGN_CENTER); + table->attach(*dashSelector, 1, i, 3, 1); +#else table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast(0), 0, 0); +#endif + dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB)); i++; @@ -298,7 +314,16 @@ StrokeStyle::StrokeStyle() : sigc::bind( sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START)); startMarkerCombo->show(); + +#if WITH_GTKMM_3_0 + startMarkerCombo->set_hexpand(); + startMarkerCombo->set_halign(Gtk::ALIGN_FILL); + startMarkerCombo->set_valign(Gtk::ALIGN_CENTER); + table->attach(*startMarkerCombo, 1, i, 3, 1); +#else table->attach(*startMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast(0), 0, 0); +#endif + i++; midMarkerCombo = manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID)); @@ -308,7 +333,16 @@ StrokeStyle::StrokeStyle() : sigc::bind( sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID)); midMarkerCombo->show(); + +#if WITH_GTKMM_3_0 + midMarkerCombo->set_hexpand(); + midMarkerCombo->set_halign(Gtk::ALIGN_FILL); + midMarkerCombo->set_valign(Gtk::ALIGN_CENTER); + table->attach(*midMarkerCombo, 1, i, 3, 1); +#else table->attach(*midMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast(0), 0, 0); +#endif + i++; endMarkerCombo = manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END)); @@ -318,7 +352,16 @@ StrokeStyle::StrokeStyle() : sigc::bind( sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END)); endMarkerCombo->show(); + +#if WITH_GTKMM_3_0 + endMarkerCombo->set_hexpand(); + endMarkerCombo->set_halign(Gtk::ALIGN_FILL); + endMarkerCombo->set_valign(Gtk::ALIGN_CENTER); + table->attach(*endMarkerCombo, 1, i, 3, 1); +#else table->attach(*endMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast(0), 0, 0); +#endif + i++; setDesktop(desktop); diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index d437f7e12..5f05b97d1 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -15,9 +15,19 @@ #ifndef SEEN_DIALOGS_STROKE_STYLE_H #define SEEN_DIALOGS_STROKE_STYLE_H +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "widgets/dash-selector.h" #include + +#if WITH_GTKMM_3_0 +#include +#else #include +#endif + #include #include "desktop.h" @@ -139,11 +149,12 @@ private: MarkerComboBox *startMarkerCombo; MarkerComboBox *midMarkerCombo; MarkerComboBox *endMarkerCombo; - Gtk::Table *table; #if WITH_GTKMM_3_0 + Gtk::Grid *table; Glib::RefPtr *widthAdj; Glib::RefPtr *miterLimitAdj; #else + Gtk::Table *table; Gtk::Adjustment *widthAdj; Gtk::Adjustment *miterLimitAdj; #endif -- cgit v1.2.3 From afc564d8f86c9b0413c3318e8b0f9a33ca988b3c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 9 Dec 2012 16:29:45 +0100 Subject: Revert r11914, better fix for bug #955141 coming. (bzr r11940) --- src/display/drawing-item.cpp | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index b443ad22a..0fb1f0018 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -20,7 +20,6 @@ #include "nr-filter.h" #include "preferences.h" #include "style.h" -#include "2geom/rect.h" namespace Inkscape { @@ -541,17 +540,8 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag iarea.intersectWith(_drawbox); } - // Must use same scale factor between "logical space" (coordinates in the - // rendering) and "physical space" (surface pixels). See drawing-surface.cpp. - // See bug 955141. - // There must be a better lib2geom way of finding sarea. - DrawingSurface* ds = ct.surface(); - Geom::Scale scale = ds->scale(); - Geom::Rect rarea( *iarea ); - Geom::Point sarea( rarea.dimensions() * scale ); - DrawingSurface intermediate( *iarea, sarea.ceil() ); + DrawingSurface intermediate(*iarea); DrawingContext ict(intermediate); - unsigned render_result = RENDER_OK; // 1. Render clipping path with alpha = opacity. @@ -624,24 +614,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag cachect.fill(); _cache->markClean(*carea); } - - ct.rectangle(*carea); // Area to be filled - - // Account for difference between logical and physical spaces. - ct.scale( intermediate.scale().inverse() ); - - // Must shift origin to compensate for scaling. - Geom::Point factor( Geom::Point(1,1) - intermediate.scale().vector() ); - Geom::Point origin( intermediate.origin() ); - Geom::Point shift( origin[Geom::X] * factor[Geom::X], origin[Geom::Y] * factor[Geom::Y] ); - ct.translate( -shift ); - + ct.rectangle(*carea); ct.setSource(&intermediate); ct.fill(); - - ct.translate( shift ); - ct.scale( intermediate.scale() ); - ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct -- cgit v1.2.3 From d56037fd9574f7235138fefd9ebf44f5fc18d466 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 9 Dec 2012 16:34:43 +0100 Subject: noop: Added some comments, rearranged some lines to make code easier to follow. (bzr r11941) --- src/sp-pattern.cpp | 52 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 19c0180a7..ba171bb05 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -608,8 +608,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, double opacity) { SPPattern *pat = SP_PATTERN (ps); - Geom::Affine ps2user; - Geom::Affine vb2ps = Geom::identity(); + bool needs_opacity = (1.0 - opacity) >= 1e-3; bool visible = opacity >= 1e-3; @@ -646,6 +645,8 @@ sp_pattern_create_pattern(SPPaintServer *ps, } } + // viewBox to pattern server + Geom::Affine vb2ps = Geom::identity(); if (pat->viewBox_set) { Geom::Rect vb = *pattern_viewBox(pat); gdouble tmp_x = pattern_width (pat) / vb.width(); @@ -655,6 +656,11 @@ sp_pattern_create_pattern(SPPaintServer *ps, vb2ps = Geom::Affine(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - vb.left() * tmp_x, pattern_y(pat) - vb.top() * tmp_y); } + // We must determine the size and scaling of the pattern at the time it is displayed and render + // the pattern onto a surface with that size and at that resolution. + + // Pattern server to user + Geom::Affine ps2user; ps2user = pattern_patternTransform(pat); if (!pat->viewBox_set && pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { /* BBox to user coordinate system */ @@ -663,6 +669,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; + // Pattern size in pattern space Geom::Rect pattern_tile = Geom::Rect::from_xywh(pattern_x(pat), pattern_y(pat), pattern_width(pat), pattern_height(pat)); @@ -672,22 +679,33 @@ sp_pattern_create_pattern(SPPaintServer *ps, pattern_tile = pattern_tile * bbox2user; } + // Transform of object with pattern (includes screen scaling) cairo_matrix_t cm; cairo_get_matrix(base_ct, &cm); Geom::Affine full(cm.xx, cm.yx, cm.xy, cm.yy, 0, 0); + // The DrawingSurface class is suppose to handle the mapping from "logical space" + // (coordinates in the rendering) to "physical space" (surface pixels). + // An oversampling is done as the pattern may not pixel align with the final surface. + // The cairo surface is created when the DrawingContext is declared. + // oversample the pattern slightly // TODO: find optimum value // TODO: this is lame. instead of using descrim(), we should extract // the scaling component from the complete matrix and use it // to find the optimum tile size for rendering - Geom::Point c(pattern_tile.dimensions()*vb2ps.descrim()*ps2user.descrim()*full.descrim()*1.1); + // c is number of pixels in buffer x and y. + Geom::Point c(pattern_tile.dimensions()*vb2ps.descrim()*ps2user.descrim()*full.descrim()*2); + c[Geom::X] = ceil(c[Geom::X]); c[Geom::Y] = ceil(c[Geom::Y]); - + + // Create drawing surface with size of pattern tile (in tile space) but with number of pixels + // based on required resolution (c). + Inkscape::DrawingSurface pattern_surface(pattern_tile, c.ceil()); + Inkscape::DrawingContext ct(pattern_surface); + Geom::IntRect one_tile = pattern_tile.roundOutwards(); - Inkscape::DrawingSurface temp(pattern_tile, c.ceil()); - Inkscape::DrawingContext ct(temp); // render pattern. if (needs_opacity) { @@ -695,9 +713,13 @@ sp_pattern_create_pattern(SPPaintServer *ps, } // TODO: make sure there are no leaks. - Inkscape::UpdateContext ctx; - ctx.ctm = vb2ps; + Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! + ctx.ctm = vb2ps;// * full; + drawing.update(Geom::IntRect::infinite(), ctx); + + // Render drawing to pattern_surface via drawing context, this calls root->render + // which is really DrawingItem->render(). drawing.render(ct, one_tile); for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { @@ -705,15 +727,23 @@ sp_pattern_create_pattern(SPPaintServer *ps, } } + // Uncomment to debug + // cairo_surface_t* raw = pattern_surface.raw(); + // std::cout << " cairo_surface (sp-pattern): " + // << " width: " << cairo_image_surface_get_width( raw ) + // << " height: " << cairo_image_surface_get_height( raw ) + // << std::endl; + // cairo_surface_write_to_png( pattern_surface.raw(), "sp-pattern.png" ); + if (needs_opacity) { ct.popGroupToSource(); // pop raw pattern ct.paint(opacity); // apply opacity } - cairo_pattern_t *cp = cairo_pattern_create_for_surface(temp.raw()); - + cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); // Apply transformation to user space. Also compensate for oversampling. - ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * temp.drawingTransform()); + ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform()); + cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); return cp; -- cgit v1.2.3 From a5db129462657ccdc1cea0f3319f5f812e0a8c40 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 9 Dec 2012 16:39:53 +0100 Subject: Second attempt at fix for #955141, rasterization of clipped/masked objects in patterns. (bzr r11942) --- src/sp-pattern.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ba171bb05..137864101 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -695,7 +695,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, // the scaling component from the complete matrix and use it // to find the optimum tile size for rendering // c is number of pixels in buffer x and y. - Geom::Point c(pattern_tile.dimensions()*vb2ps.descrim()*ps2user.descrim()*full.descrim()*2); + Geom::Point c(pattern_tile.dimensions()*vb2ps.descrim()*ps2user.descrim()*full.descrim()*1.1); c[Geom::X] = ceil(c[Geom::X]); c[Geom::Y] = ceil(c[Geom::Y]); @@ -705,6 +705,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, Inkscape::DrawingSurface pattern_surface(pattern_tile, c.ceil()); Inkscape::DrawingContext ct(pattern_surface); + pattern_tile *= pattern_surface.drawingTransform(); Geom::IntRect one_tile = pattern_tile.roundOutwards(); // render pattern. @@ -714,8 +715,8 @@ sp_pattern_create_pattern(SPPaintServer *ps, // TODO: make sure there are no leaks. Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! - ctx.ctm = vb2ps;// * full; - + ctx.ctm = vb2ps * pattern_surface.drawingTransform(); + ct.transform( pattern_surface.drawingTransform().inverse() ); drawing.update(Geom::IntRect::infinite(), ctx); // Render drawing to pattern_surface via drawing context, this calls root->render -- cgit v1.2.3 From 775dd4552f125326bfbb8873433972f6c37adc9e Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 9 Dec 2012 11:53:12 -0500 Subject: stacked clip paths. patch by Ted Janeczko for Bug 1067271 Fixed bugs: - https://launchpad.net/bugs/1067271 (bzr r11943) --- src/display/drawing-item.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 0fb1f0018..1e6e44d6f 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -667,29 +667,24 @@ DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) if (!_visible) return; if (!area.intersects(_bbox)) return; - // The item used as the clipping path itself has a clipping path. - // Render this item's clipping path onto a temporary surface, then composite it - // with the item using the IN operator - if (_clip) { - ct.pushAlphaGroup(); - { Inkscape::DrawingContext::Save save(ct); - ct.setSource(0,0,0,1); - _clip->clip(ct, area); - } - ct.pushAlphaGroup(); - } - + ct.setSource(0,0,0,1); + ct.pushGroup(); // rasterize the clipping path _clipItem(ct, area); - if (_clip) { + // The item used as the clipping path itself has a clipping path. + // Render this item's clipping path onto a temporary surface, then composite it + // with the item using the IN operator + ct.pushGroup(); + _clip->clip(ct, area); ct.popGroupToSource(); ct.setOperator(CAIRO_OPERATOR_IN); ct.paint(); - ct.popGroupToSource(); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); } + ct.popGroupToSource(); + ct.setOperator(CAIRO_OPERATOR_OVER); + ct.paint(); + ct.setSource(0,0,0,0); } /** -- cgit v1.2.3 From 7187bdb88d899e490e3dfa7471030473822bd93d Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 9 Dec 2012 19:07:59 -0500 Subject: clip path bbox refresh. partial fix for Bug 1005085 Fixed bugs: - https://launchpad.net/bugs/1005085 (bzr r11944) --- src/sp-item.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 3ca7d5d16..abb5c1633 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -552,6 +552,7 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { + item->bbox_valid = FALSE; // force a re-evaluation if (old_clip) { SPItemView *v; /* Hide clippath */ -- cgit v1.2.3 From 1432aefd92049594904ce1fd2366ada678d5d642 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 10 Dec 2012 10:57:22 +0900 Subject: Fix for 1086643 : Input devices : Simplify dialog (bzr r11945) --- src/ui/dialog/input.cpp | 463 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 341 insertions(+), 122 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 7e2b0a1e1..4c567a6e3 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -357,6 +357,15 @@ static std::map &getModeToString() return mapping; } +static int getModeId(Gdk::InputMode im) +{ + if (im == Gdk::MODE_DISABLED) return 0; + if (im == Gdk::MODE_SCREEN) return 1; + if (im == Gdk::MODE_WINDOW) return 2; + + return 0; +} + static std::map &getStringToMode() { static std::map mapping; @@ -400,15 +409,59 @@ private: static void setCellStateToggle(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter); void saveSettings(); + void onTreeSelect(); void useExtToggled(); - Glib::RefPtr store; - Gtk::TreeIter tabletIter; - Gtk::TreeView tree; - Gtk::ScrolledWindow treeScroller; + void onModeChange(); + void setKeys(gint count); + void setAxis(gint count); + + Glib::RefPtr confDeviceStore; + Gtk::TreeIter confDeviceIter; + Gtk::TreeView confDeviceTree; + Gtk::ScrolledWindow confDeviceScroller; Blink watcher; Gtk::CheckButton useExt; Gtk::Button save; + + Gtk::HPaned pane; + Gtk::VBox detailsBox; + Gtk::HBox titleFrame; + Gtk::Label titleLabel; + Inkscape::UI::Widget::Frame axisFrame; + Inkscape::UI::Widget::Frame keysFrame; + Gtk::VBox axisVBox; + Gtk::ComboBoxText modeCombo; + Gtk::Label modeLabel; + Gtk::HBox modeBox; + + class KeysColumns : public Gtk::TreeModel::ColumnRecord + { + public: + KeysColumns() + { + add(name); + add(value); + } + virtual ~KeysColumns() {} + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn value; + }; + + KeysColumns keysColumns; + KeysColumns axisColumns; + + Glib::RefPtr axisStore; + Gtk::TreeView axisTree; + Gtk::ScrolledWindow axisScroll; + + Glib::RefPtr keysStore; + Gtk::TreeView keysTree; + Gtk::ScrolledWindow keysScroll; + Gtk::CellRendererAccel _kb_shortcut_renderer; + + }; static DeviceModelColumns &getCols(); @@ -425,11 +478,11 @@ private: GdkInputSource lastSourceSeen; Glib::ustring lastDevnameSeen; - Glib::RefPtr store; - Gtk::TreeIter tabletIter; - Gtk::TreeView tree; - Inkscape::UI::Widget::Frame detailFrame; + Glib::RefPtr deviceStore; + Gtk::TreeIter deviceIter; + Gtk::TreeView deviceTree; Inkscape::UI::Widget::Frame testFrame; + Inkscape::UI::Widget::Frame axisFrame; Gtk::ScrolledWindow treeScroller; Gtk::ScrolledWindow detailScroller; Gtk::HPaned splitter; @@ -439,12 +492,13 @@ private: Gtk::Label devAxesCount; Gtk::ComboBoxText axesCombo; Gtk::ProgressBar axesValues[6]; + Gtk::Table axisTable; + Gtk::ComboBoxText buttonCombo; Gtk::ComboBoxText linkCombo; sigc::connection linkConnection; Gtk::Label keyVal; Gtk::Entry keyEntry; - Gtk::Table devDetails; Gtk::Notebook topHolder; Gtk::Image testThumb; Gtk::Image testButtons[24]; @@ -454,6 +508,7 @@ private: ConfPanel cfgPanel; + static void setupTree( Glib::RefPtr store, Gtk::TreeIter &tablet ); void setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo ); void updateTestButtons( Glib::ustring const& key, gint hotButton ); @@ -526,17 +581,17 @@ InputDialogImpl::InputDialogImpl() : lastSourceSeen((GdkInputSource)-1), lastDevnameSeen(""), - store(Gtk::TreeStore::create(getCols())), - tabletIter(), - tree(store), - detailFrame(), + deviceStore(Gtk::TreeStore::create(getCols())), + deviceIter(), + deviceTree(deviceStore), testFrame(_("Test Area")), + axisFrame(_("Axis")), treeScroller(), detailScroller(), splitter(), split2(), + axisTable(11, 2), linkCombo(), - devDetails(12, 2), topHolder(), imageTable(8, 7), testDetector(), @@ -547,10 +602,12 @@ InputDialogImpl::InputDialogImpl() : treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); treeScroller.set_shadow_type(Gtk::SHADOW_IN); - treeScroller.add(tree); + treeScroller.add(deviceTree); treeScroller.set_size_request(50, 0); - split2.pack1(testFrame, false, false); - split2.pack2(detailFrame, true, true); + + split2.pack1(axisFrame, false, false); + split2.pack2(testFrame, true, true); + splitter.pack1(treeScroller); splitter.pack2(split2); @@ -585,27 +642,35 @@ InputDialogImpl::InputDialogImpl() : } - topHolder.append_page(cfgPanel, _("Configuration")); - topHolder.append_page(splitter, _("Hardware")); - topHolder.show_all(); - topHolder.set_current_page(0); + // This is a hidden preference to enable the "hardware" details in a separate tab + // By default this is not available to users + if (Preferences::get()->getBool("/dialogs/inputdevices/test")) { + topHolder.append_page(cfgPanel, _("Configuration")); + topHolder.append_page(splitter, _("Hardware")); + topHolder.show_all(); + topHolder.set_current_page(0); + contents->pack_start(topHolder); + } else { + contents->pack_start(cfgPanel); + } - contents->pack_start(topHolder); int rowNum = 0; /* Gtk::Label* lbl = Gtk::manage(new Gtk::Label(_("Name:"))); - devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, + axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); - devDetails.attach(devName, 1, 2, rowNum, rowNum + 1, + axisTable.attach(devName, 1, 2, rowNum, rowNum + 1, ::Gtk::SHRINK, ::Gtk::SHRINK); rowNum++;*/ + axisFrame.add(axisTable); + Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:"))); - devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, + axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -614,21 +679,23 @@ InputDialogImpl::InputDialogImpl() : linkCombo.set_sensitive(false); linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged)); - devDetails.attach(linkCombo, 1, 2, rowNum, rowNum + 1, + axisTable.attach(linkCombo, 1, 2, rowNum, rowNum + 1, ::Gtk::FILL, ::Gtk::SHRINK); rowNum++; + lbl = Gtk::manage(new Gtk::Label(_("Axes count:"))); - devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, + axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); - devDetails.attach(devAxesCount, 1, 2, rowNum, rowNum + 1, + axisTable.attach(devAxesCount, 1, 2, rowNum, rowNum + 1, ::Gtk::SHRINK, ::Gtk::SHRINK); rowNum++; + /* lbl = Gtk::manage(new Gtk::Label(_("Actual axes count:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, @@ -643,22 +710,24 @@ InputDialogImpl::InputDialogImpl() : for ( guint barNum = 0; barNum < static_cast(G_N_ELEMENTS(axesValues)); barNum++ ) { lbl = Gtk::manage(new Gtk::Label(_("axis:"))); - devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, + axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, + ::Gtk::EXPAND, ::Gtk::SHRINK); - devDetails.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1, + axisTable.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1, ::Gtk::EXPAND, ::Gtk::SHRINK); axesValues[barNum].set_sensitive(false); rowNum++; + + } lbl = Gtk::manage(new Gtk::Label(_("Button count:"))); - devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, + axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); - devDetails.attach(devKeyCount, 1, 2, rowNum, rowNum + 1, + axisTable.attach(devKeyCount, 1, 2, rowNum, rowNum + 1, ::Gtk::SHRINK, ::Gtk::SHRINK); @@ -676,7 +745,7 @@ InputDialogImpl::InputDialogImpl() : rowNum++; */ - devDetails.attach(keyVal, 0, 2, rowNum, rowNum + 1, + axisTable.attach(keyVal, 0, 2, rowNum, rowNum + 1, ::Gtk::FILL, ::Gtk::SHRINK); rowNum++; @@ -696,19 +765,18 @@ InputDialogImpl::InputDialogImpl() : #endif testDetector.add_events(Gdk::POINTER_MOTION_MASK|Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK |Gdk::PROXIMITY_IN_MASK|Gdk::PROXIMITY_OUT_MASK|Gdk::SCROLL_MASK); - devDetails.attach(keyEntry, 0, 2, rowNum, rowNum + 1, + axisTable.attach(keyEntry, 0, 2, rowNum, rowNum + 1, ::Gtk::FILL, ::Gtk::SHRINK); rowNum++; - devDetails.set_sensitive(false); - detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + axisTable.set_sensitive(false); + +/* detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); detailScroller.set_shadow_type(Gtk::SHADOW_NONE); detailScroller.set_border_width (0); - detailScroller.add(devDetails); - detailFrame.add(detailScroller); - detailFrame.set_size_request(0, 60); + detailScroller.add(devDetails);*/ //- 16x16/devices // gnome-dev-mouse-optical @@ -717,25 +785,24 @@ InputDialogImpl::InputDialogImpl() : // mouse - //Add the TreeView's view columns: - tree.append_column("I", getCols().thumbnail); - tree.append_column("Bar", getCols().description); + deviceTree.append_column("I", getCols().thumbnail); + deviceTree.append_column("Bar", getCols().description); - tree.set_enable_tree_lines(); - tree.set_headers_visible(false); - tree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::resyncToSelection)); + deviceTree.set_enable_tree_lines(); + deviceTree.set_headers_visible(false); + deviceTree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::resyncToSelection)); - setupTree( store, tabletIter ); + setupTree( deviceStore, deviceIter ); Inkscape::DeviceManager::getManager().signalDeviceChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::handleDeviceChange)); Inkscape::DeviceManager::getManager().signalAxesChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceAxes)); Inkscape::DeviceManager::getManager().signalButtonsChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceButtons)); - Glib::RefPtr treePtr(&tree); - Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr)); + Glib::RefPtr treePtr(&deviceTree); + Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), deviceIter, treePtr)); - tree.expand_all(); + deviceTree.expand_all(); show_all_children(); } @@ -777,12 +844,30 @@ static Glib::ustring getCommon( std::list const &names ) return result; } + +void InputDialogImpl::ConfPanel::onModeChange() +{ + Glib::ustring newText = modeCombo.get_active_text(); + + Glib::RefPtr sel = confDeviceTree.get_selection(); + Gtk::TreeModel::iterator iter = sel->get_selected(); + if (iter) { + Glib::RefPtr dev = (*iter)[getCols().device]; + if (dev && (getStringToMode().find(newText) != getStringToMode().end())) { + Gdk::InputMode mode = getStringToMode()[newText]; + Inkscape::DeviceManager::getManager().setMode( dev->getId(), mode ); + } + } + +} + + void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIter &tablet ) { std::list > devList = Inkscape::DeviceManager::getManager().getDevices(); if ( !devList.empty() ) { - Gtk::TreeModel::Row row = *(store->append()); - row[getCols().description] = _("Hardware"); + //Gtk::TreeModel::Row row = *(store->append()); + //row[getCols().description] = _("Hardware"); // Let's make some tablets!!! std::list tablets; @@ -807,7 +892,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt // Phase 2 - build a UI for the present devices for ( std::list::iterator it = tablets.begin(); it != tablets.end(); ++it ) { - tablet = store->append(row.children()); + tablet = store->prepend(/*row.children()*/); Gtk::TreeModel::Row childrow = *tablet; if ( it->name.empty() ) { // Check to see if we can derive one @@ -870,13 +955,14 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt for ( std::list >::iterator it = devList.begin(); it != devList.end(); ++it ) { Glib::RefPtr dev = *it; if ( dev && (consumed.find( dev->getId() ) == consumed.end()) ) { - Gtk::TreeModel::Row deviceRow = *(store->append(row.children())); + Gtk::TreeModel::Row deviceRow = *(store->prepend(/*row.children()*/)); deviceRow[getCols().description] = dev->getName(); deviceRow[getCols().device] = dev; deviceRow[getCols().mode] = dev->getMode(); deviceRow[getCols().thumbnail] = getPix(PIX_CORE); } } + } else { g_warning("No devices found"); } @@ -885,84 +971,158 @@ void InputDialogImpl::setupTree( Glib::RefPtr store, Gtk::TreeIt InputDialogImpl::ConfPanel::ConfPanel() : Gtk::VBox(), - store(Gtk::TreeStore::create(getCols())), - tabletIter(), - tree(store), - treeScroller(), + confDeviceStore(Gtk::TreeStore::create(getCols())), + confDeviceIter(), + confDeviceTree(confDeviceStore), + confDeviceScroller(), watcher(*this), useExt(_("_Use pressure-sensitive tablet (requires restart)"), true), - save(_("_Save"), true) + save(_("_Save"), true), + detailsBox(false, 4), + titleFrame(false, 4), + titleLabel(""), + axisFrame(_("Axes")), + keysFrame(_("Keys")), + modeLabel(_("Mode")), + modeBox(false, 4) + { - pack_start(treeScroller); - treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - treeScroller.add(tree); - class Foo : public Gtk::TreeModel::ColumnRecord { + confDeviceScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + confDeviceScroller.set_shadow_type(Gtk::SHADOW_IN); + confDeviceScroller.add(confDeviceTree); + confDeviceScroller.set_size_request(120, 0); + + /* class Foo : public Gtk::TreeModel::ColumnRecord { public : Gtk::TreeModelColumn one; Foo() {add(one);} }; static Foo foo; - Glib::RefPtr poppers = Gtk::ListStore::create(foo); - poppers->reference(); - - Gtk::TreeModel::Row row = *(poppers->append()); - row[foo.one] = getModeToString()[Gdk::MODE_DISABLED]; - row = *(poppers->append()); - row[foo.one] = getModeToString()[Gdk::MODE_SCREEN]; - row = *(poppers->append()); - row[foo.one] = getModeToString()[Gdk::MODE_WINDOW]; //Add the TreeView's view columns: { Gtk::CellRendererToggle *rendr = new Gtk::CellRendererToggle(); Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("xx", *rendr); if (col) { - tree.append_column(*col); + confDeviceTree.append_column(*col); col->set_cell_data_func(*rendr, sigc::ptr_fun(setCellStateToggle)); - rendr->signal_toggled().connect(sigc::bind(sigc::ptr_fun(commitCellStateChange), store)); + rendr->signal_toggled().connect(sigc::bind(sigc::ptr_fun(commitCellStateChange), confDeviceStore)); } - } + }*/ - int expPos = tree.append_column("", getCols().expander); + //int expPos = confDeviceTree.append_column("", getCols().expander); - tree.append_column("I", getCols().thumbnail); - tree.append_column("Bar", getCols().description); + confDeviceTree.append_column("I", getCols().thumbnail); + confDeviceTree.append_column("Bar", getCols().description); - { - Gtk::CellRendererCombo *rendr = new Gtk::CellRendererCombo(); - rendr->property_model().set_value(poppers); - rendr->property_text_column().set_value(0); - rendr->property_has_entry() = false; + //confDeviceTree.get_column(0)->set_fixed_width(100); + //confDeviceTree.get_column(1)->set_expand(); + +/* { Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("X", *rendr); if (col) { - tree.append_column(*col); + confDeviceTree.append_column(*col); col->set_cell_data_func(*rendr, sigc::ptr_fun(setModeCellString)); - rendr->signal_edited().connect(sigc::bind(sigc::ptr_fun(commitCellModeChange), store)); + rendr->signal_edited().connect(sigc::bind(sigc::ptr_fun(commitCellModeChange), confDeviceStore)); rendr->property_editable() = true; } - } + }*/ - tree.set_enable_tree_lines(); - tree.set_headers_visible(false); - tree.set_expander_column( *tree.get_column(expPos - 1) ); + //confDeviceTree.set_enable_tree_lines(); + confDeviceTree.property_enable_tree_lines() = false; + confDeviceTree.property_enable_grid_lines() = false; + confDeviceTree.set_headers_visible(false); + //confDeviceTree.set_expander_column( *confDeviceTree.get_column(expPos - 1) ); - setupTree( store, tabletIter ); + confDeviceTree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::onTreeSelect)); - Glib::RefPtr treePtr(&tree); - Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr)); + setupTree( confDeviceStore, confDeviceIter ); - tree.expand_all(); + Glib::RefPtr treePtr(&confDeviceTree); + Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), confDeviceIter, treePtr)); + + confDeviceTree.expand_all(); useExt.set_active(Preferences::get()->getBool("/options/useextinput/value")); useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled)); - pack_start(useExt, Gtk::PACK_SHRINK); + Gtk::HButtonBox *buttonBox = manage (new Gtk::HButtonBox); + buttonBox->set_layout (Gtk::BUTTONBOX_END); + //Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0); + buttonBox->add(save); save.signal_clicked().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::saveSettings)); - Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0); - align->add(save); - pack_start(*Gtk::manage(align), Gtk::PACK_SHRINK); + + titleFrame.pack_start(titleLabel, true, true); + //titleFrame.set_shadow_type(Gtk::SHADOW_IN); + + modeCombo.append(getModeToString()[Gdk::MODE_DISABLED]); + modeCombo.append(getModeToString()[Gdk::MODE_SCREEN]); + modeCombo.append(getModeToString()[Gdk::MODE_WINDOW]); + modeCombo.set_tooltip_text(_("A device can be 'Disabled', its co-ordinates mapped to the whole 'Screen', or to a single (usually focused) 'Window'")); + modeCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::onModeChange)); + + modeBox.pack_start(modeLabel, false, false); + modeBox.pack_start(modeCombo, true, true); + + axisVBox.add(axisScroll); + axisFrame.add(axisVBox); + + keysFrame.add(keysScroll); + + /** + * Scrolled Window + */ + keysScroll.add(keysTree); + keysScroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + keysScroll.set_shadow_type(Gtk::SHADOW_IN); + keysScroll.set_size_request(120, 80); + + keysStore = Gtk::ListStore::create(keysColumns); + + _kb_shortcut_renderer.property_editable() = true; + + keysTree.set_model(keysStore); + keysTree.set_headers_visible(false); + keysTree.append_column("Name", keysColumns.name); + keysTree.append_column("Value", keysColumns.value); + + //keysTree.append_column("Value", _kb_shortcut_renderer); + //keysTree.get_column(1)->add_attribute(_kb_shortcut_renderer.property_text(), keysColumns.value); + //_kb_shortcut_renderer.signal_accel_edited().connect( sigc::mem_fun(*this, &InputDialogImpl::onKBTreeEdited) ); + //_kb_shortcut_renderer.signal_accel_cleared().connect( sigc::mem_fun(*this, &InputDialogImpl::onKBTreeCleared) ); + + axisStore = Gtk::ListStore::create(axisColumns); + + axisTree.set_model(axisStore); + axisTree.set_headers_visible(false); + axisTree.append_column("Name", axisColumns.name); + axisTree.append_column("Value", axisColumns.value); + + /** + * Scrolled Window + */ + axisScroll.add(axisTree); + axisScroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + axisScroll.set_shadow_type(Gtk::SHADOW_IN); + axisScroll.set_size_request(0, 150); + + pane.pack1(confDeviceScroller); + pane.pack2(detailsBox); + + detailsBox.pack_start(titleFrame, false, false, 6); + detailsBox.pack_start(modeBox, false, false, 6); + detailsBox.pack_start(axisFrame, false, false); + detailsBox.pack_start(keysFrame, false, false); + + pack_start(pane, true, true); + pack_start(useExt, Gtk::PACK_SHRINK); + pack_start(*buttonBox, false, false); + + // Select the first device + confDeviceTree.get_selection()->select(confDeviceStore->get_iter("0")); + } InputDialogImpl::ConfPanel::~ConfPanel() @@ -995,6 +1155,8 @@ void InputDialogImpl::ConfPanel::commitCellModeChange(Glib::ustring const &path, Inkscape::DeviceManager::getManager().setMode( dev->getId(), mode ); } } + + } void InputDialogImpl::ConfPanel::setCellStateToggle(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter) @@ -1029,6 +1191,25 @@ void InputDialogImpl::ConfPanel::commitCellStateChange(Glib::ustring const &path } } +void InputDialogImpl::ConfPanel::onTreeSelect() +{ + Glib::RefPtr treeSel = confDeviceTree.get_selection(); + Gtk::TreeModel::iterator iter = treeSel->get_selected(); + if (iter) { + Gtk::TreeModel::Row row = *iter; + Glib::ustring val = row[getCols().description]; + Glib::RefPtr dev = row[getCols().device]; + Gdk::InputMode mode = (*iter)[getCols().mode]; + modeCombo.set_active(getModeId(mode)); + + titleLabel.set_markup("" + row[getCols().description] + ""); + + if (dev) { + setKeys(dev->getNumKeys()); + setAxis(dev->getNumAxes()); + } + } +} void InputDialogImpl::ConfPanel::saveSettings() { Inkscape::DeviceManager::getManager().saveConfig(); @@ -1070,8 +1251,8 @@ void InputDialogImpl::handleDeviceChange(Glib::RefPtr device) { // g_message("OUCH!!!! for %p hits %s", &device, device->getId().c_str()); std::vector > stores; - stores.push_back(store); - stores.push_back(cfgPanel.store); + stores.push_back(deviceStore); + stores.push_back(cfgPanel.confDeviceStore); for (std::vector >::iterator it = stores.begin(); it != stores.end(); ++it) { Gtk::TreeModel::iterator deviceIter; @@ -1154,11 +1335,11 @@ bool InputDialogImpl::findDeviceByLink(const Gtk::TreeModel::iterator& iter, void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, Gtk::TreeIter tabletIter, Glib::RefPtr tree) { - Glib::RefPtr store = Glib::RefPtr::cast_dynamic(tree->get_model()); + Glib::RefPtr deviceStore = Glib::RefPtr::cast_dynamic(tree->get_model()); // g_message("Links!!!! for %p hits [%s] with link of [%s]", &device, device->getId().c_str(), device->getLink().c_str()); Gtk::TreeModel::iterator deviceIter; - store->foreach_iter( sigc::bind( + deviceStore->foreach_iter( sigc::bind( sigc::ptr_fun(&InputDialogImpl::findDevice), device->getId(), &deviceIter) ); @@ -1176,16 +1357,16 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, Glib::ustring descr = (*deviceIter)[getCols().description]; Glib::RefPtr thumb = (*deviceIter)[getCols().thumbnail]; - Gtk::TreeModel::Row deviceRow = *store->append(tabletIter->children()); + Gtk::TreeModel::Row deviceRow = *deviceStore->append(tabletIter->children()); deviceRow[getCols().description] = descr; deviceRow[getCols().thumbnail] = thumb; deviceRow[getCols().device] = dev; deviceRow[getCols().mode] = dev->getMode(); Gtk::TreeModel::iterator oldParent = deviceIter->parent(); - store->erase(deviceIter); + deviceStore->erase(deviceIter); if ( oldParent->children().empty() ) { - store->erase(oldParent); + deviceStore->erase(oldParent); } } } else { @@ -1193,7 +1374,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, if ( deviceIter->parent() == tabletIter ) { // Simple case. Not already linked - Gtk::TreeIter newGroup = store->append(tabletIter->children()); + Gtk::TreeIter newGroup = deviceStore->append(tabletIter->children()); (*newGroup)[getCols().description] = _("Pen"); (*newGroup)[getCols().thumbnail] = getPix(PIX_PEN); @@ -1201,7 +1382,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, Glib::ustring descr = (*deviceIter)[getCols().description]; Glib::RefPtr thumb = (*deviceIter)[getCols().thumbnail]; - Gtk::TreeModel::Row deviceRow = *store->append(newGroup->children()); + Gtk::TreeModel::Row deviceRow = *deviceStore->append(newGroup->children()); deviceRow[getCols().description] = descr; deviceRow[getCols().thumbnail] = thumb; deviceRow[getCols().device] = dev; @@ -1209,7 +1390,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, Gtk::TreeModel::iterator linkIter; - store->foreach_iter( sigc::bind( + deviceStore->foreach_iter( sigc::bind( sigc::ptr_fun(&InputDialogImpl::findDeviceByLink), device->getId(), &linkIter) ); @@ -1218,22 +1399,22 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, descr = (*linkIter)[getCols().description]; thumb = (*linkIter)[getCols().thumbnail]; - deviceRow = *store->append(newGroup->children()); + deviceRow = *deviceStore->append(newGroup->children()); deviceRow[getCols().description] = descr; deviceRow[getCols().thumbnail] = thumb; deviceRow[getCols().device] = dev; deviceRow[getCols().mode] = dev->getMode(); Gtk::TreeModel::iterator oldParent = linkIter->parent(); - store->erase(linkIter); + deviceStore->erase(linkIter); if ( oldParent->children().empty() ) { - store->erase(oldParent); + deviceStore->erase(oldParent); } } Gtk::TreeModel::iterator oldParent = deviceIter->parent(); - store->erase(deviceIter); + deviceStore->erase(deviceIter); if ( oldParent->children().empty() ) { - store->erase(oldParent); + deviceStore->erase(oldParent); } tree->expand_row(Gtk::TreePath(newGroup), true); } @@ -1242,7 +1423,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr device, } void InputDialogImpl::linkComboChanged() { - Glib::RefPtr treeSel = tree.get_selection(); + Glib::RefPtr treeSel = deviceTree.get_selection(); Gtk::TreeModel::iterator iter = treeSel->get_selected(); if (iter) { Gtk::TreeModel::Row row = *iter; @@ -1268,14 +1449,15 @@ void InputDialogImpl::linkComboChanged() { void InputDialogImpl::resyncToSelection() { bool clear = true; - Glib::RefPtr treeSel = tree.get_selection(); + Glib::RefPtr treeSel = deviceTree.get_selection(); Gtk::TreeModel::iterator iter = treeSel->get_selected(); if (iter) { Gtk::TreeModel::Row row = *iter; Glib::ustring val = row[getCols().description]; Glib::RefPtr dev = row[getCols().device]; + if ( dev ) { - devDetails.set_sensitive(true); + axisTable.set_sensitive(true); linkConnection.block(); linkCombo.remove_all(); @@ -1300,21 +1482,60 @@ void InputDialogImpl::resyncToSelection() { clear = false; devName.set_label(row[getCols().description]); - detailFrame.set_label(row[getCols().description]); + axisFrame.set_label(row[getCols().description]); setupValueAndCombo( dev->getNumAxes(), dev->getNumAxes(), devAxesCount, axesCombo); setupValueAndCombo( dev->getNumKeys(), dev->getNumKeys(), devKeyCount, buttonCombo); + + } } - devDetails.set_sensitive(!clear); + axisTable.set_sensitive(!clear); if (clear) { - detailFrame.set_label(""); + axisFrame.set_label(""); devName.set_label(""); devAxesCount.set_label(""); devKeyCount.set_label(""); } } +void InputDialogImpl::ConfPanel::setAxis(gint count) +{ + /* + * TODO - Make each axis editable + */ + axisStore->clear(); + + static Glib::ustring axesLabels[6] = {_("X"), _("Y"), _("Pressure"), _("X tilt"), _("Y tilt"), _("Wheel")}; + + for ( gint barNum = 0; barNum < static_cast(G_N_ELEMENTS(axesLabels)); barNum++ ) { + + Gtk::TreeModel::Row row = *(axisStore->append()); + row[axisColumns.name] = axesLabels[barNum]; + if (barNum < count) { + row[axisColumns.value] = Glib::ustring::format(barNum+1); + } else { + row[axisColumns.value] = _("None"); + } + } + +} +void InputDialogImpl::ConfPanel::setKeys(gint count) +{ + /* + * TODO - Make each key assignable + */ + + keysStore->clear(); + + for (gint i = 0; i < count; i++) { + Gtk::TreeModel::Row row = *(keysStore->append()); + row[keysColumns.name] = Glib::ustring::format(i+1); + row[keysColumns.value] = _("Disabled"); + } + + +} void InputDialogImpl::setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo ) { gchar *tmp = g_strdup_printf("%d", reported); @@ -1350,9 +1571,9 @@ void InputDialogImpl::updateTestButtons( Glib::ustring const& key, gint hotButto void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) { - static gdouble epsilon = 0.0001; + //static gdouble epsilon = 0.0001; { - Glib::RefPtr treeSel = tree.get_selection(); + Glib::RefPtr treeSel = deviceTree.get_selection(); Gtk::TreeModel::iterator iter = treeSel->get_selected(); if (iter) { Gtk::TreeModel::Row row = *iter; @@ -1364,7 +1585,6 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) } } - for ( gint i = 0; i < static_cast(G_N_ELEMENTS(testAxes)); i++ ) { if ( axesMap[key].find(i) != axesMap[key].end() ) { switch ( axesMap[key][i].first ) { @@ -1379,7 +1599,6 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) testAxes[i].set(getPix(PIX_AXIS_OFF)); axesValues[i].set_sensitive(true); if ( dev && (i < static_cast(G_N_ELEMENTS(axesValues)) ) ) { - // FIXME: Device axis ranges are inaccessible in GTK+ 3 and // are deprecated in GTK+ 2. Progress-bar ranges are disabled // until we find an alternative solution -- cgit v1.2.3 From bf4abaf38b53688e63b3d56040c9893deb6f8dcc Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 9 Dec 2012 22:53:37 -0500 Subject: reverting rev 11944 (bzr r11946) --- src/sp-item.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index abb5c1633..3ca7d5d16 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -552,7 +552,6 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { - item->bbox_valid = FALSE; // force a re-evaluation if (old_clip) { SPItemView *v; /* Hide clippath */ -- cgit v1.2.3 From d4b890423b79c8148bfa81ad1199bc846b723290 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 10 Dec 2012 11:59:04 +0000 Subject: GTK3: Migrate guides dialog to Gtk::Grid (bzr r11947) --- src/ui/dialog/guides.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++----- src/ui/dialog/guides.h | 16 +++++++++++ 2 files changed, 79 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index d20f2a220..1f02002ca 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -168,30 +168,54 @@ void GuidelinePropertiesDialog::_setup() { Gtk::Box *mainVBox = get_vbox(); +#if WITH_GTKMM_3_0 + _layout_table.set_row_spacing(4); + _layout_table.set_column_spacing(4); +#else _layout_table.set_spacings(4); _layout_table.resize (3, 4); +#endif mainVBox->pack_start(_layout_table, false, false, 0); _label_name.set_label("foo0"); - _layout_table.attach(_label_name, - 0, 3, 0, 1, Gtk::FILL, Gtk::FILL); _label_name.set_alignment(0, 0.5); _label_descr.set_label("foo1"); - _layout_table.attach(_label_descr, - 0, 3, 1, 2, Gtk::FILL, Gtk::FILL); _label_descr.set_alignment(0, 0.5); + +#if WITH_GTKMM_3_0 + _label_name.set_halign(Gtk::ALIGN_FILL); + _label_name.set_valign(Gtk::ALIGN_FILL); + _layout_table.attach(_label_name, 0, 0, 3, 1); + + _label_descr.set_halign(Gtk::ALIGN_FILL); + _label_descr.set_valign(Gtk::ALIGN_FILL); + _layout_table.attach(_label_descr, 0, 1, 3, 1); + + _label_entry.set_halign(Gtk::ALIGN_FILL); + _label_entry.set_valign(Gtk::ALIGN_FILL); + _label_entry.set_hexpand(); + _layout_table.attach(_label_entry, 1, 2, 2, 1); + + _color.set_halign(Gtk::ALIGN_FILL); + _color.set_valign(Gtk::ALIGN_FILL); + _color.set_hexpand(); + _layout_table.attach(_color, 1, 3, 2, 1); +#else + _layout_table.attach(_label_name, + 0, 3, 0, 1, Gtk::FILL, Gtk::FILL); - // indent -// _layout_table.attach(*manage(new Gtk::Label(" ")), -// 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); + _layout_table.attach(_label_descr, + 0, 3, 1, 2, Gtk::FILL, Gtk::FILL); _layout_table.attach(_label_entry, 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_color, 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); +#endif + _color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged)); @@ -211,6 +235,22 @@ void GuidelinePropertiesDialog::_setup() { _spin_button_y.setDigits(3); _spin_button_y.setIncrements(1.0, 10.0); _spin_button_y.setRange(-1e6, 1e6); + +#if WITH_GTKMM_3_0 + _spin_button_x.set_halign(Gtk::ALIGN_FILL); + _spin_button_x.set_valign(Gtk::ALIGN_FILL); + _spin_button_x.set_hexpand(); + _layout_table.attach(_spin_button_x, 1, 4, 1, 1); + + _spin_button_y.set_halign(Gtk::ALIGN_FILL); + _spin_button_y.set_valign(Gtk::ALIGN_FILL); + _spin_button_y.set_hexpand(); + _layout_table.attach(_spin_button_y, 1, 5, 1, 1); + + _unit_menu.set_halign(Gtk::ALIGN_FILL); + _unit_menu.set_valign(Gtk::ALIGN_FILL); + _layout_table.attach(_unit_menu, 2, 4, 1, 1); +#else _layout_table.attach(_spin_button_x, 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_y, @@ -218,17 +258,33 @@ void GuidelinePropertiesDialog::_setup() { _layout_table.attach(_unit_menu, 2, 3, 4, 5, Gtk::FILL, Gtk::FILL); +#endif // angle spinbutton _spin_angle.setDigits(3); _spin_angle.setIncrements(1.0, 10.0); _spin_angle.setRange(-3600., 3600.); + +#if WITH_GTKMM_3_0 + _spin_angle.set_halign(Gtk::ALIGN_FILL); + _spin_angle.set_valign(Gtk::ALIGN_FILL); + _spin_angle.set_hexpand(); + _layout_table.attach(_spin_angle, 1, 6, 2, 1); + + // mode radio button + _relative_toggle.set_halign(Gtk::ALIGN_FILL); + _relative_toggle.set_valign(Gtk::ALIGN_FILL); + _relative_toggle.set_hexpand(); + _layout_table.attach(_relative_toggle, 1, 7, 2, 1); +#else _layout_table.attach(_spin_angle, 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); // mode radio button _layout_table.attach(_relative_toggle, 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); +#endif + _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); _relative_toggle.set_active(_relative_toggle_status); diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index d06c3afc8..a15667152 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -11,8 +11,18 @@ #ifndef INKSCAPE_DIALOG_GUIDELINE_H #define INKSCAPE_DIALOG_GUIDELINE_H +#ifdef HAVE_CONFIG_H +# include +#endif + #include + +#if WITH_GTKMM_3_0 +#include +#else #include +#endif + #include #include #include "ui/widget/button.h" @@ -62,7 +72,13 @@ private: SPDesktop *_desktop; SPGuide *_guide; + +#if WITH_GTKMM_3_0 + Gtk::Grid _layout_table; +#else Gtk::Table _layout_table; +#endif + Gtk::Label _label_name; Gtk::Label _label_descr; Inkscape::UI::Widget::CheckButton _relative_toggle; -- cgit v1.2.3 From c72c1ac700fbe0c1a54062209c17cee1bb0257b5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 10 Dec 2012 12:09:02 +0000 Subject: Migrate Layers dialog to Gtk::Grid (bzr r11948) --- src/ui/dialog/layer-properties.cpp | 45 ++++++++++++++++++++++++++++++++++++-- src/ui/dialog/layer-properties.h | 16 ++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 245dac5e0..6a1bc829e 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -42,18 +42,35 @@ LayerPropertiesDialog::LayerPropertiesDialog() { Gtk::Box *mainVBox = get_vbox(); +#if WITH_GTKMM_3_0 + _layout_table.set_row_spacing(4); + _layout_table.set_column_spacing(4); +#else _layout_table.set_spacings(4); _layout_table.resize (1, 2); +#endif // Layer name widgets _layer_name_entry.set_activates_default(true); _layer_name_label.set_label(_("Layer name:")); _layer_name_label.set_alignment(1.0, 0.5); +#if WITH_GTKMM_3_0 + _layer_name_label.set_halign(Gtk::ALIGN_FILL); + _layer_name_label.set_valign(Gtk::ALIGN_FILL); + _layout_table.attach(_layer_name_label, 0, 0, 1, 1); + + _layer_name_entry.set_halign(Gtk::ALIGN_FILL); + _layer_name_entry.set_valign(Gtk::ALIGN_FILL); + _layer_name_entry.set_hexpand(); + _layout_table.attach(_layer_name_entry, 1, 0, 1, 1); +#else _layout_table.attach(_layer_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); _layout_table.attach(_layer_name_entry, 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); +#endif + mainVBox->pack_start(_layout_table, true, true, 4); // Buttons @@ -149,7 +166,9 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_combo.set_cell_data_func(_label_renderer, sigc::mem_fun(*this, &LayerPropertiesDialog::_prepareLabelRenderer)); +#if !WITH_GTKMM_3_0 _layout_table.resize (2, 2); +#endif Gtk::ListStore::iterator row; row = _dropdown_list->append(); @@ -163,12 +182,25 @@ LayerPropertiesDialog::_setup_position_controls() { row->set_value(_dropdown_columns.position, LPOS_CHILD); row->set_value(_dropdown_columns.name, Glib::ustring(_("As sublayer of current"))); - _layout_table.attach(_layer_position_combo, - 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); _layer_position_label.set_label(_("Position:")); _layer_position_label.set_alignment(1.0, 0.5); + +#if WITH_GTKMM_3_0 + _layer_position_combo.set_halign(Gtk::ALIGN_FILL); + _layer_position_combo.set_valign(Gtk::ALIGN_FILL); + _layer_position_combo.set_hexpand(); + _layout_table.attach(_layer_position_combo, 1, 1, 1, 1); + + _layer_position_label.set_halign(Gtk::ALIGN_FILL); + _layer_position_label.set_valign(Gtk::ALIGN_FILL); + _layout_table.attach(_layer_position_label, 0, 1, 1, 1); +#else + _layout_table.attach(_layer_position_combo, + 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); _layout_table.attach(_layer_position_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); +#endif + show_all_children(); } @@ -222,8 +254,17 @@ LayerPropertiesDialog::_setup_layers_controls() { _layout_table.remove(_layer_name_entry); _layout_table.remove(_layer_name_label); +#if WITH_GTKMM_3_0 + _scroller.set_halign(Gtk::ALIGN_FILL); + _scroller.set_valign(Gtk::ALIGN_FILL); + _scroller.set_hexpand(); + _scroller.set_vexpand(); + _layout_table.attach(_scroller, 0, 1, 2, 1); +#else _layout_table.attach(_scroller, 0, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND); +#endif + show_all_children(); } diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index 46b31ad35..9de303f89 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -12,10 +12,20 @@ #ifndef INKSCAPE_DIALOG_LAYER_PROPERTIES_H #define INKSCAPE_DIALOG_LAYER_PROPERTIES_H +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include + +#if WITH_GTKMM_3_0 +#include +#else #include +#endif + #include #include #include @@ -92,7 +102,13 @@ protected: Gtk::Entry _layer_name_entry; Gtk::Label _layer_position_label; Gtk::ComboBox _layer_position_combo; + +#if WITH_GTKMM_3_0 + Gtk::Grid _layout_table; +#else Gtk::Table _layout_table; +#endif + bool _position_visible; class ModelColumns : public Gtk::TreeModel::ColumnRecord -- cgit v1.2.3 From d99fc1e4b455820b561fc20c422fe6cc4945292f Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 10 Dec 2012 18:15:39 +0100 Subject: Fix for bug #837066: Bucket Tool regressions with Cairo renderer. (bzr r11949) --- src/flood-context.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index a6c7fa0dc..3c656527e 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -205,6 +205,10 @@ static void sp_flood_context_setup(SPEventContext *ec) } } +// Changes from 0.48 -> 0.49 (Cairo) +// 0.49: Ignores alpha in background +// 0.48: RGBA, 0.49 ARGB +// 0.49: premultiplied alpha inline static guint32 compose_onto(guint32 px, guint32 bg) { guint ap = 0, rp = 0, gp = 0, bp = 0; @@ -212,10 +216,12 @@ inline static guint32 compose_onto(guint32 px, guint32 bg) ExtractARGB32(px, ap, rp, gp, bp); ExtractRGB32(bg, rb, gb, bb); - guint ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255; - guint ro = (255-ap)*rb + rp; ro = (ro + 127) / 255; - guint go = (255-ap)*gb + gp; go = (go + 127) / 255; - guint bo = (255-ap)*bb + bp; bo = (bo + 127) / 255; + // guint ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255; + // guint ao = (255-ap)*ab + 255*ap; ao = (ao + 127) / 255; + guint ao = 255; // Cairo version doesn't allow background to have alpha != 1. + guint ro = (255-ap)*rb + 255*rp; ro = (ro + 127) / 255; + guint go = (255-ap)*gb + 255*gp; go = (go + 127) / 255; + guint bo = (255-ap)*bb + 255*bp; bo = (bo + 127) / 255; guint pxout = AssembleARGB32(ao, ro, go, bo); return pxout; @@ -314,10 +320,12 @@ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixe return abs(static_cast(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; case FLOOD_CHANNELS_RGB: guint32 amc, rmc, bmc, gmc; - amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; - rmc = (255-ac)*rd + rc; rmc = (rmc + 127) / 255; - gmc = (255-ac)*gd + gc; gmc = (gmc + 127) / 255; - bmc = (255-ac)*bd + bc; bmc = (bmc + 127) / 255; + //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; + //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255; + amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha + rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255; + gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; + bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; diff += abs(static_cast(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0)); diff += abs(static_cast(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0)); @@ -826,6 +834,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even guchar *px = g_new(guchar, stride * height); guint32 bgcolor, dtc; + // Draw image into data block px { // this block limits the lifetime of Drawing and DrawingContext /* Create DrawingItems and set transform */ unsigned dkey = SPItem::display_key_new(1); @@ -854,6 +863,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even drawing.render(ct, final_bbox); + //cairo_surface_write_to_png( s, "cairo.png" ); + cairo_surface_flush(s); cairo_surface_destroy(s); @@ -861,6 +872,14 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even document->getRoot()->invoke_hide(dkey); } + // { + // // Dump data to png + // cairo_surface_t *s = cairo_image_surface_create_for_data( + // px, CAIRO_FORMAT_ARGB32, width, height, stride); + // cairo_surface_write_to_png( s, "cairo2.png" ); + // std::cout << " Wrote cairo2.png" << std::endl; + // } + guchar *trace_px = g_new(guchar, width * height); memset(trace_px, 0x00, width * height); -- cgit v1.2.3 From 2ceb091e1e3956cf1386507571d23de569917b01 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 11 Dec 2012 09:32:34 +0900 Subject: Fix for 1086225 : Command line PDF export fails if FeFlood filter primitive is present (bzr r11950) --- src/sp-item.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 3ca7d5d16..363aa8c17 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1514,8 +1514,6 @@ Geom::Affine SPItem::i2dt_affine() const ret = i2doc_affine() * Geom::Scale(1, -1) * Geom::Translate(0, document->getHeight()); - - g_return_val_if_fail(desktop != NULL, ret); } return ret; } -- cgit v1.2.3 From 41a4d9fcbeddb37d209754c2649249b613bec52c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 12 Dec 2012 12:50:43 +0000 Subject: Stop using invalid casting in spinbutton-events Fixed bugs: - https://launchpad.net/bugs/1089290 (bzr r11951) --- src/widgets/spinbutton-events.cpp | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp index c718b6712..1d44b9190 100644 --- a/src/widgets/spinbutton-events.cpp +++ b/src/widgets/spinbutton-events.cpp @@ -66,26 +66,25 @@ spinbutton_defocus (GtkWidget *container) gboolean spinbutton_keypress(GtkWidget *w, GdkEventKey *event, gpointer data) { - SPWidget *spw = SP_WIDGET(data); gdouble v; gdouble step; gdouble page; switch (get_group0_keyval (event)) { case GDK_KEY_Escape: // defocus - spinbutton_undo (w); - spinbutton_defocus(GTK_WIDGET(spw)); + spinbutton_undo(w); + spinbutton_defocus(w); return TRUE; // I consumed the event break; case GDK_KEY_Return: // defocus case GDK_KEY_KP_Enter: - spinbutton_defocus (GTK_WIDGET(spw)); + spinbutton_defocus(w); return TRUE; // I consumed the event break; case GDK_KEY_Tab: case GDK_KEY_ISO_Left_Tab: // set the flag meaning "do not leave toolbar when changing value" - g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE)); return FALSE; // I didn't consume the event break; @@ -94,45 +93,45 @@ gboolean spinbutton_keypress(GtkWidget *w, GdkEventKey *event, gpointer data) case GDK_KEY_Up: case GDK_KEY_KP_Up: - g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); - v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); - gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page); + g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE)); + v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w)); + gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page); v += step; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); return TRUE; // I consumed the event break; case GDK_KEY_Down: case GDK_KEY_KP_Down: - g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); - v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); - gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page); + g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE)); + v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w)); + gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page); v -= step; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); return TRUE; // I consumed the event break; case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up: - g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); - v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); - gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page); + g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE)); + v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w)); + gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page); v += page; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); return TRUE; // I consumed the event break; case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down: - g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); - v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); - gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page); + g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE)); + v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w)); + gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page); v -= page; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); return TRUE; // I consumed the event break; case GDK_KEY_z: case GDK_KEY_Z: - g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE)); if (event->state & GDK_CONTROL_MASK) { - spinbutton_undo (w); + spinbutton_undo(w); return TRUE; // I consumed the event } break; @@ -142,3 +141,14 @@ gboolean spinbutton_keypress(GtkWidget *w, GdkEventKey *event, gpointer data) } return FALSE; // I didn't consume the event } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 4efaa02ff5474bb1342308a6eb3313fbb08f6c9c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 12 Dec 2012 22:40:59 +0000 Subject: Migrate document metadata from NotbookPage to Gtk::Grid and drop dead code (bzr r11952) --- src/ui/dialog/document-metadata.cpp | 112 ++++++++++++++++++++---------------- src/ui/dialog/document-metadata.h | 21 ++++++- 2 files changed, 79 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 6318ffbbb..efe25d843 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -61,13 +61,30 @@ DocumentMetadata::getInstance() DocumentMetadata::DocumentMetadata() +#if WITH_GTKMM_3_0 + : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA) +#else : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA), _page_metadata1(1, 1), _page_metadata2(1, 1) +#endif { hide(); _getContents()->set_spacing (4); _getContents()->pack_start(_notebook, true, true); + _page_metadata1.set_border_width(2); + _page_metadata2.set_border_width(2); + +#if WITH_GTKMM_3_0 + _page_metadata1.set_column_spacing(2); + _page_metadata2.set_column_spacing(2); + _page_metadata1.set_row_spacing(2); + _page_metadata2.set_row_spacing(2); +#else + _page_metadata1.set_spacings(2); + _page_metadata2.set_spacings(2); +#endif + _notebook.append_page(_page_metadata1, _("Metadata")); _notebook.append_page(_page_metadata2, _("License")); @@ -98,50 +115,6 @@ DocumentMetadata::~DocumentMetadata() delete (*it); } -//======================================================================== - -/** - * Helper function that attachs widgets in a 3xn table. The widgets come in an - * array that has two entries per table row. The two entries code for four - * possible cases: (0,0) means insert space in first column; (0, non-0) means - * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and - * (non-0, non-0) means two widgets in columns 2 and 3. - */ -inline void attach_all(Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0) -{ - for (unsigned i=0, r=start; i(*arr[i]), 1, 2, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - table.attach (const_cast(*arr[i+1]), 2, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - } - else - { - if (arr[i+1]) - table.attach (const_cast(*arr[i+1]), 1, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - else if (arr[i]) - { - Gtk::Label& label = static_cast (const_cast(*arr[i])); - label.set_alignment (0.0); - table.attach (label, 0, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - } - else - { - Gtk::HBox *space = manage (new Gtk::HBox); - space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - table.attach (*space, 0, 1, r, r+1, - (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); - } - } - ++r; - } -} - void DocumentMetadata::build_metadata() { @@ -152,7 +125,14 @@ DocumentMetadata::build_metadata() Gtk::Label *label = manage (new Gtk::Label); label->set_markup (_("Dublin Core Entities")); label->set_alignment (0.0); - _page_metadata1.table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); + +#if WITH_GTKMM_3_0 + label->set_valign(Gtk::ALIGN_CENTER); + _page_metadata1.attach(*label, 0, 0, 3, 1); +#else + _page_metadata1.attach(*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); +#endif + /* add generic metadata entry areas */ struct rdf_work_entity_t * entity; int row = 1; @@ -162,9 +142,22 @@ DocumentMetadata::build_metadata() _rdflist.push_back (w); Gtk::HBox *space = manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - _page_metadata1.table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1.table().attach (w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1.table().attach (*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); + +#if WITH_GTKMM_3_0 + space->set_valign(Gtk::ALIGN_CENTER); + _page_metadata1.attach(*space, 0, row, 1, 1); + + w->_label.set_valign(Gtk::ALIGN_CENTER); + _page_metadata1.attach(w->_label, 1, row, 1, 1); + + w->_packable->set_hexpand(); + w->_packable->set_valign(Gtk::ALIGN_CENTER); + _page_metadata1.attach(*w->_packable, 2, row, 1, 1); +#else + _page_metadata1.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); + _page_metadata1.attach(w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); + _page_metadata1.attach(*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); +#endif } } @@ -174,14 +167,31 @@ DocumentMetadata::build_metadata() Gtk::Label *llabel = manage (new Gtk::Label); llabel->set_markup (_("License")); llabel->set_alignment (0.0); - _page_metadata2.table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); + +#if WITH_GTKMM_3_0 + llabel->set_valign(Gtk::ALIGN_CENTER); + _page_metadata2.attach(*llabel, 0, row, 3, 1); +#else + _page_metadata2.attach(*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); +#endif + /* add license selector pull-down and URI */ ++row; _licensor.init (_wr); Gtk::HBox *space = manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - _page_metadata2.table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata2.table().attach (_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0); + +#if WITH_GTKMM_3_0 + space->set_valign(Gtk::ALIGN_CENTER); + _page_metadata2.attach(*space, 0, row, 1, 1); + + _licensor.set_hexpand(); + _licensor.set_valign(Gtk::ALIGN_CENTER); + _page_metadata2.attach(_licensor, 1, row, 2, 1); +#else + _page_metadata2.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); + _page_metadata2.attach(_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0); +#endif } /** diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h index f201679b5..3b7ed1ec8 100644 --- a/src/ui/dialog/document-metadata.h +++ b/src/ui/dialog/document-metadata.h @@ -13,12 +13,22 @@ #ifndef INKSCAPE_UI_DIALOG_DOCUMENT_METADATA_H #define INKSCAPE_UI_DIALOG_DOCUMENT_METADATA_H +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include "ui/widget/panel.h" #include + +#if WITH_GTKMM_3_0 +# include +#else +# include +#endif + #include "ui/widget/licensor.h" -#include "ui/widget/notebook-page.h" #include "ui/widget/registry.h" namespace Inkscape { @@ -51,8 +61,13 @@ protected: Gtk::Notebook _notebook; - UI::Widget::NotebookPage _page_metadata1; - UI::Widget::NotebookPage _page_metadata2; +#if WITH_GTKMM_3_0 + Gtk::Grid _page_metadata1; + Gtk::Grid _page_metadata2; +#else + Gtk::Table _page_metadata1; + Gtk::Table _page_metadata2; +#endif //--------------------------------------------------------------- RDElist _rdflist; -- cgit v1.2.3 From ed8bc9e004c3f0fc7aed2459b70e183012d9cdc9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 13 Dec 2012 23:17:51 +0100 Subject: re-add Grayscale color mode Fixed bugs: - https://launchpad.net/bugs/885048 (bzr r11953) --- src/display/drawing.cpp | 34 +++++++++++++++- src/display/nr-filter-colormatrix.cpp | 77 +++++++++++++++++------------------ src/display/nr-filter-colormatrix.h | 9 ++++ 3 files changed, 79 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 77f24caf3..171cc014f 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -4,8 +4,9 @@ *//* * Authors: * Krzysztof Kosiński + * Johan Engelen * - * Copyright (C) 2011 Authors + * Copyright (C) 2011-2012 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -14,6 +15,12 @@ #include "nr-filter-gaussian.h" #include "nr-filter-types.h" +//grayscale colormode: +#include "nr-filter-colormatrix.h" +#include "cairo-templates.h" +#include "drawing-context.h" + + namespace Inkscape { Drawing::Drawing(SPCanvasArena *arena) @@ -145,12 +152,37 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl _pickItemsForCaching(); } +// hardcoded grayscale color matrix values. could be turned into preference settings in future. +static const gdouble grayscale_value_matrix[] = { + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0 , 0 , 0 , 1, 0 +}; +static Filters::FilterColorMatrix::ColorMatrixMatrix grayscale_colormatrix( + std::vector (grayscale_value_matrix, grayscale_value_matrix + sizeof(grayscale_value_matrix) / sizeof(grayscale_value_matrix[0]) ) +); + void Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { if (_root) { _root->render(ct, area, flags); } + + if (colorMode() == COLORMODE_GRAYSCALE) { + // apply grayscale filter on top of everything + cairo_surface_t *input = ct.rawTarget(); + cairo_surface_t *out = ink_cairo_surface_create_identical(input); + ink_cairo_surface_filter(input, out, grayscale_colormatrix); + Geom::Point origin = ct.targetLogicalBounds().min(); + ct.setSource(out, origin[Geom::X], origin[Geom::Y]); + ct.setOperator(CAIRO_OPERATOR_SOURCE); + ct.paint(); + ct.setOperator(CAIRO_OPERATOR_OVER); + + cairo_surface_destroy(out); + } } DrawingItem * diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 33718ed68..fad6215ff 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -32,50 +32,47 @@ FilterPrimitive * FilterColorMatrix::create() { FilterColorMatrix::~FilterColorMatrix() {} -struct ColorMatrixMatrix { - ColorMatrixMatrix(std::vector const &values) { - unsigned limit = std::min(static_cast(20), values.size()); - for (unsigned i = 0; i < limit; ++i) { - if (i % 5 == 4) { - _v[i] = round(values[i]*255*255); - } else { - _v[i] = round(values[i]*255); - } - } - for (unsigned i = limit; i < 20; ++i) { - _v[i] = 0; +FilterColorMatrix::ColorMatrixMatrix::ColorMatrixMatrix(std::vector const &values) { + unsigned limit = std::min(static_cast(20), values.size()); + for (unsigned i = 0; i < limit; ++i) { + if (i % 5 == 4) { + _v[i] = round(values[i]*255*255); + } else { + _v[i] = round(values[i]*255); } } + for (unsigned i = limit; i < 20; ++i) { + _v[i] = 0; + } +} - guint32 operator()(guint32 in) { - EXTRACT_ARGB32(in, a, r, g, b) - // we need to un-premultiply alpha values for this type of matrix - // TODO: unpremul can be ignored if there is an identity mapping on the alpha channel - if (a != 0) { - r = unpremul_alpha(r, a); - g = unpremul_alpha(g, a); - b = unpremul_alpha(b, a); - } - - gint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + a*_v[3] + _v[4]; - gint32 go = r*_v[5] + g*_v[6] + b*_v[7] + a*_v[8] + _v[9]; - gint32 bo = r*_v[10] + g*_v[11] + b*_v[12] + a*_v[13] + _v[14]; - gint32 ao = r*_v[15] + g*_v[16] + b*_v[17] + a*_v[18] + _v[19]; - ro = (pxclamp(ro, 0, 255*255) + 127) / 255; - go = (pxclamp(go, 0, 255*255) + 127) / 255; - bo = (pxclamp(bo, 0, 255*255) + 127) / 255; - ao = (pxclamp(ao, 0, 255*255) + 127) / 255; +guint32 FilterColorMatrix::ColorMatrixMatrix::operator()(guint32 in) { + EXTRACT_ARGB32(in, a, r, g, b) + // we need to un-premultiply alpha values for this type of matrix + // TODO: unpremul can be ignored if there is an identity mapping on the alpha channel + if (a != 0) { + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); + } - ro = premul_alpha(ro, ao); - go = premul_alpha(go, ao); - bo = premul_alpha(bo, ao); + gint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + a*_v[3] + _v[4]; + gint32 go = r*_v[5] + g*_v[6] + b*_v[7] + a*_v[8] + _v[9]; + gint32 bo = r*_v[10] + g*_v[11] + b*_v[12] + a*_v[13] + _v[14]; + gint32 ao = r*_v[15] + g*_v[16] + b*_v[17] + a*_v[18] + _v[19]; + ro = (pxclamp(ro, 0, 255*255) + 127) / 255; + go = (pxclamp(go, 0, 255*255) + 127) / 255; + bo = (pxclamp(bo, 0, 255*255) + 127) / 255; + ao = (pxclamp(ao, 0, 255*255) + 127) / 255; + + ro = premul_alpha(ro, ao); + go = premul_alpha(go, ao); + bo = premul_alpha(bo, ao); + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + return pxout; +} - ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) - return pxout; - } -private: - gint32 _v[20]; -}; struct ColorMatrixSaturate { ColorMatrixSaturate(double v_in) { @@ -163,7 +160,7 @@ void FilterColorMatrix::render_cairo(FilterSlot &slot) switch (type) { case COLORMATRIX_MATRIX: - ink_cairo_surface_filter(input, out, ColorMatrixMatrix(values)); + ink_cairo_surface_filter(input, out, FilterColorMatrix::ColorMatrixMatrix(values)); break; case COLORMATRIX_SATURATE: ink_cairo_surface_filter(input, out, ColorMatrixSaturate(value)); diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index 5f21a4210..c7e5e91d9 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -42,6 +42,15 @@ public: virtual void set_type(FilterColorMatrixType type); virtual void set_value(gdouble value); virtual void set_values(std::vector const &values); + +public: + struct ColorMatrixMatrix { + ColorMatrixMatrix(std::vector const &values); + guint32 operator()(guint32 in); + private: + gint32 _v[20]; + }; + private: std::vector values; gdouble value; -- cgit v1.2.3 From cb1f232c390a1e0b96d140c2fdc52b526dc4573f Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 14 Dec 2012 12:17:13 +0900 Subject: Fix for 383871 : Let space switch to selector tool even when used for panning (bzr r11954) --- src/event-context.cpp | 70 +++++++++++++++++++++++----------- src/ui/dialog/inkscape-preferences.cpp | 2 + 2 files changed, 50 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/event-context.cpp b/src/event-context.cpp index e9d0aa935..3c1609d97 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -464,10 +464,23 @@ static gint sp_event_context_private_root_handler( break; case GDK_MOTION_NOTIFY: if (panning) { + if (panning == 4 && !xp && !yp ) { + // + mouse panning started, save location and grab canvas + xp = event->motion.x; + yp = event->motion.y; + button_w = Geom::Point(event->motion.x, event->motion.y); + + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK, NULL, + event->motion.time - 1); + + + } if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) - || (panning == 1 && !(event->motion.state - & GDK_BUTTON1_MASK)) || (panning == 3 - && !(event->motion.state & GDK_BUTTON3_MASK))) { + || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) + || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { /* Gdk seems to lose button release for us sometimes :-( */ panning = 0; sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), @@ -570,6 +583,7 @@ static gint sp_event_context_private_root_handler( } ret = TRUE; } + break; case GDK_KEY_PRESS: { double const acceleration = prefs->getDoubleLimited( @@ -672,15 +686,13 @@ static gint sp_event_context_private_root_handler( } break; case GDK_KEY_space: - if (prefs->getBool("/options/spacepans/value")) { - event_context->space_panning = true; - event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, - _("Space+mouse drag to pan canvas")); - ret = TRUE; - } else { - sp_toggle_selector(desktop); - ret = TRUE; - } + xp = yp = 0; + within_tolerance = true; + panning = 4; + event_context->space_panning = true; + event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, + _("Space+mouse move to pan canvas")); + ret = TRUE; break; case GDK_KEY_z: case GDK_KEY_Z: @@ -695,18 +707,32 @@ static gint sp_event_context_private_root_handler( } break; case GDK_KEY_RELEASE: + + // Stop panning on any key release + if (event_context->space_panning) { + event_context->space_panning = false; + event_context->_message_context->clear(); + } + + if (panning) { + panning = 0; + xp = yp = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->key.time); + desktop->updateNow(); + } + + if (panning_cursor == 1) { + panning_cursor = 0; + GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop)); + gdk_window_set_cursor(gtk_widget_get_window (w), event_context->cursor); + } + switch (get_group0_keyval(&event->key)) { case GDK_KEY_space: - if (event_context->space_panning) { - event_context->space_panning = false; - event_context->_message_context->clear(); - - if (panning == 1) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->key.time); - desktop->updateNow(); - } + if (within_tolerance == true) { + // Space was pressed, but not panned + sp_toggle_selector(desktop); ret = TRUE; } break; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 291059999..cc145c16b 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1162,9 +1162,11 @@ void InkscapePreferences::initPageBehavior() _scroll_auto_thres.init ( "/options/autoscrolldistance/value", -600.0, 600.0, 1.0, 1.0, -10.0, true, false); _page_scrolling.add_line( true, _("_Threshold:"), _scroll_auto_thres, _("pixels"), _("How far (in screen pixels) you need to be from the canvas edge to trigger autoscroll; positive is outside the canvas, negative is within the canvas"), false); +/* _scroll_space.init ( _("Left mouse button pans when Space is pressed"), "/options/spacepans/value", false); _page_scrolling.add_line( false, "", _scroll_space, "", _("When on, pressing and holding Space and dragging with left mouse button pans canvas (as in Adobe Illustrator); when off, Space temporarily switches to Selector tool (default)")); +*/ _wheel_zoom.init ( _("Mouse wheel zooms by default"), "/options/wheelzooms/value", false); _page_scrolling.add_line( false, "", _wheel_zoom, "", _("When on, mouse wheel zooms without Ctrl and scrolls canvas with Ctrl; when off, it zooms with Ctrl and scrolls without Ctrl")); -- cgit v1.2.3