From: johanengelen Date: Sun, 1 Apr 2007 22:32:34 +0000 (+0000) Subject: removed leftover debug messages. Toggling new grids now works. Almost ready to commen... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=115d424c293045ccb2bb23f6b2322a2dd6e13a7d;p=inkscape.git removed leftover debug messages. Toggling new grids now works. Almost ready to comment-out old grid code. --- diff --git a/src/desktop.cpp b/src/desktop.cpp index 0d7d43646..187dcd010 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1094,6 +1094,14 @@ void SPDesktop::clearWaitingCursor() sp_event_context_update_cursor(sp_desktop_event_context(this)); } +void SPDesktop::toggleGrid() +{ + for ( GSList const *l = namedview->grids; l != NULL; l = l->next) { + Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; + grid->toggle_visibility(); + } +} + //---------------------------------------------------------------------- // Callback implementations. The virtual ones are connected by the view. diff --git a/src/desktop.h b/src/desktop.h index e5f9cdacc..1770af9f5 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -245,6 +245,8 @@ struct SPDesktop : public Inkscape::UI::View::View void setWaitingCursor(); void clearWaitingCursor(); + void toggleGrid(); + void fullscreen(); void registerEditWidget (Inkscape::UI::View::EditWidgetInterface *widget) diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 643ffccdc..f343077c3 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -143,7 +143,7 @@ CanvasGrid::CanvasGrid(SPDesktop *desktop, Inkscape::XML::Node * in_repr) gtk_object_ref(GTK_OBJECT(canvasitem)); // since we're keeping a copy, we need to bump up the ref count canvasitem->grid = this; - enabled = false; + snapenabled = false; visible = false; // sp_canvas_item_hide(canvasitem); @@ -166,7 +166,6 @@ CanvasGrid::~CanvasGrid() // deref canvasitem gtk_object_unref(GTK_OBJECT(canvasitem)); g_free(canvasitem); - g_message("~CanvasGrid"); } /* @@ -217,6 +216,7 @@ CanvasGrid::hide() { sp_canvas_item_hide(canvasitem); visible = false; + disable_snapping(); // temporary hack, because at the moment visibilty and snapping are linked } void @@ -224,6 +224,25 @@ CanvasGrid::show() { sp_canvas_item_show(canvasitem); visible = true; + enable_snapping(); // temporary hack, because at the moment visibilty and snapping are linked +} + +void +CanvasGrid::set_visibility(bool visible) +{ + this->visible = visible; + if(visible) { + show(); + } else { + hide(); + } +} + +void +CanvasGrid::toggle_visibility() +{ + visible = !visible; + set_visibility(visible); } void diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index c501ab3f3..54a57d3d0 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -73,10 +73,13 @@ public: virtual Gtk::Widget & getWidget() = 0; - bool enabled; - bool visible; void hide(); void show(); + void set_visibility(bool visible); + void toggle_visibility(); + void enable_snapping() { snapenabled = true; snapper->setEnabled(true); } ; + void disable_snapping() { snapenabled = false; snapper->setEnabled(false); } ; + void toggle_snapping() { snapenabled = !snapenabled; snapper->setEnabled(snapenabled);}; Inkscape::XML::Node * repr; @@ -90,6 +93,9 @@ protected: Gtk::VBox vbox; + bool snapenabled; + bool visible; + private: CanvasGrid(const CanvasGrid&); CanvasGrid& operator=(const CanvasGrid&); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 0928de19e..26c53c8e0 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -527,8 +527,6 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { -g_message("named view:: child added"); - SPNamedView *nv = (SPNamedView *) object; if (((SPObjectClass *) (parent_class))->child_added) { @@ -660,7 +658,7 @@ void SPNamedView::show(SPDesktop *desktop) Inkscape::CanvasXYGrid* addedgrid = new Inkscape::CanvasXYGrid(desktop, child); if (addedgrid) { grids = g_slist_append(grids, addedgrid); - addedgrid->enabled = true; + addedgrid->enable_snapping(); addedgrid->show(); } } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 3f84c1808..fff815d8c 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -388,11 +388,7 @@ DocumentProperties::update_gridspage() } _grids_notebook.show_all(); - const Gtk::Widget* widget_array[] = - { - (Gtk::Widget*) &_grids_notebook, 0 - }; - attach_all (_page_grids.table(), widget_array, sizeof(widget_array),3); // FIXME: a hack to let GTK show all tabs, otherwise XML manually added grids setting widgets do no show. + _page_grids.table().resize_children(); } /** diff --git a/src/verbs.cpp b/src/verbs.cpp index 28e008486..172b5220c 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1552,6 +1552,7 @@ ZoomVerb::perform(SPAction *action, void *data, void *pdata) break; case SP_VERB_TOGGLE_GRID: sp_namedview_toggle_grid(doc, repr); + dt->toggleGrid(); break; #ifdef HAVE_GTK_WINDOW_FULLSCREEN case SP_VERB_FULLSCREEN: