diff options
| author | Ted Gould <ted@gould.cx> | 2010-05-15 18:08:17 +0000 |
|---|---|---|
| committer | Ted Gould <ted@gould.cx> | 2010-05-15 18:08:17 +0000 |
| commit | 2d8c2dfd832ce207aef3895e702bff4098ab7136 (patch) | |
| tree | 642a37c6e3ca05d5e991ffe868f03c9cc58e51bc /src/ui | |
| parent | Merge from trunk (diff) | |
| parent | Minor tweaks to text toolbar. (diff) | |
| download | inkscape-2d8c2dfd832ce207aef3895e702bff4098ab7136.tar.gz inkscape-2d8c2dfd832ce207aef3895e702bff4098ab7136.zip | |
Updating to trunk
(bzr r8254.1.54)
Diffstat (limited to 'src/ui')
32 files changed, 2033 insertions, 541 deletions
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 033bec875..da9be1e7c 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -22,6 +22,8 @@ ink_common_sources += \ ui/dialog/color-item.h \ ui/dialog/debug.cpp \ ui/dialog/debug.h \ + ui/dialog/desktop-tracker.cpp \ + ui/dialog/desktop-tracker.h \ ui/dialog/dialog.cpp \ ui/dialog/dialog.h \ ui/dialog/dialog-manager.cpp \ @@ -50,6 +52,8 @@ ink_common_sources += \ ui/dialog/find.h \ ui/dialog/floating-behavior.cpp \ ui/dialog/floating-behavior.h \ + ui/dialog/glyphs.cpp \ + ui/dialog/glyphs.h \ ui/dialog/guides.cpp \ ui/dialog/guides.h \ ui/dialog/icon-preview.cpp \ diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 0d41bb221..297b3d2a1 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -32,8 +32,6 @@ #include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" -using namespace Inkscape::UI::Widget; - class SPItem; diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp new file mode 100644 index 000000000..f527f1c05 --- /dev/null +++ b/src/ui/dialog/desktop-tracker.cpp @@ -0,0 +1,159 @@ +/** + * Glyph selector dialog. + */ + +/* Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Jon A. Cruz + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <glib-object.h> + +#include "desktop-tracker.h" + +#include "inkscape.h" +#include "desktop.h" +#include "widgets/desktop-widget.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +DesktopTracker::DesktopTracker() : + base(0), + desktop(0), + widget(0), + hierID(0), + inkID(0), + trackActive(false), + desktopChangedSig() +{ +} + +DesktopTracker::~DesktopTracker() +{ + disconnect(); +} + +void DesktopTracker::connect(GtkWidget *widget) +{ + disconnect(); + + this->widget = widget; + + // Use C/gobject callbacks to avoid gtkmm rewrap-during-destruct issues: + hierID = g_signal_connect( G_OBJECT(widget), "hierarchy-changed", G_CALLBACK(hierarchyChangeCB), this ); + inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this ); + + GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET); + if (wdgt && !base) { + SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(wdgt); + if (dtw && dtw->desktop) { + setBase(dtw->desktop); // may also set desktop + } + } +} + +void DesktopTracker::disconnect() +{ + if (hierID) { + if (widget) { + g_signal_handler_disconnect(G_OBJECT(widget), hierID); + } + hierID = 0; + } + if (inkID) { + if (INKSCAPE) { + g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID); + } + inkID = 0; + } +} + +void DesktopTracker::setBase(SPDesktop *desktop) +{ + if (this->base != desktop) { + base = desktop; + // Do not override an existing target desktop + if (!this->desktop) { + setDesktop(desktop); + } + } +} + +SPDesktop *DesktopTracker::getBase() const +{ + return base; +} + +SPDesktop *DesktopTracker::getDesktop() const +{ + return desktop; +} + +sigc::connection DesktopTracker::connectDesktopChanged( const sigc::slot<void, SPDesktop*> & slot ) +{ + return desktopChangedSig.connect(slot); +} + +gboolean DesktopTracker::activateDesktopCB(Inkscape::Application */*inkscape*/, SPDesktop *desktop, DesktopTracker *self ) +{ + if (self && self->trackActive) { + self->setDesktop(desktop); + } + return FALSE; +} + +bool DesktopTracker::hierarchyChangeCB(GtkWidget * /*widget*/, GtkWidget* /*prev*/, DesktopTracker *self) +{ + if (self) { + self->handleHierarchyChange(); + } + return false; +} + +void DesktopTracker::handleHierarchyChange() +{ + GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET); + bool newFlag = (wdgt == 0); // true means not in an SPDesktopWidget, thus floating. + if (wdgt && !base) { + SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(wdgt); + if (dtw && dtw->desktop) { + setBase(dtw->desktop); // may also set desktop + } + } + if (newFlag != trackActive) { + trackActive = newFlag; + if (trackActive) { + setDesktop(SP_ACTIVE_DESKTOP); + } else if (desktop != base) { + setDesktop(getBase()); + } + } +} + +void DesktopTracker::setDesktop(SPDesktop *desktop) +{ + if (desktop != this->desktop) { + this->desktop = desktop; + desktopChangedSig.emit(desktop); + } +} + + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h new file mode 100644 index 000000000..7a5bc39c2 --- /dev/null +++ b/src/ui/dialog/desktop-tracker.h @@ -0,0 +1,73 @@ +/** + * Glyph selector dialog. + */ + +/* Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Jon A. Cruz + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#ifndef SEEN_DIALOG_DESKTOP_TRACKER +#define SEEN_DIALOG_DESKTOP_TRACKER + +#include <sigc++/connection.h> +#include <glib/gtypes.h> + +typedef struct _GtkWidget GtkWidget; +class SPDesktop; + +namespace Inkscape { + +class Application; + +namespace UI { +namespace Dialog { + +class DesktopTracker +{ +public: + DesktopTracker(); + virtual ~DesktopTracker(); + + void connect(GtkWidget *widget); + void disconnect(); + + SPDesktop *getDesktop() const; + + void setBase(SPDesktop *desktop); + SPDesktop *getBase() const; + + sigc::connection connectDesktopChanged( const sigc::slot<void, SPDesktop*> & slot ); + +private: + static gboolean activateDesktopCB(Inkscape::Application *inkscape, SPDesktop *desktop, DesktopTracker *self ); + static bool hierarchyChangeCB(GtkWidget *widget, GtkWidget* prev, DesktopTracker *self); + + void handleHierarchyChange(); + void setDesktop(SPDesktop *desktop); + + SPDesktop *base; + SPDesktop *desktop; + GtkWidget *widget; + gulong hierID; + gulong inkID; + bool trackActive; + sigc::signal<void, SPDesktop*> desktopChangedSig; +}; + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +#endif // SEEN_DIALOG_DESKTOP_TRACKER +/* + 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:encoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 30cbed649..6d3bc817e 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -25,6 +25,7 @@ #include "ui/dialog/fill-and-stroke.h" #include "ui/dialog/filter-effects-dialog.h" #include "ui/dialog/find.h" +#include "ui/dialog/glyphs.h" #include "ui/dialog/inkscape-preferences.h" #include "ui/dialog/input.h" #include "ui/dialog/livepatheffect-editor.h" @@ -96,6 +97,7 @@ DialogManager::DialogManager() { registerFactory("FillAndStroke", &create<FillAndStroke, FloatingBehavior>); registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog, FloatingBehavior>); registerFactory("Find", &create<Find, FloatingBehavior>); + registerFactory("Glyphs", &create<GlyphsPanel, FloatingBehavior>); registerFactory("IconPreviewPanel", &create<IconPreviewPanel, FloatingBehavior>); registerFactory("InkscapePreferences", &create<InkscapePreferences, FloatingBehavior>); registerFactory("LayersPanel", &create<LayersPanel, FloatingBehavior>); @@ -123,6 +125,7 @@ DialogManager::DialogManager() { registerFactory("FillAndStroke", &create<FillAndStroke, DockBehavior>); registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog, DockBehavior>); registerFactory("Find", &create<Find, DockBehavior>); + registerFactory("Glyphs", &create<GlyphsPanel, DockBehavior>); registerFactory("IconPreviewPanel", &create<IconPreviewPanel, DockBehavior>); registerFactory("InkscapePreferences", &create<InkscapePreferences, DockBehavior>); registerFactory("LayersPanel", &create<LayersPanel, DockBehavior>); @@ -159,11 +162,11 @@ DialogManager &DialogManager::getInstance() /* Use singleton behavior for floating dialogs */ if (dialogs_type == FLOATING) { static DialogManager *instance = 0; - + if (!instance) instance = new DialogManager(); return *instance; - } + } return *new DialogManager(); } diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 2b39eb3c9..2483dc50e 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -139,6 +139,7 @@ Dialog::~Dialog() save_geometry(); delete _behavior; + _behavior = 0; } diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h index 1a59a236c..f07c1bc86 100644 --- a/src/ui/dialog/dialog.h +++ b/src/ui/dialog/dialog.h @@ -21,9 +21,9 @@ class SPDesktop; -namespace Inkscape { -class Selection; -class Application; +namespace Inkscape { +class Selection; +class Application; } namespace Inkscape { @@ -36,7 +36,7 @@ void sp_retransientize(Inkscape::Application *inkscape, SPDesktop *desktop, gpoi gboolean sp_retransientize_again(gpointer dlgPtr); void sp_dialog_shutdown(GtkObject *object, gpointer dlgPtr); -/** +/** * @brief Base class for Inkscape dialogs * This class provides certain common behaviors and styles wanted of all dialogs * in the application. Fundamental parts of the dialog's behavior are controlled by @@ -46,7 +46,7 @@ class Dialog { public: - Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL, + Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL, int verb_num = 0, Glib::ustring const &apply_label = ""); virtual ~Dialog(); diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 96cad1fbe..55eb94f92 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -148,6 +148,8 @@ attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int star void DocumentMetadata::build_metadata() { + using Inkscape::UI::Widget::EntityEntry; + _page_metadata1.show(); Gtk::Label *label = manage (new Gtk::Label); diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h index 7f718e9f7..f21bb0d83 100644 --- a/src/ui/dialog/document-metadata.h +++ b/src/ui/dialog/document-metadata.h @@ -23,8 +23,6 @@ #include "ui/widget/notebook-page.h" #include "ui/widget/registry.h" -using namespace Inkscape::UI::Widget; - namespace Inkscape { namespace XML { class Node; @@ -35,7 +33,7 @@ namespace Inkscape { } namespace Dialog { -typedef std::list<EntityEntry*> RDElist; +typedef std::list<UI::Widget::EntityEntry*> RDElist; class DocumentMetadata : public Inkscape::UI::Widget::Panel { public: @@ -56,13 +54,14 @@ protected: Gtk::Tooltips _tt; Gtk::Notebook _notebook; - NotebookPage _page_metadata1, _page_metadata2; + UI::Widget::NotebookPage _page_metadata1; + UI::Widget::NotebookPage _page_metadata2; //--------------------------------------------------------------- RDElist _rdflist; - Licensor _licensor; + UI::Widget::Licensor _licensor; - Registry _wr; + UI::Widget::Registry _wr; private: virtual ~DocumentMetadata(); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 136ae2c89..c67dc9706 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -28,8 +28,6 @@ #include "xml/helper-observer.h" -using namespace Inkscape::UI::Widget; - namespace Inkscape { namespace UI { namespace Dialog { @@ -78,21 +76,31 @@ protected: Gtk::Tooltips _tt; Gtk::Notebook _notebook; - NotebookPage _page_page, _page_guides; - NotebookPage _page_snap, _page_cms, _page_scripting; + UI::Widget::NotebookPage _page_page; + UI::Widget::NotebookPage _page_guides; + UI::Widget::NotebookPage _page_snap; + UI::Widget::NotebookPage _page_cms; + UI::Widget::NotebookPage _page_scripting; Gtk::VBox _grids_vbox; - Registry _wr; + UI::Widget::Registry _wr; //--------------------------------------------------------------- - RegisteredCheckButton _rcb_canb, _rcb_bord, _rcb_shad; - RegisteredColorPicker _rcp_bg, _rcp_bord; - RegisteredUnitMenu _rum_deflt; - PageSizer _page_sizer; + UI::Widget::RegisteredCheckButton _rcb_canb; + UI::Widget::RegisteredCheckButton _rcb_bord; + UI::Widget::RegisteredCheckButton _rcb_shad; + UI::Widget::RegisteredColorPicker _rcp_bg; + UI::Widget::RegisteredColorPicker _rcp_bord; + UI::Widget::RegisteredUnitMenu _rum_deflt; + UI::Widget::PageSizer _page_sizer; //--------------------------------------------------------------- - RegisteredCheckButton _rcb_sgui, _rcbsng; - RegisteredColorPicker _rcp_gui, _rcp_hgui; + UI::Widget::RegisteredCheckButton _rcb_sgui; + UI::Widget::RegisteredCheckButton _rcbsng; + UI::Widget::RegisteredColorPicker _rcp_gui; + UI::Widget::RegisteredColorPicker _rcp_hgui; //--------------------------------------------------------------- - ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn; + UI::Widget::ToleranceSlider _rsu_sno; + UI::Widget::ToleranceSlider _rsu_sn; + UI::Widget::ToleranceSlider _rsu_gusn; //--------------------------------------------------------------- Gtk::Menu _menu; Gtk::OptionMenu _combo_avail; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 916e3ec97..6f83a706f 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -271,7 +271,7 @@ void SVGPreview::showImage(Glib::ustring &theFileName) "<text\n" " style=\"font-size:24.000000;font-style:normal;font-weight:normal;" " fill:#000000;fill-opacity:1.0000000;stroke:none;" - " font-family:Bitstream Vera Sans\"\n" + " font-family:Sans\"\n" " x=\"10\" y=\"26\">%d x %d</text>\n" //# VALUES HERE "</svg>\n\n"; @@ -374,7 +374,7 @@ void SVGPreview::showNoPreview() "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;" "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;" "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;" - "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n" + "font-family:Sans;text-anchor:middle;writing-mode:lr\"\n" "x=\"190\" y=\"240\">%s</text></g>\n" //# VALUE HERE "</svg>\n\n"; @@ -471,13 +471,13 @@ void SVGPreview::showTooLarge(long fileLength) "style=\"font-size:32.000000;font-style:normal;font-variant:normal;font-weight:bold;" "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;" "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;" - "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n" + "font-family:Sans;text-anchor:middle;writing-mode:lr\"\n" "x=\"170\" y=\"215\">%5.1f MB</text>\n" //# VALUE HERE "<text xml:space=\"preserve\"\n" "style=\"font-size:24.000000;font-style:normal;font-variant:normal;font-weight:bold;" "font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;" "stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;" - "font-family:Bitstream Vera Sans;text-anchor:middle;writing-mode:lr\"\n" + "font-family:Sans;text-anchor:middle;writing-mode:lr\"\n" "x=\"180\" y=\"245\">%s</text>\n" //# VALUE HERE "</svg>\n\n"; diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index fe63c6e24..8c86e1ca4 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -6,8 +6,10 @@ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * Gustav Broberg <broberg@kth.se> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2004--2007 Authors + * Copyright (C) 2010 Jon A. Cruz * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -29,6 +31,8 @@ #include "widgets/stroke-style.h" #include "xml/repr.h" +#include "ui/view/view-widget.h" + namespace Inkscape { namespace UI { namespace Dialog { @@ -38,7 +42,12 @@ FillAndStroke::FillAndStroke() _page_fill(1, 1, true, true), _page_stroke_paint(1, 1, true, true), _page_stroke_style(1, 1, true, true), - _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke", SimpleFilterModifier::BLUR) + _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke", UI::Widget::SimpleFilterModifier::BLUR), + deskTrack(), + targetDesktop(0), + fillWdgt(0), + strokeWdgt(0), + desktopChangeConn() { Gtk::Box *contents = _getContents(); contents->set_spacing(0); @@ -58,25 +67,51 @@ FillAndStroke::FillAndStroke() show_all_children(); _composite_settings.setSubject(&_subject); + + // Connect this up last + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &FillAndStroke::setTargetDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); } FillAndStroke::~FillAndStroke() { _composite_settings.setSubject(NULL); + + desktopChangeConn.disconnect(); + deskTrack.disconnect(); +} + +void FillAndStroke::setDesktop(SPDesktop *desktop) +{ + Panel::setDesktop(desktop); + deskTrack.setBase(desktop); +} + +void FillAndStroke::setTargetDesktop(SPDesktop *desktop) +{ + if (targetDesktop != desktop) { + targetDesktop = desktop; + if (fillWdgt) { + sp_fill_style_widget_set_desktop(fillWdgt, desktop); + } + if (strokeWdgt) { + sp_stroke_style_widget_set_desktop(strokeWdgt, desktop); + } + } } void FillAndStroke::_layoutPageFill() { - Gtk::Widget *fs = manage(Glib::wrap(sp_fill_style_widget_new())); - _page_fill.table().attach(*fs, 0, 1, 0, 1); + fillWdgt = manage(sp_fill_style_widget_new()); + _page_fill.table().attach(*fillWdgt, 0, 1, 0, 1); } void FillAndStroke::_layoutPageStrokePaint() { - Gtk::Widget *ssp = manage(Glib::wrap(sp_stroke_style_paint_widget_new())); - _page_stroke_paint.table().attach(*ssp, 0, 1, 0, 1); + strokeWdgt = manage(sp_stroke_style_paint_widget_new()); + _page_stroke_paint.table().attach(*strokeWdgt, 0, 1, 0, 1); } void diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index 7dc892fea..2d4e90d73 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -4,8 +4,10 @@ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * Gustav Broberg <broberg@kth.se> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2004--2007 Authors + * Copyright (C) 2010 Jon A. Cruz * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -23,8 +25,7 @@ #include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" #include "ui/widget/object-composite-settings.h" - -using namespace Inkscape::UI::Widget; +#include "ui/dialog/desktop-tracker.h" namespace Inkscape { namespace UI { @@ -37,6 +38,9 @@ public: static FillAndStroke &getInstance() { return *new FillAndStroke(); } + + virtual void setDesktop(SPDesktop *desktop); + void selectionChanged(Inkscape::Application *inkscape, Inkscape::Selection *selection); @@ -47,14 +51,14 @@ public: protected: Gtk::Notebook _notebook; - NotebookPage _page_fill; - NotebookPage _page_stroke_paint; - NotebookPage _page_stroke_style; + UI::Widget::NotebookPage _page_fill; + UI::Widget::NotebookPage _page_stroke_paint; + UI::Widget::NotebookPage _page_stroke_style; - StyleSubject::Selection _subject; - ObjectCompositeSettings _composite_settings; + UI::Widget::StyleSubject::Selection _subject; + UI::Widget::ObjectCompositeSettings _composite_settings; - Gtk::HBox &_createPageTabLabel(const Glib::ustring &label, + Gtk::HBox &_createPageTabLabel(const Glib::ustring &label, const char *label_image); void _layoutPageFill(); @@ -64,12 +68,21 @@ protected: private: FillAndStroke(FillAndStroke const &d); FillAndStroke& operator=(FillAndStroke const &d); + + void setTargetDesktop(SPDesktop *desktop); + + DesktopTracker deskTrack; + SPDesktop *targetDesktop; + Gtk::Widget *fillWdgt; + Gtk::Widget *strokeWdgt; + sigc::connection desktopChangeConn; }; } // namespace Dialog } // namespace UI } // namespace Inkscape + #endif // INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H /* diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 132e5fd4e..1672c4b69 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -74,6 +74,12 @@ namespace Inkscape { namespace UI { namespace Dialog { +using Inkscape::UI::Widget::AttrWidget; +using Inkscape::UI::Widget::ComboBoxEnum; +using Inkscape::UI::Widget::DualSpinSlider; +using Inkscape::UI::Widget::SpinSlider; + + // Returns the number of inputs available for the filter primitive type int input_count(const SPFilterPrimitive* prim) { diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 3fb9a46fb..a14c85a91 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -35,8 +35,6 @@ #include "ui/widget/spin-slider.h" #include "xml/helper-observer.h" -using namespace Inkscape::UI::Widget; - namespace Inkscape { namespace UI { namespace Dialog { @@ -214,9 +212,9 @@ private: void duplicate_primitive(); void convolve_order_changed(); - void set_attr_direct(const AttrWidget*); - void set_child_attr_direct(const AttrWidget*); - void set_filternode_attr(const AttrWidget*); + void set_attr_direct(const UI::Widget::AttrWidget*); + void set_child_attr_direct(const UI::Widget::AttrWidget*); + void set_filternode_attr(const UI::Widget::AttrWidget*); void set_attr(SPObject*, const SPAttributeEnum, const gchar* val); void update_settings_view(); void update_filter_general_settings_view(); diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 19147f2c7..85f078439 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -33,11 +33,11 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : Behavior(dialog), _d (new Gtk::Dialog(_dialog._title)) #if GTK_VERSION_GE(2, 12) - ,_dialog_active(_d->property_is_active()) - ,_steps(0) - ,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0)) - ,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0)) - ,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000)) + ,_dialog_active(_d->property_is_active()) + ,_steps(0) + ,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0)) + ,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0)) + ,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000)) #endif { hide(); @@ -49,8 +49,8 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : _dialog.retransientize_suppress = false; #if GTK_VERSION_GE(2, 12) - _focus_event(); - _dialog_active.signal_changed().connect(sigc::mem_fun(this, &FloatingBehavior::_focus_event)); + _focus_event(); + _dialog_active.signal_changed().connect(sigc::mem_fun(this, &FloatingBehavior::_focus_event)); #endif } @@ -58,12 +58,12 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : #if GTK_VERSION_GE(2, 12) /** \brief A function called when the window gets focus - This function gets called on a focus event. It figures out how much - time is required for a transition, and the number of steps that'll take, - and sets up the _trans_timer function to do the work. If the transition - time is set to 0 ms it just calls _trans_timer once with _steps equal to - zero so that the transition happens instantaneously. This occurs on - windows as opacity changes cause flicker there. + This function gets called on a focus event. It figures out how much + time is required for a transition, and the number of steps that'll take, + and sets up the _trans_timer function to do the work. If the transition + time is set to 0 ms it just calls _trans_timer once with _steps equal to + zero so that the transition happens instantaneously. This occurs on + windows as opacity changes cause flicker there. */ void FloatingBehavior::_focus_event (void) { @@ -93,42 +93,43 @@ void FloatingBehavior::_focus_event (void) /** \brief Move the opacity of a window towards our goal - This is a timer function that is set up by _focus_event to slightly - move the opacity of the window along in an animated fashion. It moves - the opacity half way to the goal until it runs out of steps, and then - it just forces the goal. + This is a timer function that is set up by _focus_event to slightly + move the opacity of the window along in an animated fashion. It moves + the opacity half way to the goal until it runs out of steps, and then + it just forces the goal. */ bool FloatingBehavior::_trans_timer (void) { - // printf("Go go gadget timer: %d\n", _steps); - if (_steps == 0) { - if (_dialog_active.get_value()) { - _d->set_opacity(_trans_focus); - } else { - _d->set_opacity(_trans_blur); - } - - return false; - } - - float goal, current; - goal = current = _d->get_opacity(); - - if (_dialog_active.get_value()) { - goal = _trans_focus; - } else { - goal = _trans_blur; - } - - _d->set_opacity(current - ((current - goal) / 2)); - _steps--; - return true; + // printf("Go go gadget timer: %d\n", _steps); + if (_steps == 0) { + if (_dialog_active.get_value()) { + _d->set_opacity(_trans_focus); + } else { + _d->set_opacity(_trans_blur); + } + + return false; + } + + float goal, current; + goal = current = _d->get_opacity(); + + if (_dialog_active.get_value()) { + goal = _trans_focus; + } else { + goal = _trans_blur; + } + + _d->set_opacity(current - ((current - goal) / 2)); + _steps--; + return true; } #endif -FloatingBehavior::~FloatingBehavior() -{ +FloatingBehavior::~FloatingBehavior() +{ delete _d; + _d = 0; } Behavior * @@ -184,9 +185,9 @@ FloatingBehavior::onDesktopActivated (SPDesktop *desktop) #ifdef WIN32 // Win32 special code to enable transient dialogs transient_policy = 2; -#endif +#endif - if (!transient_policy) + if (!transient_policy) return; GtkWindow *dialog_win = GTK_WINDOW(_d->gobj()); diff --git a/src/ui/dialog/floating-behavior.h b/src/ui/dialog/floating-behavior.h index 0360ccf49..30ecaa053 100644 --- a/src/ui/dialog/floating-behavior.h +++ b/src/ui/dialog/floating-behavior.h @@ -64,14 +64,14 @@ private: Gtk::Dialog *_d; //< the actual dialog #if GTK_VERSION_GE(2, 12) - void _focus_event (void); - bool _trans_timer (void); - - Glib::PropertyProxy_ReadOnly<bool> _dialog_active; //< Variable proxy to track whether the dialog is the active window - int _steps; //< Number of steps for the timer to animate the transparent dialog - float _trans_focus; //< The percentage opacity when the dialog is focused - float _trans_blur; //< The percentage opactiy when the dialog is not focused - int _trans_time; //< The amount of time (in ms) for the dialog to change it's transparency + void _focus_event (void); + bool _trans_timer (void); + + Glib::PropertyProxy_ReadOnly<bool> _dialog_active; //< Variable proxy to track whether the dialog is the active window + int _steps; //< Number of steps for the timer to animate the transparent dialog + float _trans_focus; //< The percentage opacity when the dialog is focused + float _trans_blur; //< The percentage opactiy when the dialog is not focused + int _trans_time; //< The amount of time (in ms) for the dialog to change it's transparency #endif }; diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp new file mode 100644 index 000000000..8ed502aae --- /dev/null +++ b/src/ui/dialog/glyphs.cpp @@ -0,0 +1,749 @@ +/** + * Glyph selector dialog. + */ + +/* Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Jon A. Cruz + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <vector> + +#include <glibmm/i18n.h> +#include <gtkmm/entry.h> +#include <gtkmm/iconview.h> +#include <gtkmm/label.h> +#include <gtkmm/liststore.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/table.h> +#include <gtkmm/treemodelcolumn.h> +#include <gtkmm/widget.h> + +#include <gtk/gtkbutton.h> +#include <gtk/gtkstock.h> +#include <gtk/gtkversion.h> + +#include "glyphs.h" + +#include "desktop.h" +#include "document.h" // for sp_document_done() +#include "libnrtype/font-instance.h" +#include "sp-flowtext.h" +#include "sp-text.h" +#include "verbs.h" +#include "widgets/font-selector.h" +#include "text-editing.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + + +GlyphsPanel &GlyphsPanel::getInstance() +{ + return *new GlyphsPanel(); +} + + +#if GLIB_CHECK_VERSION(2,14,0) +static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() +{ + static bool init = false; + static std::map<GUnicodeScript, Glib::ustring> mappings; + if (!init) { + init = true; + mappings[G_UNICODE_SCRIPT_INVALID_CODE] = _("all"); + mappings[G_UNICODE_SCRIPT_COMMON] = _("common"); + mappings[G_UNICODE_SCRIPT_INHERITED] = _("inherited"); + mappings[G_UNICODE_SCRIPT_ARABIC] = _("Arabic"); + mappings[G_UNICODE_SCRIPT_ARMENIAN] = _("Armenian"); + mappings[G_UNICODE_SCRIPT_BENGALI] = _("Bengali"); + mappings[G_UNICODE_SCRIPT_BOPOMOFO] = _("Bopomofo"); + mappings[G_UNICODE_SCRIPT_CHEROKEE] = _("Cherokee"); + mappings[G_UNICODE_SCRIPT_COPTIC] = _("Coptic"); + mappings[G_UNICODE_SCRIPT_CYRILLIC] = _("Cyrillic"); + mappings[G_UNICODE_SCRIPT_DESERET] = _("Deseret"); + mappings[G_UNICODE_SCRIPT_DEVANAGARI] = _("Devanagari"); + mappings[G_UNICODE_SCRIPT_ETHIOPIC] = _("Ethiopic"); + mappings[G_UNICODE_SCRIPT_GEORGIAN] = _("Georgian"); + mappings[G_UNICODE_SCRIPT_GOTHIC] = _("Gothic"); + mappings[G_UNICODE_SCRIPT_GREEK] = _("Greek"); + mappings[G_UNICODE_SCRIPT_GUJARATI] = _("Gujarati"); + mappings[G_UNICODE_SCRIPT_GURMUKHI] = _("Gurmukhi"); + mappings[G_UNICODE_SCRIPT_HAN] = _("Han"); + mappings[G_UNICODE_SCRIPT_HANGUL] = _("Hangul"); + mappings[G_UNICODE_SCRIPT_HEBREW] = _("Hebrew"); + mappings[G_UNICODE_SCRIPT_HIRAGANA] = _("Hiragana"); + mappings[G_UNICODE_SCRIPT_KANNADA] = _("Kannada"); + mappings[G_UNICODE_SCRIPT_KATAKANA] = _("Katakana"); + mappings[G_UNICODE_SCRIPT_KHMER] = _("Khmer"); + mappings[G_UNICODE_SCRIPT_LAO] = _("Lao"); + mappings[G_UNICODE_SCRIPT_LATIN] = _("Latin"); + mappings[G_UNICODE_SCRIPT_MALAYALAM] = _("Malayalam"); + mappings[G_UNICODE_SCRIPT_MONGOLIAN] = _("Mongolian"); + mappings[G_UNICODE_SCRIPT_MYANMAR] = _("Myanmar"); + mappings[G_UNICODE_SCRIPT_OGHAM] = _("Ogham"); + mappings[G_UNICODE_SCRIPT_OLD_ITALIC] = _("Old Italic"); + mappings[G_UNICODE_SCRIPT_ORIYA] = _("Oriya"); + mappings[G_UNICODE_SCRIPT_RUNIC] = _("Runic"); + mappings[G_UNICODE_SCRIPT_SINHALA] = _("Sinhala"); + mappings[G_UNICODE_SCRIPT_SYRIAC] = _("Syriac"); + mappings[G_UNICODE_SCRIPT_TAMIL] = _("Tamil"); + mappings[G_UNICODE_SCRIPT_TELUGU] = _("Telugu"); + mappings[G_UNICODE_SCRIPT_THAANA] = _("Thaana"); + mappings[G_UNICODE_SCRIPT_THAI] = _("Thai"); + mappings[G_UNICODE_SCRIPT_TIBETAN] = _("Tibetan"); + mappings[G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL] = _("Canadian Aboriginal"); + mappings[G_UNICODE_SCRIPT_YI] = _("Yi"); + mappings[G_UNICODE_SCRIPT_TAGALOG] = _("Tagalog"); + mappings[G_UNICODE_SCRIPT_HANUNOO] = _("Hanunoo"); + mappings[G_UNICODE_SCRIPT_BUHID] = _("Buhid"); + mappings[G_UNICODE_SCRIPT_TAGBANWA] = _("Tagbanwa"); + mappings[G_UNICODE_SCRIPT_BRAILLE] = _("Braille"); + mappings[G_UNICODE_SCRIPT_CYPRIOT] = _("Cypriot"); + mappings[G_UNICODE_SCRIPT_LIMBU] = _("Limbu"); + mappings[G_UNICODE_SCRIPT_OSMANYA] = _("Osmanya"); + mappings[G_UNICODE_SCRIPT_SHAVIAN] = _("Shavian"); + mappings[G_UNICODE_SCRIPT_LINEAR_B] = _("Linear B"); + mappings[G_UNICODE_SCRIPT_TAI_LE] = _("Tai Le"); + mappings[G_UNICODE_SCRIPT_UGARITIC] = _("Ugaritic"); + mappings[G_UNICODE_SCRIPT_NEW_TAI_LUE] = _("New Tai Lue"); + mappings[G_UNICODE_SCRIPT_BUGINESE] = _("Buginese"); + mappings[G_UNICODE_SCRIPT_GLAGOLITIC] = _("Glagolitic"); + mappings[G_UNICODE_SCRIPT_TIFINAGH] = _("Tifinagh"); + mappings[G_UNICODE_SCRIPT_SYLOTI_NAGRI] = _("Syloti Nagri"); + mappings[G_UNICODE_SCRIPT_OLD_PERSIAN] = _("Old Persian"); + mappings[G_UNICODE_SCRIPT_KHAROSHTHI] = _("Kharoshthi"); + mappings[G_UNICODE_SCRIPT_UNKNOWN] = _("unassigned"); + mappings[G_UNICODE_SCRIPT_BALINESE] = _("Balinese"); + mappings[G_UNICODE_SCRIPT_CUNEIFORM] = _("Cuneiform"); + mappings[G_UNICODE_SCRIPT_PHOENICIAN] = _("Phoenician"); + mappings[G_UNICODE_SCRIPT_PHAGS_PA] = _("Phags-pa"); + mappings[G_UNICODE_SCRIPT_NKO] = _("N'Ko"); + +#if GLIB_CHECK_VERSION(2,14,0) + mappings[G_UNICODE_SCRIPT_KAYAH_LI] = _("Kayah Li"); + mappings[G_UNICODE_SCRIPT_LEPCHA] = _("Lepcha"); + mappings[G_UNICODE_SCRIPT_REJANG] = _("Rejang"); + mappings[G_UNICODE_SCRIPT_SUNDANESE] = _("Sundanese"); + mappings[G_UNICODE_SCRIPT_SAURASHTRA] = _("Saurashtra"); + mappings[G_UNICODE_SCRIPT_CHAM] = _("Cham"); + mappings[G_UNICODE_SCRIPT_OL_CHIKI] = _("Ol Chiki"); + mappings[G_UNICODE_SCRIPT_VAI] = _("Vai"); + mappings[G_UNICODE_SCRIPT_CARIAN] = _("Carian"); + mappings[G_UNICODE_SCRIPT_LYCIAN] = _("Lycian"); + mappings[G_UNICODE_SCRIPT_LYDIAN] = _("Lydian"); +#endif // GLIB_CHECK_VERSION(2,14,0) + } + return mappings; +} +#endif // GLIB_CHECK_VERSION(2,14,0) + +typedef std::pair<gunichar, gunichar> Range; +typedef std::pair<Range, Glib::ustring> NamedRange; + +static std::vector<NamedRange> & getRanges() +{ + static bool init = false; + static std::vector<NamedRange> ranges; + if (!init) { + init = true; + ranges.push_back(std::make_pair(std::make_pair(0x0000, 0xFFFD), _("all"))); + ranges.push_back(std::make_pair(std::make_pair(0x0000, 0x007F), _("Basic Latin"))); + ranges.push_back(std::make_pair(std::make_pair(0x0080, 0x00FF), _("Latin-1 Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x0100, 0x017F), _("Latin Extended-A"))); + ranges.push_back(std::make_pair(std::make_pair(0x0180, 0x024F), _("Latin Extended-B"))); + ranges.push_back(std::make_pair(std::make_pair(0x0250, 0x02AF), _("IPA Extensions"))); + ranges.push_back(std::make_pair(std::make_pair(0x02B0, 0x02FF), _("Spacing Modifier Letters"))); + ranges.push_back(std::make_pair(std::make_pair(0x0300, 0x036F), _("Combining Diacritical Marks"))); + ranges.push_back(std::make_pair(std::make_pair(0x0370, 0x03FF), _("Greek and Coptic"))); + ranges.push_back(std::make_pair(std::make_pair(0x0400, 0x04FF), _("Cyrillic"))); + ranges.push_back(std::make_pair(std::make_pair(0x0500, 0x052F), _("Cyrillic Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x0530, 0x058F), _("Armenian"))); + ranges.push_back(std::make_pair(std::make_pair(0x0590, 0x05FF), _("Hebrew"))); + ranges.push_back(std::make_pair(std::make_pair(0x0600, 0x06FF), _("Arabic"))); + ranges.push_back(std::make_pair(std::make_pair(0x0700, 0x074F), _("Syriac"))); + ranges.push_back(std::make_pair(std::make_pair(0x0750, 0x077F), _("Arabic Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x0780, 0x07BF), _("Thaana"))); + ranges.push_back(std::make_pair(std::make_pair(0x07C0, 0x07FF), _("NKo"))); + ranges.push_back(std::make_pair(std::make_pair(0x0800, 0x083F), _("Samaritan"))); + ranges.push_back(std::make_pair(std::make_pair(0x0900, 0x097F), _("Devanagari"))); + ranges.push_back(std::make_pair(std::make_pair(0x0980, 0x09FF), _("Bengali"))); + ranges.push_back(std::make_pair(std::make_pair(0x0A00, 0x0A7F), _("Gurmukhi"))); + ranges.push_back(std::make_pair(std::make_pair(0x0A80, 0x0AFF), _("Gujarati"))); + ranges.push_back(std::make_pair(std::make_pair(0x0B00, 0x0B7F), _("Oriya"))); + ranges.push_back(std::make_pair(std::make_pair(0x0B80, 0x0BFF), _("Tamil"))); + ranges.push_back(std::make_pair(std::make_pair(0x0C00, 0x0C7F), _("Telugu"))); + ranges.push_back(std::make_pair(std::make_pair(0x0C80, 0x0CFF), _("Kannada"))); + ranges.push_back(std::make_pair(std::make_pair(0x0D00, 0x0D7F), _("Malayalam"))); + ranges.push_back(std::make_pair(std::make_pair(0x0D80, 0x0DFF), _("Sinhala"))); + ranges.push_back(std::make_pair(std::make_pair(0x0E00, 0x0E7F), _("Thai"))); + ranges.push_back(std::make_pair(std::make_pair(0x0E80, 0x0EFF), _("Lao"))); + ranges.push_back(std::make_pair(std::make_pair(0x0F00, 0x0FFF), _("Tibetan"))); + ranges.push_back(std::make_pair(std::make_pair(0x1000, 0x109F), _("Myanmar"))); + ranges.push_back(std::make_pair(std::make_pair(0x10A0, 0x10FF), _("Georgian"))); + ranges.push_back(std::make_pair(std::make_pair(0x1100, 0x11FF), _("Hangul Jamo"))); + ranges.push_back(std::make_pair(std::make_pair(0x1200, 0x137F), _("Ethiopic"))); + ranges.push_back(std::make_pair(std::make_pair(0x1380, 0x139F), _("Ethiopic Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x13A0, 0x13FF), _("Cherokee"))); + ranges.push_back(std::make_pair(std::make_pair(0x1400, 0x167F), _("Unified Canadian Aboriginal Syllabics"))); + ranges.push_back(std::make_pair(std::make_pair(0x1680, 0x169F), _("Ogham"))); + ranges.push_back(std::make_pair(std::make_pair(0x16A0, 0x16FF), _("Runic"))); + ranges.push_back(std::make_pair(std::make_pair(0x1700, 0x171F), _("Tagalog"))); + ranges.push_back(std::make_pair(std::make_pair(0x1720, 0x173F), _("Hanunoo"))); + ranges.push_back(std::make_pair(std::make_pair(0x1740, 0x175F), _("Buhid"))); + ranges.push_back(std::make_pair(std::make_pair(0x1760, 0x177F), _("Tagbanwa"))); + ranges.push_back(std::make_pair(std::make_pair(0x1780, 0x17FF), _("Khmer"))); + ranges.push_back(std::make_pair(std::make_pair(0x1800, 0x18AF), _("Mongolian"))); + ranges.push_back(std::make_pair(std::make_pair(0x18B0, 0x18FF), _("Unified Canadian Aboriginal Syllabics Extended"))); + ranges.push_back(std::make_pair(std::make_pair(0x1900, 0x194F), _("Limbu"))); + ranges.push_back(std::make_pair(std::make_pair(0x1950, 0x197F), _("Tai Le"))); + ranges.push_back(std::make_pair(std::make_pair(0x1980, 0x19DF), _("New Tai Lue"))); + ranges.push_back(std::make_pair(std::make_pair(0x19E0, 0x19FF), _("Khmer Symbols"))); + ranges.push_back(std::make_pair(std::make_pair(0x1A00, 0x1A1F), _("Buginese"))); + ranges.push_back(std::make_pair(std::make_pair(0x1A20, 0x1AAF), _("Tai Tham"))); + ranges.push_back(std::make_pair(std::make_pair(0x1B00, 0x1B7F), _("Balinese"))); + ranges.push_back(std::make_pair(std::make_pair(0x1B80, 0x1BBF), _("Sundanese"))); + ranges.push_back(std::make_pair(std::make_pair(0x1C00, 0x1C4F), _("Lepcha"))); + ranges.push_back(std::make_pair(std::make_pair(0x1C50, 0x1C7F), _("Ol Chiki"))); + ranges.push_back(std::make_pair(std::make_pair(0x1CD0, 0x1CFF), _("Vedic Extensions"))); + ranges.push_back(std::make_pair(std::make_pair(0x1D00, 0x1D7F), _("Phonetic Extensions"))); + ranges.push_back(std::make_pair(std::make_pair(0x1D80, 0x1DBF), _("Phonetic Extensions Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x1DC0, 0x1DFF), _("Combining Diacritical Marks Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x1E00, 0x1EFF), _("Latin Extended Additional"))); + ranges.push_back(std::make_pair(std::make_pair(0x1F00, 0x1FFF), _("Greek Extended"))); + ranges.push_back(std::make_pair(std::make_pair(0x2000, 0x206F), _("General Punctuation"))); + ranges.push_back(std::make_pair(std::make_pair(0x2070, 0x209F), _("Superscripts and Subscripts"))); + ranges.push_back(std::make_pair(std::make_pair(0x20A0, 0x20CF), _("Currency Symbols"))); + ranges.push_back(std::make_pair(std::make_pair(0x20D0, 0x20FF), _("Combining Diacritical Marks for Symbols"))); + ranges.push_back(std::make_pair(std::make_pair(0x2100, 0x214F), _("Letterlike Symbols"))); + ranges.push_back(std::make_pair(std::make_pair(0x2150, 0x218F), _("Number Forms"))); + ranges.push_back(std::make_pair(std::make_pair(0x2190, 0x21FF), _("Arrows"))); + ranges.push_back(std::make_pair(std::make_pair(0x2200, 0x22FF), _("Mathematical Operators"))); + ranges.push_back(std::make_pair(std::make_pair(0x2300, 0x23FF), _("Miscellaneous Technical"))); + ranges.push_back(std::make_pair(std::make_pair(0x2400, 0x243F), _("Control Pictures"))); + ranges.push_back(std::make_pair(std::make_pair(0x2440, 0x245F), _("Optical Character Recognition"))); + ranges.push_back(std::make_pair(std::make_pair(0x2460, 0x24FF), _("Enclosed Alphanumerics"))); + ranges.push_back(std::make_pair(std::make_pair(0x2500, 0x257F), _("Box Drawing"))); + ranges.push_back(std::make_pair(std::make_pair(0x2580, 0x259F), _("Block Elements"))); + ranges.push_back(std::make_pair(std::make_pair(0x25A0, 0x25FF), _("Geometric Shapes"))); + ranges.push_back(std::make_pair(std::make_pair(0x2600, 0x26FF), _("Miscellaneous Symbols"))); + ranges.push_back(std::make_pair(std::make_pair(0x2700, 0x27BF), _("Dingbats"))); + ranges.push_back(std::make_pair(std::make_pair(0x27C0, 0x27EF), _("Miscellaneous Mathematical Symbols-A"))); + ranges.push_back(std::make_pair(std::make_pair(0x27F0, 0x27FF), _("Supplemental Arrows-A"))); + ranges.push_back(std::make_pair(std::make_pair(0x2800, 0x28FF), _("Braille Patterns"))); + ranges.push_back(std::make_pair(std::make_pair(0x2900, 0x297F), _("Supplemental Arrows-B"))); + ranges.push_back(std::make_pair(std::make_pair(0x2980, 0x29FF), _("Miscellaneous Mathematical Symbols-B"))); + ranges.push_back(std::make_pair(std::make_pair(0x2A00, 0x2AFF), _("Supplemental Mathematical Operators"))); + ranges.push_back(std::make_pair(std::make_pair(0x2B00, 0x2BFF), _("Miscellaneous Symbols and Arrows"))); + ranges.push_back(std::make_pair(std::make_pair(0x2C00, 0x2C5F), _("Glagolitic"))); + ranges.push_back(std::make_pair(std::make_pair(0x2C60, 0x2C7F), _("Latin Extended-C"))); + ranges.push_back(std::make_pair(std::make_pair(0x2C80, 0x2CFF), _("Coptic"))); + ranges.push_back(std::make_pair(std::make_pair(0x2D00, 0x2D2F), _("Georgian Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x2D30, 0x2D7F), _("Tifinagh"))); + ranges.push_back(std::make_pair(std::make_pair(0x2D80, 0x2DDF), _("Ethiopic Extended"))); + ranges.push_back(std::make_pair(std::make_pair(0x2DE0, 0x2DFF), _("Cyrillic Extended-A"))); + ranges.push_back(std::make_pair(std::make_pair(0x2E00, 0x2E7F), _("Supplemental Punctuation"))); + ranges.push_back(std::make_pair(std::make_pair(0x2E80, 0x2EFF), _("CJK Radicals Supplement"))); + ranges.push_back(std::make_pair(std::make_pair(0x2F00, 0x2FDF), _("Kangxi Radicals"))); + ranges.push_back(std::make_pair(std::make_pair(0x2FF0, 0x2FFF), _("Ideographic Description Characters"))); + ranges.push_back(std::make_pair(std::make_pair(0x3000, 0x303F), _("CJK Symbols and Punctuation"))); + ranges.push_back(std::make_pair(std::make_pair(0x3040, 0x309F), _("Hiragana"))); + ranges.push_back(std::make_pair(std::make_pair(0x30A0, 0x30FF), _("Katakana"))); + ranges.push_back(std::make_pair(std::make_pair(0x3100, 0x312F), _("Bopomofo"))); + ranges.push_back(std::make_pair(std::make_pair(0x3130, 0x318F), _("Hangul Compatibility Jamo"))); + ranges.push_back(std::make_pair(std::make_pair(0x3190, 0x319F), _("Kanbun"))); + ranges.push_back(std::make_pair(std::make_pair(0x31A0, 0x31BF), _("Bopomofo Extended"))); + ranges.push_back(std::make_pair(std::make_pair(0x31C0, 0x31EF), _("CJK Strokes"))); + ranges.push_back(std::make_pair(std::make_pair(0x31F0, 0x31FF), _("Katakana Phonetic Extensions"))); + ranges.push_back(std::make_pair(std::make_pair(0x3200, 0x32FF), _("Enclosed CJK Letters and Months"))); + ranges.push_back(std::make_pair(std::make_pair(0x3300, 0x33FF), _("CJK Compatibility"))); + ranges.push_back(std::make_pair(std::make_pair(0x3400, 0x4DBF), _("CJK Unified Ideographs Extension A"))); + ranges.push_back(std::make_pair(std::make_pair(0x4DC0, 0x4DFF), _("Yijing Hexagram Symbols"))); + ranges.push_back(std::make_pair(std::make_pair(0x4E00, 0x9FFF), _("CJK Unified Ideographs"))); + ranges.push_back(std::make_pair(std::make_pair(0xA000, 0xA48F), _("Yi Syllables"))); + ranges.push_back(std::make_pair(std::make_pair(0xA490, 0xA4CF), _("Yi Radicals"))); + ranges.push_back(std::make_pair(std::make_pair(0xA4D0, 0xA4FF), _("Lisu"))); + ranges.push_back(std::make_pair(std::make_pair(0xA500, 0xA63F), _("Vai"))); + ranges.push_back(std::make_pair(std::make_pair(0xA640, 0xA69F), _("Cyrillic Extended-B"))); + ranges.push_back(std::make_pair(std::make_pair(0xA6A0, 0xA6FF), _("Bamum"))); + ranges.push_back(std::make_pair(std::make_pair(0xA700, 0xA71F), _("Modifier Tone Letters"))); + ranges.push_back(std::make_pair(std::make_pair(0xA720, 0xA7FF), _("Latin Extended-D"))); + ranges.push_back(std::make_pair(std::make_pair(0xA800, 0xA82F), _("Syloti Nagri"))); + ranges.push_back(std::make_pair(std::make_pair(0xA830, 0xA83F), _("Common Indic Number Forms"))); + ranges.push_back(std::make_pair(std::make_pair(0xA840, 0xA87F), _("Phags-pa"))); + ranges.push_back(std::make_pair(std::make_pair(0xA880, 0xA8DF), _("Saurashtra"))); + ranges.push_back(std::make_pair(std::make_pair(0xA8E0, 0xA8FF), _("Devanagari Extended"))); + ranges.push_back(std::make_pair(std::make_pair(0xA900, 0xA92F), _("Kayah Li"))); + ranges.push_back(std::make_pair(std::make_pair(0xA930, 0xA95F), _("Rejang"))); + ranges.push_back(std::make_pair(std::make_pair(0xA960, 0xA97F), _("Hangul Jamo Extended-A"))); + ranges.push_back(std::make_pair(std::make_pair(0xA980, 0xA9DF), _("Javanese"))); + ranges.push_back(std::make_pair(std::make_pair(0xAA00, 0xAA5F), _("Cham"))); + ranges.push_back(std::make_pair(std::make_pair(0xAA60, 0xAA7F), _("Myanmar Extended-A"))); + ranges.push_back(std::make_pair(std::make_pair(0xAA80, 0xAADF), _("Tai Viet"))); + ranges.push_back(std::make_pair(std::make_pair(0xABC0, 0xABFF), _("Meetei Mayek"))); + ranges.push_back(std::make_pair(std::make_pair(0xAC00, 0xD7AF), _("Hangul Syllables"))); + ranges.push_back(std::make_pair(std::make_pair(0xD7B0, 0xD7FF), _("Hangul Jamo Extended-B"))); + ranges.push_back(std::make_pair(std::make_pair(0xD800, 0xDB7F), _("High Surrogates"))); + ranges.push_back(std::make_pair(std::make_pair(0xDB80, 0xDBFF), _("High Private Use Surrogates"))); + ranges.push_back(std::make_pair(std::make_pair(0xDC00, 0xDFFF), _("Low Surrogates"))); + ranges.push_back(std::make_pair(std::make_pair(0xE000, 0xF8FF), _("Private Use Area"))); + ranges.push_back(std::make_pair(std::make_pair(0xF900, 0xFAFF), _("CJK Compatibility Ideographs"))); + ranges.push_back(std::make_pair(std::make_pair(0xFB00, 0xFB4F), _("Alphabetic Presentation Forms"))); + ranges.push_back(std::make_pair(std::make_pair(0xFB50, 0xFDFF), _("Arabic Presentation Forms-A"))); + ranges.push_back(std::make_pair(std::make_pair(0xFE00, 0xFE0F), _("Variation Selectors"))); + ranges.push_back(std::make_pair(std::make_pair(0xFE10, 0xFE1F), _("Vertical Forms"))); + ranges.push_back(std::make_pair(std::make_pair(0xFE20, 0xFE2F), _("Combining Half Marks"))); + ranges.push_back(std::make_pair(std::make_pair(0xFE30, 0xFE4F), _("CJK Compatibility Forms"))); + ranges.push_back(std::make_pair(std::make_pair(0xFE50, 0xFE6F), _("Small Form Variants"))); + ranges.push_back(std::make_pair(std::make_pair(0xFE70, 0xFEFF), _("Arabic Presentation Forms-B"))); + ranges.push_back(std::make_pair(std::make_pair(0xFF00, 0xFFEF), _("Halfwidth and Fullwidth Forms"))); + ranges.push_back(std::make_pair(std::make_pair(0xFFF0, 0xFFFF), _("Specials"))); + } + + return ranges; +} + +class GlyphColumns : public Gtk::TreeModel::ColumnRecord +{ +public: + Gtk::TreeModelColumn<gunichar> code; + Gtk::TreeModelColumn<Glib::ustring> name; + + GlyphColumns() + { + add(code); + add(name); + } +}; + +GlyphColumns *GlyphsPanel::getColumns() +{ + static GlyphColumns *columns = new GlyphColumns(); + + return columns; +} + +/** + * Constructor + */ +GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : + Inkscape::UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_GLYPHS, "", false), + store(Gtk::ListStore::create(*getColumns())), + iconView(0), + entry(0), + label(0), + insertBtn(0), +#if GLIB_CHECK_VERSION(2,14,0) + scriptCombo(0), +#endif // GLIB_CHECK_VERSION(2,14,0) + fsel(0), + targetDesktop(0), + deskTrack(), + instanceConns(), + desktopConns() +{ + Gtk::Table *table = new Gtk::Table(3, 1, false); + _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); + guint row = 0; + +// ------------------------------- + + GtkWidget *fontsel = sp_font_selector_new(); + fsel = SP_FONT_SELECTOR(fontsel); + sp_font_selector_set_font(fsel, sp_font_selector_get_font(fsel), 12.0); + + g_signal_connect( G_OBJECT(fontsel), "font_set", G_CALLBACK(fontChangeCB), this ); + + table->attach(*Gtk::manage(Glib::wrap(fontsel)), + 0, 3, row, row + 1, + Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL); + row++; + + +// ------------------------------- + +#if GLIB_CHECK_VERSION(2,14,0) + { + Gtk::Label *label = new Gtk::Label(_("Script: ")); + table->attach( *Gtk::manage(label), + 0, 1, row, row + 1, + Gtk::SHRINK, Gtk::SHRINK); + + scriptCombo = new Gtk::ComboBoxText(); + for (std::map<GUnicodeScript, Glib::ustring>::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) + { + scriptCombo->append_text(it->second); + } + + scriptCombo->set_active_text(getScriptToName()[G_UNICODE_SCRIPT_INVALID_CODE]); + sigc::connection conn = scriptCombo->signal_changed().connect(sigc::mem_fun(*this, &GlyphsPanel::rebuild)); + instanceConns.push_back(conn); + + Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP, 0.0, 0.0); + align->add(*Gtk::manage(scriptCombo)); + table->attach( *Gtk::manage(align), + 1, 2, row, row + 1, + Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); + } + + row++; +#endif // GLIB_CHECK_VERSION(2,14,0) + +// ------------------------------- + + { + Gtk::Label *label = new Gtk::Label(_("Range: ")); + table->attach( *Gtk::manage(label), + 0, 1, row, row + 1, + Gtk::SHRINK, Gtk::SHRINK); + + rangeCombo = new Gtk::ComboBoxText(); + for ( std::vector<NamedRange>::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { + rangeCombo->append_text(it->second); + } + + rangeCombo->set_active_text(getRanges()[1].second); + sigc::connection conn = rangeCombo->signal_changed().connect(sigc::mem_fun(*this, &GlyphsPanel::rebuild)); + instanceConns.push_back(conn); + + Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP, 0.0, 0.0); + align->add(*Gtk::manage(rangeCombo)); + table->attach( *Gtk::manage(align), + 1, 2, row, row + 1, + Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); + } + + row++; + +// ------------------------------- + + GlyphColumns *columns = getColumns(); + + iconView = new Gtk::IconView(store); + iconView->set_text_column(columns->name); + //iconView->set_columns(16); + + sigc::connection conn; + conn = iconView->signal_item_activated().connect(sigc::mem_fun(*this, &GlyphsPanel::glyphActivated)); + instanceConns.push_back(conn); + conn = iconView->signal_selection_changed().connect(sigc::mem_fun(*this, &GlyphsPanel::glyphSelectionChanged)); + instanceConns.push_back(conn); + + + 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, 3, row, row + 1, + Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); + row++; + +// ------------------------------- + + Gtk::HBox *box = new Gtk::HBox(); + + entry = new Gtk::Entry(); + conn = entry->signal_changed().connect(sigc::mem_fun(*this, &GlyphsPanel::calcCanInsert)); + instanceConns.push_back(conn); + entry->set_width_chars(18); + box->pack_start(*Gtk::manage(entry), Gtk::PACK_SHRINK); + + Gtk::Label *pad = new Gtk::Label(" "); + box->pack_start(*Gtk::manage(pad), Gtk::PACK_SHRINK); + + label = new Gtk::Label(" "); + box->pack_start(*Gtk::manage(label), Gtk::PACK_SHRINK); + + pad = new Gtk::Label(""); + box->pack_start(*Gtk::manage(pad), Gtk::PACK_EXPAND_WIDGET); + + insertBtn = new Gtk::Button(_("Append")); + conn = insertBtn->signal_clicked().connect(sigc::mem_fun(*this, &GlyphsPanel::insertText)); + instanceConns.push_back(conn); +#if GTK_CHECK_VERSION(2,18,0) + //gtkmm 2.18 + insertBtn->set_can_default(); +#endif + insertBtn->set_sensitive(false); + + box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); + + table->attach( *Gtk::manage(box), + 0, 3, row, row + 1, + Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + row++; + +// ------------------------------- + + + show_all_children(); + + restorePanelPrefs(); + + // Connect this up last + conn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &GlyphsPanel::setTargetDesktop) ); + instanceConns.push_back(conn); + deskTrack.connect(GTK_WIDGET(gobj())); +} + +GlyphsPanel::~GlyphsPanel() +{ + for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { + it->disconnect(); + } + instanceConns.clear(); + for (std::vector<sigc::connection>::iterator it = desktopConns.begin(); it != desktopConns.end(); ++it) { + it->disconnect(); + } + desktopConns.clear(); +} + + +void GlyphsPanel::setDesktop(SPDesktop *desktop) +{ + Panel::setDesktop(desktop); + deskTrack.setBase(desktop); +} + +void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) +{ + if (targetDesktop != desktop) { + if (targetDesktop) { + for (std::vector<sigc::connection>::iterator it = desktopConns.begin(); it != desktopConns.end(); ++it) { + it->disconnect(); + } + desktopConns.clear(); + } + + targetDesktop = desktop; + + if (targetDesktop && targetDesktop->selection) { + sigc::connection conn = desktop->selection->connectChanged(sigc::hide(sigc::bind(sigc::mem_fun(*this, &GlyphsPanel::readSelection), true, true))); + desktopConns.push_back(conn); + + // Text selection within selected items has changed: + conn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::bind(sigc::mem_fun(*this, &GlyphsPanel::readSelection), true, false))); + desktopConns.push_back(conn); + + // Must check flags, so can't call performUpdate() directly. + conn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &GlyphsPanel::selectionModifiedCB))); + desktopConns.push_back(conn); + + readSelection(true, true); + } + } +} + +void GlyphsPanel::insertText() +{ + SPItem *textItem = 0; + for (const GSList *item = targetDesktop->selection->itemList(); item; item = item->next ) { + if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) { + textItem = SP_ITEM(item->data); + break; + } + } + + if (textItem) { + Glib::ustring glyphs; + if (entry->get_text_length() > 0) { + glyphs = entry->get_text(); + } else { + Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items(); + if (!itemArray.empty()) { + Gtk::TreeModel::Path const & path = *itemArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + gunichar ch = (*row)[getColumns()->code]; + glyphs = ch; + } + } + + if (!glyphs.empty()) { + Glib::ustring combined; + gchar *str = sp_te_get_string_multiline(textItem); + if (str) { + combined = str; + g_free(str); + str = 0; + } + combined += glyphs; + sp_te_set_repr_text_multiline(textItem, combined.c_str()); + sp_document_done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); + } + } +} + +void GlyphsPanel::glyphActivated(Gtk::TreeModel::Path const & path) +{ + Gtk::ListStore::iterator row = store->get_iter(path); + gunichar ch = (*row)[getColumns()->code]; + Glib::ustring tmp; + tmp += ch; + + int startPos = 0; + int endPos = 0; + if (entry->get_selection_bounds(startPos, endPos)) { + // there was something selected. + entry->delete_text(startPos, endPos); + } + startPos = entry->get_position(); + entry->insert_text(tmp, -1, startPos); + entry->set_position(startPos); +} + +void GlyphsPanel::glyphSelectionChanged() +{ + Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items(); + if (itemArray.empty()) { + label->set_text(" "); + } else { + Gtk::TreeModel::Path const & path = *itemArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + gunichar ch = (*row)[getColumns()->code]; + + + Glib::ustring scriptName; +#if GLIB_CHECK_VERSION(2,14,0) + GUnicodeScript script = g_unichar_get_script(ch); + std::map<GUnicodeScript, Glib::ustring> mappings = getScriptToName(); + if (mappings.find(script) != mappings.end()) { + scriptName = mappings[script]; + } +#endif + gchar * tmp = g_strdup_printf("U+%04X %s", ch, scriptName.c_str()); + label->set_text(tmp); + } + calcCanInsert(); +} + +void GlyphsPanel::fontChangeCB(SPFontSelector * /*fontsel*/, font_instance * /*font*/, GlyphsPanel *self) +{ + if (self) { + self->rebuild(); + } +} + +void GlyphsPanel::selectionModifiedCB(guint flags) +{ + bool style = ((flags & ( SP_OBJECT_CHILD_MODIFIED_FLAG | + SP_OBJECT_STYLE_MODIFIED_FLAG )) != 0 ); + + bool content = ((flags & ( SP_OBJECT_CHILD_MODIFIED_FLAG | + SP_TEXT_CONTENT_MODIFIED_FLAG )) != 0 ); + + readSelection(style, content); +} + +void GlyphsPanel::calcCanInsert() +{ + int items = 0; + for (const GSList *item = targetDesktop->selection->itemList(); item; item = item->next ) { + if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) { + ++items; + } + } + + bool enable = (items == 1); + if (enable) { + enable &= (!iconView->get_selected_items().empty() + || (entry->get_text_length() > 0)); + } + + if (enable != insertBtn->is_sensitive()) { + insertBtn->set_sensitive(enable); + } +} + +void GlyphsPanel::readSelection( bool updateStyle, bool /*updateContent*/ ) +{ + calcCanInsert(); + + if (targetDesktop && updateStyle) { + //SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT); + + //int result_family = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY); + //int result_style = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE); + //int result_numbers = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); + + //sp_style_unref(query); + } +} + + +void GlyphsPanel::rebuild() +{ + font_instance *font = fsel ? sp_font_selector_get_font(fsel) : 0; + if (font) { + //double sp_font_selector_get_size (SPFontSelector *fsel); + +#if GLIB_CHECK_VERSION(2,14,0) + GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; + Glib::ustring scriptName = scriptCombo->get_active_text(); + std::map<GUnicodeScript, Glib::ustring> items = getScriptToName(); + for (std::map<GUnicodeScript, Glib::ustring>::iterator it = items.begin(); it != items.end(); ++it) { + if (scriptName == it->second) { + script = it->first; + break; + } + } +#endif // GLIB_CHECK_VERSION(2,14,0) + + // Disconnect the model while we update it. Simple work-around for 5x+ performance boost. + Glib::RefPtr<Gtk::ListStore> tmp = Gtk::ListStore::create(*getColumns()); + iconView->set_model(tmp); + + gunichar lower = 0x0001; + gunichar upper = 0xFFFD; + int active = rangeCombo->get_active_row_number(); + if (active >= 0) { + lower = getRanges()[active].first.first; + upper = getRanges()[active].first.second; + } + std::vector<gunichar> present; + for (gunichar ch = lower; ch <= upper; ch++) { + int glyphId = font->MapUnicodeChar(ch); + if (glyphId > 0) { +#if GLIB_CHECK_VERSION(2,14,0) + if ((script == G_UNICODE_SCRIPT_INVALID_CODE) || (script == g_unichar_get_script(ch))) { + present.push_back(ch); + } +#else + present.push_back(ch); +#endif + } + } + + GlyphColumns *columns = getColumns(); + store->clear(); + for (std::vector<gunichar>::iterator it = present.begin(); it != present.end(); ++it) + { + Gtk::ListStore::iterator row = store->append(); + Glib::ustring tmp; + tmp += *it; + (*row)[columns->code] = *it; + (*row)[columns->name] = tmp; + } + + // Reconnect the model once it has been updated: + iconView->set_model(store); + } +} + + +} // namespace Dialogs +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h new file mode 100644 index 000000000..1a01aebca --- /dev/null +++ b/src/ui/dialog/glyphs.h @@ -0,0 +1,107 @@ +/** + * Glyph selector dialog. + */ + +/* Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Jon A. Cruz + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#ifndef SEEN_DIALOGS_GLYPHS_H +#define SEEN_DIALOGS_GLYPHS_H + +#include <gtkmm/treemodel.h> +#include "ui/widget/panel.h" +#include "ui/dialog/desktop-tracker.h" + + +namespace Gtk { +class ComboBoxText; +class Entry; +class IconView; +class Label; +class ListStore; +} + +class SPFontSelector; +class font_instance; + + +namespace Inkscape { +namespace UI { + +class PreviewHolder; + +namespace Dialog { + +class GlyphColumns; + +/** + * A panel that displays character glyphs. + */ + +class GlyphsPanel : public Inkscape::UI::Widget::Panel +{ +public: + GlyphsPanel(gchar const *prefsPath = "/dialogs/glyphs"); + virtual ~GlyphsPanel(); + + static GlyphsPanel& getInstance(); + + virtual void setDesktop(SPDesktop *desktop); + +protected: + +private: + GlyphsPanel(GlyphsPanel const &); // no copy + GlyphsPanel &operator=(GlyphsPanel const &); // no assign + + static GlyphColumns *getColumns(); + + static void fontChangeCB(SPFontSelector *fontsel, font_instance *font, GlyphsPanel *self); + + void rebuild(); + + void glyphActivated(Gtk::TreeModel::Path const & path); + void glyphSelectionChanged(); + void setTargetDesktop(SPDesktop *desktop); + void selectionModifiedCB(guint flags); + void readSelection( bool updateStyle, bool updateContent ); + void calcCanInsert(); + void insertText(); + + + Glib::RefPtr<Gtk::ListStore> store; + Gtk::IconView *iconView; + Gtk::Entry *entry; + Gtk::Label *label; + Gtk::Button *insertBtn; +#if GLIB_CHECK_VERSION(2,14,0) + Gtk::ComboBoxText *scriptCombo; +#endif //GLIB_CHECK_VERSION(2,14,0) + Gtk::ComboBoxText *rangeCombo; + SPFontSelector *fsel; + SPDesktop *targetDesktop; + DesktopTracker deskTrack; + + std::vector<sigc::connection> instanceConns; + std::vector<sigc::connection> desktopConns; +}; + + +} // namespace Dialogs +} // namespace UI +} // namespace Inkscape + +#endif // SEEN_DIALOGS_GLYPHS_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:encoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 088f63031..a210fe163 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -45,14 +45,13 @@ namespace UI { namespace Dialogs { -IconPreviewPanel& -IconPreviewPanel::getInstance() +IconPreviewPanel &IconPreviewPanel::getInstance() { - static IconPreviewPanel &instance = *new IconPreviewPanel(); + IconPreviewPanel *instance = new IconPreviewPanel(); - instance.refreshPreview(); + instance->refreshPreview(); - return instance; + return *instance; } //######################################################################### diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 40efc8282..96f0a0f6e 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -56,6 +56,13 @@ namespace Inkscape { namespace UI { namespace Dialog { +using Inkscape::UI::Widget::DialogPage; +using Inkscape::UI::Widget::PrefCheckButton; +using Inkscape::UI::Widget::PrefRadioButton; +using Inkscape::UI::Widget::PrefSpinButton; +using Inkscape::UI::Widget::StyleSwatch; + + InkscapePreferences::InkscapePreferences() : UI::Widget::Panel ("", "/dialogs/preferences", SP_VERB_DIALOG_DISPLAY), _max_dialog_width(0), @@ -205,10 +212,10 @@ void InkscapePreferences::initPageScrolling() _("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).")); + _("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.")); + _("When on, mouse wheel zooms without Ctrl and scrolls canvas with Ctrl; when off, it zooms with Ctrl and scrolls without Ctrl")); } void InkscapePreferences::initPageSnapping() @@ -284,7 +291,7 @@ void InkscapePreferences::AddGradientCheckbox(DialogPage &p, Glib::ustring const void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value) { PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); cb->init ( _("Conversion to guides uses edges instead of bounding box"), prefs_path + "/convertguides", def_value); - p.add_line( false, "", *cb, "", _("Converting an object to guides places these along the object's true edges (imitating the object's shape), not along the bounding box.")); + p.add_line( false, "", *cb, "", _("Converting an object to guides places these along the object's true edges (imitating the object's shape), not along the bounding box")); } void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring const &prefs_path, double def_value) @@ -397,10 +404,10 @@ void InkscapePreferences::initPageTools() _page_tools.add_group_header( _("Conversion to guides:")); _t_cvg_keep_objects.init ( _("Keep objects after conversion to guides"), "/tools/cvg_keep_objects", false); _page_tools.add_line( true, "", _t_cvg_keep_objects, "", - _("When converting an object to guides, don't delete the object after the conversion.")); + _("When converting an object to guides, don't delete the object after the conversion")); _t_cvg_convert_whole_groups.init ( _("Treat groups as a single object"), "/tools/cvg_convert_whole_groups", false); _page_tools.add_line( true, "", _t_cvg_convert_whole_groups, "", - _("Treat groups as a single object during conversion to guides rather than converting each child separately.")); + _("Treat groups as a single object during conversion to guides rather than converting each child separately")); _pencil_average_all_sketches.init ( _("Average all sketches"), "/tools/freehand/pencil/average_all_sketches", false); _calligrapy_use_abs_size.init ( _("Width is in absolute units"), "/tools/calligraphic/abs_width", false); @@ -435,26 +442,26 @@ void InkscapePreferences::initPageTools() AddGradientCheckbox(_page_node, "/tools/nodes", true); _page_node.add_group_header( _("Path outline")); _t_node_pathoutline_color.init(_("Path outline color"), "/tools/nodes/highlight_color", 0xff0000ff); - _page_node.add_line( false, "", _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline."), false); + _page_node.add_line( false, "", _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline"), false); _t_node_show_outline.init(_("Always show outline"), "/tools/nodes/show_outline", false); _page_node.add_line( true, "", _t_node_show_outline, "", _("Show outlines for all paths, not only invisible paths")); _t_node_live_outline.init(_("Update outline when dragging nodes"), "/tools/nodes/live_outline", false); - _page_node.add_line( true, "", _t_node_live_outline, "", _("Update the outline when dragging or transforming nodes. If this is off, the outline will only update when completing a drag.")); + _page_node.add_line( true, "", _t_node_live_outline, "", _("Update the outline when dragging or transforming nodes; if this is off, the outline will only update when completing a drag")); _t_node_live_objects.init(_("Update paths when dragging nodes"), "/tools/nodes/live_objects", false); - _page_node.add_line( true, "", _t_node_live_objects, "", _("Update paths when dragging or transforming nodes. If this is off, paths will only be updated when completing a drag.")); + _page_node.add_line( true, "", _t_node_live_objects, "", _("Update paths when dragging or transforming nodes; if this is off, paths will only be updated when completing a drag")); _t_node_show_path_direction.init(_("Show path direction on outlines"), "/tools/nodes/show_path_direction", false); _page_node.add_line( true, "", _t_node_show_path_direction, "", _("Visualize the direction of selected paths by drawing small arrows in the middle of each outline segment")); _t_node_pathflash_enabled.init ( _("Show temporary path outline"), "/tools/nodes/pathflash_enabled", false); - _page_node.add_line( true, "", _t_node_pathflash_enabled, "", _("When hovering over a path, briefly flash its outline.")); + _page_node.add_line( true, "", _t_node_pathflash_enabled, "", _("When hovering over a path, briefly flash its outline")); _t_node_pathflash_selected.init ( _("Show temporary outline for selected paths"), "/tools/nodes/pathflash_selected", false); _page_node.add_line( true, "", _t_node_pathflash_selected, "", _("Show temporary outline even when a path is selected for editing")); _t_node_pathflash_timeout.init("/tools/nodes/pathflash_timeout", 0, 10000.0, 100.0, 100.0, 1000.0, true, false); - _page_node.add_line( false, _("Flash time"), _t_node_pathflash_timeout, "ms", _("Specifies how long the path outline will be visible after a mouse-over (in milliseconds). Specify 0 to have the outline shown until mouse leaves the path."), false); + _page_node.add_line( false, _("Flash time"), _t_node_pathflash_timeout, "ms", _("Specifies how long the path outline will be visible after a mouse-over (in milliseconds); specify 0 to have the outline shown until mouse leaves the path"), false); _page_node.add_group_header(_("Editing preferences")); _t_node_single_node_transform_handles.init(_("Show transform handles for single nodes"), "/tools/nodes/single_node_transform_handles", false); - _page_node.add_line( true, "", _t_node_single_node_transform_handles, "", _("Show transform handles even when only a single node is selected.")); + _page_node.add_line( true, "", _t_node_single_node_transform_handles, "", _("Show transform handles even when only a single node is selected")); _t_node_delete_preserves_shape.init(_("Deleting nodes preserves shape"), "/tools/nodes/delete_preserves_shape", true); - _page_node.add_line( true, "", _t_node_delete_preserves_shape, "", _("Move handles next to deleted nodes to resemble original shape. Hold Ctrl to get the other behavior.")); + _page_node.add_line( true, "", _t_node_delete_preserves_shape, "", _("Move handles next to deleted nodes to resemble original shape; hold Ctrl to get the other behavior")); //Tweak this->AddPage(_page_tweak, _("Tweak"), iter_tools, PREFS_PAGE_TOOLS_TWEAK); @@ -508,7 +515,7 @@ void InkscapePreferences::initPageTools() this->AddDotSizeSpinbutton(_page_pencil, "/tools/freehand/pencil", 3.0); _page_pencil.add_group_header( _("Sketch mode")); _page_pencil.add_line( true, "", _pencil_average_all_sketches, "", - _("If on, the sketch result will be the normal average of all sketches made, instead of averaging the old result with the new sketch.")); + _("If on, the sketch result will be the normal average of all sketches made, instead of averaging the old result with the new sketch")); //Pen this->AddPage(_page_pen, _("Pen"), iter_tools, PREFS_PAGE_TOOLS_PEN); @@ -641,16 +648,16 @@ void InkscapePreferences::initPageClones() _page_clones.add_group_header( _("When the original moves, its clones and linked offsets:")); _page_clones.add_line( true, "", _clone_option_parallel, "", - _("Clones are translated by the same vector as their original.")); + _("Clones are translated by the same vector as their original")); _page_clones.add_line( true, "", _clone_option_stay, "", - _("Clones preserve their positions when their original is moved.")); + _("Clones preserve their positions when their original is moved")); _page_clones.add_line( true, "", _clone_option_transform, "", - _("Each clone moves according to the value of its transform= attribute. For example, a rotated clone will move in a different direction than its original.")); + _("Each clone moves according to the value of its transform= attribute; for example, a rotated clone will move in a different direction than its original")); _page_clones.add_group_header( _("When the original is deleted, its clones:")); _page_clones.add_line( true, "", _clone_option_unlink, "", - _("Orphaned clones are converted to regular objects.")); + _("Orphaned clones are converted to regular objects")); _page_clones.add_line( true, "", _clone_option_delete, "", - _("Orphaned clones are deleted along with their original.")); + _("Orphaned clones are deleted along with their original")); _page_clones.add_group_header( _("When duplicating original+clones:")); @@ -774,12 +781,12 @@ void InkscapePreferences::initPageFilters() /* show infobox */ _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); _page_filters.add_line(true, "", _show_filters_info_box, "", - _("Show icons and descriptions for the filter primitives available at the filter effects dialog.")); + _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); _page_filters.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), - _("Configure number of processors/threads to use with rendering of gaussian blur."), false); + _("Configure number of processors/threads to use with rendering of gaussian blur"), false); this->AddPage(_page_filters, _("Filters"), PREFS_PAGE_FILTERS); } @@ -820,13 +827,13 @@ void InkscapePreferences::initPageImportExport() _("Default bitmap resolution (in dots per inch) in the Export dialog"), false); _importexport_ocal_url.init("/options/ocalurl/str", true, g_strdup_printf("openclipart.org")); _page_importexport.add_line( false, _("Open Clip Art Library Server Name:"), _importexport_ocal_url, "", - _("The server name of the Open Clip Art Library webdav server. It's used by the Import and Export to OCAL function."), true); + _("The server name of the Open Clip Art Library webdav server; it's used by the Import and Export to OCAL function"), true); _importexport_ocal_username.init("/options/ocalusername/str", true); _page_importexport.add_line( false, _("Open Clip Art Library Username:"), _importexport_ocal_username, "", - _("The username used to log into Open Clip Art Library."), true); + _("The username used to log into Open Clip Art Library"), true); _importexport_ocal_password.init("/options/ocalpassword/str", false); _page_importexport.add_line( false, _("Open Clip Art Library Password:"), _importexport_ocal_password, "", - _("The password used to log into Open Clip Art Library."), true); + _("The password used to log into Open Clip Art Library"), true); this->AddPage(_page_importexport, _("Import/Export"), PREFS_PAGE_IMPORTEXPORT); } @@ -905,42 +912,42 @@ void InkscapePreferences::initPageCMS() _cms_from_display.init( _("Retrieve profile from display"), "/options/displayprofile/from_display", false); _page_cms.add_line( false, "", _cms_from_display, "", #ifdef GDK_WINDOWING_X11 - _("Retrieve profiles from those attached to displays via XICC."), false); + _("Retrieve profiles from those attached to displays via XICC"), false); #else - _("Retrieve profiles from those attached to displays."), false); + _("Retrieve profiles from those attached to displays"), false); #endif // GDK_WINDOWING_X11 _cms_intent.init("/options/displayprofile/intent", intentLabels, intentValues, numIntents, 0); _page_cms.add_line( false, _("Display rendering intent:"), _cms_intent, "", - _("The rendering intent to use to calibrate display output."), false); + _("The rendering intent to use to calibrate display output"), false); _page_cms.add_group_header( _("Proofing")); _cms_softproof.init( _("Simulate output on screen"), "/options/softproof/enable", false); _page_cms.add_line( false, "", _cms_softproof, "", - _("Simulates output of target device."), false); + _("Simulates output of target device"), false); _cms_gamutwarn.init( _("Mark out of gamut colors"), "/options/softproof/gamutwarn", false); _page_cms.add_line( false, "", _cms_gamutwarn, "", - _("Highlights colors that are out of gamut for the target device."), false); + _("Highlights colors that are out of gamut for the target device"), false); Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor"); Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr); _cms_gamutcolor.set_color( tmpColor ); _page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "", - _("Selects the color used for out of gamut warning."), false); + _("Selects the color used for out of gamut warning"), false); _page_cms.add_line( false, _("Device profile:"), _cms_proof_profile, "", - _("The ICC profile to use to simulate device output."), false); + _("The ICC profile to use to simulate device output"), false); _cms_proof_intent.init("/options/softproof/intent", intentLabels, intentValues, numIntents, 0); _page_cms.add_line( false, _("Device rendering intent:"), _cms_proof_intent, "", - _("The rendering intent to use to calibrate display output."), false); + _("The rendering intent to use to calibrate display output"), false); _cms_proof_blackpoint.init( _("Black point compensation"), "/options/softproof/bpc", false); _page_cms.add_line( false, "", _cms_proof_blackpoint, "", - _("Enables black point compensation."), false); + _("Enables black point compensation"), false); _cms_proof_preserveblack.init( _("Preserve black"), "/options/softproof/preserveblack", false); _page_cms.add_line( false, "", _cms_proof_preserveblack, @@ -1015,7 +1022,7 @@ void InkscapePreferences::initPageGrids() _page_grids.add_group_header( _("Major grid line emphasizing")); _grids_no_emphasize_on_zoom.init( _("Don't emphasize gridlines when zoomed out"), "/options/grids/no_emphasize_when_zoomedout", false); - _page_grids.add_line( false, "", _grids_no_emphasize_on_zoom, "", _("If set and zoomed out, the gridlines will be shown in normal color instead of major grid line color."), false); + _page_grids.add_line( false, "", _grids_no_emphasize_on_zoom, "", _("If set and zoomed out, the gridlines will be shown in normal color instead of major grid line color"), false); _page_grids.add_group_header( _("Default grid settings")); @@ -1092,7 +1099,7 @@ void InkscapePreferences::initPageSVGOutput() _page_svgoutput.add_line( false, _("Numeric precision:"), _svgoutput_numericprecision, "", _("How many digits to write after the decimal dot"), false); _svgoutput_minimumexponent.init("/options/svgoutput/minimumexponent", -32.0, -1, 1.0, 2.0, -8.0, true, false); - _page_svgoutput.add_line( false, _("Minimum exponent:"), _svgoutput_minimumexponent, "", _("The smallest number written to SVG is 10 to the power of this exponent; anything smaller is written as zero."), false); + _page_svgoutput.add_line( false, _("Minimum exponent:"), _svgoutput_minimumexponent, "", _("The smallest number written to SVG is 10 to the power of this exponent; anything smaller is written as zero"), false); this->AddPage(_page_svgoutput, _("SVG output"), PREFS_PAGE_SVGOUTPUT); } @@ -1124,21 +1131,21 @@ void InkscapePreferences::initPageUI() int sizeValues[] = {0, 1, 2}; _misc_small_tools.init( "/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); - _page_ui.add_line( false, _("Toolbox icon size"), _misc_small_tools, "", + _page_ui.add_line( false, _("Toolbox icon size:"), _misc_small_tools, "", _("Set the size for the tool icons (requires restart)"), false); _misc_small_toolbar.init( "/toolbox/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); - _page_ui.add_line( false, _("Control bar icon size"), _misc_small_toolbar, "", + _page_ui.add_line( false, _("Control bar icon size:"), _misc_small_toolbar, "", _("Set the size for the icons in tools' control bars to use (requires restart)"), false); _misc_small_secondary.init( "/toolbox/secondary", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 1 ); - _page_ui.add_line( false, _("Secondary toolbar icon size"), _misc_small_secondary, "", + _page_ui.add_line( false, _("Secondary toolbar icon size:"), _misc_small_secondary, "", _("Set the size for the icons in secondary toolbars to use (requires restart)"), false); - _ui_colorsliders_top.init( _("Work-around color sliders not drawing."), "/options/workarounds/colorsontop", false); + _ui_colorsliders_top.init( _("Work-around color sliders not drawing"), "/options/workarounds/colorsontop", false); _page_ui.add_line( false, "", _ui_colorsliders_top, "", - _("When on, will attempt to work around bugs in certain GTK themes drawing color sliders."), true); + _("When on, will attempt to work around bugs in certain GTK themes drawing color sliders"), true); _misc_recent.init("/options/maxrecentdocuments/value", 0.0, 1000.0, 1.0, 1.0, 1.0, true, false); @@ -1157,9 +1164,9 @@ void InkscapePreferences::initPageUI() _("Adjust the slider until the length of the ruler on your screen matches its real length. This information is used when zooming to 1:1, 1:2, etc., to display objects in their true sizes"), true); - _ui_partialdynamic.init( _("Enable dynamic relayout for incomplete sections."), "/options/workarounds/dynamicnotdone", false); + _ui_partialdynamic.init( _("Enable dynamic relayout for incomplete sections"), "/options/workarounds/dynamicnotdone", false); _page_ui.add_line( false, "", _ui_partialdynamic, "", - _("When on, will allow dynamic layout of components that are not completely finished being refactored."), true); + _("When on, will allow dynamic layout of components that are not completely finished being refactored"), true); this->AddPage(_page_ui, _("Interface"), PREFS_PAGE_UI); @@ -1170,7 +1177,7 @@ void InkscapePreferences::initPageSave() { _save_use_current_dir.init( _("Use current directory for \"Save As ...\""), "/dialogs/save_as/use_current_dir", true); _page_save.add_line( false, "", _save_use_current_dir, "", - _("When this option is on, the \"Save as...\" dialog will always open in the directory where the currently open document is. When it's off, it will open in the directory where you last saved a file using that dialog."), true); + _("When this option is on, the \"Save as...\" dialog will always open in the directory where the currently open document is; when it's off, it will open in the directory where you last saved a file using that dialog"), true); // Autosave options @@ -1341,7 +1348,7 @@ void InkscapePreferences::initPageMisc() _misc_latency_skew.init("/debug/latency/skew", 0.5, 2.0, 0.01, 0.10, 1.0, false, false); _page_misc.add_line( false, _("Latency skew:"), _misc_latency_skew, _("(requires restart)"), - _("Factor by which the event clock is skewed from the actual time (0.9766 on some systems)."), false); + _("Factor by which the event clock is skewed from the actual time (0.9766 on some systems)"), false); _misc_namedicon_delay.init( _("Pre-render named icons"), "/options/iconrender/named_nodelay", false); _page_misc.add_line( false, "", _misc_namedicon_delay, "", diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 0ba8c965d..5ee916e4c 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -82,8 +82,6 @@ enum { PREFS_PAGE_MISC }; -using namespace Inkscape::UI::Widget; - namespace Inkscape { namespace UI { namespace Dialog { @@ -108,188 +106,272 @@ protected: { Gtk::TreeModelColumnRecord::add(_col_name); Gtk::TreeModelColumnRecord::add(_col_page); Gtk::TreeModelColumnRecord::add(_col_id); } Gtk::TreeModelColumn<Glib::ustring> _col_name; Gtk::TreeModelColumn<int> _col_id; - Gtk::TreeModelColumn<DialogPage*> _col_page; + Gtk::TreeModelColumn<UI::Widget::DialogPage*> _col_page; }; PageListModelColumns _page_list_columns; Gtk::TreeModel::Path _path_tools; Gtk::TreeModel::Path _path_shapes; - DialogPage _page_mouse, _page_scrolling, _page_snapping, _page_steps, _page_tools, _page_windows, - _page_clones, _page_mask, _page_transforms, _page_filters, _page_select, - _page_importexport, _page_cms, _page_grids, _page_svgoutput, _page_misc, - _page_ui, _page_save, _page_bitmaps, _page_spellcheck; - DialogPage _page_selector, _page_node, _page_tweak, _page_spray, _page_zoom, _page_shapes, _page_pencil, _page_pen, - _page_calligraphy, _page_text, _page_gradient, _page_connector, _page_dropper, _page_lpetool; - DialogPage _page_rectangle, _page_3dbox, _page_ellipse, _page_star, _page_spiral, _page_paintbucket, _page_eraser; - - PrefSpinButton _mouse_sens, _mouse_thres; - PrefCheckButton _mouse_use_ext_input; - PrefCheckButton _mouse_switch_on_ext_input; - - PrefSpinButton _scroll_wheel, _scroll_arrow_px, _scroll_arrow_acc, _scroll_auto_speed, _scroll_auto_thres; - PrefCheckButton _scroll_space; - PrefCheckButton _wheel_zoom; + UI::Widget::DialogPage _page_mouse; + UI::Widget::DialogPage _page_scrolling; + UI::Widget::DialogPage _page_snapping; + UI::Widget::DialogPage _page_steps; + UI::Widget::DialogPage _page_tools; + UI::Widget::DialogPage _page_windows; + UI::Widget::DialogPage _page_clones; + UI::Widget::DialogPage _page_mask; + UI::Widget::DialogPage _page_transforms; + UI::Widget::DialogPage _page_filters; + UI::Widget::DialogPage _page_select; + UI::Widget::DialogPage _page_importexport; + UI::Widget::DialogPage _page_cms; + UI::Widget::DialogPage _page_grids; + UI::Widget::DialogPage _page_svgoutput; + UI::Widget::DialogPage _page_misc; + UI::Widget::DialogPage _page_ui; + UI::Widget::DialogPage _page_save; + UI::Widget::DialogPage _page_bitmaps; + UI::Widget::DialogPage _page_spellcheck; + + UI::Widget::DialogPage _page_selector; + UI::Widget::DialogPage _page_node; + UI::Widget::DialogPage _page_tweak; + UI::Widget::DialogPage _page_spray; + UI::Widget::DialogPage _page_zoom; + UI::Widget::DialogPage _page_shapes; + UI::Widget::DialogPage _page_pencil; + UI::Widget::DialogPage _page_pen; + UI::Widget::DialogPage _page_calligraphy; + UI::Widget::DialogPage _page_text; + UI::Widget::DialogPage _page_gradient; + UI::Widget::DialogPage _page_connector; + UI::Widget::DialogPage _page_dropper; + UI::Widget::DialogPage _page_lpetool; + + UI::Widget::DialogPage _page_rectangle; + UI::Widget::DialogPage _page_3dbox; + UI::Widget::DialogPage _page_ellipse; + UI::Widget::DialogPage _page_star; + UI::Widget::DialogPage _page_spiral; + UI::Widget::DialogPage _page_paintbucket; + UI::Widget::DialogPage _page_eraser; + + UI::Widget::PrefSpinButton _mouse_sens; + UI::Widget::PrefSpinButton _mouse_thres; + UI::Widget::PrefCheckButton _mouse_use_ext_input; + UI::Widget::PrefCheckButton _mouse_switch_on_ext_input; + + UI::Widget::PrefSpinButton _scroll_wheel; + UI::Widget::PrefSpinButton _scroll_arrow_px; + UI::Widget::PrefSpinButton _scroll_arrow_acc; + UI::Widget::PrefSpinButton _scroll_auto_speed; + UI::Widget::PrefSpinButton _scroll_auto_thres; + UI::Widget::PrefCheckButton _scroll_space; + UI::Widget::PrefCheckButton _wheel_zoom; Gtk::HScale *_slider_snapping_delay; - PrefCheckButton _snap_indicator, _snap_closest_only, _snap_mouse_pointer; - - PrefCombo _steps_rot_snap; - PrefCheckButton _steps_compass; - PrefSpinButton _steps_arrow, _steps_scale, _steps_inset, _steps_zoom; - - PrefRadioButton _t_sel_trans_obj, _t_sel_trans_outl, _t_sel_cue_none, _t_sel_cue_mark, - _t_sel_cue_box, _t_bbox_visual, _t_bbox_geometric; - PrefCheckButton _t_cvg_keep_objects, _t_cvg_convert_whole_groups; - PrefCheckButton _t_node_show_outline; - PrefCheckButton _t_node_live_outline; - PrefCheckButton _t_node_live_objects; - PrefCheckButton _t_node_pathflash_enabled; - PrefCheckButton _t_node_pathflash_selected; - PrefSpinButton _t_node_pathflash_timeout; - PrefCheckButton _t_node_show_path_direction; - PrefCheckButton _t_node_single_node_transform_handles; - PrefCheckButton _t_node_delete_preserves_shape; - PrefColorPicker _t_node_pathoutline_color; - - PrefRadioButton _win_dockable, _win_floating; - PrefRadioButton _win_ontop_none, _win_ontop_normal, _win_ontop_agressive; - PrefRadioButton _win_save_geom_off, _win_save_geom, _win_save_geom_prefs; - PrefCheckButton _win_hide_task, _win_zoom_resize , _win_show_close; - PrefSpinButton _win_trans_focus; /**< The dialog transparency setting for when the dialog is focused. */ - PrefSpinButton _win_trans_blur; /**< The dialog transparency setting for when the dialog is out of focus. */ - PrefSpinButton _win_trans_time; /**< How much time to go from one transparency setting to another */ - - PrefCheckButton _pencil_average_all_sketches; - - PrefCheckButton _calligrapy_use_abs_size; - PrefCheckButton _calligrapy_keep_selected; - - PrefCheckButton _connector_ignore_text; - - PrefRadioButton _clone_option_parallel, _clone_option_stay, _clone_option_transform, - _clone_option_unlink, _clone_option_delete; - PrefCheckButton _clone_relink_on_duplicate; - - PrefCheckButton _mask_mask_on_top; - PrefCheckButton _mask_mask_remove; - PrefRadioButton _mask_grouping_none, _mask_grouping_separate, _mask_grouping_all; - PrefCheckButton _mask_ungrouping; - - PrefRadioButton _blur_quality_best, _blur_quality_better, _blur_quality_normal, _blur_quality_worse, _blur_quality_worst; - PrefRadioButton _filter_quality_best, _filter_quality_better, _filter_quality_normal, _filter_quality_worse, _filter_quality_worst; - PrefCheckButton _show_filters_info_box; - PrefSpinButton _filter_multi_threaded; - - PrefCheckButton _trans_scale_stroke, _trans_scale_corner, _trans_gradient,_trans_pattern; - PrefRadioButton _trans_optimized, _trans_preserved; - - PrefRadioButton _sel_all; - PrefRadioButton _sel_current; - PrefRadioButton _sel_recursive; - PrefCheckButton _sel_hidden, _sel_locked; - PrefCheckButton _sel_layer_deselects; - - PrefSpinButton _importexport_export, _misc_simpl; - PrefSlider _snap_delay, _snap_weight; - PrefSpinButton _misc_latency_skew; - PrefCheckButton _misc_comment, _misc_forkvectors, _misc_scripts, _misc_namedicon_delay; + UI::Widget::PrefCheckButton _snap_indicator; + UI::Widget::PrefCheckButton _snap_closest_only; + UI::Widget::PrefCheckButton _snap_mouse_pointer; + + UI::Widget::PrefCombo _steps_rot_snap; + UI::Widget::PrefCheckButton _steps_compass; + UI::Widget::PrefSpinButton _steps_arrow; + UI::Widget::PrefSpinButton _steps_scale; + UI::Widget::PrefSpinButton _steps_inset; + UI::Widget::PrefSpinButton _steps_zoom; + + UI::Widget::PrefRadioButton _t_sel_trans_obj; + UI::Widget::PrefRadioButton _t_sel_trans_outl; + UI::Widget::PrefRadioButton _t_sel_cue_none; + UI::Widget::PrefRadioButton _t_sel_cue_mark; + UI::Widget::PrefRadioButton _t_sel_cue_box; + UI::Widget::PrefRadioButton _t_bbox_visual; + UI::Widget::PrefRadioButton _t_bbox_geometric; + + UI::Widget::PrefCheckButton _t_cvg_keep_objects; + UI::Widget::PrefCheckButton _t_cvg_convert_whole_groups; + UI::Widget::PrefCheckButton _t_node_show_outline; + UI::Widget::PrefCheckButton _t_node_live_outline; + UI::Widget::PrefCheckButton _t_node_live_objects; + UI::Widget::PrefCheckButton _t_node_pathflash_enabled; + UI::Widget::PrefCheckButton _t_node_pathflash_selected; + UI::Widget::PrefSpinButton _t_node_pathflash_timeout; + UI::Widget::PrefCheckButton _t_node_show_path_direction; + UI::Widget::PrefCheckButton _t_node_single_node_transform_handles; + UI::Widget::PrefCheckButton _t_node_delete_preserves_shape; + UI::Widget::PrefColorPicker _t_node_pathoutline_color; + + UI::Widget::PrefRadioButton _win_dockable; + UI::Widget::PrefRadioButton _win_floating; + UI::Widget::PrefRadioButton _win_ontop_none; + UI::Widget::PrefRadioButton _win_ontop_normal; + UI::Widget::PrefRadioButton _win_ontop_agressive; + UI::Widget::PrefRadioButton _win_save_geom_off; + UI::Widget::PrefRadioButton _win_save_geom; + UI::Widget::PrefRadioButton _win_save_geom_prefs; + UI::Widget::PrefCheckButton _win_hide_task; + UI::Widget::PrefCheckButton _win_zoom_resize; + UI::Widget::PrefCheckButton _win_show_close; + UI::Widget::PrefSpinButton _win_trans_focus; /**< The dialog transparency setting for when the dialog is focused. */ + UI::Widget::PrefSpinButton _win_trans_blur; /**< The dialog transparency setting for when the dialog is out of focus. */ + UI::Widget::PrefSpinButton _win_trans_time; /**< How much time to go from one transparency setting to another */ + + UI::Widget::PrefCheckButton _pencil_average_all_sketches; + + UI::Widget::PrefCheckButton _calligrapy_use_abs_size; + UI::Widget::PrefCheckButton _calligrapy_keep_selected; + + UI::Widget::PrefCheckButton _connector_ignore_text; + + UI::Widget::PrefRadioButton _clone_option_parallel; + UI::Widget::PrefRadioButton _clone_option_stay; + UI::Widget::PrefRadioButton _clone_option_transform; + UI::Widget::PrefRadioButton _clone_option_unlink; + UI::Widget::PrefRadioButton _clone_option_delete; + UI::Widget::PrefCheckButton _clone_relink_on_duplicate; + + UI::Widget::PrefCheckButton _mask_mask_on_top; + UI::Widget::PrefCheckButton _mask_mask_remove; + UI::Widget::PrefRadioButton _mask_grouping_none; + UI::Widget::PrefRadioButton _mask_grouping_separate; + UI::Widget::PrefRadioButton _mask_grouping_all; + UI::Widget::PrefCheckButton _mask_ungrouping; + + UI::Widget::PrefRadioButton _blur_quality_best; + UI::Widget::PrefRadioButton _blur_quality_better; + UI::Widget::PrefRadioButton _blur_quality_normal; + UI::Widget::PrefRadioButton _blur_quality_worse; + UI::Widget::PrefRadioButton _blur_quality_worst; + UI::Widget::PrefRadioButton _filter_quality_best; + UI::Widget::PrefRadioButton _filter_quality_better; + UI::Widget::PrefRadioButton _filter_quality_normal; + UI::Widget::PrefRadioButton _filter_quality_worse; + UI::Widget::PrefRadioButton _filter_quality_worst; + UI::Widget::PrefCheckButton _show_filters_info_box; + UI::Widget::PrefSpinButton _filter_multi_threaded; + + UI::Widget::PrefCheckButton _trans_scale_stroke; + UI::Widget::PrefCheckButton _trans_scale_corner; + UI::Widget::PrefCheckButton _trans_gradient; + UI::Widget::PrefCheckButton _trans_pattern; + UI::Widget::PrefRadioButton _trans_optimized; + UI::Widget::PrefRadioButton _trans_preserved; + + UI::Widget::PrefRadioButton _sel_all; + UI::Widget::PrefRadioButton _sel_current; + UI::Widget::PrefRadioButton _sel_recursive; + UI::Widget::PrefCheckButton _sel_hidden; + UI::Widget::PrefCheckButton _sel_locked; + UI::Widget::PrefCheckButton _sel_layer_deselects; + + UI::Widget::PrefSpinButton _importexport_export; + UI::Widget::PrefSpinButton _misc_simpl; + UI::Widget::PrefSlider _snap_delay; + UI::Widget::PrefSlider _snap_weight; + UI::Widget::PrefSpinButton _misc_latency_skew; + UI::Widget::PrefCheckButton _misc_comment; + UI::Widget::PrefCheckButton _misc_forkvectors; + UI::Widget::PrefCheckButton _misc_scripts; + UI::Widget::PrefCheckButton _misc_namedicon_delay; Gtk::TextView _misc_info; Gtk::ScrolledWindow _misc_info_scroll; // UI page - PrefCombo _ui_languages; - PrefCombo _misc_small_toolbar; - PrefCombo _misc_small_secondary; - PrefCombo _misc_small_tools; - PrefCheckButton _ui_colorsliders_top; - PrefSpinButton _misc_recent; - PrefCheckButton _ui_partialdynamic; - ZoomCorrRulerSlider _ui_zoom_correction; + UI::Widget::PrefCombo _ui_languages; + UI::Widget::PrefCombo _misc_small_toolbar; + UI::Widget::PrefCombo _misc_small_secondary; + UI::Widget::PrefCombo _misc_small_tools; + UI::Widget::PrefCheckButton _ui_colorsliders_top; + UI::Widget::PrefSpinButton _misc_recent; + UI::Widget::PrefCheckButton _ui_partialdynamic; + UI::Widget::ZoomCorrRulerSlider _ui_zoom_correction; //Spellcheck - PrefCombo _spell_language; - PrefCombo _spell_language2; - PrefCombo _spell_language3; - PrefCheckButton _spell_ignorenumbers; - PrefCheckButton _spell_ignoreallcaps; - - PrefCombo _misc_overs_bitmap; - PrefCombo _misc_bitmap_editor; - PrefCheckButton _misc_bitmap_autoreload; - PrefSpinButton _bitmap_copy_res; - - PrefCheckButton _save_use_current_dir; - PrefCheckButton _save_autosave_enable; - PrefSpinButton _save_autosave_interval; - PrefEntry _save_autosave_path; - PrefSpinButton _save_autosave_max; + UI::Widget::PrefCombo _spell_language; + UI::Widget::PrefCombo _spell_language2; + UI::Widget::PrefCombo _spell_language3; + UI::Widget::PrefCheckButton _spell_ignorenumbers; + UI::Widget::PrefCheckButton _spell_ignoreallcaps; + + UI::Widget::PrefCombo _misc_overs_bitmap; + UI::Widget::PrefCombo _misc_bitmap_editor; + UI::Widget::PrefCheckButton _misc_bitmap_autoreload; + UI::Widget::PrefSpinButton _bitmap_copy_res; + + UI::Widget::PrefCheckButton _save_use_current_dir; + UI::Widget::PrefCheckButton _save_autosave_enable; + UI::Widget::PrefSpinButton _save_autosave_interval; + UI::Widget::PrefEntry _save_autosave_path; + UI::Widget::PrefSpinButton _save_autosave_max; Gtk::ComboBoxText _cms_display_profile; - PrefCheckButton _cms_from_display; - PrefCombo _cms_intent; + UI::Widget::PrefCheckButton _cms_from_display; + UI::Widget::PrefCombo _cms_intent; - PrefCheckButton _cms_softproof; - PrefCheckButton _cms_gamutwarn; + UI::Widget::PrefCheckButton _cms_softproof; + UI::Widget::PrefCheckButton _cms_gamutwarn; Gtk::ColorButton _cms_gamutcolor; Gtk::ComboBoxText _cms_proof_profile; - PrefCombo _cms_proof_intent; - PrefCheckButton _cms_proof_blackpoint; - PrefCheckButton _cms_proof_preserveblack; + UI::Widget::PrefCombo _cms_proof_intent; + UI::Widget::PrefCheckButton _cms_proof_blackpoint; + UI::Widget::PrefCheckButton _cms_proof_preserveblack; Gtk::Notebook _grids_notebook; - PrefCheckButton _grids_no_emphasize_on_zoom; - DialogPage _grids_xy, _grids_axonom; + UI::Widget::PrefCheckButton _grids_no_emphasize_on_zoom; + UI::Widget::DialogPage _grids_xy; + UI::Widget::DialogPage _grids_axonom; // CanvasXYGrid properties: - PrefUnit _grids_xy_units; - PrefSpinButton _grids_xy_origin_x; - PrefSpinButton _grids_xy_origin_y; - PrefSpinButton _grids_xy_spacing_x; - PrefSpinButton _grids_xy_spacing_y; - PrefColorPicker _grids_xy_color; - PrefColorPicker _grids_xy_empcolor; - PrefSpinButton _grids_xy_empspacing; - PrefCheckButton _grids_xy_dotted; + UI::Widget::PrefUnit _grids_xy_units; + UI::Widget::PrefSpinButton _grids_xy_origin_x; + UI::Widget::PrefSpinButton _grids_xy_origin_y; + UI::Widget::PrefSpinButton _grids_xy_spacing_x; + UI::Widget::PrefSpinButton _grids_xy_spacing_y; + UI::Widget::PrefColorPicker _grids_xy_color; + UI::Widget::PrefColorPicker _grids_xy_empcolor; + UI::Widget::PrefSpinButton _grids_xy_empspacing; + UI::Widget::PrefCheckButton _grids_xy_dotted; // CanvasAxonomGrid properties: - PrefUnit _grids_axonom_units; - PrefSpinButton _grids_axonom_origin_x; - PrefSpinButton _grids_axonom_origin_y; - PrefSpinButton _grids_axonom_spacing_y; - PrefSpinButton _grids_axonom_angle_x; - PrefSpinButton _grids_axonom_angle_z; - PrefColorPicker _grids_axonom_color; - PrefColorPicker _grids_axonom_empcolor; - PrefSpinButton _grids_axonom_empspacing; + UI::Widget::PrefUnit _grids_axonom_units; + UI::Widget::PrefSpinButton _grids_axonom_origin_x; + UI::Widget::PrefSpinButton _grids_axonom_origin_y; + UI::Widget::PrefSpinButton _grids_axonom_spacing_y; + UI::Widget::PrefSpinButton _grids_axonom_angle_x; + UI::Widget::PrefSpinButton _grids_axonom_angle_z; + UI::Widget::PrefColorPicker _grids_axonom_color; + UI::Widget::PrefColorPicker _grids_axonom_empcolor; + UI::Widget::PrefSpinButton _grids_axonom_empspacing; // SVG Output page: - PrefCheckButton _svgoutput_usenamedcolors; - PrefSpinButton _svgoutput_numericprecision; - PrefSpinButton _svgoutput_minimumexponent; - PrefCheckButton _svgoutput_inlineattrs; - PrefSpinButton _svgoutput_indent; - PrefCheckButton _svgoutput_allowrelativecoordinates; - PrefCheckButton _svgoutput_forcerepeatcommands; - - PrefEntryButtonHBox _importexport_ocal_url; - PrefEntry _importexport_ocal_username; - PrefEntry _importexport_ocal_password; + UI::Widget::PrefCheckButton _svgoutput_usenamedcolors; + UI::Widget::PrefSpinButton _svgoutput_numericprecision; + UI::Widget::PrefSpinButton _svgoutput_minimumexponent; + UI::Widget::PrefCheckButton _svgoutput_inlineattrs; + UI::Widget::PrefSpinButton _svgoutput_indent; + UI::Widget::PrefCheckButton _svgoutput_allowrelativecoordinates; + UI::Widget::PrefCheckButton _svgoutput_forcerepeatcommands; + + UI::Widget::PrefEntryButtonHBox _importexport_ocal_url; + UI::Widget::PrefEntry _importexport_ocal_username; + UI::Widget::PrefEntry _importexport_ocal_password; int _max_dialog_width; int _max_dialog_height; int _sb_width; - DialogPage* _current_page; + UI::Widget::DialogPage* _current_page; - Gtk::TreeModel::iterator AddPage(DialogPage& p, Glib::ustring title, int id); - Gtk::TreeModel::iterator AddPage(DialogPage& p, Glib::ustring title, Gtk::TreeModel::iterator parent, int id); + Gtk::TreeModel::iterator AddPage(UI::Widget::DialogPage& p, Glib::ustring title, int id); + Gtk::TreeModel::iterator AddPage(UI::Widget::DialogPage& p, Glib::ustring title, Gtk::TreeModel::iterator parent, int id); bool SetMaxDialogSize(const Gtk::TreeModel::iterator& iter); bool PresentPage(const Gtk::TreeModel::iterator& iter); - static void AddSelcueCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value); - static void AddGradientCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value); - static void AddConvertGuidesCheckbox(DialogPage& p, Glib::ustring const &prefs_path, bool def_value); - static void AddDotSizeSpinbutton(DialogPage& p, Glib::ustring const &prefs_path, double def_value); - static void AddNewObjectsStyle(DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); + static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddDotSizeSpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value); + static void AddNewObjectsStyle(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); void on_pagelist_selection_changed(); void on_reset_open_recent_clicked(); diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index ae8594e50..92a54affb 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -12,11 +12,15 @@ #include <set> #include <glib/gprintf.h> #include <glibmm/i18n.h> +#include <gtkmm/alignment.h> +#include <gtkmm/cellrenderercombo.h> +#include <gtkmm/checkbutton.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/enums.h> #include <gtkmm/eventbox.h> #include <gtkmm/frame.h> #include <gtkmm/image.h> +#include <gtkmm/liststore.h> #include <gtkmm/menubar.h> #include <gtkmm/notebook.h> #include <gtkmm/paned.h> @@ -28,8 +32,9 @@ #include <gtkmm/treestore.h> #include <gtkmm/treeview.h> -#include "ui/widget/panel.h" #include "device-manager.h" +#include "preferences.h" +#include "ui/widget/panel.h" #include "input.h" @@ -323,38 +328,87 @@ namespace Dialog { -class MyModelColumns : public Gtk::TreeModel::ColumnRecord +class DeviceModelColumns : public Gtk::TreeModel::ColumnRecord { public: - Gtk::TreeModelColumn<Glib::ustring> filename; Gtk::TreeModelColumn<Glib::ustring> description; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > thumbnail; - Gtk::TreeModelColumn<InputDevice const *> device; + Gtk::TreeModelColumn<Glib::RefPtr<InputDevice const> > device; + Gtk::TreeModelColumn<Gdk::InputMode> mode; - MyModelColumns() { add(filename); add(description); add(thumbnail); add(device); } + DeviceModelColumns() { add(description); add(thumbnail); add(device); add(mode); } }; +static std::map<Gdk::InputMode, Glib::ustring> &getModeToString() +{ + static std::map<Gdk::InputMode, Glib::ustring> mapping; + if (mapping.empty()) { + mapping[Gdk::MODE_DISABLED] = _("Disabled"); + mapping[Gdk::MODE_SCREEN] = _("Screen"); + mapping[Gdk::MODE_WINDOW] = _("Window"); + } + + return mapping; +} + +static std::map<Glib::ustring, Gdk::InputMode> &getStringToMode() +{ + static std::map<Glib::ustring, Gdk::InputMode> mapping; + if (mapping.empty()) { + mapping[_("Disabled")] = Gdk::MODE_DISABLED; + mapping[_("Screen")] = Gdk::MODE_SCREEN; + mapping[_("Window")] = Gdk::MODE_WINDOW; + } + + return mapping; +} + + + class InputDialogImpl : public InputDialog { public: InputDialogImpl(); virtual ~InputDialogImpl() {} private: - Glib::RefPtr<Gdk::Pixbuf> corePix; - Glib::RefPtr<Gdk::Pixbuf> penPix; - Glib::RefPtr<Gdk::Pixbuf> mousePix; - Glib::RefPtr<Gdk::Pixbuf> tipPix; - Glib::RefPtr<Gdk::Pixbuf> tabletPix; - Glib::RefPtr<Gdk::Pixbuf> eraserPix; - Glib::RefPtr<Gdk::Pixbuf> sidebuttonsPix; - - Glib::RefPtr<Gdk::Pixbuf> buttonsNonePix; - Glib::RefPtr<Gdk::Pixbuf> buttonsOnPix; - Glib::RefPtr<Gdk::Pixbuf> buttonsOffPix; - - Glib::RefPtr<Gdk::Pixbuf> axisNonePix; - Glib::RefPtr<Gdk::Pixbuf> axisOnPix; - Glib::RefPtr<Gdk::Pixbuf> axisOffPix; + class ConfPanel : public Gtk::VBox + { + public: + ConfPanel(); + ~ConfPanel(); + + class Blink : public Preferences::Observer + { + public: + Blink(ConfPanel &parent); + virtual ~Blink(); + virtual void notify(Preferences::Entry const &new_val); + + ConfPanel &parent; + }; + + static void commitCellModeChange(Glib::ustring const &path, Glib::ustring const &newText, Glib::RefPtr<Gtk::TreeStore> store); + static void setModeCellString(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter); + + void saveSettings(); + void useExtToggled(); + + Glib::RefPtr<Gtk::TreeStore> store; + Gtk::TreeIter tabletIter; + Gtk::TreeView tree; + Gtk::ScrolledWindow treeScroller; + Blink watcher; + Gtk::CheckButton useExt; + Gtk::Button save; + }; + + static DeviceModelColumns &getCols(); + + enum PixId {PIX_CORE, PIX_PEN, PIX_MOUSE, PIX_TIP, PIX_TABLET, PIX_ERASER, PIX_SIDEBUTTONS, + PIX_BUTTONS_NONE, PIX_BUTTONS_ON, PIX_BUTTONS_OFF, + PIX_AXIS_NONE, PIX_AXIS_ON, PIX_AXIS_OFF}; + + static Glib::RefPtr<Gdk::Pixbuf> getPix(PixId id); std::map<Glib::ustring, std::set<guint> > buttonMap; std::map<Glib::ustring, std::map<guint, std::pair<guint, gdouble> > > axesMap; @@ -362,7 +416,6 @@ private: GdkInputSource lastSourceSeen; Glib::ustring lastDevnameSeen; - MyModelColumns cols; Glib::RefPtr<Gtk::TreeStore> store; Gtk::TreeIter tabletIter; Gtk::TreeView tree; @@ -383,7 +436,6 @@ private: Gtk::Label keyVal; Gtk::Entry keyEntry; Gtk::Table devDetails; - Gtk::HPaned confSplitter; Gtk::Notebook topHolder; Gtk::Image testThumb; Gtk::Image testButtons[24]; @@ -391,6 +443,9 @@ private: Gtk::Table imageTable; Gtk::EventBox testDetector; + ConfPanel cfgPanel; + + static void setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIter &tablet ); void setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo ); void updateTestButtons( Glib::ustring const& key, gint hotButton ); void updateTestAxes( Glib::ustring const& key, GdkDevice* dev ); @@ -399,18 +454,54 @@ private: bool eventSnoop(GdkEvent* event); void linkComboChanged(); void resyncToSelection(); - void handleDeviceChange(const Glib::RefPtr<InputDevice>& device); - void updateDeviceAxes(const Glib::RefPtr<InputDevice>& device); - void updateDeviceButtons(const Glib::RefPtr<InputDevice>& device); - void updateDeviceLinks(const Glib::RefPtr<InputDevice>& device); - - bool findDevice(const Gtk::TreeModel::iterator& iter, - Glib::ustring id, - Gtk::TreeModel::iterator* result); - bool findDeviceByLink(const Gtk::TreeModel::iterator& iter, - Glib::ustring link, - Gtk::TreeModel::iterator* result); -}; + void handleDeviceChange(Glib::RefPtr<InputDevice const> device); + void updateDeviceAxes(Glib::RefPtr<InputDevice const> device); + void updateDeviceButtons(Glib::RefPtr<InputDevice const> device); + static void updateDeviceLinks(Glib::RefPtr<InputDevice const> device, Gtk::TreeIter tabletIter, Glib::RefPtr<Gtk::TreeView> tree); + + static bool findDevice(const Gtk::TreeModel::iterator& iter, + Glib::ustring id, + Gtk::TreeModel::iterator* result); + static bool findDeviceByLink(const Gtk::TreeModel::iterator& iter, + Glib::ustring link, + Gtk::TreeModel::iterator* result); + +}; // class InputDialogImpl + + +DeviceModelColumns &InputDialogImpl::getCols() +{ + static DeviceModelColumns cols; + return cols; +} + +Glib::RefPtr<Gdk::Pixbuf> InputDialogImpl::getPix(PixId id) +{ + static std::map<PixId, Glib::RefPtr<Gdk::Pixbuf> > mappings; + + mappings[PIX_CORE] = Gdk::Pixbuf::create_from_xpm_data(core_xpm); + mappings[PIX_PEN] = Gdk::Pixbuf::create_from_xpm_data(pen); + mappings[PIX_MOUSE] = Gdk::Pixbuf::create_from_xpm_data(mouse); + mappings[PIX_TIP] = Gdk::Pixbuf::create_from_xpm_data(tip); + mappings[PIX_TABLET] = Gdk::Pixbuf::create_from_xpm_data(tablet); + mappings[PIX_ERASER] = Gdk::Pixbuf::create_from_xpm_data(eraser); + mappings[PIX_SIDEBUTTONS] = Gdk::Pixbuf::create_from_xpm_data(sidebuttons); + + mappings[PIX_BUTTONS_NONE] = Gdk::Pixbuf::create_from_xpm_data(button_none); + mappings[PIX_BUTTONS_ON] = Gdk::Pixbuf::create_from_xpm_data(button_on); + mappings[PIX_BUTTONS_OFF] = Gdk::Pixbuf::create_from_xpm_data(button_off); + + mappings[PIX_AXIS_NONE] = Gdk::Pixbuf::create_from_xpm_data(axis_none_xpm); + mappings[PIX_AXIS_ON] = Gdk::Pixbuf::create_from_xpm_data(axis_on_xpm); + mappings[PIX_AXIS_OFF] = Gdk::Pixbuf::create_from_xpm_data(axis_off_xpm); + + Glib::RefPtr<Gdk::Pixbuf> pix; + if (mappings.find(id) != mappings.end()) { + pix = mappings[id]; + } + + return pix; +} // Now that we've defined the *Impl class, we can do the method to aquire one. @@ -424,38 +515,23 @@ InputDialog &InputDialog::getInstance() InputDialogImpl::InputDialogImpl() : InputDialog(), - corePix(Gdk::Pixbuf::create_from_xpm_data(core_xpm)), - penPix(Gdk::Pixbuf::create_from_xpm_data(pen)), - mousePix(Gdk::Pixbuf::create_from_xpm_data(mouse)), - tipPix(Gdk::Pixbuf::create_from_xpm_data(tip)), - tabletPix(Gdk::Pixbuf::create_from_xpm_data(tablet)), - eraserPix(Gdk::Pixbuf::create_from_xpm_data(eraser)), - sidebuttonsPix(Gdk::Pixbuf::create_from_xpm_data(sidebuttons)), - - buttonsNonePix(Gdk::Pixbuf::create_from_xpm_data(button_none)), - buttonsOnPix(Gdk::Pixbuf::create_from_xpm_data(button_on)), - buttonsOffPix(Gdk::Pixbuf::create_from_xpm_data(button_off)), - - axisNonePix(Gdk::Pixbuf::create_from_xpm_data(axis_none_xpm)), - axisOnPix(Gdk::Pixbuf::create_from_xpm_data(axis_on_xpm)), - axisOffPix(Gdk::Pixbuf::create_from_xpm_data(axis_off_xpm)), - lastSourceSeen((GdkInputSource)-1), lastDevnameSeen(""), - cols(), - store(Gtk::TreeStore::create(cols)), + store(Gtk::TreeStore::create(getCols())), + tabletIter(), tree(store), frame2(), - testFrame("Test Area"), + testFrame(_("Test Area")), treeScroller(), detailScroller(), splitter(), split2(), linkCombo(), devDetails(12, 2), - confSplitter(), topHolder(), - imageTable(8, 7) + imageTable(8, 7), + testDetector(), + cfgPanel() { Gtk::Box *contents = _getContents(); @@ -469,14 +545,14 @@ InputDialogImpl::InputDialogImpl() : testDetector.add(imageTable); testFrame.add(testDetector); - testThumb.set(tabletPix); + testThumb.set(getPix(PIX_TABLET)); testThumb.set_padding(24, 24); imageTable.attach(testThumb, 0, 8, 0, 1, ::Gtk::EXPAND, ::Gtk::EXPAND); { guint col = 0; guint row = 1; for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) { - testButtons[num].set(buttonsNonePix); + testButtons[num].set(getPix(PIX_BUTTONS_NONE)); imageTable.attach(testButtons[num], col, col + 1, row, row + 1, ::Gtk::FILL, ::Gtk::FILL); col++; if (col > 7) { @@ -487,7 +563,7 @@ InputDialogImpl::InputDialogImpl() : col = 0; for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) { - testAxes[num].set(axisNonePix); + testAxes[num].set(getPix(PIX_AXIS_NONE)); imageTable.attach(testAxes[num], col * 2, (col + 1) * 2, row, row + 1, ::Gtk::FILL, ::Gtk::FILL); col++; if (col > 3) { @@ -498,18 +574,16 @@ InputDialogImpl::InputDialogImpl() : } - topHolder.append_page(confSplitter, "Configuration"); - topHolder.append_page(splitter, "Hardware"); -// confSplitter.show_all(); -// splitter.show_all(); + topHolder.append_page(cfgPanel, _("Configuration")); + topHolder.append_page(splitter, _("Hardware")); topHolder.show_all(); - topHolder.set_current_page(1); + topHolder.set_current_page(0); contents->pack_start(topHolder); int rowNum = 0; - Gtk::Label* lbl = Gtk::manage(new Gtk::Label("Name:")); + Gtk::Label* lbl = Gtk::manage(new Gtk::Label(_("Name:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -519,13 +593,13 @@ InputDialogImpl::InputDialogImpl() : rowNum++; - lbl = Gtk::manage(new Gtk::Label("Link:")); + lbl = Gtk::manage(new Gtk::Label(_("Link:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); - linkCombo.append_text("None"); - linkCombo.set_active_text("None"); + linkCombo.append_text(_("None")); + linkCombo.set_active_text(_("None")); linkCombo.set_sensitive(false); linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged)); @@ -534,7 +608,7 @@ InputDialogImpl::InputDialogImpl() : ::Gtk::SHRINK); rowNum++; - lbl = Gtk::manage(new Gtk::Label("Axes count:")); + lbl = Gtk::manage(new Gtk::Label(_("Axes count:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -545,7 +619,7 @@ InputDialogImpl::InputDialogImpl() : rowNum++; /* - lbl = Gtk::manage(new Gtk::Label("Actual axes count:")); + lbl = Gtk::manage(new Gtk::Label(_("Actual axes count:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -557,7 +631,7 @@ InputDialogImpl::InputDialogImpl() : */ for ( guint barNum = 0; barNum < static_cast<guint>(G_N_ELEMENTS(axesValues)); barNum++ ) { - lbl = Gtk::manage(new Gtk::Label("axis:")); + lbl = Gtk::manage(new Gtk::Label(_("axis:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -569,7 +643,7 @@ InputDialogImpl::InputDialogImpl() : rowNum++; } - lbl = Gtk::manage(new Gtk::Label("Button count:")); + lbl = Gtk::manage(new Gtk::Label(_("Button count:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -580,7 +654,7 @@ InputDialogImpl::InputDialogImpl() : rowNum++; /* - lbl = Gtk::manage(new Gtk::Label("Actual button count:")); + lbl = Gtk::manage(new Gtk::Label(_("Actual button count:"))); devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1, ::Gtk::FILL, ::Gtk::SHRINK); @@ -625,58 +699,67 @@ InputDialogImpl::InputDialogImpl() : - Gtk::TreeModel::Row row; - Gtk::TreeModel::Row childrow; - Gtk::TreeModel::Row deviceRow; - - //Add the TreeView's view columns: - tree.append_column("I", cols.thumbnail); - tree.append_column("Bar", cols.description); + tree.append_column("I", getCols().thumbnail); + tree.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)); + setupTree( store, tabletIter ); - std::list<InputDevice const *> devList = Inkscape::DeviceManager::getManager().getDevices(); + 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<Gtk::TreeView> treePtr(&tree); + Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr)); + + tree.expand_all(); + show_all_children(); +} + +void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIter &tablet ) +{ + std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices(); if ( !devList.empty() ) { - row = *(store->append()); - row[cols.description] = "Hardware"; + Gtk::TreeModel::Row row = *(store->append()); + row[getCols().description] = _("Hardware"); - tabletIter = store->append(row.children()); - childrow = *tabletIter; - childrow[cols.description] = "Tablet"; - childrow[cols.thumbnail] = tabletPix; + tablet = store->append(row.children()); + Gtk::TreeModel::Row childrow = *tablet; + childrow[getCols().description] = _("Tablet"); + childrow[getCols().thumbnail] = getPix(PIX_TABLET); - for ( std::list<InputDevice const *>::iterator it = devList.begin(); it != devList.end(); ++it ) { - InputDevice const* dev = *it; + for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it = devList.begin(); it != devList.end(); ++it ) { + Glib::RefPtr<InputDevice const> dev = *it; if ( dev ) { // g_message("device: name[%s] source[0x%x] mode[0x%x] cursor[%s] axis count[%d] key count[%d]", dev->getName().c_str(), dev->getSource(), dev->getMode(), // dev->hasCursor() ? "Yes":"no", dev->getNumAxes(), dev->getNumKeys()); // if ( dev->getSource() != Gdk::SOURCE_MOUSE ) { if ( dev ) { - deviceRow = *(store->append(childrow.children())); - deviceRow[cols.description] = dev->getName(); - deviceRow[cols.device] = dev; + Gtk::TreeModel::Row deviceRow = *(store->append(childrow.children())); + deviceRow[getCols().description] = dev->getName(); + deviceRow[getCols().device] = dev; + deviceRow[getCols().mode] = dev->getMode(); switch ( dev->getSource() ) { case GDK_SOURCE_MOUSE: - deviceRow[cols.thumbnail] = corePix; + deviceRow[getCols().thumbnail] = getPix(PIX_CORE); break; case GDK_SOURCE_PEN: - if (deviceRow[cols.description] == "pad") { - deviceRow[cols.thumbnail] = sidebuttonsPix; + if (deviceRow[getCols().description] == _("pad")) { + deviceRow[getCols().thumbnail] = getPix(PIX_SIDEBUTTONS); } else { - deviceRow[cols.thumbnail] = tipPix; + deviceRow[getCols().thumbnail] = getPix(PIX_TIP); } break; case GDK_SOURCE_CURSOR: - deviceRow[cols.thumbnail] = mousePix; + deviceRow[getCols().thumbnail] = getPix(PIX_MOUSE); break; case GDK_SOURCE_ERASER: - deviceRow[cols.thumbnail] = eraserPix; + deviceRow[getCols().thumbnail] = getPix(PIX_ERASER); break; default: ; // nothing @@ -689,21 +772,169 @@ InputDialogImpl::InputDialogImpl() : } else { g_warning("No devices found"); } - 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)); - Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceLinks)); +} + + +InputDialogImpl::ConfPanel::ConfPanel() : + Gtk::VBox(), + store(Gtk::TreeStore::create(getCols())), + tabletIter(), + tree(store), + treeScroller(), + watcher(*this), + useExt(_("Use pressure-sensitive tablet (requires restart)")), + save(_("Save")) +{ + pack_start(treeScroller); + + treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + treeScroller.add(tree); + + class Foo : public Gtk::TreeModel::ColumnRecord { + public : + Gtk::TreeModelColumn<Glib::ustring> one; + Foo() {add(one);} + }; + static Foo foo; + Glib::RefPtr<Gtk::ListStore> 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]; + + Gtk::CellRendererCombo *rendr = new Gtk::CellRendererCombo(); + rendr->property_model().set_value(poppers); + rendr->property_text_column().set_value(0); + rendr->property_has_entry() = false; + + //Add the TreeView's view columns: + tree.append_column("I", getCols().thumbnail); + tree.append_column("Bar", getCols().description); + Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("X", *rendr); + if (col) { + tree.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->property_editable() = true; + } + + tree.set_enable_tree_lines(); + tree.set_headers_visible(false); + + setupTree( store, tabletIter ); + + Glib::RefPtr<Gtk::TreeView> treePtr(&tree); + Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr)); tree.expand_all(); - show_all_children(); + + 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); + + save.signal_clicked().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::saveSettings)); + Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_TOP, 0, 0); + align->add(save); + pack_start(*Gtk::manage(align), Gtk::PACK_SHRINK); +} + +InputDialogImpl::ConfPanel::~ConfPanel() +{ +} + +void InputDialogImpl::ConfPanel::setModeCellString(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter) +{ + if (iter) { + Gtk::CellRendererCombo *combo = dynamic_cast<Gtk::CellRendererCombo *>(rndr); + if (combo) { + Glib::RefPtr<InputDevice const> dev = (*iter)[getCols().device]; + Gdk::InputMode mode = (*iter)[getCols().mode]; + if (dev && (getModeToString().find(mode) != getModeToString().end())) { + combo->property_text() = getModeToString()[mode]; + } else { + combo->property_text() = ""; + } + } + } } -void InputDialogImpl::handleDeviceChange(const Glib::RefPtr<InputDevice>& /*device*/) +void InputDialogImpl::ConfPanel::commitCellModeChange(Glib::ustring const &path, Glib::ustring const &newText, Glib::RefPtr<Gtk::TreeStore> store) +{ + Gtk::TreeIter iter = store->get_iter(path); + if (iter) { + Glib::RefPtr<InputDevice const> 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::ConfPanel::saveSettings() +{ + Inkscape::DeviceManager::getManager().saveConfig(); +} + +void InputDialogImpl::ConfPanel::useExtToggled() +{ + bool active = useExt.get_active(); + if (active != Preferences::get()->getBool("/options/useextinput/value")) { + Preferences::get()->setBool("/options/useextinput/value", active); + if (active) { + // As a work-around for a common problem, enable tablet toggles on the calligraphic tool. + // Covered in Launchpad bug #196195. + Preferences::get()->setBool("/tools/tweak/usepressure", true); + Preferences::get()->setBool("/tools/calligraphic/usepressure", true); + Preferences::get()->setBool("/tools/calligraphic/usetilt", true); + } + } +} + +InputDialogImpl::ConfPanel::Blink::Blink(ConfPanel &parent) : + Preferences::Observer("/options/useextinput/value"), + parent(parent) +{ + Preferences::get()->addObserver(*this); +} + +InputDialogImpl::ConfPanel::Blink::~Blink() +{ + Preferences::get()->removeObserver(*this); +} + +void InputDialogImpl::ConfPanel::Blink::notify(Preferences::Entry const &new_val) +{ + parent.useExt.set_active(new_val.getBool()); +} + +void InputDialogImpl::handleDeviceChange(Glib::RefPtr<InputDevice const> device) { // g_message("OUCH!!!! for %p hits %s", &device, device->getId().c_str()); + std::vector<Glib::RefPtr<Gtk::TreeStore> > stores; + stores.push_back(store); + stores.push_back(cfgPanel.store); + + for (std::vector<Glib::RefPtr<Gtk::TreeStore> >::iterator it = stores.begin(); it != stores.end(); ++it) { + Gtk::TreeModel::iterator deviceIter; + (*it)->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>( + sigc::ptr_fun(&InputDialogImpl::findDevice), + device->getId(), + &deviceIter) ); + if ( deviceIter ) { + Gdk::InputMode mode = device->getMode(); + Gtk::TreeModel::Row row = *deviceIter; + if (row[getCols().mode] != mode) { + row[getCols().mode] = mode; + } + } + } } -void InputDialogImpl::updateDeviceAxes(const Glib::RefPtr<InputDevice>& device) +void InputDialogImpl::updateDeviceAxes(Glib::RefPtr<InputDevice const> device) { gint live = device->getLiveAxes(); @@ -720,7 +951,7 @@ void InputDialogImpl::updateDeviceAxes(const Glib::RefPtr<InputDevice>& device) updateTestAxes( device->getId(), 0 ); } -void InputDialogImpl::updateDeviceButtons(const Glib::RefPtr<InputDevice>& device) +void InputDialogImpl::updateDeviceButtons(Glib::RefPtr<InputDevice const> device) { gint live = device->getLiveButtons(); std::set<guint> existing = buttonMap[device->getId()]; @@ -741,7 +972,7 @@ bool InputDialogImpl::findDevice(const Gtk::TreeModel::iterator& iter, Gtk::TreeModel::iterator* result) { bool stop = false; - const InputDevice* dev = (*iter)[cols.device]; + Glib::RefPtr<InputDevice const> dev = (*iter)[getCols().device]; if ( dev && (dev->getId() == id) ) { if ( result ) { *result = iter; @@ -756,7 +987,7 @@ bool InputDialogImpl::findDeviceByLink(const Gtk::TreeModel::iterator& iter, Gtk::TreeModel::iterator* result) { bool stop = false; - const InputDevice* dev = (*iter)[cols.device]; + Glib::RefPtr<InputDevice const> dev = (*iter)[getCols().device]; if ( dev && (dev->getLink() == link) ) { if ( result ) { *result = iter; @@ -766,12 +997,14 @@ bool InputDialogImpl::findDeviceByLink(const Gtk::TreeModel::iterator& iter, return stop; } -void InputDialogImpl::updateDeviceLinks(const Glib::RefPtr<InputDevice>& device) +void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device, Gtk::TreeIter tabletIter, Glib::RefPtr<Gtk::TreeView> tree) { + Glib::RefPtr<Gtk::TreeStore> store = Glib::RefPtr<Gtk::TreeStore>::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<Glib::ustring, Gtk::TreeModel::iterator*>( - sigc::mem_fun(*this, &InputDialogImpl::findDevice), + sigc::ptr_fun(&InputDialogImpl::findDevice), device->getId(), &deviceIter) ); @@ -783,15 +1016,16 @@ void InputDialogImpl::updateDeviceLinks(const Glib::RefPtr<InputDevice>& device) // g_message("Item %s is unlinked", device->getId().c_str()); if ( deviceIter->parent() != tabletIter ) { // Not the child of the tablet. move on up - - InputDevice const *dev = (*deviceIter)[cols.device]; - Glib::ustring descr = (*deviceIter)[cols.description]; - Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[cols.thumbnail]; + + Glib::RefPtr<InputDevice const> dev = (*deviceIter)[getCols().device]; + Glib::ustring descr = (*deviceIter)[getCols().description]; + Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[getCols().thumbnail]; Gtk::TreeModel::Row deviceRow = *store->append(tabletIter->children()); - deviceRow[cols.description] = descr; - deviceRow[cols.thumbnail] = thumb; - deviceRow[cols.device] = dev; + 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); @@ -805,33 +1039,35 @@ void InputDialogImpl::updateDeviceLinks(const Glib::RefPtr<InputDevice>& device) // Simple case. Not already linked Gtk::TreeIter newGroup = store->append(tabletIter->children()); - (*newGroup)[cols.description] = "Pen"; - (*newGroup)[cols.thumbnail] = penPix; + (*newGroup)[getCols().description] = _("Pen"); + (*newGroup)[getCols().thumbnail] = getPix(PIX_PEN); - InputDevice const *dev = (*deviceIter)[cols.device]; - Glib::ustring descr = (*deviceIter)[cols.description]; - Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[cols.thumbnail]; + Glib::RefPtr<InputDevice const> dev = (*deviceIter)[getCols().device]; + Glib::ustring descr = (*deviceIter)[getCols().description]; + Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[getCols().thumbnail]; Gtk::TreeModel::Row deviceRow = *store->append(newGroup->children()); - deviceRow[cols.description] = descr; - deviceRow[cols.thumbnail] = thumb; - deviceRow[cols.device] = dev; + deviceRow[getCols().description] = descr; + deviceRow[getCols().thumbnail] = thumb; + deviceRow[getCols().device] = dev; + deviceRow[getCols().mode] = dev->getMode(); + - Gtk::TreeModel::iterator linkIter; store->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>( - sigc::mem_fun(*this, &InputDialogImpl::findDeviceByLink), + sigc::ptr_fun(&InputDialogImpl::findDeviceByLink), device->getId(), &linkIter) ); if ( linkIter ) { - dev = (*linkIter)[cols.device]; - descr = (*linkIter)[cols.description]; - thumb = (*linkIter)[cols.thumbnail]; + dev = (*linkIter)[getCols().device]; + descr = (*linkIter)[getCols().description]; + thumb = (*linkIter)[getCols().thumbnail]; deviceRow = *store->append(newGroup->children()); - deviceRow[cols.description] = descr; - deviceRow[cols.thumbnail] = thumb; - deviceRow[cols.device] = dev; + 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); if ( oldParent->children().empty() ) { @@ -844,7 +1080,7 @@ void InputDialogImpl::updateDeviceLinks(const Glib::RefPtr<InputDevice>& device) if ( oldParent->children().empty() ) { store->erase(oldParent); } - tree.expand_row(Gtk::TreePath(newGroup), true); + tree->expand_row(Gtk::TreePath(newGroup), true); } } } @@ -855,16 +1091,16 @@ void InputDialogImpl::linkComboChanged() { Gtk::TreeModel::iterator iter = treeSel->get_selected(); if (iter) { Gtk::TreeModel::Row row = *iter; - Glib::ustring val = row[cols.description]; - InputDevice const * dev = row[cols.device]; + Glib::ustring val = row[getCols().description]; + Glib::RefPtr<InputDevice const> dev = row[getCols().device]; if ( dev ) { if ( linkCombo.get_active_row_number() == 0 ) { // It is the "None" entry DeviceManager::getManager().setLinkedTo(dev->getId(), ""); } else { Glib::ustring linkName = linkCombo.get_active_text(); - std::list<InputDevice const *> devList = Inkscape::DeviceManager::getManager().getDevices(); - for ( std::list<InputDevice const *>::const_iterator it = devList.begin(); it != devList.end(); ++it ) { + std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices(); + for ( std::list<Glib::RefPtr<InputDevice const> >::const_iterator it = devList.begin(); it != devList.end(); ++it ) { if ( linkName == (*it)->getName() ) { DeviceManager::getManager().setLinkedTo(dev->getId(), (*it)->getId()); break; @@ -881,19 +1117,19 @@ void InputDialogImpl::resyncToSelection() { Gtk::TreeModel::iterator iter = treeSel->get_selected(); if (iter) { Gtk::TreeModel::Row row = *iter; - Glib::ustring val = row[cols.description]; - InputDevice const * dev = row[cols.device]; + Glib::ustring val = row[getCols().description]; + Glib::RefPtr<InputDevice const> dev = row[getCols().device]; if ( dev ) { devDetails.set_sensitive(true); linkConnection.block(); linkCombo.clear_items(); - linkCombo.append_text("None"); + linkCombo.append_text(_("None")); linkCombo.set_active(0); if ( dev->getSource() != Gdk::SOURCE_MOUSE ) { Glib::ustring linked = dev->getLink(); - std::list<InputDevice const *> devList = Inkscape::DeviceManager::getManager().getDevices(); - for ( std::list<InputDevice const *>::const_iterator it = devList.begin(); it != devList.end(); ++it ) { + std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices(); + for ( std::list<Glib::RefPtr<InputDevice const> >::const_iterator it = devList.begin(); it != devList.end(); ++it ) { if ( ((*it)->getSource() != Gdk::SOURCE_MOUSE) && ((*it) != dev) ) { linkCombo.append_text((*it)->getName().c_str()); if ( (linked.length() > 0) && (linked == (*it)->getId()) ) { @@ -908,7 +1144,7 @@ void InputDialogImpl::resyncToSelection() { linkConnection.unblock(); clear = false; - devName.set_label(row[cols.description]); + devName.set_label(row[getCols().description]); setupValueAndCombo( dev->getNumAxes(), dev->getNumAxes(), devAxesCount, axesCombo); setupValueAndCombo( dev->getNumKeys(), dev->getNumKeys(), devKeyCount, buttonCombo); } @@ -945,12 +1181,12 @@ void InputDialogImpl::updateTestButtons( Glib::ustring const& key, gint hotButto for ( gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(testButtons)); i++ ) { if ( buttonMap[key].find(i) != buttonMap[key].end() ) { if ( i == hotButton ) { - testButtons[i].set(buttonsOnPix); + testButtons[i].set(getPix(PIX_BUTTONS_ON)); } else { - testButtons[i].set(buttonsOffPix); + testButtons[i].set(getPix(PIX_BUTTONS_OFF)); } } else { - testButtons[i].set(buttonsNonePix); + testButtons[i].set(getPix(PIX_BUTTONS_NONE)); } } } @@ -963,8 +1199,8 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) Gtk::TreeModel::iterator iter = treeSel->get_selected(); if (iter) { Gtk::TreeModel::Row row = *iter; - Glib::ustring val = row[cols.description]; - InputDevice const * idev = row[cols.device]; + Glib::ustring val = row[getCols().description]; + Glib::RefPtr<InputDevice const> idev = row[getCols().device]; if ( !idev || (idev->getId() != key) ) { dev = 0; } @@ -977,13 +1213,13 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) switch ( axesMap[key][i].first ) { case 0: case 1: - testAxes[i].set(axisNonePix); + testAxes[i].set(getPix(PIX_AXIS_NONE)); if ( dev && (i < static_cast<gint>(G_N_ELEMENTS(axesValues)) ) ) { axesValues[i].set_sensitive(false); } break; case 2: - testAxes[i].set(axisOffPix); + testAxes[i].set(getPix(PIX_AXIS_OFF)); axesValues[i].set_sensitive(true); if ( dev && (i < static_cast<gint>(G_N_ELEMENTS(axesValues)) ) ) { if ( (dev->axes[i].max - dev->axes[i].min) > epsilon ) { @@ -996,7 +1232,7 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) } break; case 3: - testAxes[i].set(axisOnPix); + testAxes[i].set(getPix(PIX_AXIS_ON)); axesValues[i].set_sensitive(true); if ( dev && (i < static_cast<gint>(G_N_ELEMENTS(axesValues)) ) ) { if ( (dev->axes[i].max - dev->axes[i].min) > epsilon ) { @@ -1010,7 +1246,7 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) } } else { - testAxes[i].set(axisNonePix); + testAxes[i].set(getPix(PIX_AXIS_NONE)); } } if ( !dev ) { @@ -1180,30 +1416,30 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event) switch (source) { case GDK_SOURCE_MOUSE: { - testThumb.set(corePix); + testThumb.set(getPix(PIX_CORE)); } break; case GDK_SOURCE_CURSOR: { // g_message("flip to cursor"); - testThumb.set(mousePix); + testThumb.set(getPix(PIX_MOUSE)); } break; case GDK_SOURCE_PEN: { - if (devName == "pad") { + if (devName == _("pad")) { // g_message("flip to pad"); - testThumb.set(sidebuttonsPix); + testThumb.set(getPix(PIX_SIDEBUTTONS)); } else { // g_message("flip to pen"); - testThumb.set(tipPix); + testThumb.set(getPix(PIX_TIP)); } } break; case GDK_SOURCE_ERASER: { // g_message("flip to eraser"); - testThumb.set(eraserPix); + testThumb.set(getPix(PIX_ERASER)); } break; // default: diff --git a/src/ui/dialog/input.h b/src/ui/dialog/input.h index 38666f52c..186612af0 100644 --- a/src/ui/dialog/input.h +++ b/src/ui/dialog/input.h @@ -25,7 +25,7 @@ class InputDialog : public UI::Widget::Panel public: static InputDialog &getInstance(); - InputDialog() : UI::Widget::Panel("", "/dialogs/inputdevices2", SP_VERB_DIALOG_INPUT2) {} + InputDialog() : UI::Widget::Panel("", "/dialogs/inputdevices", SP_VERB_DIALOG_INPUT) {} virtual ~InputDialog() {} }; diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index 7dbb6dd4a..dc01c6a29 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -30,14 +30,14 @@ namespace Dialog { class PanelDialogBase { public: - PanelDialogBase(Panel &panel, char const */*prefs_path*/, int const /*verb_num*/, + PanelDialogBase(UI::Widget::Panel &panel, char const */*prefs_path*/, int const /*verb_num*/, Glib::ustring const &/*apply_label*/) : _panel (panel) { } virtual void present() = 0; virtual ~PanelDialogBase() {} - virtual Panel &getPanel() { return _panel; } + virtual UI::Widget::Panel &getPanel() { return _panel; } protected: static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { @@ -54,7 +54,7 @@ protected: inline virtual void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *); inline virtual void _propagateDesktopDeactivated(Inkscape::Application *, SPDesktop *); - Panel &_panel; + UI::Widget::Panel &_panel; sigc::connection _document_replaced_connection; }; @@ -62,7 +62,7 @@ template <typename Behavior> class PanelDialog : public PanelDialogBase, public Inkscape::UI::Dialog::Dialog { public: - PanelDialog(Panel &contents, char const *prefs_path, int const verb_num, + PanelDialog(UI::Widget::Panel &contents, char const *prefs_path, int const verb_num, Glib::ustring const &apply_label); virtual ~PanelDialog() {} @@ -86,7 +86,7 @@ class PanelDialog<Behavior::FloatingBehavior> : public PanelDialogBase, public Inkscape::UI::Dialog::Dialog { public: - inline PanelDialog(Panel &contents, char const *prefs_path, int const verb_num, + inline PanelDialog(UI::Widget::Panel &contents, char const *prefs_path, int const verb_num, Glib::ustring const &apply_label); virtual ~PanelDialog() {} @@ -128,7 +128,7 @@ PanelDialogBase::_propagateDesktopDeactivated(Inkscape::Application *application template <typename B> -PanelDialog<B>::PanelDialog(Panel &panel, char const *prefs_path, int const verb_num, +PanelDialog<B>::PanelDialog(Widget::Panel &panel, char const *prefs_path, int const verb_num, Glib::ustring const &apply_label) : PanelDialogBase(panel, prefs_path, verb_num, apply_label), Dialog(&B::create, prefs_path, verb_num, apply_label) @@ -163,7 +163,7 @@ template <typename B> template <typename P> PanelDialog<B> * PanelDialog<B>::create() { - Panel &panel = P::getInstance(); + UI::Widget::Panel &panel = P::getInstance(); return new PanelDialog<B>(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); } @@ -171,17 +171,17 @@ template <typename B> void PanelDialog<B>::present() { - _panel.present(); + _panel.present(); } template <typename B> void PanelDialog<B>::_presentDialog() { - Dialog::present(); + Dialog::present(); } -PanelDialog<Behavior::FloatingBehavior>::PanelDialog(Panel &panel, char const *prefs_path, +PanelDialog<Behavior::FloatingBehavior>::PanelDialog(UI::Widget::Panel &panel, char const *prefs_path, int const verb_num, Glib::ustring const &apply_label) : PanelDialogBase(panel, prefs_path, verb_num, apply_label), Dialog(&Behavior::FloatingBehavior::create, prefs_path, verb_num, apply_label) @@ -213,7 +213,7 @@ PanelDialog<Behavior::FloatingBehavior>::PanelDialog(Panel &panel, char const *p void PanelDialog<Behavior::FloatingBehavior>::present() -{ +{ Dialog::present(); _panel.present(); } @@ -226,7 +226,7 @@ template <typename P> PanelDialog<Behavior::FloatingBehavior> * PanelDialog<Behavior::FloatingBehavior>::create() { - Panel &panel = P::getInstance(); + UI::Widget::Panel &panel = P::getInstance(); PanelDialog<Behavior::FloatingBehavior> *instance = new PanelDialog<Behavior::FloatingBehavior>(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index e0191c589..6be346582 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -31,6 +31,7 @@ #include "sp-item.h" #include "widgets/icon.h" #include "tile.h" +#include "desktop.h" /* * Sort items by their x co-ordinates, taking account of y (keeps rows intact) @@ -161,7 +162,7 @@ void TileDialog::Grid_Arrange () sp_document_ensure_up_to_date(sp_desktop_document(desktop)); Inkscape::Selection *selection = sp_desktop_selection (desktop); - const GSList *items = selection->itemList(); + const GSList *items = selection ? selection->itemList() : 0; cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); @@ -193,6 +194,7 @@ void TileDialog::Grid_Arrange () // require the sorting done before we can calculate row heights etc. + g_return_if_fail(selection); const GSList *items2 = selection->itemList(); GSList *rev = g_slist_copy((GSList *) items2); GSList *sorted = NULL; @@ -373,7 +375,8 @@ void TileDialog::on_row_spinbutton_changed() updating = true; SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); GSList const *items = selection->itemList(); int selcount = g_slist_length((GSList *)items); @@ -398,7 +401,8 @@ void TileDialog::on_col_spinbutton_changed() // in turn, prevent listener from responding updating = true; SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail(selection); GSList const *items = selection->itemList(); int selcount = g_slist_length((GSList *)items); @@ -560,32 +564,33 @@ void TileDialog::updateSelection() // in turn, prevent listener from responding updating = true; SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); - const GSList *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); - - if (NoOfColsSpinner.get_value()>1 && NoOfRowsSpinner.get_value()>1){ - // Update the number of rows assuming number of columns wanted remains same. - double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); - NoOfRowsSpinner.set_value(NoOfRows); - - // if the selection has less than the number set for one row, reduce it appropriately - if (selcount<NoOfColsSpinner.get_value()) { - double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); - NoOfColsSpinner.set_value(NoOfCols); - prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + GSList const *items = selection ? selection->itemList() : 0; + + if (items) { + int selcount = g_slist_length((GSList *)items); + + if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ + // Update the number of rows assuming number of columns wanted remains same. + double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); + NoOfRowsSpinner.set_value(NoOfRows); + + // if the selection has less than the number set for one row, reduce it appropriately + if (selcount < NoOfColsSpinner.get_value()) { + double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); + NoOfColsSpinner.set_value(NoOfCols); + prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); + } + } else { + double PerRow = ceil(sqrt(selcount)); + double PerCol = ceil(sqrt(selcount)); + NoOfRowsSpinner.set_value(PerRow); + NoOfColsSpinner.set_value(PerCol); + prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast<int>(PerCol)); } - } else { - double PerRow = ceil(sqrt(selcount)); - double PerCol = ceil(sqrt(selcount)); - NoOfRowsSpinner.set_value(PerRow); - NoOfColsSpinner.set_value(PerCol); - prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast<int>(PerCol)); - } - updating=false; - + updating = false; } @@ -632,7 +637,8 @@ TileDialog::TileDialog() SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { GSList const *items = selection->itemList(); diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 075b2b33f..9ade64935 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -66,10 +66,7 @@ public: void VertAlign_changed(); void HorizAlign_changed(); - static TileDialog& getInstance() { - static TileDialog instance; - return instance; - } + static TileDialog& getInstance() { return *new TileDialog(); } private: TileDialog(TileDialog const &d); // no copy diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h index 9d05713ad..0607871fd 100644 --- a/src/ui/dialog/transformation.h +++ b/src/ui/dialog/transformation.h @@ -26,8 +26,6 @@ #include "ui/widget/button.h" -using namespace Inkscape::UI::Widget; - namespace Inkscape { @@ -105,36 +103,36 @@ protected: Gtk::Notebook _notebook; - NotebookPage _page_move; - NotebookPage _page_scale; - NotebookPage _page_rotate; - NotebookPage _page_skew; - NotebookPage _page_transform; - - UnitMenu _units_move; - UnitMenu _units_scale; - UnitMenu _units_rotate; - UnitMenu _units_skew; - - ScalarUnit _scalar_move_horizontal; - ScalarUnit _scalar_move_vertical; - ScalarUnit _scalar_scale_horizontal; - ScalarUnit _scalar_scale_vertical; - ScalarUnit _scalar_rotate; - ScalarUnit _scalar_skew_horizontal; - ScalarUnit _scalar_skew_vertical; - - Scalar _scalar_transform_a; - Scalar _scalar_transform_b; - Scalar _scalar_transform_c; - Scalar _scalar_transform_d; - Scalar _scalar_transform_e; - Scalar _scalar_transform_f; - - CheckButton _check_move_relative; - CheckButton _check_scale_proportional; - CheckButton _check_apply_separately; - CheckButton _check_replace_matrix; + UI::Widget::NotebookPage _page_move; + UI::Widget::NotebookPage _page_scale; + UI::Widget::NotebookPage _page_rotate; + UI::Widget::NotebookPage _page_skew; + UI::Widget::NotebookPage _page_transform; + + UI::Widget::UnitMenu _units_move; + UI::Widget::UnitMenu _units_scale; + UI::Widget::UnitMenu _units_rotate; + UI::Widget::UnitMenu _units_skew; + + UI::Widget::ScalarUnit _scalar_move_horizontal; + UI::Widget::ScalarUnit _scalar_move_vertical; + UI::Widget::ScalarUnit _scalar_scale_horizontal; + UI::Widget::ScalarUnit _scalar_scale_vertical; + UI::Widget::ScalarUnit _scalar_rotate; + UI::Widget::ScalarUnit _scalar_skew_horizontal; + UI::Widget::ScalarUnit _scalar_skew_vertical; + + UI::Widget::Scalar _scalar_transform_a; + UI::Widget::Scalar _scalar_transform_b; + UI::Widget::Scalar _scalar_transform_c; + UI::Widget::Scalar _scalar_transform_d; + UI::Widget::Scalar _scalar_transform_e; + UI::Widget::Scalar _scalar_transform_f; + + UI::Widget::CheckButton _check_move_relative; + UI::Widget::CheckButton _check_scale_proportional; + UI::Widget::CheckButton _check_apply_separately; + UI::Widget::CheckButton _check_replace_matrix; /** * Layout the GUI components, and prepare for use diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 443e7f258..b5f420597 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -316,7 +316,8 @@ void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value) Glib::ustring entry_name = value->getEntryName(); if (entry_name == "show_handles") { - nt->_multipath->showHandles(value->getBool(true)); + nt->show_handles = value->getBool(true); + nt->_multipath->showHandles(nt->show_handles); } else if (entry_name == "show_outline") { nt->show_outline = value->getBool(); nt->_multipath->showOutline(nt->show_outline); @@ -491,6 +492,7 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) ink_node_tool_update_tip(nt, event); return TRUE; case GDK_a: + case GDK_A: if (held_control(event->key) && held_alt(event->key)) { nt->_selected_nodes->selectAll(); // Ctrl+A is handled in selection-chemistry.cpp via verb @@ -498,6 +500,14 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) return TRUE; } break; + case GDK_h: + case GDK_H: + if (held_only_control(event->key)) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setBool("/tools/nodes/show_handles", !nt->show_handles); + return TRUE; + } + break; default: break; } diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index baac642ac..641d064c1 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -58,6 +58,7 @@ struct InkNodeTool : public SPEventContext SPItem *_last_over; unsigned cursor_drag : 1; + unsigned show_handles : 1; unsigned show_outline : 1; unsigned live_outline : 1; unsigned live_objects : 1; diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 6a817e30d..71ba4428c 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -295,7 +295,7 @@ void ImageIcon::showBrokenImage(const Glib::ustring &errorMessage) " <text" " xml:space='preserve'" " id='text1644'" - " style='font-size:12.000000;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Bitstream Vera Sans'" + " style='font-size:12.000000;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Sans'" " y='59.288345'" " x='12.760736'><tspan" " id='tspan1646'" diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 93a950d1a..4b806afb5 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -133,9 +133,9 @@ void Panel::_init() { //TRANSLATORS: only translate "string" in "context|string". // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - Glib::ustring heightItemLabel(Q_("swatches|Size")); + Glib::ustring heightItemLabel(Q_("swatches|Size")); - //TRANSLATORS: Indicates size of colour swatches + //TRANSLATORS: Indicates size of colour swatches const gchar *heightLabels[] = { N_("tiny"), N_("small"), @@ -157,7 +157,7 @@ void Panel::_init() Gtk::RadioMenuItem* _item = manage(new Gtk::RadioMenuItem(heightGroup, _label)); sizeMenu->append(*_item); if (i == panel_size) { - _item->set_active(true); + _item->set_active(true); } _item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_SIZE, i)); } @@ -198,11 +198,11 @@ void Panel::_init() } } for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) { - Glib::ustring _label(Q_(widthLabels[i])); + Glib::ustring _label(Q_(widthLabels[i])); Gtk::RadioMenuItem *_item = manage(new Gtk::RadioMenuItem(widthGroup, _label)); type_menu->append(*_item); if ( i <= hot_index ) { - _item->set_active(true); + _item->set_active(true); } _item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_SHAPE, values[i])); } @@ -212,7 +212,7 @@ void Panel::_init() //TRANSLATORS: only translate "string" in "context|string". // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS // "Wrap" indicates how colour swatches are displayed - Glib::ustring wrap_label(Q_("swatches|Wrap")); + Glib::ustring wrap_label(Q_("swatches|Wrap")); Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrap_label)); check->set_active(panel_wrap); _menu->append(*check); |
