diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-06-19 10:00:24 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-06-19 10:00:24 +0000 |
| commit | 06dfaa02d7a80bcdff717d579a48f81643f53f31 (patch) | |
| tree | 49b8e67ad9051f1507b0959cac986383ab4001e2 /src/ui | |
| parent | Fix rendering of control points (diff) | |
| parent | fix bug 796451: Measure tools should support rotation constraint (diff) | |
| download | inkscape-06dfaa02d7a80bcdff717d579a48f81643f53f31.tar.gz inkscape-06dfaa02d7a80bcdff717d579a48f81643f53f31.zip | |
Merge from trunk
(bzr r9508.1.89)
Diffstat (limited to 'src/ui')
73 files changed, 1382 insertions, 520 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 01dadb7c2..30b72437f 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,24 +1,247 @@ -SET(uifolders -cache -dialog -view -widget -) -FOREACH(uilistsrc ${uifolders}) - ADD_SUBDIRECTORY(${uilistsrc}) -ENDFOREACH(uilistsrc) - -SET(ui_SRC -clipboard.cpp -context-menu.cpp -previewholder.cpp -stock.cpp -stock-items.cpp -${ui_cache_SRC} -${ui_dialog_SRC} -${ui_view_SRC} -${ui_widget_SRC} + +set(ui_SRC + clipboard.cpp + context-menu.cpp + previewholder.cpp + uxmanager.cpp + + cache/svg_preview_cache.cpp + + tool/control-point-selection.cpp + tool/control-point.cpp + tool/curve-drag-point.cpp + tool/event-utils.cpp + tool/manipulator.cpp + tool/modifier-tracker.cpp + tool/multi-path-manipulator.cpp + tool/node-tool.cpp + tool/node.cpp + tool/path-manipulator.cpp + tool/selectable-control-point.cpp + tool/selector.cpp + tool/transform-handle-set.cpp + + dialog/aboutbox.cpp + dialog/align-and-distribute.cpp + dialog/calligraphic-profile-rename.cpp + dialog/color-item.cpp + dialog/debug.cpp + dialog/desktop-tracker.cpp + dialog/dialog-manager.cpp + dialog/dialog.cpp + dialog/dock-behavior.cpp + dialog/document-metadata.cpp + dialog/document-properties.cpp + dialog/extension-editor.cpp + dialog/extensions.cpp + dialog/filedialog.cpp + dialog/filedialogimpl-gtkmm.cpp + dialog/fill-and-stroke.cpp + dialog/filter-effects-dialog.cpp + dialog/find.cpp + dialog/floating-behavior.cpp + dialog/glyphs.cpp + dialog/guides.cpp + dialog/icon-preview.cpp + dialog/inkscape-preferences.cpp + dialog/input.cpp + dialog/layer-properties.cpp + dialog/layers.cpp + dialog/livepatheffect-editor.cpp + dialog/memory.cpp + dialog/messages.cpp + dialog/ocaldialogs.cpp + dialog/print-colors-preview-dialog.cpp + dialog/print.cpp + dialog/scriptdialog.cpp + # dialog/session-player.cpp + dialog/svg-fonts-dialog.cpp + dialog/swatches.cpp + dialog/tile.cpp + dialog/tracedialog.cpp + dialog/transformation.cpp + dialog/undo-history.cpp + # dialog/whiteboard-connect.cpp + # dialog/whiteboard-sharewithchat.cpp + # dialog/whiteboard-sharewithuser.cpp + + widget/button.cpp + widget/color-picker.cpp + widget/color-preview.cpp + widget/combo-text.cpp + widget/dock-item.cpp + widget/dock.cpp + widget/entity-entry.cpp + widget/entry.cpp + widget/filter-effect-chooser.cpp + widget/handlebox.cpp + widget/icon-widget.cpp + widget/imageicon.cpp + widget/imagetoggler.cpp + widget/labelled.cpp + widget/layer-selector.cpp + widget/licensor.cpp + widget/notebook-page.cpp + widget/object-composite-settings.cpp + widget/page-sizer.cpp + widget/panel.cpp + widget/point.cpp + widget/preferences-widget.cpp + widget/random.cpp + widget/registered-widget.cpp + widget/registry.cpp + widget/rendering-options.cpp + widget/rotateable.cpp + widget/ruler.cpp + widget/scalar-unit.cpp + widget/scalar.cpp + widget/selected-style.cpp + widget/spin-slider.cpp + widget/spinbutton.cpp + widget/style-subject.cpp + widget/style-swatch.cpp + widget/svg-canvas.cpp + widget/text.cpp + widget/tolerance-slider.cpp + widget/toolbox.cpp + widget/unit-menu.cpp + widget/zoom-status.cpp + + view/view.cpp + view/view-widget.cpp + + + # ------- + # Headers + clipboard.h + context-menu.h + icon-names.h + previewable.h + previewfillable.h + previewholder.h + uxmanager.h + + cache/svg_preview_cache.h + + dialog/aboutbox.h + dialog/align-and-distribute.h + dialog/behavior.h + dialog/calligraphic-profile-rename.h + dialog/color-item.h + dialog/debug.h + dialog/desktop-tracker.h + dialog/dialog-manager.h + dialog/dialog.h + dialog/dock-behavior.h + dialog/document-metadata.h + dialog/document-properties.h + dialog/extension-editor.h + dialog/extensions.h + dialog/filedialog.h + dialog/filedialogimpl-gtkmm.h + dialog/filedialogimpl-win32.h + dialog/fill-and-stroke.h + dialog/filter-effects-dialog.h + dialog/find.h + dialog/floating-behavior.h + dialog/glyphs.h + dialog/guides.h + dialog/icon-preview.h + dialog/inkscape-preferences.h + dialog/input.h + dialog/layer-properties.h + dialog/layers.h + dialog/livepatheffect-editor.h + dialog/memory.h + dialog/messages.h + dialog/ocaldialogs.h + dialog/panel-dialog.h + dialog/print-colors-preview-dialog.h + dialog/print.h + dialog/scriptdialog.h + dialog/session-player.h + dialog/svg-fonts-dialog.h + dialog/swatches.h + dialog/tile.h + dialog/tracedialog.h + dialog/transformation.h + dialog/undo-history.h + dialog/whiteboard-connect.h + dialog/whiteboard-sharewithchat.h + dialog/whiteboard-sharewithuser.h + + tool/commit-events.h + tool/control-point-selection.h + tool/control-point.h + tool/curve-drag-point.h + tool/event-utils.h + tool/manipulator.h + tool/modifier-tracker.h + tool/multi-path-manipulator.h + tool/node-tool.h + tool/node-types.h + tool/node.h + tool/path-manipulator.h + tool/selectable-control-point.h + tool/selector.h + tool/shape-record.h + tool/transform-handle-set.h + + view/edit-widget-interface.h + view/view-widget.h + view/view.h + + widget/attr-widget.h + widget/button.h + widget/color-picker.h + widget/color-preview.h + widget/combo-enums.h + widget/combo-text.h + widget/dock-item.h + widget/dock.h + widget/entity-entry.h + widget/entry.h + widget/filter-effect-chooser.h + widget/handlebox.h + widget/icon-widget.h + widget/imageicon.h + widget/imagetoggler.h + widget/labelled.h + widget/layer-selector.h + widget/licensor.h + widget/notebook-page.h + widget/object-composite-settings.h + widget/page-sizer.h + widget/panel.h + widget/point.h + widget/preferences-widget.h + widget/random.h + widget/registered-enums.h + widget/registered-widget.h + widget/registry.h + widget/rendering-options.h + widget/rotateable.h + widget/ruler.h + widget/scalar-unit.h + widget/scalar.h + widget/selected-style.h + widget/spin-slider.h + widget/spinbutton.h + widget/style-subject.h + widget/style-swatch.h + widget/svg-canvas.h + widget/text.h + widget/tolerance-slider.h + widget/toolbox.h + widget/unit-menu.h + widget/zoom-status.h ) -ADD_LIBRARY(ui STATIC ${ui_SRC}) -TARGET_LINK_LIBRARIES(ui -2geom ${INKSCAPE_LIBS})
\ No newline at end of file + +if(WIN32) + list(APPEND ui_SRC + dialog/filedialogimpl-win32.cpp + ) +endif() + +# add_inkscape_lib(ui_LIB "${ui_SRC}") +add_inkscape_source("${ui_SRC}") diff --git a/src/ui/cache/CMakeLists.txt b/src/ui/cache/CMakeLists.txt deleted file mode 100644 index a78010196..000000000 --- a/src/ui/cache/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -SET(ui_cache_SRC -svg_preview_cache.cpp -) diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 4f4f8a022..60379a966 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -894,7 +894,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) SPDocument *target_document = sp_desktop_document(desktop); Inkscape::XML::Node *root = clipdoc->getReprRoot(); Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); - Inkscape::XML::Node *target_defs = SP_DOCUMENT_DEFS(target_document)->getRepr(); + Inkscape::XML::Node *target_defs = target_document->getDefs()->getRepr(); Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); prevent_id_clashes(clipdoc, target_document); @@ -1197,7 +1197,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) gdouble dpi = PX_PER_IN; guint32 bgcolor = 0x00000000; - Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed); + Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); @@ -1254,7 +1254,7 @@ void ClipboardManagerImpl::_createInternalClipboard() if ( _clipboardSPDoc == NULL ) { _clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); - _defs = SP_DOCUMENT_DEFS(_clipboardSPDoc)->getRepr(); + _defs = _clipboardSPDoc->getDefs()->getRepr(); _doc = _clipboardSPDoc->getReprDoc(); _root = _clipboardSPDoc->getReprRoot(); diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 05fe9a459..a45b8ceaa 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -42,7 +42,7 @@ sp_object_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* Implementation */ -#include <gtk/gtkmenuitem.h> +#include <gtk/gtk.h> #include <glibmm/i18n.h> @@ -111,7 +111,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Object Properties...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_properties), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Separator */ @@ -124,21 +124,21 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_widget_set_sensitive(w, FALSE); } else { gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_select_this), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_this), item); } gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Create link */ w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_create_link), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_create_link), item); gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item)); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Set mask */ w = gtk_menu_item_new_with_mnemonic(_("Set Mask")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_mask), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_mask), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); } else { @@ -149,7 +149,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Release mask */ w = gtk_menu_item_new_with_mnemonic(_("Release Mask")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_mask), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_mask), item); if (item && item->mask_ref && item->mask_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); } else { @@ -160,7 +160,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Set Clip */ w = gtk_menu_item_new_with_mnemonic(_("Set _Clip")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_clip), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_clip), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); } else { @@ -171,7 +171,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Release Clip */ w = gtk_menu_item_new_with_mnemonic(_("Release C_lip")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_clip), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_clip), item); if (item && item->clip_ref && item->clip_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); } else { @@ -312,7 +312,7 @@ sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* "Ungroup" */ w = gtk_menu_item_new_with_mnemonic(_("_Ungroup")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_group_ungroup_activate), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_group_ungroup_activate), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(menu), w); } @@ -352,18 +352,18 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Link _Properties...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_properties), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Select item */ w = gtk_menu_item_new_with_mnemonic(_("_Follow Link")); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_follow), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_follow), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Reset transformations */ w = gtk_menu_item_new_with_mnemonic(_("_Remove Link")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_remove), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_remove), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); } @@ -411,13 +411,13 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Image _Properties...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_properties), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_edit), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_edit), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); Inkscape::XML::Node *ir = object->getRepr(); @@ -534,7 +534,7 @@ sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); } @@ -590,21 +590,21 @@ sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Fill and Stroke dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Edit Text dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Text and Font...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_text_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_text_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Spellcheck dialog */ w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_spellcheck_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_spellcheck_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); } diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index 36846edc3..1f8208ebe 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -11,7 +11,7 @@ * This code is in public domain */ -#include <gtk/gtkmenu.h> +#include <gtk/gtk.h> #include "forward.h" #include "sp-object.h" diff --git a/src/ui/dialog/CMakeLists.txt b/src/ui/dialog/CMakeLists.txt deleted file mode 100644 index 98c4a47bb..000000000 --- a/src/ui/dialog/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -IF(WIN32) -SET(ui_dialog_WIN32_SRC -filedialogimpl-win32.cpp -) -ELSEIF(WIN32) - SET(ui_dialog_WIN32_SRC) -ENDIF(WIN32) - -SET(ui_dialog_SRC -aboutbox.cpp -align-and-distribute.cpp -color-item.cpp -debug.cpp -dialog.cpp -dialog-manager.cpp -dock-behavior.cpp -document-metadata.cpp -document-properties.cpp -extension-editor.cpp -eek-preview.cpp -ege-paint-def.cpp -filedialog.cpp -filedialogimpl-gtkmm.cpp -fill-and-stroke.cpp -filter-effects-dialog.cpp -find.cpp -floating-behavior.cpp -inkscape-preferences.cpp -input.cpp -livepatheffect-editor.cpp -memory.cpp -messages.cpp -ocaldialogs.cpp -print.cpp -scriptdialog.cpp -#session-player.cpp -tile.cpp -tracedialog.cpp -transformation.cpp -undo-history.cpp -#whiteboard-connect.cpp -#whiteboard-sharewithchat.cpp -#whiteboard-sharewithuser.cpp -${ui_dialog_WIN32_SRC} -) diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index f974ec6ce..a2169c0b3 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -20,7 +20,7 @@ # include <config.h> #endif -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include "desktop-handles.h" #include "unclump.h" @@ -43,6 +43,7 @@ #include "util/glib-list-iterators.h" #include "verbs.h" #include "widgets/icon.h" +#include "sp-root.h" #include "align-and-distribute.h" @@ -171,7 +172,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = static_cast<SPItem *>( sp_desktop_document(desktop)->getRoot() )->getBboxDesktop(); + Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->getBboxDesktop(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -445,8 +446,8 @@ class ActionRemoveOverlaps : public Action { private: Gtk::Label removeOverlapXGapLabel; Gtk::Label removeOverlapYGapLabel; - Gtk::SpinButton removeOverlapXGap; - Gtk::SpinButton removeOverlapYGap; + Inkscape::UI::Widget::SpinButton removeOverlapXGap; + Inkscape::UI::Widget::SpinButton removeOverlapYGap; public: ActionRemoveOverlaps(Glib::ustring const &id, diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 014273274..89245575c 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -13,8 +13,8 @@ #include <errno.h> #include <glibmm/i18n.h> #include <gtkmm/label.h> -#include <gtk/gtkdnd.h> #include <cairo.h> +#include <gtk/gtk.h> #include "color-item.h" diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0c001da4b..569dd2311 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -88,6 +88,7 @@ DocumentProperties::DocumentProperties() : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW), _page_page(1, 1, true, true), _page_guides(1, 1), _page_snap(1, 1), _page_cms(1, 1), _page_scripting(1, 1), + _page_external_scripts(1, 1), _page_embedded_scripts(1, 1), //--------------------------------------------------------------- _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), @@ -145,7 +146,7 @@ DocumentProperties::init() Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->addListener (&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->addListener (&_repr_events, this); show_all_children(); @@ -156,7 +157,7 @@ DocumentProperties::~DocumentProperties() { Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->removeListenerByData (this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->removeListenerByData (this); } @@ -421,7 +422,7 @@ DocumentProperties::linkSelectedProfile() xml_doc->root()->addChild(defsRepr, NULL); } - g_assert(SP_ROOT(desktop->doc()->root)->defs); + g_assert(desktop->doc()->getDefs()); defsRepr->addChild(cprofRepr, NULL); // TODO check if this next line was sometimes needed. It being there caused an assertion. @@ -459,6 +460,13 @@ void DocumentProperties::external_scripts_list_button_release(GdkEventButton* ev } } +void DocumentProperties::embedded_scripts_list_button_release(GdkEventButton* event) +{ + if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) { + _EmbeddedScriptsContextMenu.popup(event->button, event->time); + } +} + void DocumentProperties::linked_profiles_list_button_release(GdkEventButton* event) { if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) { @@ -476,7 +484,7 @@ void DocumentProperties::cms_create_popup_menu(Gtk::Widget& parent, sigc::slot<v } -void DocumentProperties::scripting_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) +void DocumentProperties::external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) { Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE)); _ExternalScriptsContextMenu.append(*mi); @@ -485,6 +493,15 @@ void DocumentProperties::scripting_create_popup_menu(Gtk::Widget& parent, sigc:: _ExternalScriptsContextMenu.accelerate(parent); } +void DocumentProperties::embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) +{ + Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE)); + _EmbeddedScriptsContextMenu.append(*mi); + mi->signal_activate().connect(rem); + mi->show(); + _EmbeddedScriptsContextMenu.accelerate(parent); +} + void DocumentProperties::removeSelectedProfile(){ Glib::ustring name; if(_LinkedProfilesList.get_selection()) { @@ -584,27 +601,36 @@ DocumentProperties::build_scripting() { _page_scripting.show(); - Gtk::Label *label_script= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); - label_script->set_markup (_("<b>External script files:</b>")); + _page_scripting.set_spacing (4); + _page_scripting.pack_start(_scripting_notebook, true, true); + + _scripting_notebook.append_page(_page_external_scripts, _("External scripts")); + _scripting_notebook.append_page(_page_embedded_scripts, _("Embedded scripts")); + + //# External scripts tab + _page_external_scripts.show(); + + Gtk::Label *label_external= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_external->set_markup (_("<b>External script files:</b>")); _add_btn.set_label(_("Add")); - _page_scripting.set_spacing(4); + _page_external_scripts.set_spacing(4); gint row = 0; - label_script->set_alignment(0.0); - _page_scripting.table().attach(*label_script, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + label_external->set_alignment(0.0); + _page_external_scripts.table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - _page_scripting.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox()); - spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); - _page_scripting.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox()); + spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); + _page_external_scripts.table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - _page_scripting.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_scripting.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; //# Set up the External Scripts box @@ -614,7 +640,58 @@ DocumentProperties::build_scripting() _ExternalScriptsList.set_headers_visible(true); // TODO restore? _ExternalScriptsList.set_fixed_height_mode(true); - populate_external_scripts_box(); + + //# Embedded scripts tab + _page_embedded_scripts.show(); + + Gtk::Label *label_embedded= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_embedded->set_markup (_("<b>Embedded script files:</b>")); + + _new_btn.set_label(_("New")); + + _page_embedded_scripts.set_spacing(4); + row = 0; + + label_embedded->set_alignment(0.0); + _page_embedded_scripts.table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + _page_embedded_scripts.table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox()); + spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); + _page_embedded_scripts.table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + _page_embedded_scripts.table().attach(_new_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + //# Set up the Embedded Scripts box + _EmbeddedScriptsListStore = Gtk::ListStore::create(_EmbeddedScriptsListColumns); + _EmbeddedScriptsList.set_model(_EmbeddedScriptsListStore); + _EmbeddedScriptsList.append_column(_("Script id"), _EmbeddedScriptsListColumns.idColumn); + _EmbeddedScriptsList.set_headers_visible(true); +// TODO restore? _EmbeddedScriptsList.set_fixed_height_mode(true); + + //# Set up the Embedded Scripts content box + Gtk::Label *label_embedded_content= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_embedded_content->set_markup (_("<b>Content:</b>")); + + label_embedded_content->set_alignment(0.0); + _page_embedded_scripts.table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + _page_embedded_scripts.table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + + _EmbeddedContentScroller.add(_EmbeddedContent); + _EmbeddedContentScroller.set_shadow_type(Gtk::SHADOW_IN); + _EmbeddedContentScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _EmbeddedContentScroller.set_size_request(-1, -1); + + _EmbeddedScriptsList.signal_cursor_changed().connect(sigc::mem_fun(*this, &DocumentProperties::changeEmbeddedScript)); + _EmbeddedContent.get_buffer()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::editEmbeddedScript)); + + populate_script_lists(); _ExternalScriptsListScroller.add(_ExternalScriptsList); _ExternalScriptsListScroller.set_shadow_type(Gtk::SHADOW_IN); @@ -623,17 +700,28 @@ DocumentProperties::build_scripting() _add_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::addExternalScript)); + _EmbeddedScriptsListScroller.add(_EmbeddedScriptsList); + _EmbeddedScriptsListScroller.set_shadow_type(Gtk::SHADOW_IN); + _EmbeddedScriptsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); + _EmbeddedScriptsListScroller.set_size_request(-1, 90); + + _new_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::addEmbeddedScript)); + + #if ENABLE_LCMS _ExternalScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::external_scripts_list_button_release)); - scripting_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript)); + external_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript)); + + _EmbeddedScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::embedded_scripts_list_button_release)); + embedded_create_popup_menu(_EmbeddedScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript)); #endif // ENABLE_LCMS //TODO: review this observers code: const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) { - _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); + _scripts_observer.set(SP_OBJECT(current->data)->parent); } - _ext_scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_external_scripts_box)); + _scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_script_lists)); } @@ -652,7 +740,24 @@ void DocumentProperties::addExternalScript(){ // inform the document, so we can undo DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); - populate_external_scripts_box(); + populate_script_lists(); + } +} + +void DocumentProperties::addEmbeddedScript(){ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (!desktop){ + g_warning("No active desktop"); + } else { + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script"); + + xml_doc->root()->addChild(scriptRepr, NULL); + + // inform the document, so we can undo + DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EMBEDDED_SCRIPT, _("Add embedded script...")); + + populate_script_lists(); } } @@ -675,20 +780,138 @@ void DocumentProperties::removeExternalScript(){ if (name == script->xlinkhref){ //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(obj->getRepr()); - DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + } + } + current = g_slist_next(current); + } + + populate_script_lists(); +} + +void DocumentProperties::removeEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script")); + } + } + current = g_slist_next(current); + } + + populate_script_lists(); +} + +void DocumentProperties::changeEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + bool voidscript=true; + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + int count=0; + for ( SPObject *child = obj->children ; child; child = child->next ) + { + count++; + } + + if (count>1) + g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); + + //XML Tree being used directly here while it shouldn't be. + SPObject* child = obj->firstChild(); + //TODO: shouldnt we get all children instead of simply the first child? + + if (child && child->getRepr()){ + const gchar* content = child->getRepr()->content(); + if (content){ + voidscript=false; + _EmbeddedContent.get_buffer()->set_text(content); + } + } } current = g_slist_next(current); } - populate_external_scripts_box(); + if (voidscript) + _EmbeddedContent.get_buffer()->set_text(""); +} + +void DocumentProperties::editEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + Inkscape::XML::Document *xml_doc = SP_ACTIVE_DOCUMENT->getReprDoc(); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + SPObject *child; + while (NULL != (child = obj->firstChild())) child->deleteObject(); + obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str())); + //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text()); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_EMBEDDED_SCRIPT, _("Edit embedded script")); + } + } + current = g_slist_next(current); + } } -void DocumentProperties::populate_external_scripts_box(){ +void DocumentProperties::populate_script_lists(){ _ExternalScriptsListStore->clear(); + _EmbeddedScriptsListStore->clear(); const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); + if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; @@ -697,6 +920,11 @@ void DocumentProperties::populate_external_scripts_box(){ Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append()); row[_ExternalScriptsListColumns.filenameColumn] = script->xlinkhref; } + else // Embedded scripts + { + Gtk::TreeModel::Row row = *(_EmbeddedScriptsListStore->append()); + row[_EmbeddedScriptsListColumns.idColumn] = obj->getId(); + } current = g_slist_next(current); } @@ -877,7 +1105,7 @@ DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *docu { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = document->root->getRepr(); + Inkscape::XML::Node *root = document->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } @@ -887,7 +1115,7 @@ DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *d { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } @@ -897,7 +1125,7 @@ DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->removeListenerByData(this); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index b88f0db26..69729f2da 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -64,16 +64,22 @@ protected: #endif // ENABLE_LCMS void external_scripts_list_button_release(GdkEventButton* event); - void populate_external_scripts_box(); + void embedded_scripts_list_button_release(GdkEventButton* event); + void populate_script_lists(); void addExternalScript(); + void addEmbeddedScript(); void removeExternalScript(); - void scripting_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); + void removeEmbeddedScript(); + void changeEmbeddedScript(); + void editEmbeddedScript(); + void external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); + void embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); void _handleActivateDesktop(Inkscape::Application *application, SPDesktop *desktop); void _handleDeactivateDesktop(Inkscape::Application *application, SPDesktop *desktop); - Inkscape::XML::SignalObserver _emb_profiles_observer, _ext_scripts_observer; + Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer; Gtk::Tooltips _tt; Gtk::Notebook _notebook; @@ -82,6 +88,11 @@ protected: UI::Widget::NotebookPage _page_snap; UI::Widget::NotebookPage _page_cms; UI::Widget::NotebookPage _page_scripting; + + Gtk::Notebook _scripting_notebook; + UI::Widget::NotebookPage _page_external_scripts; + UI::Widget::NotebookPage _page_embedded_scripts; + Gtk::VBox _grids_vbox; UI::Widget::Registry _wr; @@ -122,6 +133,7 @@ protected: //--------------------------------------------------------------- Gtk::Button _add_btn; + Gtk::Button _new_btn; class ExternalScriptsColumns : public Gtk::TreeModel::ColumnRecord { public: @@ -130,11 +142,25 @@ protected: Gtk::TreeModelColumn<Glib::ustring> filenameColumn; }; ExternalScriptsColumns _ExternalScriptsListColumns; + class EmbeddedScriptsColumns : public Gtk::TreeModel::ColumnRecord + { + public: + EmbeddedScriptsColumns() + { add(idColumn); } + Gtk::TreeModelColumn<Glib::ustring> idColumn; + }; + EmbeddedScriptsColumns _EmbeddedScriptsListColumns; Glib::RefPtr<Gtk::ListStore> _ExternalScriptsListStore; + Glib::RefPtr<Gtk::ListStore> _EmbeddedScriptsListStore; Gtk::TreeView _ExternalScriptsList; + Gtk::TreeView _EmbeddedScriptsList; Gtk::ScrolledWindow _ExternalScriptsListScroller; + Gtk::ScrolledWindow _EmbeddedScriptsListScroller; Gtk::Menu _ExternalScriptsContextMenu; + Gtk::Menu _EmbeddedScriptsContextMenu; Gtk::Entry _script_entry; + Gtk::TextView _EmbeddedContent; + Gtk::ScrolledWindow _EmbeddedContentScroller; //--------------------------------------------------------------- Gtk::Notebook _grids_notebook; diff --git a/src/ui/dialog/extensions.cpp b/src/ui/dialog/extensions.cpp index 3c778affe..27cd15e8c 100644 --- a/src/ui/dialog/extensions.cpp +++ b/src/ui/dialog/extensions.cpp @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <gtkmm/scrolledwindow.h> #include "extension/db.h" diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index af607c124..1598a04d3 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -35,11 +35,7 @@ //Temporary ugly hack //Remove this after the get_filter() calls in //show() on both classes are fixed -#include <gtk/gtkfilechooser.h> - -//Another hack -#include <gtk/gtkentry.h> -#include <gtk/gtkexpander.h> +#include <gtk/gtk.h> //Inkscape includes #include "extension/input.h" diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index b3c71e8c8..e83aeccad 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -41,6 +41,7 @@ #include "filedialog.h" #include "filedialogimpl-win32.h" +#include "sp-root.h" #include <zlib.h> #include <cairomm/win32_surface.h> @@ -407,7 +408,7 @@ void FileOpenDialogImplWin32::createFilterMenu() *(filterptr++) = L'\0'; _filter_count = extension_index; - _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd + _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd } void FileOpenDialogImplWin32::GetOpenFileName_thread() @@ -419,7 +420,7 @@ void FileOpenDialogImplWin32::GetOpenFileName_thread() WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( _current_directory.data(), _current_directory.length(), - NULL, NULL, NULL); + NULL, NULL, NULL); memset(&ofn, 0, sizeof(ofn)); @@ -964,8 +965,10 @@ bool FileOpenDialogImplWin32::set_svg_preview() g_free(utf8string); // Check the document loaded properly - if(svgDoc == NULL) return false; - if(svgDoc->root == NULL) + if (svgDoc == NULL) { + return false; + } + if (svgDoc->getRoot() == NULL) { svgDoc->doUnref(); return false; @@ -991,14 +994,14 @@ bool FileOpenDialogImplWin32::set_svg_preview() // write object bbox to area Geom::OptRect maybeArea(area); svgDoc->ensureUpToDate(); - static_cast<SPItem *>(svgDoc->root)->invoke_bbox( maybeArea, - static_cast<SPItem *>(svgDoc->root)->i2d_affine(), TRUE); + svgDoc->getRoot()->invoke_bbox( maybeArea, + svgDoc->getRoot()->i2d_affine(), TRUE); NRArena *const arena = NRArena::create(); unsigned const key = SPItem::display_key_new(1); - NRArenaItem *root = static_cast<SPItem*>(svgDoc->root)->invoke_show( + NRArenaItem *root = svgDoc->getRoot()->invoke_show( arena, key, SP_ITEM_SHOW_DISPLAY); NRGC gc(NULL); @@ -1035,7 +1038,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() // Tidy up svgDoc->doUnref(); - static_cast<SPItem*>(svgDoc->root)->invoke_hide(key); + svgDoc->getRoot()->invoke_hide(key); nr_object_unref((NRObject *) arena); // Create the GDK pixbuf @@ -1669,7 +1672,7 @@ void FileSaveDialogImplWin32::createFilterMenu() *(filterptr++) = 0; _filter_count = extension_index; - _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd + _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd } void FileSaveDialogImplWin32::GetSaveFileName_thread() @@ -1681,7 +1684,7 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( _current_directory.data(), _current_directory.length(), - NULL, NULL, NULL); + NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 memset(_path_string, 0, sizeof(_path_string)); @@ -1733,14 +1736,14 @@ FileSaveDialogImplWin32::show() _result = false; _main_loop = g_main_loop_new(g_main_context_default(), FALSE); - if(_main_loop != NULL) - { - if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) - g_main_loop_run(_main_loop); + if(_main_loop != NULL) + { + if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) + g_main_loop_run(_main_loop); - if(_result) - appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); - } + if(_result) + appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); + } return _result; } diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index fe72aa31c..b4be9ce59 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -15,11 +15,9 @@ #ifndef INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H #define INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H -#include <gtkmm/adjustment.h> #include <gtkmm/alignment.h> #include <gtkmm/notebook.h> #include <gtkmm/scale.h> -#include <gtkmm/spinbutton.h> #include <glibmm/i18n.h> #include "ui/widget/panel.h" diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index f7911f79a..c6d81b070 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -24,7 +24,7 @@ #include <gtkmm/paned.h> #include <gtkmm/scale.h> #include <gtkmm/scrolledwindow.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/stock.h> #include <gtkmm/tooltips.h> #include <glibmm/i18n.h> @@ -133,12 +133,12 @@ private: const Glib::ustring _true_val, _false_val; }; -class SpinButtonAttr : public Gtk::SpinButton, public AttrWidget +class SpinButtonAttr : public Inkscape::UI::Widget::SpinButton, public AttrWidget { public: SpinButtonAttr(double lower, double upper, double step_inc, double climb_rate, int digits, const SPAttributeEnum a, double def, char* tip_text) - : Gtk::SpinButton(climb_rate, digits), + : Inkscape::UI::Widget::SpinButton(climb_rate, digits), AttrWidget(a, def) { if (tip_text) _tt.set_tip(*this, tip_text); @@ -248,12 +248,12 @@ public: pack_start(_s2, false, false); } - Gtk::SpinButton& get_spinbutton1() + Inkscape::UI::Widget::SpinButton& get_spinbutton1() { return _s1; } - Gtk::SpinButton& get_spinbutton2() + Inkscape::UI::Widget::SpinButton& get_spinbutton2() { return _s2; } @@ -285,7 +285,7 @@ public: } private: - Gtk::SpinButton _s1, _s2; + Inkscape::UI::Widget::SpinButton _s1, _s2; }; class ColorButton : public Gtk::ColorButton, public AttrWidget diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index bdae14c62..aa6b4081e 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -50,6 +50,7 @@ #include "sp-use.h" #include "sp-image.h" #include "sp-offset.h" +#include "sp-root.h" #include "xml/repr.h" diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index f3d7ed971..fc0912539 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -22,9 +22,7 @@ #include <gtkmm/treemodelcolumn.h> #include <gtkmm/widget.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkversion.h> +#include <gtk/gtk.h> #include "glyphs.h" @@ -48,7 +46,6 @@ GlyphsPanel &GlyphsPanel::getInstance() } -#if GLIB_CHECK_VERSION(2,14,0) static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() { static bool init = false; @@ -123,8 +120,6 @@ static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() 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"); @@ -136,11 +131,9 @@ static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() 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; @@ -337,9 +330,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : 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(), @@ -366,7 +357,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- -#if GLIB_CHECK_VERSION(2,14,0) { Gtk::Label *label = new Gtk::Label(_("Script: ")); table->attach( *Gtk::manage(label), @@ -391,7 +381,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : } row++; -#endif // GLIB_CHECK_VERSION(2,14,0) // ------------------------------- @@ -464,10 +453,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : 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); @@ -607,13 +593,11 @@ void GlyphsPanel::glyphSelectionChanged() 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); } @@ -680,7 +664,6 @@ void GlyphsPanel::rebuild() 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(); @@ -690,7 +673,6 @@ void GlyphsPanel::rebuild() 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()); @@ -707,13 +689,9 @@ void GlyphsPanel::rebuild() 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 } } diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index d6c731dda..1440a693f 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -77,9 +77,7 @@ private: 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; diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index bd9777048..542fed5bb 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -15,9 +15,9 @@ #ifdef HAVE_CONFIG_H # include <config.h> #endif +#include "guides.h" + #include "display/guideline.h" -#include "helper/unit-menu.h" -#include "helper/units.h" #include "desktop.h" #include "document.h" #include "sp-guide.h" @@ -25,14 +25,13 @@ #include "desktop-handles.h" #include "event-context.h" #include "widgets/desktop-widget.h" -#include "sp-metrics.h" #include <glibmm/i18n.h> #include "dialogs/dialog-events.h" #include "message-context.h" #include "xml/repr.h" + #include <2geom/point.h> #include <2geom/angle.h> -#include "guides.h" namespace Inkscape { namespace UI { @@ -40,19 +39,22 @@ namespace Dialogs { GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop) : _desktop(desktop), _guide(guide), - _label_units(_("Unit:")), - _label_X(_("X:")), - _label_Y(_("Y:")), - _label_degrees(_("Angle (degrees):")), _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), - _adjustment_x(0.0, -1e6, 1e6, 1.0, 10.0, 10.0), - _adjustment_y(0.0, -1e6, 1e6, 1.0, 10.0, 10.0), - _adj_angle(0.0, -360, 360, 1.0, 10.0, 10.0), - _unit_selector(NULL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) + _spin_button_x(_("_X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _spin_button_y(_("_Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _label_entry(_("_Label:"), _("Optionally give this guideline a name")), + _spin_angle(_("_Angle:"), "", UNIT_TYPE_RADIAL), + _mode(true), _oldpos(0.,0.), _oldangle(0.0) { } +bool GuidelinePropertiesDialog::_relative_toggle_status = false; // initialize relative checkbox status for when this dialog is opened for first time +Glib::ustring GuidelinePropertiesDialog::_angle_unit_status = "deg"; // initialize angle unit status + GuidelinePropertiesDialog::~GuidelinePropertiesDialog() { + // save current status + _relative_toggle_status = _relative_toggle.get_active(); + _angle_unit_status = _spin_angle.getUnit().abbr; } void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { @@ -61,30 +63,35 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { dialog.run(); } +void GuidelinePropertiesDialog::_colorChanged() +{ + const Gdk::Color c = _color.get_color(); + char r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; + //TODO: why 257? verify this! + sp_guide_set_color(*_guide, r, g, b, true); +} + void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); if (!_mode) { // relative - _spin_angle.set_value(0); + _spin_angle.setValue(0); - _spin_button_y.set_value(0); - _spin_button_x.set_value(0); + _spin_button_y.setValue(0); + _spin_button_x.setValue(0); } else { // absolute - _spin_angle.set_value(_oldangle); + _spin_angle.setValueKeepUnit(_oldangle, "deg"); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); - gdouble const val_y = sp_pixels_get_units(_oldpos[Geom::Y], unit); - _spin_button_y.set_value(val_y); - gdouble const val_x = sp_pixels_get_units(_oldpos[Geom::X], unit); - _spin_button_x.set_value(val_x); + _spin_button_x.setValueKeepUnit(_oldpos[Geom::X], "px"); + _spin_button_y.setValueKeepUnit(_oldpos[Geom::Y], "px"); } } void GuidelinePropertiesDialog::_onApply() { - double deg_angle = _spin_angle.get_value(); + double deg_angle = _spin_angle.getValue("deg"); if (!_mode) deg_angle += _oldangle; Geom::Point normal; @@ -98,17 +105,17 @@ void GuidelinePropertiesDialog::_onApply() } sp_guide_set_normal(*_guide, normal, true); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); - gdouble const raw_dist_x = _spin_button_x.get_value(); - gdouble const points_x = sp_units_get_pixels(raw_dist_x, unit); - gdouble const raw_dist_y = _spin_button_y.get_value(); - gdouble const points_y = sp_units_get_pixels(raw_dist_y, unit); + double const points_x = _spin_button_x.getValue("px"); + double const points_y = _spin_button_y.getValue("px"); Geom::Point newpos(points_x, points_y); if (!_mode) newpos += _oldpos; sp_guide_moveto(*_guide, newpos, true); + const gchar* name = _label_entry.getEntry()->get_text().c_str(); + sp_guide_set_label(*_guide, name, true); + DocumentUndo::done(_guide->document, SP_VERB_NONE, _("Set guide properties")); } @@ -172,52 +179,61 @@ void GuidelinePropertiesDialog::_setup() { _label_descr.set_alignment(0, 0.5); // indent - _layout_table.attach(*manage(new Gtk::Label(" ")), - 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); +// _layout_table.attach(*manage(new Gtk::Label(" ")), +// 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); - // mode radio button - _layout_table.attach(_relative_toggle, - 1, 3, 9, 10, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); + _layout_table.attach(_label_entry, + 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + + _layout_table.attach(_color, + 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged)); - // unitmenu + + // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ - GtkWidget *unit_selector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unit_selector), _desktop->namedview->doc_units); - _unit_selector = Gtk::manage(Glib::wrap(unit_selector)); + _unit_menu.setUnitType(UNIT_TYPE_LINEAR); + _unit_menu.setUnit("px"); + if (_desktop->namedview->doc_units) { + _unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); + } + _spin_angle.setUnit(_angle_unit_status); // position spinbuttons - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj())); - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj())); - _spin_button_x.configure(_adjustment_x, 1.0 , 3); - _spin_button_x.set_numeric(); - _spin_button_y.configure(_adjustment_y, 1.0 , 3); - _spin_button_y.set_numeric(); - _layout_table.attach(_label_X, - 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _spin_button_x.setDigits(3); + _spin_button_x.setIncrements(1.0, 10.0); + _spin_button_x.setRange(-1e6, 1e6); + _spin_button_y.setDigits(3); + _spin_button_y.setIncrements(1.0, 10.0); + _spin_button_y.setRange(-1e6, 1e6); _layout_table.attach(_spin_button_x, - 2, 3, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_label_Y, - 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_y, - 2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.gobj()), "activate", - GTK_SIGNAL_FUNC(gtk_window_activate_default), - gobj()); + 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_label_units, - 1, 2, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(*_unit_selector, - 2, 3, 6, 7, Gtk::FILL, Gtk::FILL); + _layout_table.attach(_unit_menu, + 2, 3, 4, 5, Gtk::FILL, Gtk::FILL); // angle spinbutton - _spin_angle.configure(_adj_angle, 5.0 , 3); - _spin_angle.set_numeric(); - _spin_angle.show(); - _layout_table.attach(_label_degrees, - 1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _spin_angle.setDigits(3); + _spin_angle.setIncrements(1.0, 10.0); + _spin_angle.setRange(-3600., 3600.); _layout_table.attach(_spin_angle, - 2, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + + // mode radio button + _layout_table.attach(_relative_toggle, + 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); + _relative_toggle.set_active(_relative_toggle_status); + + // don't know what this exactly does, but it results in that the dialog closes when entering a value and pressing enter (see LP bug 484187) + g_signal_connect_swapped(G_OBJECT(_spin_button_x.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_button_y.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_angle.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); // dialog @@ -249,17 +265,20 @@ void GuidelinePropertiesDialog::_setup() { g_free(label); } + // init name entry + _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + Gdk::Color c; + c.set_rgb_p(((_guide->color>>24)&0xff) / 255.0, ((_guide->color>>16)&0xff) / 255.0, ((_guide->color>>8)&0xff) / 255.0); + _color.set_color(c); + _modeChanged(); // sets values of spinboxes. if ( _oldangle == 90. || _oldangle == 270. || _oldangle == -90. || _oldangle == -270.) { - _spin_button_x.grab_focus(); - _spin_button_x.select_region(0, 20); + _spin_button_x.grabFocusAndSelectEntry(); } else if ( _oldangle == 0. || _oldangle == 180. || _oldangle == -180.) { - _spin_button_y.grab_focus(); - _spin_button_y.select_region(0, 20); + _spin_button_y.grabFocusAndSelectEntry(); } else { - _spin_angle.grab_focus(); - _spin_angle.select_region(0, 20); + _spin_angle.grabFocusAndSelectEntry(); } set_position(Gtk::WIN_POS_MOUSE); diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 2817e2644..88d0310b9 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -20,11 +20,24 @@ #include <gtkmm/label.h> #include <gtkmm/stock.h> #include <gtkmm/adjustment.h> +#include <gtkmm/colorbutton.h> #include "ui/widget/button.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/unit-menu.h" +#include "ui/widget/scalar-unit.h" +#include "ui/widget/entry.h" #include <2geom/point.h> +class SPGuide; +class SPDesktop; + namespace Inkscape { namespace UI { + +namespace Widget { + class UnitMenu; +}; + namespace Dialogs { class GuidelinePropertiesDialog : public Gtk::Dialog { @@ -45,6 +58,7 @@ protected: void _response(gint response); void _modeChanged(); + void _colorChanged(); private: GuidelinePropertiesDialog(GuidelinePropertiesDialog const &); // no copy @@ -55,20 +69,17 @@ private: Gtk::Table _layout_table; Gtk::Label _label_name; Gtk::Label _label_descr; - Gtk::Label _label_units; - Gtk::Label _label_X; - Gtk::Label _label_Y; - Gtk::Label _label_degrees; Inkscape::UI::Widget::CheckButton _relative_toggle; - Gtk::Adjustment _adjustment_x; - Gtk::SpinButton _spin_button_x; - Gtk::Adjustment _adjustment_y; - Gtk::SpinButton _spin_button_y; + static bool _relative_toggle_status; // remember the status of the _relative_toggle_status button across instances + Inkscape::UI::Widget::UnitMenu _unit_menu; + Inkscape::UI::Widget::ScalarUnit _spin_button_x; + Inkscape::UI::Widget::ScalarUnit _spin_button_y; + Inkscape::UI::Widget::Entry _label_entry; + Gtk::ColorButton _color; - Gtk::Adjustment _adj_angle; - Gtk::SpinButton _spin_angle; + Inkscape::UI::Widget::ScalarUnit _spin_angle; + static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances - Gtk::Widget *_unit_selector; bool _mode; Geom::Point _oldpos; gdouble _oldangle; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 8681ed98f..3c272e691 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -7,7 +7,7 @@ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Bruno Dilly <bruno.dilly@gmail.com> * - * Copyright (C) 2004-2007 Authors + * Copyright (C) 2004-2011 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -21,7 +21,7 @@ #include <gtkmm/scrolledwindow.h> #include <gtkmm/alignment.h> -#include <gtk/gtkicontheme.h> +#include <gtk/gtk.h> #include "preferences.h" #include "inkscape-preferences.h" @@ -38,6 +38,7 @@ #include "selection-chemistry.h" #include "xml/repr.h" #include "ui/widget/style-swatch.h" +#include "ui/widget/spinbutton.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" #include "color-profile-fns.h" @@ -70,7 +71,7 @@ InkscapePreferences::InkscapePreferences() _current_page(0) { //get the width of a spinbutton - Gtk::SpinButton* sb = new Gtk::SpinButton; + Inkscape::UI::Widget::SpinButton* sb = new Inkscape::UI::Widget::SpinButton; sb->set_width_chars(6); _getContents()->add(*sb); show_all_children(); @@ -248,17 +249,17 @@ void InkscapePreferences::initPageSteps() { this->AddPage(_page_steps, _("Steps"), PREFS_PAGE_STEPS); - _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false); + _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); //nudgedistance is limited to 1000 in select-context.cpp: use the same limit here - _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, _("px"), - _("Pressing an arrow key moves selected object(s) or node(s) by this distance (in px units)"), false); - _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false); + _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, "", + _("Pressing an arrow key moves selected object(s) or node(s) by this distance"), false); + _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); //defaultscale is limited to 1000 in select-context.cpp: use the same limit here - _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, _("px"), - _("Pressing > or < scales selection up or down by this increment (in px units)"), false); - _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 1.0, 2.0, false, false); - _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, _("px"), - _("Inset and Outset commands displace the path by this distance (in px units)"), false); + _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, "", + _("Pressing > or < scales selection up or down by this increment"), false); + _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); + _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, "", + _("Inset and Outset commands displace the path by this distance"), false); _steps_compass.init ( _("Compass-like display of angles"), "/options/compassangledisplay/value", true); _page_steps.add_line( false, "", _steps_compass, "", _("When on, angles are displayed with 0 at north, 0 to 360 range, positive clockwise; otherwise with 0 at east, -180 to 180 range, positive counterclockwise")); @@ -269,6 +270,9 @@ void InkscapePreferences::initPageSteps() _steps_rot_snap.init("/options/rotationsnapsperpi/value", labels, values, num_items, 12); _page_steps.add_line( false, _("Rotation snaps every:"), _steps_rot_snap, _("degrees"), _("Rotating with Ctrl pressed snaps every that much degrees; also, pressing [ or ] rotates by this amount"), false); + _steps_rot_relative.init ( _("Relative snapping of guideline angles"), "/options/relativeguiderotationsnap/value", false); + _page_steps.add_line( false, "", _steps_rot_relative, "", + _("When on, the snap angles when rotating a guideline will be relative to the original angle")); _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true); _page_steps.add_line( false, _("Zoom in/out by:"), _steps_zoom, _("%"), _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false); @@ -479,6 +483,12 @@ void InkscapePreferences::initPageTools() AddSelcueCheckbox(_page_zoom, "/tools/zoom", true); AddGradientCheckbox(_page_zoom, "/tools/zoom", false); + //Measure + this->AddPage(_page_measure, _("Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); + PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); + cb->init ( _("Ignore first and last points"), "/tools/measure/ignore_1st_and_last", true); + _page_measure.add_line( false, "", *cb, "", _("The start and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); + //Shapes Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES); _path_shapes = _page_list.get_model()->get_path(iter_shapes); @@ -1123,6 +1133,31 @@ void InkscapePreferences::initPageUI() "gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "mk", "mn", "ne", "nb", "nn", "pa", "pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te_IN", "th", "tr", "uk", "vi" }; + { + // sorting languages according to translated name + int i = 0; + int j = 0; + int n = sizeof( languages ) / sizeof( Glib::ustring ); + Glib::ustring key_language; + Glib::ustring key_langValue; + for ( j = 1 ; j < n ; j++ ) { + key_language = languages[j]; + key_langValue = langValues[j]; + i = j-1; + while ( i >= 0 + && ( ( languages[i] > key_language + && langValues[i] != "" ) + || key_langValue == "" ) ) + { + languages[i+1] = languages[i]; + langValues[i+1] = langValues[i]; + i--; + } + languages[i+1] = key_language; + langValues[i+1] = key_langValue; + } + } + _ui_languages.init( "/ui/language", languages, langValues, G_N_ELEMENTS(languages), languages[0]); _page_ui.add_line( false, _("Language (requires restart):"), _ui_languages, "", _("Set the language for menus and number formats"), false); @@ -1177,7 +1212,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...\" and \"Save a Copy\" dialogs will always open in the directory where the currently open document is; when it's off, each will open in the directory where you last saved a file using it"), true); // Autosave options diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index a20278551..13851e525 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -46,6 +46,7 @@ enum { PREFS_PAGE_TOOLS_TWEAK, PREFS_PAGE_TOOLS_SPRAY, PREFS_PAGE_TOOLS_ZOOM, + PREFS_PAGE_TOOLS_MEASURE, PREFS_PAGE_TOOLS_SHAPES, PREFS_PAGE_TOOLS_SHAPES_RECT, PREFS_PAGE_TOOLS_SHAPES_3DBOX, @@ -140,6 +141,7 @@ protected: UI::Widget::DialogPage _page_tweak; UI::Widget::DialogPage _page_spray; UI::Widget::DialogPage _page_zoom; + UI::Widget::DialogPage _page_measure; UI::Widget::DialogPage _page_shapes; UI::Widget::DialogPage _page_pencil; UI::Widget::DialogPage _page_pen; @@ -177,11 +179,12 @@ protected: UI::Widget::PrefCheckButton _snap_mouse_pointer; UI::Widget::PrefCombo _steps_rot_snap; + UI::Widget::PrefCheckButton _steps_rot_relative; 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::PrefSpinUnit _steps_arrow; + UI::Widget::PrefSpinUnit _steps_scale; + UI::Widget::PrefSpinUnit _steps_inset; + UI::Widget::PrefSpinButton _steps_zoom; UI::Widget::PrefRadioButton _t_sel_trans_obj; UI::Widget::PrefRadioButton _t_sel_trans_outl; @@ -371,6 +374,7 @@ protected: 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 AddFirstAndLastCheckbox(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); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 0eca5bbca..8d2d25162 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -13,8 +13,7 @@ # include <config.h> #endif -#include <gtk/gtkstock.h> -#include <gtk/gtkmain.h> +#include <gtk/gtk.h> #include <gtkmm/widget.h> #include <gtkmm/icontheme.h> #include <glibmm/i18n.h> @@ -35,6 +34,7 @@ #include "verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "sp-root.h" #include "layers.h" @@ -293,7 +293,7 @@ bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::Tre } void LayersPanel::_selectLayer( SPObject *layer ) { - if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->root)) ) { + if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->getRoot())) ) { if ( _tree.get_selection()->count_selected_rows() != 0 ) { _tree.get_selection()->unselect_all(); } @@ -328,7 +328,7 @@ void LayersPanel::_layersChanged() // g_message("_layersChanged()"); if (_desktop) { SPDocument* document = _desktop->doc(); - SPObject* root = document->root; + SPRoot* root = document->getRoot(); if ( root ) { _selectedConnection.block(); if ( _desktop->layer_manager && _desktop->layer_manager->includes( root ) ) { @@ -402,7 +402,7 @@ void LayersPanel::_pushTreeSelectionToCurrent() _desktop->layer_manager->setCurrentLayer( inTree ); } } else { - _desktop->layer_manager->setCurrentLayer( _desktop->doc()->root ); + _desktop->layer_manager->setCurrentLayer( _desktop->doc()->getRoot() ); } } } diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index b7e81480c..018357425 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -19,7 +19,7 @@ #include <gtkmm/scrolledwindow.h> #include <gtkmm/box.h> #include <gtkmm/buttonbox.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/notebook.h> //#include "ui/previewholder.h" @@ -117,7 +117,7 @@ private: Gtk::HButtonBox _buttonsRow; Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; - Gtk::SpinButton _spinBtn; + Inkscape::UI::Widget::SpinButton _spinBtn; Gtk::VBox _layersPage; UI::Widget::StyleSubject::CurrentLayer _subject; diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 85aefade8..a7dfaa5cd 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -33,11 +33,9 @@ //Temporary ugly hack //Remove this after the get_filter() calls in //show() on both classes are fixed -#include <gtk/gtkfilechooser.h> +#include <gtk/gtk.h> //Another hack -#include <gtk/gtkentry.h> -#include <gtk/gtkexpander.h> #ifdef WITH_GNOME_VFS #include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized #include<libgnomevfs/gnome-vfs.h> diff --git a/src/ui/dialog/print.h b/src/ui/dialog/print.h index cc27955cb..0184bc783 100644 --- a/src/ui/dialog/print.h +++ b/src/ui/dialog/print.h @@ -13,7 +13,7 @@ #include <glibmm/i18n.h> #include <gtkmm/printoperation.h> // GtkMM -#include <gtk/gtkprintoperation.h> // Gtk +#include <gtk/gtk.h> // Gtk #include "desktop.h" #include "sp-item.h" diff --git a/src/ui/dialog/session-player.cpp b/src/ui/dialog/session-player.cpp index d8ff8ca56..040c1419b 100644 --- a/src/ui/dialog/session-player.cpp +++ b/src/ui/dialog/session-player.cpp @@ -15,7 +15,7 @@ #include <glibmm.h> #include <glibmm/i18n.h> -#include <gtk/gtkdialog.h> +#include <gtk/gtk.h> #include <gtkmm.h> #include "inkscape.h" diff --git a/src/ui/dialog/session-player.h b/src/ui/dialog/session-player.h index 9c10f264f..2d235cd25 100644 --- a/src/ui/dialog/session-player.h +++ b/src/ui/dialog/session-player.h @@ -75,7 +75,7 @@ private: Gtk::Tooltips _tooltips; Gtk::Toolbar _playbackcontrols; Gtk::Adjustment _delay; - Gtk::SpinButton _delayentry; + Widget::SpinButton _delayentry; Gtk::Frame _filemanager; Gtk::VBox _fm; diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 2d1b5ae39..fbca0bf10 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -16,7 +16,6 @@ #ifdef ENABLE_SVG_FONTS -#include <2geom/pathvector.h> #include "document-private.h" #include <gtkmm/notebook.h> #include <glibmm/i18n.h> @@ -137,7 +136,7 @@ Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum /*attr*/) Gtk::HBox* SvgFontsDialog::AttrSpin(gchar* lbl){ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); hbox->add(* Gtk::manage(new Gtk::Label(lbl)) ); - hbox->add(* Gtk::manage(new Gtk::SpinBox()) ); + hbox->add(* Gtk::manage(new Inkscape::UI::Widget::SpinBox()) ); hbox->show_all(); return hbox; }*/ @@ -162,7 +161,10 @@ void GlyphComboBox::update(SPFont* spfont){ } void SvgFontsDialog::on_kerning_value_changed(){ - if (!this->kerning_pair) return; + if (!get_selected_kerning_pair()) { + return; + } + SPDocument* document = sp_desktop_document(this->getDesktop()); //TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done @@ -471,6 +473,24 @@ void SvgFontsDialog::add_glyph(){ update_glyphs(); } +Geom::PathVector +SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ + double units_per_em = 1000; + SPObject* obj; + for (obj = get_selected_spfont()->children; obj; obj=obj->next){ + if (SP_IS_FONTFACE(obj)){ + //XML Tree being directly used here while it shouldn't be. + sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em); + } + } + + double baseline_offset = units_per_em - get_selected_spfont()->horiz_origin_y; + + //This matrix flips y-axis and places the origin at baseline + Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset)); + return pathv*m; +} + void SvgFontsDialog::set_glyph_description_from_selected_path(){ SPDesktop* desktop = this->getDesktop(); if (!desktop) { @@ -495,22 +515,17 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } //TODO: //Is there a better way to tell it to to the user? - Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - pathv*=m; - //then we offset it - pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x)); - SPGlyph* glyph = get_selected_glyph(); if (!glyph){ char *msg = _("No glyph selected in the SVGFonts dialog."); msgStack->flash(Inkscape::ERROR_MESSAGE, msg); return; } + + Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); + //XML Tree being directly used here while it shouldn't be. - glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); @@ -542,19 +557,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - pathv*=m; - //then we offset it -// pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x)); - pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(1000));//TODO: use here the units-per-em attribute? - SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } @@ -786,7 +794,7 @@ SPFont *new_font(SPDocument *document) { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -903,7 +911,7 @@ SvgFontsDialog::SvgFontsDialog() _FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release)); create_fonts_popup_menu(_FontsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_font)); - _defs_observer.set(SP_DOCUMENT_DEFS(sp_desktop_document(this->getDesktop()))); + _defs_observer.set(sp_desktop_document(this->getDesktop())->getDefs()); _defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts)); _getContents()->show_all(); diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index e819187a1..8c2bdc1a4 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -11,7 +11,9 @@ #ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H #define INKSCAPE_UI_DIALOG_SVG_FONTS_H +#include <2geom/pathvector.h> #include "ui/widget/panel.h" +#include "ui/widget/spinbutton.h" #include "sp-font.h" #include "sp-font-face.h" #include "verbs.h" @@ -77,6 +79,7 @@ public: void on_kerning_value_changed(); void on_setwidth_changed(); void add_font(); + Geom::PathVector flip_coordinate_system(Geom::PathVector pathv); //TODO: AttrEntry is currently unused. Should we remove it? class AttrEntry : public Gtk::HBox @@ -206,7 +209,7 @@ private: SvgFontDrawingArea _font_da, kerning_preview; GlyphComboBox first_glyph, second_glyph; SPGlyphKerning* kerning_pair; - Gtk::SpinButton setwidth_spin; + Inkscape::UI::Widget::SpinButton setwidth_spin; Gtk::HScale kerning_slider; class EntryWidget : public Gtk::HBox diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 0fa791366..ad3b79630 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -17,12 +17,9 @@ #include <map> #include <algorithm> -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types -#include <gtk/gtkdnd.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkseparatormenuitem.h> +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> +#include <glibmm/main.h> #include <gdkmm/pixbuf.h> #include "color-item.h" @@ -63,8 +60,6 @@ namespace Dialogs { void _loadPaletteFile( gchar const *filename ); -class DocTrack; - std::vector<SwatchPage*> possible; static std::map<SPDocument*, SwatchPage*> docPalettes; static std::vector<DocTrack*> docTrackings; @@ -715,14 +710,31 @@ class DocTrack public: DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) : doc(doc), + updatePending(false), + lastGradientUpdate(0.0), gradientRsrcChanged(gradientRsrcChanged), defsChanged(defsChanged), defsModified(defsModified) { + if ( !timer ) { + timer = new Glib::Timer(); + refreshTimer = Glib::signal_timeout().connect( sigc::ptr_fun(handleTimerCB), 33 ); + } + timerRefCount++; } ~DocTrack() { + timerRefCount--; + if ( timerRefCount <= 0 ) { + refreshTimer.disconnect(); + timerRefCount = 0; + if ( timer ) { + timer->stop(); + delete timer; + timer = 0; + } + } if (doc) { gradientRsrcChanged.disconnect(); defsChanged.disconnect(); @@ -730,7 +742,22 @@ public: } } + static bool handleTimerCB(); + + /** + * Checks if update should be queued or executed immediately. + * + * @return true if the update was queued and should not be immediately executed. + */ + static bool queueUpdateIfNeeded(SPDocument *doc); + + static Glib::Timer *timer; + static int timerRefCount; + static sigc::connection refreshTimer; + SPDocument *doc; + bool updatePending; + double lastGradientUpdate; sigc::connection gradientRsrcChanged; sigc::connection defsChanged; sigc::connection defsModified; @@ -740,6 +767,58 @@ private: DocTrack &operator=(DocTrack const &); // no assign }; +Glib::Timer *DocTrack::timer = 0; +int DocTrack::timerRefCount = 0; +sigc::connection DocTrack::refreshTimer; + +static const double DOC_UPDATE_THREASHOLD = 0.090; + +bool DocTrack::handleTimerCB() +{ + double now = timer->elapsed(); + + std::vector<DocTrack *> needCallback; + for (std::vector<DocTrack *>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { + DocTrack *track = *it; + if ( track->updatePending && ( (now - track->lastGradientUpdate) >= DOC_UPDATE_THREASHOLD) ) { + needCallback.push_back(track); + } + } + + for (std::vector<DocTrack *>::iterator it = needCallback.begin(); it != needCallback.end(); ++it) { + DocTrack *track = *it; + if ( std::find(docTrackings.begin(), docTrackings.end(), track) != docTrackings.end() ) { // Just in case one gets deleted while we are looping + // Note: calling handleDefsModified will call queueUpdateIfNeeded and thus update the time and flag. + SwatchesPanel::handleDefsModified(track->doc); + } + } + + return true; +} + +bool DocTrack::queueUpdateIfNeeded( SPDocument *doc ) +{ + bool deferProcessing = false; + for (std::vector<DocTrack*>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { + DocTrack *track = *it; + if ( track->doc == doc ) { + double now = timer->elapsed(); + double elapsed = now - track->lastGradientUpdate; + + if ( elapsed < DOC_UPDATE_THREASHOLD ) { + deferProcessing = true; + track->updatePending = true; + } else { + track->lastGradientUpdate = now; + track->updatePending = false; + } + + break; + } + } + return deferProcessing; +} + void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) { SPDocument *oldDoc = 0; @@ -775,8 +854,8 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) docPerPanel[panel] = document; if (!found) { sigc::connection conn1 = document->connectResourcesChanged( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); - sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); - sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); + sigc::connection conn2 = document->getDefs()->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); + sigc::connection conn3 = document->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); DocTrack *dt = new DocTrack(document, conn1, conn2, conn3); docTrackings.push_back(dt); @@ -896,7 +975,7 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) void SwatchesPanel::handleDefsModified(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; - if (docPalette) { + if (docPalette && !DocTrack::queueUpdateIfNeeded(document) ) { std::vector<ColorItem*> tmpColors; std::map<ColorItem*, cairo_pattern_t*> tmpPrevs; std::map<ColorItem*, SPGradient*> tmpGrads; diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h index f9f3daf91..95d7acb00 100644 --- a/src/ui/dialog/swatches.h +++ b/src/ui/dialog/swatches.h @@ -23,6 +23,7 @@ namespace Dialogs { class ColorItem; class SwatchPage; +class DocTrack; /** * A panel that displays paint swatches. @@ -68,6 +69,8 @@ private: sigc::connection _documentConnection; sigc::connection _selChanged; + + friend class DocTrack; }; } //namespace Dialogs diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index b0a39bd0e..ae17214bf 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -18,8 +18,7 @@ # include <config.h> #endif -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types -#include <gtk/gtksizegroup.h> +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> #include <gtkmm/stock.h> @@ -136,8 +135,8 @@ void TileDialog::Grid_Arrange () on_row_spinbutton_changed(); // set padding to manual values - paddingx = XPadSpinner.get_value(); - paddingy = YPadSpinner.get_value(); + paddingx = XPadding.getValue("px"); + paddingy = YPadding.getValue("px"); std::vector<double> row_heights; std::vector<double> col_widths; @@ -422,7 +421,7 @@ void TileDialog::on_col_spinbutton_changed() void TileDialog::on_xpad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/XPad", XPadSpinner.get_value()); + prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); } @@ -432,7 +431,7 @@ void TileDialog::on_xpad_spinbutton_changed() void TileDialog::on_ypad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/YPad", YPadSpinner.get_value()); + prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); } @@ -512,7 +511,8 @@ void TileDialog::Spacing_button_changed() prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); } - SizesHBox.set_sensitive ( SpaceManualRadioButton.get_active()); + XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); + YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); } /** @@ -614,7 +614,9 @@ static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscap * Constructor */ TileDialog::TileDialog() - : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE) + : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), + XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), + YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") { // bool used by spin button callbacks to stop loops where they change each other. updating = false; @@ -814,51 +816,25 @@ TileDialog::TileDialog() } { - /*#### Y Padding ####*/ + /*#### Padding ####*/ - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-rows"); - YPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN); + YPadding.setDigits(1); + YPadding.setIncrements(0.2, 0); + YPadding.setRange(-10000, 10000); + double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); + YPadding.setValue(yPad, "px"); + YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - YPadSpinner.set_digits(1); - YPadSpinner.set_increments(0.2, 0); - YPadSpinner.set_range(-10000, 10000); - double YPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); - YPadSpinner.set_value(YPad); - YPadBox.pack_start(YPadSpinner, true, true, MARGIN); - tips.set_tip(YPadSpinner, _("Vertical spacing between rows (px units)")); - YPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - gtk_size_group_add_widget(_col1, (GtkWidget *) YPadBox.gobj()); + XPadding.setDigits(1); + XPadding.setIncrements(0.2, 0); + XPadding.setRange(-10000, 10000); + double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); + XPadding.setValue(xPad, "px"); - SizesHBox.pack_start(YPadBox, false, false, MARGIN); + XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); } - - { - Gtk::HBox *spacer = new Gtk::HBox; - SizesHBox.pack_start(*spacer, false, false, 0); - gtk_size_group_add_widget(_col2, (GtkWidget *) spacer->gobj()); - } - - { - /*#### X padding ####*/ - - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-columns"); - XPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN); - - XPadSpinner.set_digits(1); - XPadSpinner.set_increments(0.2, 0); - XPadSpinner.set_range(-10000, 10000); - double XPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); - XPadSpinner.set_value(XPad); - XPadBox.pack_start(XPadSpinner, true, true, MARGIN); - tips.set_tip(XPadSpinner, _("Horizontal spacing between columns (px units)")); - XPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); - gtk_size_group_add_widget(_col3, (GtkWidget *) XPadBox.gobj()); - - SizesHBox.pack_start(XPadBox, false, false, MARGIN); - } - - - TileBox.pack_start(SizesHBox, false, false, MARGIN); + TileBox.pack_start(XPadding, false, false, MARGIN); + TileBox.pack_start(YPadding, false, false, MARGIN); contents->pack_start(TileBox); @@ -870,7 +846,8 @@ TileDialog::TileDialog() } SpaceManualRadioButton.set_active(ManualSpacing); SpaceByBBoxRadioButton.set_active(!ManualSpacing); - SizesHBox.set_sensitive (ManualSpacing); + XPadding.set_sensitive (ManualSpacing); + YPadding.set_sensitive (ManualSpacing); //## The OK button TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 16ae3e4f8..fe77a9098 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -24,6 +24,8 @@ #include <gtkmm/radiobutton.h> #include "ui/widget/panel.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/scalar-unit.h" namespace Inkscape { namespace UI { @@ -88,12 +90,11 @@ private: Gtk::HBox AlignHBox; Gtk::HBox SpinsHBox; - Gtk::HBox SizesHBox; // Number per Row Gtk::VBox NoOfColsBox; Gtk::Label NoOfColsLabel; - Gtk::SpinButton NoOfColsSpinner; + Inkscape::UI::Widget::SpinButton NoOfColsSpinner; bool AutoRowSize; Gtk::CheckButton RowHeightButton; @@ -104,7 +105,7 @@ private: // Number per Column Gtk::VBox NoOfRowsBox; Gtk::Label NoOfRowsLabel; - Gtk::SpinButton NoOfRowsSpinner; + Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; bool AutoColSize; Gtk::CheckButton ColumnWidthButton; @@ -128,15 +129,8 @@ private: Gtk::RadioButton HorizRightRadioButton; double HorizAlign; - // padding in x - Gtk::VBox XPadBox; - Gtk::Label XPadLabel; - Gtk::SpinButton XPadSpinner; - - // padding in y - Gtk::VBox YPadBox; - Gtk::Label YPadLabel; - Gtk::SpinButton YPadSpinner; + Inkscape::UI::Widget::ScalarUnit XPadding; + Inkscape::UI::Widget::ScalarUnit YPadding; // BBox or manual spacing Gtk::VBox SpacingVBox; @@ -145,19 +139,17 @@ private: Gtk::RadioButton SpaceManualRadioButton; bool ManualSpacing; - - // Row height Gtk::VBox RowHeightVBox; Gtk::HBox RowHeightBox; Gtk::Label RowHeightLabel; - Gtk::SpinButton RowHeightSpinner; + Inkscape::UI::Widget::SpinButton RowHeightSpinner; // Column width Gtk::VBox ColumnWidthVBox; Gtk::HBox ColumnWidthBox; Gtk::Label ColumnWidthLabel; - Gtk::SpinButton ColumnWidthSpinner; + Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; }; diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index f6dd6cb28..7fb172531 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -16,10 +16,10 @@ #include <gtkmm/notebook.h> #include <gtkmm/frame.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/stock.h> -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> #include "desktop.h" @@ -109,7 +109,7 @@ class TraceDialogImpl : public TraceDialog Gtk::HBox modeBrightnessBox; Gtk::RadioButton modeBrightnessRadioButton; Gtk::Label modeBrightnessSpinnerLabel; - Gtk::SpinButton modeBrightnessSpinner; + Inkscape::UI::Widget::SpinButton modeBrightnessSpinner; //edge detection Gtk::Frame modeCannyFrame; Gtk::HBox modeCannyBox; @@ -117,16 +117,16 @@ class TraceDialogImpl : public TraceDialog Gtk::RadioButton modeCannyRadioButton; //Gtk::HSeparator modeCannySeparator; //Gtk::Label modeCannyLoSpinnerLabel; - //Gtk::SpinButton modeCannyLoSpinner; + //Inkscape::UI::Widget::SpinButton modeCannyLoSpinner; Gtk::Label modeCannyHiSpinnerLabel; - Gtk::SpinButton modeCannyHiSpinner; + Inkscape::UI::Widget::SpinButton modeCannyHiSpinner; //quantization Gtk::Frame modeQuantFrame; Gtk::HBox modeQuantBox; Gtk::VBox modeQuantVBox; Gtk::RadioButton modeQuantRadioButton; Gtk::Label modeQuantNrColorLabel; - Gtk::SpinButton modeQuantNrColorSpinner; + Inkscape::UI::Widget::SpinButton modeQuantNrColorSpinner; //params Gtk::CheckButton modeInvertButton; Gtk::HBox modeInvertBox; @@ -137,7 +137,7 @@ class TraceDialogImpl : public TraceDialog //brightness Gtk::HBox modeMultiScanHBox1; Gtk::RadioButton modeMultiScanBrightnessRadioButton; - Gtk::SpinButton modeMultiScanNrColorSpinner; + Inkscape::UI::Widget::SpinButton modeMultiScanNrColorSpinner; //colors Gtk::HBox modeMultiScanHBox2; Gtk::RadioButton modeMultiScanColorRadioButton; @@ -162,15 +162,15 @@ class TraceDialogImpl : public TraceDialog Gtk::HBox optionsSpecklesBox; Gtk::CheckButton optionsSpecklesButton; Gtk::Label optionsSpecklesSizeLabel; - Gtk::SpinButton optionsSpecklesSizeSpinner; + Inkscape::UI::Widget::SpinButton optionsSpecklesSizeSpinner; Gtk::HBox optionsCornersBox; Gtk::CheckButton optionsCornersButton; Gtk::Label optionsCornersThresholdLabel; - Gtk::SpinButton optionsCornersThresholdSpinner; + Inkscape::UI::Widget::SpinButton optionsCornersThresholdSpinner; Gtk::HBox optionsOptimBox; Gtk::CheckButton optionsOptimButton; Gtk::Label optionsOptimToleranceLabel; - Gtk::SpinButton optionsOptimToleranceSpinner; + Inkscape::UI::Widget::SpinButton optionsOptimToleranceSpinner; //#### Credits diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index e6f113e48..4c3446a51 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -14,7 +14,7 @@ #endif #include <glibmm/i18n.h> -#include <gtk/gtkimage.h> +#include <gtk/gtk.h> #include <stddef.h> #include <sigc++/sigc++.h> diff --git a/src/ui/dialog/whiteboard-connect.cpp b/src/ui/dialog/whiteboard-connect.cpp index 0555281d4..ca18cd20d 100644 --- a/src/ui/dialog/whiteboard-connect.cpp +++ b/src/ui/dialog/whiteboard-connect.cpp @@ -14,7 +14,7 @@ */ #include <glibmm/i18n.h> -#include <gtk/gtkdialog.h> +#include <gtk/gtk.h> #include <gtkmm/entry.h> #include <gtkmm/checkbutton.h> #include <gtkmm/table.h> diff --git a/src/ui/dialog/whiteboard-sharewithchat.cpp b/src/ui/dialog/whiteboard-sharewithchat.cpp index 3315a7029..8ef69613a 100644 --- a/src/ui/dialog/whiteboard-sharewithchat.cpp +++ b/src/ui/dialog/whiteboard-sharewithchat.cpp @@ -16,7 +16,7 @@ #include <glibmm/i18n.h> #include <sigc++/sigc++.h> -#include <gtk/gtkdialog.h> +#include <gtk/gtk.h> #include "message-stack.h" #include "message-context.h" diff --git a/src/ui/dialog/whiteboard-sharewithuser.cpp b/src/ui/dialog/whiteboard-sharewithuser.cpp index 6d905b684..772184107 100644 --- a/src/ui/dialog/whiteboard-sharewithuser.cpp +++ b/src/ui/dialog/whiteboard-sharewithuser.cpp @@ -13,7 +13,7 @@ #include <glibmm/i18n.h> #include <sigc++/sigc++.h> -#include <gtk/gtkdialog.h> +#include <gtk/gtk.h> #include "message-stack.h" #include "message-context.h" diff --git a/src/ui/icon-names.h b/src/ui/icon-names.h index 2ec03c5cc..f7c16b0ed 100644 --- a/src/ui/icon-names.h +++ b/src/ui/icon-names.h @@ -556,6 +556,8 @@ "xml-text-new" #define INKSCAPE_ICON_ZOOM \ "zoom" +#define INKSCAPE_ICON_MEASURE \ + "measure" #define INKSCAPE_ICON_ZOOM_DOUBLE_SIZE \ "zoom-double-size" #define INKSCAPE_ICON_ZOOM_FIT_DRAWING \ diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 1fb98d78f..13da4a712 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -432,7 +432,7 @@ bool ControlPointSelection::_keyboardMove(GdkEventKey const &event, Geom::Point delta /= _desktop->current_zoom(); } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); + double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); delta *= nudge; } @@ -533,7 +533,7 @@ bool ControlPointSelection::_keyboardScale(GdkEventKey const &event, int dir) length_change = 1.0 / _desktop->current_zoom() * dir; } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000); + length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000, "px"); length_change *= dir; } double scale = (maxext + length_change) / maxext; diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index d005a0bdf..218e697b7 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -21,10 +21,10 @@ #include "ui/tool/node-types.h" #define INK_TYPE_NODE_TOOL (ink_node_tool_get_type ()) -#define INK_NODE_TOOL(obj) (GTK_CHECK_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) -#define INK_NODE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) -#define INK_IS_NODE_TOOL(obj) (GTK_CHECK_TYPE ((obj), INK_TYPE_NODE_TOOL)) -#define INK_IS_NODE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) +#define INK_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) +#define INK_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) +#define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) +#define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) class InkNodeTool; class InkNodeToolClass; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 7c2013872..52286c6cc 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -727,7 +727,7 @@ void PathManipulator::scaleHandle(Node *n, int which, int dir, bool pixel) length_change = 1.0 / _desktop->current_zoom() * dir; } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000); + length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000, "px"); length_change *= dir; } diff --git a/src/ui/view/CMakeLists.txt b/src/ui/view/CMakeLists.txt deleted file mode 100644 index 5c96bc40e..000000000 --- a/src/ui/view/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -SET(ui_view_SRC -desktop.cpp -desktop-events.cpp -desktop-handles.cpp -desktop-style.cpp -edit.cpp -edit-widget.cpp -view.cpp -view-widget.cpp -) diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 919b570dd..4ff4f92f9 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -137,6 +137,10 @@ struct EditWidgetInterface /// Message widget will get no content virtual void setMessage (Inkscape::MessageType type, gchar const* msg) = 0; + + /** Show an info dialog with the given message */ + virtual bool showInfoDialog( Glib::ustring const &message ) = 0; + /// Open yes/no dialog with warning text and confirmation question. virtual bool warnDialog (gchar*) = 0; diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index 9b5e9c4a8..f216c8e27 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -14,7 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtkeventbox.h> +#include <gtk/gtk.h> namespace Inkscape { namespace UI { @@ -25,10 +25,10 @@ class SPViewWidget; class SPNamedView; #define SP_TYPE_VIEW_WIDGET (sp_view_widget_get_type ()) -#define SP_VIEW_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) -#define SP_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_VIEW_WIDGET, SPViewWidgetClass)) -#define SP_IS_VIEW_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_VIEW_WIDGET)) -#define SP_IS_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_VIEW_WIDGET)) +#define SP_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) +#define SP_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VIEW_WIDGET, SPViewWidgetClass)) +#define SP_IS_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VIEW_WIDGET)) +#define SP_IS_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VIEW_WIDGET)) #define SP_VIEW_WIDGET_VIEW(w) (SP_VIEW_WIDGET (w)->view) #define SP_VIEW_WIDGET_DOCUMENT(w) (SP_VIEW_WIDGET (w)->view ? ((SPViewWidget *) (w))->view->doc : NULL) diff --git a/src/ui/view/view.h b/src/ui/view/view.h index e6853555f..13499a2e4 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -14,7 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gdk/gdktypes.h> +#include <gdk/gdk.h> #include <stddef.h> #include <sigc++/connection.h> #include "message.h" diff --git a/src/ui/widget/CMakeLists.txt b/src/ui/widget/CMakeLists.txt deleted file mode 100644 index ffc94c299..000000000 --- a/src/ui/widget/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -SET(ui_widget_SRC -button.cpp -color-picker.cpp -color-preview.cpp -combo-text.cpp -dock.cpp -dock-item.cpp -entity-entry.cpp -entry.cpp -filter-effect-chooser.cpp -handlebox.cpp -icon-widget.cpp -imageicon.cpp -imagetoggler.cpp -labelled.cpp -licensor.cpp -notebook-page.cpp -object-composite-settings.cpp -page-sizer.cpp -panel.cpp -point.cpp -preferences-widget.cpp -random.cpp -registered-widget.cpp -registry.cpp -rendering-options.cpp -rotateable.cpp -ruler.cpp -scalar.cpp -scalar-unit.cpp -selected-style.cpp -spin-slider.cpp -style-subject.cpp -style-swatch.cpp -svg-canvas.cpp -tolerance-slider.cpp -toolbox.cpp -unit-menu.cpp -zoom-status.cpp -) diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index b6069631b..bd23b6782 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -66,6 +66,8 @@ ink_common_sources += \ ui/widget/scalar.h \ ui/widget/selected-style.h \ ui/widget/selected-style.cpp \ + ui/widget/spinbutton.h \ + ui/widget/spinbutton.cpp \ ui/widget/spin-slider.h \ ui/widget/spin-slider.cpp \ ui/widget/style-subject.h \ diff --git a/src/ui/widget/combo-text.cpp b/src/ui/widget/combo-text.cpp index 7706f7c29..43428adb8 100644 --- a/src/ui/widget/combo-text.cpp +++ b/src/ui/widget/combo-text.cpp @@ -23,7 +23,7 @@ #endif #include "combo-text.h" -#include <gtk/gtkcombobox.h> +#include <gtk/gtk.h> ComboText::ComboText() : Gtk::ComboBox() diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 72a20c385..87f4d0840 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -262,7 +262,7 @@ DockItem::present() void DockItem::grab_focus() { - if (GTK_WIDGET_REALIZED (_gdl_dock_item)) { + if (gtk_widget_get_realized (_gdl_dock_item)) { // make sure the window we're in is present Gtk::Widget *toplevel = getWidget().get_toplevel(); diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index e191a9360..e62eb009c 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -25,6 +25,7 @@ #include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" +#include "sp-root.h" #include "entity-entry.h" @@ -87,8 +88,8 @@ void EntityLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); // If RDF title is not set, get the document's <title> and set the RDF: - if ( !text && !strcmp(_entity->name, "title") && doc->root ) { - text = doc->root->title(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } static_cast<Gtk::Entry*>(_packable)->set_text (text ? text : ""); @@ -133,8 +134,8 @@ void EntityMultiLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); // If RDF title is not set, get the document's <title> and set the RDF: - if ( !text && !strcmp(_entity->name, "title") && doc->root ) { - text = doc->root->title(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index 76538d6a7..8ef31a889 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -17,7 +17,7 @@ #include <gtkmm/alignment.h> #include <gtkmm/adjustment.h> #include <gtkmm/label.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/scale.h> #include <glibmm/ustring.h> @@ -47,7 +47,7 @@ private: Gtk::Label _opacity_label; Gtk::Adjustment _opacity_adjustment; Gtk::HScale _opacity_hscale; - Gtk::SpinButton _opacity_spin_button; + Inkscape::UI::Widget::SpinButton _opacity_spin_button; StyleSubject *_subject; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index f306b9eea..672e1415b 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -422,7 +422,7 @@ PageSizer::setDim (double w, double h, bool changeList) // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); - SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset); + doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index b3c8ce376..3e0c27587 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -22,7 +22,7 @@ #include <gtkmm/dialog.h> // for Gtk::RESPONSE_* #include <gtkmm/stock.h> -#include <gtk/gtkiconfactory.h> +#include <gtk/gtk.h> #include "panel.h" #include "icon-size.h" diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index afcaa338e..68faa3c66 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -227,7 +227,6 @@ void PrefSpinButton::init(Glib::ustring const &prefs_path, this->set_range (lower, upper); this->set_increments (step_increment, 0); - this->set_numeric(); this->set_value (value); this->set_width_chars(6); if (is_int) @@ -256,6 +255,45 @@ void PrefSpinButton::on_value_changed() } } +void PrefSpinUnit::init(Glib::ustring const &prefs_path, + double lower, double upper, double step_increment, + double default_value, UnitType unit_type, Glib::ustring const &default_unit) +{ + _prefs_path = prefs_path; + _is_percent = (unit_type == UNIT_TYPE_DIMENSIONLESS); + + resetUnitType(unit_type); + setUnit(default_unit); + setRange (lower, upper); /// @fixme this disregards changes of units + setIncrements (step_increment, 0); + if (step_increment < 0.1) { + setDigits(4); + } else { + setDigits(2); + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper); + Glib::ustring unitstr = prefs->getUnit(prefs_path); + if (unitstr.length() == 0) { + unitstr = default_unit; + // write the assumed unit to preferences: + prefs->setDoubleUnit(_prefs_path, value, unitstr); + } + setValue(value, unitstr); + + signal_value_changed().connect_notify(sigc::mem_fun(*this, &PrefSpinUnit::on_my_value_changed)); +} + +void PrefSpinUnit::on_my_value_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (getWidget()->is_visible()) //only take action if user changed value + { + prefs->setDoubleUnit(_prefs_path, getValue(getUnit().abbr), getUnit().abbr); + } +} + const double ZoomCorrRuler::textsize = 7; const double ZoomCorrRuler::textpadding = 5; diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 6c7f9ce4a..6caab11ae 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -17,7 +17,7 @@ #include <vector> #include <gtkmm/table.h> #include <gtkmm/comboboxtext.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/tooltips.h> #include <gtkmm/treeview.h> #include <gtkmm/radiobutton.h> @@ -32,6 +32,8 @@ #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/scalar-unit.h" namespace Inkscape { namespace UI { @@ -68,7 +70,7 @@ protected: void on_toggled(); }; -class PrefSpinButton : public Gtk::SpinButton +class PrefSpinButton : public SpinButton { public: void init(Glib::ustring const &prefs_path, @@ -81,6 +83,21 @@ protected: void on_value_changed(); }; +class PrefSpinUnit : public ScalarUnit +{ +public: + PrefSpinUnit() : ScalarUnit("", "") {}; + + void init(Glib::ustring const &prefs_path, + double lower, double upper, double step_increment, + double default_value, + UnitType unit_type, Glib::ustring const &default_unit); +protected: + Glib::ustring _prefs_path; + bool _is_percent; + void on_my_value_changed(); +}; + class ZoomCorrRuler : public Gtk::DrawingArea { public: ZoomCorrRuler(int width = 100, int height = 20); @@ -116,7 +133,7 @@ private: void on_spinbutton_value_changed(); void on_unit_changed(); - Gtk::SpinButton _sb; + Inkscape::UI::Widget::SpinButton _sb; UnitMenu _unit; Gtk::HScale _slider; ZoomCorrRuler _ruler; @@ -134,7 +151,7 @@ private: void on_spinbutton_value_changed(); Glib::ustring _prefs_path; - Gtk::SpinButton _sb; + Inkscape::UI::Widget::SpinButton _sb; Gtk::HScale _slider; bool freeze; // used to block recursive updates of slider and spinbutton }; diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 02201be12..3dcf09cb5 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -25,6 +25,8 @@ #include <glibmm/i18n.h> +#include <gtkmm/button.h> + namespace Inkscape { namespace UI { namespace Widget { diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index a220a54ad..c6ac3a381 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -108,7 +108,7 @@ Ruler::on_button_press_event(GdkEventButton *evb) _dragging = true; sp_repr_set_boolean(repr, "showguides", TRUE); sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE); - _guide = sp_guideline_new(_dt->guides, event_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.)); + _guide = sp_guideline_new(_dt->guides, NULL, event_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.)); sp_guideline_set_color(SP_GUIDELINE(_guide), _dt->namedview->guidehicolor); (void) get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK | diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 6209d40e0..1c0fdff68 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -27,6 +27,7 @@ #endif #include "scalar-unit.h" +#include "spinbutton.h" namespace Inkscape { namespace UI { @@ -65,9 +66,45 @@ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, } _unit_menu->signal_changed() .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); + + static_cast<SpinButton*>(_widget)->setUnitMenu(_unit_menu); + + lastUnits = _unit_menu->getUnitAbbr(); } /** + * Construct a ScalarUnit + * + * \param label Label. + * \param tooltip Tooltip text. + * \param take_unitmenu Use the unitmenu from this parameter. + * \param suffix Suffix, placed after the widget (defaults to ""). + * \param icon Icon filename, placed before the label (defaults to ""). + * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ +ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, + ScalarUnit &take_unitmenu, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + : Scalar(label, tooltip, suffix, icon, mnemonic), + _unit_menu(take_unitmenu._unit_menu), + _hundred_percent(0), + _absolute_is_increment(false), + _percentage_is_increment(false) +{ + _unit_menu->signal_changed() + .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); + + static_cast<SpinButton*>(_widget)->setUnitMenu(_unit_menu); + + lastUnits = _unit_menu->getUnitAbbr(); +} + + +/** * Initializes the scalar based on the settings in _unit_menu. * Requires that _unit_menu has already been initialized. */ @@ -93,6 +130,22 @@ ScalarUnit::setUnit(Glib::ustring const &unit) { return true; } +/** Adds the unit type to the ScalarUnit widget */ +void +ScalarUnit::setUnitType(UnitType unit_type) { + g_assert(_unit_menu != NULL); + _unit_menu->setUnitType(unit_type); + lastUnits = _unit_menu->getUnitAbbr(); +} + +/** Resets the unit type for the ScalarUnit widget */ +void +ScalarUnit::resetUnitType(UnitType unit_type) { + g_assert(_unit_menu != NULL); + _unit_menu->resetUnitType(unit_type); + lastUnits = _unit_menu->getUnitAbbr(); +} + /** Gets the object for the currently selected unit */ Unit ScalarUnit::getUnit() const { @@ -115,6 +168,19 @@ ScalarUnit::setValue(double number, Glib::ustring const &units) { Scalar::setValue(number); } +/** Convert and sets the number only and keeps the current unit. */ +void +ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) { + g_assert(_unit_menu != NULL); + if (units == "") { + // set the value in the default units + Scalar::setValue(number); + } else { + double conversion = _unit_menu->getConversion(units); + Scalar::setValue(number / conversion); + } +} + /** Sets the number only */ void ScalarUnit::setValue(double number) { @@ -134,6 +200,15 @@ ScalarUnit::getValue(Glib::ustring const &unit_name) const { } } +/** Grab focus, and select the text that is in the entry field. + */ +void +ScalarUnit::grabFocusAndSelectEntry() { + _widget->grab_focus(); + static_cast<SpinButton*>(_widget)->select_region(0, 20); +} + + void ScalarUnit::setHundredPercent(double number) { diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index d8b2edbd5..ed3728e69 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -32,6 +32,11 @@ public: Glib::ustring const &icon = "", UnitMenu *unit_menu = NULL, bool mnemonic = true); + ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, + ScalarUnit &take_unitmenu, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); void initScalar(double min_value, double max_value); @@ -40,9 +45,14 @@ public: double getValue(Glib::ustring const &units) const; bool setUnit(Glib::ustring const &units); + void setUnitType(UnitType unit_type); + void resetUnitType(UnitType unit_type); void setValue(double number, Glib::ustring const &units); + void setValueKeepUnit(double number, Glib::ustring const &units); void setValue(double number); + void grabFocusAndSelectEntry(); + void setHundredPercent(double number); void setAbsoluteIsIncrement(bool value); void setPercentageIsIncrement(bool value); diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 26a1f6541..6ada379fb 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -18,6 +18,7 @@ #include "scalar.h" +#include "spinbutton.h" namespace Inkscape { namespace UI { @@ -37,10 +38,9 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); } /** @@ -59,10 +59,9 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); } /** @@ -83,10 +82,9 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); } /** Fetches the precision of the spin buton */ @@ -94,7 +92,7 @@ unsigned Scalar::getDigits() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_digits(); + return static_cast<SpinButton*>(_widget)->get_digits(); } /** Gets the current step ingrement used by the spin button */ @@ -103,7 +101,7 @@ Scalar::getStep() const { g_assert(_widget != NULL); double step, page; - static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page); + static_cast<SpinButton*>(_widget)->get_increments(step, page); return step; } @@ -113,7 +111,7 @@ Scalar::getPage() const { g_assert(_widget != NULL); double step, page; - static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page); + static_cast<SpinButton*>(_widget)->get_increments(step, page); return page; } @@ -123,7 +121,7 @@ Scalar::getRangeMin() const { g_assert(_widget != NULL); double min, max; - static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max); + static_cast<SpinButton*>(_widget)->get_range(min, max); return min; } @@ -133,7 +131,7 @@ Scalar::getRangeMax() const { g_assert(_widget != NULL); double min, max; - static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max); + static_cast<SpinButton*>(_widget)->get_range(min, max); return max; } @@ -142,7 +140,7 @@ double Scalar::getValue() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_value(); + return static_cast<SpinButton*>(_widget)->get_value(); } /** Get the value spin_button represented as an integer. */ @@ -150,7 +148,7 @@ int Scalar::getValueAsInt() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_value_as_int(); + return static_cast<SpinButton*>(_widget)->get_value_as_int(); } @@ -159,7 +157,7 @@ void Scalar::setDigits(unsigned digits) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_digits(digits); + static_cast<SpinButton*>(_widget)->set_digits(digits); } /** Sets the step and page increments for the spin button @@ -169,7 +167,7 @@ void Scalar::setIncrements(double step, double /*page*/) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_increments(step, 0); + static_cast<SpinButton*>(_widget)->set_increments(step, 0); } /** Sets the minimum and maximum range allowed for the spin button */ @@ -177,7 +175,7 @@ void Scalar::setRange(double min, double max) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_range(min, max); + static_cast<SpinButton*>(_widget)->set_range(min, max); } /** Sets the value of the spin button */ @@ -186,14 +184,14 @@ Scalar::setValue(double value) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares - static_cast<Gtk::SpinButton*>(_widget)->set_value(value); + static_cast<SpinButton*>(_widget)->set_value(value); } /** Manually forces an update of the spin button */ void Scalar::update() { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->update(); + static_cast<SpinButton*>(_widget)->update(); } @@ -202,7 +200,7 @@ Scalar::update() { Glib::SignalProxy0<void> Scalar::signal_value_changed() { - return static_cast<Gtk::SpinButton*>(_widget)->signal_value_changed(); + return static_cast<SpinButton*>(_widget)->signal_value_changed(); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 6de128edb..7142ba93f 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -15,9 +15,6 @@ #ifndef INKSCAPE_UI_WIDGET_SCALAR_H #define INKSCAPE_UI_WIDGET_SCALAR_H -#include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> - #include "labelled.h" namespace Inkscape { diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 50476dc65..ae8cd564e 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -14,7 +14,7 @@ # include <config.h> #endif -#include <gtk/gtkdnd.h> +#include <gtk/gtk.h> #include "selected-style.h" diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index e74d5b1ae..0caa7fe4c 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -21,7 +21,7 @@ #include <gtkmm/menu.h> #include <gtkmm/menuitem.h> #include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <stddef.h> #include <sigc++/sigc++.h> @@ -138,7 +138,7 @@ protected: Gtk::EventBox _opacity_place; Gtk::Adjustment _opacity_adjustment; - Gtk::SpinButton _opacity_sb; + Inkscape::UI::Widget::SpinButton _opacity_sb; Gtk::Label _na[2]; Glib::ustring __na[2]; diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index faafc63b4..259b057aa 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -90,11 +90,11 @@ Gtk::HScale& SpinSlider::get_scale() return _scale; } -const Gtk::SpinButton& SpinSlider::get_spin_button() const +const Inkscape::UI::Widget::SpinButton& SpinSlider::get_spin_button() const { return _spin; } -Gtk::SpinButton& SpinSlider::get_spin_button() +Inkscape::UI::Widget::SpinButton& SpinSlider::get_spin_button() { return _spin; } diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index a4d0aa9d6..703c5d896 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -15,7 +15,7 @@ #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/scale.h> -#include <gtkmm/spinbutton.h> +#include "spinbutton.h" #include "attr-widget.h" namespace Inkscape { @@ -42,8 +42,8 @@ public: const Gtk::HScale& get_scale() const; Gtk::HScale& get_scale(); - const Gtk::SpinButton& get_spin_button() const; - Gtk::SpinButton& get_spin_button(); + const Inkscape::UI::Widget::SpinButton& get_spin_button() const; + Inkscape::UI::Widget::SpinButton& get_spin_button(); void set_update_policy(const Gtk::UpdateType); @@ -52,7 +52,7 @@ public: private: Gtk::Adjustment _adjustment; Gtk::HScale _scale; - Gtk::SpinButton _spin; + Inkscape::UI::Widget::SpinButton _spin; }; // Contains two SpinSliders for controlling number-opt-number attributes diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp new file mode 100644 index 000000000..32090f96c --- /dev/null +++ b/src/ui/widget/spinbutton.cpp @@ -0,0 +1,129 @@ +/** + * \brief SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + */ +/* + * Author: + * Johan B. C. Engelen + * + * Copyright (C) 2011 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "spinbutton.h" + +#include "unit-menu.h" +#include "util/expression-evaluator.h" +#include "event-context.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + + +void +SpinButton::connect_signals() { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + signal_focus_in_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_focus_in_event)); + signal_key_press_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_key_press_event)); +}; + +/** + * This callback function should try to convert the entered text to a number and write it to newvalue. + * It calls a method to evaluate the (potential) mathematical expression. + * + * @retval false No conversion done, continue with default handler. + * @retval true Conversion successful, don't call default handler. + */ +int +SpinButton::on_input(double* newvalue) +{ + try { + Inkscape::Util::GimpEevlQuantity result; + if (_unit_menu) { + Unit unit = _unit_menu->getUnit(); + result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); + // check if output dimension corresponds to input unit + if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { + throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); + } + } else { + result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), NULL); + } + + *newvalue = result.value; + } + catch(Inkscape::Util::EvaluatorException &e) { + g_message ("%s", e.what()); + + return false; + } + + return true; +} + +/** When focus is obtained, save the value to enable undo later. + * @retval false continue with default handler. + * @retval true don't call default handler. +*/ +bool +SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) +{ + on_focus_in_value = get_value(); + return false; // do not consume the event +} + +/** Handle specific keypress events, like Ctrl+Z + * @retval false continue with default handler. + * @retval true don't call default handler. +*/ +bool +SpinButton::on_my_key_press_event(GdkEventKey* event) +{ + switch (get_group0_keyval (event)) { + case GDK_Escape: + undo(); + return true; // I consumed the event + break; + case GDK_z: + case GDK_Z: + if (event->state & GDK_CONTROL_MASK) { + undo(); + return true; // I consumed the event + } + break; + default: + break; + } + + return false; // do not consume the event +} + +/** + * Undo the editing, by resetting the value upon when the spinbutton got focus. + */ +void +SpinButton::undo() +{ + set_value(on_focus_in_value); +} + + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h new file mode 100644 index 000000000..df913553d --- /dev/null +++ b/src/ui/widget/spinbutton.h @@ -0,0 +1,81 @@ +/** + * \brief SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + */ +/* + * Author: + * Johan B. C. Engelen + * + * Copyright (C) 2011 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_SPINBUTTON_H +#define INKSCAPE_UI_WIDGET_SPINBUTTON_H + +#include <gtkmm/spinbutton.h> + +namespace Inkscape { +namespace UI { +namespace Widget { + +class UnitMenu; + +/** + * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu). + * + * Calling "set_numeric()" effectively disables the expression parsing. If no unit menu is linked, all unitlike characters are ignored. + */ +class SpinButton : public Gtk::SpinButton +{ +public: + SpinButton(double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(climb_rate, digits), + _unit_menu(NULL) + { + connect_signals(); + }; + explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(adjustment, climb_rate, digits), + _unit_menu(NULL) + { + connect_signals(); + }; + + virtual ~SpinButton() {}; + + void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + +protected: + UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + + void connect_signals(); + int on_input(double* newvalue); + bool on_my_focus_in_event(GdkEventFocus* event); + bool on_my_key_press_event(GdkEventKey* event); + void undo(); + + double on_focus_in_value; + +private: + // noncopyable + SpinButton(const SpinButton&); + SpinButton& operator=(const SpinButton&); +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_SPINBUTTON_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp index e90a58b6e..5e5f43263 100644 --- a/src/ui/widget/toolbox.cpp +++ b/src/ui/widget/toolbox.cpp @@ -14,7 +14,7 @@ #endif #include <gtkmm/radioaction.h> -#include <gtk/gtkmain.h> +#include <gtk/gtk.h> #include "ui/widget/toolbox.h" #include "path-prefix.h" diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index b4271762c..362f5d90f 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -54,6 +54,27 @@ UnitMenu::setUnitType(UnitType unit_type) return true; } +/** Removes all unit entries, then adds the unit type to the widget. + This extracts the corresponding + units from the unit map matching the given type, and appends them + to the dropdown widget. It causes the primary unit for the given + unit_type to be selected. */ +bool +UnitMenu::resetUnitType(UnitType unit_type) +{ + clear_text(); + + return setUnitType(unit_type); +} + +/** Adds a unit, possibly user-defined, to the menu. */ +void +UnitMenu::addUnit(Unit const& u) +{ + _unit_table.addUnit(u, false); + append_text(u.abbr); +} + /** Returns the Unit object corresponding to the current selection in the dropdown widget */ Unit diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 60a9702b4..cf42231ba 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -28,6 +28,8 @@ public: virtual ~UnitMenu(); bool setUnitType(UnitType unit_type); + bool resetUnitType(UnitType unit_type); + void addUnit(Unit const& u); bool setUnit(Glib::ustring const &unit); diff --git a/src/ui/widget/zoom-status.h b/src/ui/widget/zoom-status.h index 58d595329..85c3eeee1 100644 --- a/src/ui/widget/zoom-status.h +++ b/src/ui/widget/zoom-status.h @@ -13,7 +13,7 @@ */ #include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" struct SPDesktop; @@ -22,7 +22,7 @@ namespace Inkscape { namespace UI { namespace Widget { -class ZoomStatus : public Gtk::SpinButton +class ZoomStatus : public Inkscape::UI::Widget::SpinButton { public: ZoomStatus(); |
