Code

Cleanup
[inkscape.git] / src / connector-context.cpp
index 79872536351f4f6e9f9ce72dc2f5bc7591298830..e38f8a627d34f1b7db0b21a8c4b324b6e9fa9cdc 100644 (file)
@@ -9,7 +9,7 @@
  * Released under GNU GPL, read the file 'COPYING' for more information
  *
  * TODO:
- *  o  Have shapes avoid coonvex hulls of objects, rather than their
+ *  o  Have shapes avoid convex hulls of objects, rather than their
  *     bounding box.  Possibly implement the unfinished ConvexHull
  *     class in libnr.
  *     (HOWEVER, using the convex hull C of a shape S does the wrong thing if a
  *     an object involves going inside C but without entering S.)
  *  o  Draw connectors to shape edges rather than bounding box.
  *  o  Show a visual indicator for objects with the 'avoid' property set.
+ *  o  Allow user to change a object between a path and connector through
+ *     the interface.
  *  o  Create an interface for setting markers (arrow heads).
  *  o  Better distinguish between paths and connectors to prevent problems
  *     in the node tool and paths accidently being turned into connectors
  *     in the connector tool.  Perhaps have a way to convert between.
  *  o  Only call libavoid's updateEndPoint as required.  Currently we do it
  *     for both endpoints, even if only one is moving.
- *  o  Cleanup to remove unecessary borrowed DrawContext code.
  *  o  Allow user-placeable connection points.
  *  o  Deal sanely with connectors with both endpoints attached to the
  *     same connection point, and drawing of connectors attaching
@@ -44,6 +45,7 @@
 
 #include "connector-context.h"
 #include "pixmaps/cursor-connector.xpm"
+#include "pixmaps/cursor-connector.pixbuf"
 #include "xml/node-event-vector.h"
 #include "xml/repr.h"
 #include "svg/svg.h"
@@ -68,6 +70,9 @@
 #include "libavoid/vertices.h"
 #include "context-fns.h"
 #include "sp-namedview.h"
+#include "sp-text.h"
+#include "sp-flowtext.h"
+
 
 static void sp_connector_context_class_init(SPConnectorContextClass *klass);
 static void sp_connector_context_init(SPConnectorContext *conn_context);
@@ -176,6 +181,11 @@ sp_connector_context_init(SPConnectorContext *cc)
     SPEventContext *ec = SP_EVENT_CONTEXT(cc);
 
     ec->cursor_shape = cursor_connector_xpm;
+    ec->cursor_pixbuf = gdk_pixbuf_new_from_inline(
+            -1,
+            cursor_connector_pixbuf,
+            FALSE,
+            NULL);  
     ec->hot_x = 1;
     ec->hot_y = 1;
     ec->xp = 0;
@@ -703,7 +713,8 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
                 cc->clickeditem->setHidden(false);
                 sp_conn_adjust_path(SP_PATH(cc->clickeditem));
                 cc->clickeditem->updateRepr();
-                sp_document_done(doc);
+                sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, 
+                                 _("Reroute connector"));
                 cc_set_active_conn(cc, cc->clickeditem);
                 sp_document_ensure_up_to_date(doc);
                 cc->state = SP_CONNECTOR_CONTEXT_IDLE;
@@ -783,8 +794,8 @@ spcc_connector_set_subsequent_point(SPConnectorContext *const cc, NR::Point cons
     SPDesktop *dt = cc->desktop;
     NR::Point o = dt->dt2doc(cc->p[0]);
     NR::Point d = dt->dt2doc(p);
-    Avoid::Point src = { o[NR::X], o[NR::Y] };
-    Avoid::Point dst = { d[NR::X], d[NR::Y] };
+    Avoid::Point src(o[NR::X], o[NR::Y]);
+    Avoid::Point dst(d[NR::X], d[NR::Y]);
 
     if (!cc->newConnRef) {
         Avoid::Router *router = sp_desktop_document(dt)->router;
@@ -910,7 +921,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
     sp_curve_unref(c);
 
     /* Flush pending updates */
-    sp_document_done(doc);
+    sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector"));
     sp_document_ensure_up_to_date(doc);
 }
 
@@ -1206,6 +1217,12 @@ static bool cc_item_is_shape(SPItem *item)
             return false;
         }
     }
+    else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+        if (prefs_get_int_attribute("tools.connector", "ignoretext", 1) == 1) {
+            // Don't count text as a shape we can connect connector to.
+            return false;
+        }
+    }
     return true;
 }
 
@@ -1258,7 +1275,10 @@ void cc_selection_set_avoid(bool const set_avoid)
         return;
     }
 
-    sp_document_done(document);
+    char *event_desc = (set_avoid) ?
+            _("Make connectors avoid selected objects") :
+            _("Make connectors ignore selected objects");
+    sp_document_done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc);
 }