Code

Experimental pause updating scheme.
authorglimmer07 <glimmer07@users.sourceforge.net>
Wed, 22 Jul 2009 22:40:00 +0000 (22:40 +0000)
committerglimmer07 <glimmer07@users.sourceforge.net>
Wed, 22 Jul 2009 22:40:00 +0000 (22:40 +0000)
src/display/sp-canvas.cpp
src/display/sp-canvas.h
src/extension/dbus/document-interface.cpp

index e0d885d36ba245c517ec026c42ea80486d450c73..66471358255d2d24ddffab1867afb379e267bbab 100644 (file)
@@ -1028,6 +1028,8 @@ sp_canvas_init (SPCanvas *canvas)
 
     // See comment at in sp-canvas.h.
     canvas->gen_all_enter_events = false;
+    
+    canvas->drawing_disabled = false;
 
     canvas->tiles=NULL;
     canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
@@ -2085,6 +2087,9 @@ do_update (SPCanvas *canvas)
 {
     if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop durring interrupted display!
         return TRUE;
+        
+    if (canvas->drawing_disabled)
+        return TRUE;
 
     /* Cause the update if necessary */
     if (canvas->need_update) {
index 35e3fb5de863d56f4de46a597f28f061ea92f679..a17e2e086ffc4854cfcfd2d12c83baecc2569ac6 100644 (file)
@@ -181,6 +181,9 @@ struct SPCanvas {
     // connector tool).  If so, they may temporarily set this flag to
     // 'true'.
     bool gen_all_enter_events;
+    
+    /* For scripting, sometimes we want to delay drawing. */
+    bool drawing_disabled;
 
     int rendermode;
 
index 664655f0e262b8ccdbcc8828a4150778c7b59966..76eeec509d7ea8323f9007a278b2dcdb06ef13d2 100644 (file)
@@ -161,8 +161,8 @@ finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::N
 
     if (object->updates)
         sp_document_done(sp_desktop_document(object->desk), 0, (gchar *)desc);
-    else
-        document_interface_pause_updates(object, error);
+    //else
+        //document_interface_pause_updates(object, error);
 
     return strdup(newNode->attribute("id"));
 }
@@ -178,10 +178,13 @@ dbus_call_verb (DocumentInterface *object, int verbid, GError **error)
         if ( verb ) {
             SPAction *action = verb->get_action(desk2);
             if ( action ) {
+                //if (!object->updates)
+                    //document_interface_pause_updates (object, error);
                 sp_action_perform( action, NULL );
-                if (object->updates) {
+                if (object->updates)
                     sp_document_done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip()));
-                }
+                //if (!object->updates)
+                    //document_interface_pause_updates (object, error);
                 return TRUE;
             }
         }
@@ -433,8 +436,8 @@ document_interface_node (DocumentInterface *object, gchar *type, GError **error)
 
     if (object->updates)
         sp_document_done(sp_desktop_document(object->desk), 0, (gchar *)"created empty node");
-    else
-        document_interface_pause_updates(object, error);
+    //else
+        //document_interface_pause_updates(object, error);
 
     return strdup(newNode->attribute("id"));
 }
@@ -699,6 +702,7 @@ document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape
     Geom::parse_svg_path (path);
     return NULL;
     */
+    return NULL;
 }
 
 
@@ -813,16 +817,22 @@ void
 document_interface_pause_updates (DocumentInterface *object, GError **error)
 {
     object->updates = FALSE;
-    sp_desktop_document(object->desk)->root->uflags = FALSE;
-    sp_desktop_document(object->desk)->root->mflags = FALSE;
+    object->desk->canvas->drawing_disabled = 1;
+    //object->desk->canvas->need_redraw = 0;
+    //object->desk->canvas->need_repick = 0;
+    //sp_desktop_document(object->desk)->root->uflags = FALSE;
+    //sp_desktop_document(object->desk)->root->mflags = FALSE;
 }
 
 void
 document_interface_resume_updates (DocumentInterface *object, GError **error)
 {
     object->updates = TRUE;
-    sp_desktop_document(object->desk)->root->uflags = TRUE;
-    sp_desktop_document(object->desk)->root->mflags = TRUE;
+    object->desk->canvas->drawing_disabled = 0;
+    //object->desk->canvas->need_redraw = 1;
+    //object->desk->canvas->need_repick = 1;
+    //sp_desktop_document(object->desk)->root->uflags = TRUE;
+    //sp_desktop_document(object->desk)->root->mflags = TRUE;
     //sp_desktop_document(object->desk)->_updateDocument();
     //FIXME: use better verb than rect.
     sp_document_done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions");
@@ -833,7 +843,9 @@ document_interface_update (DocumentInterface *object, GError **error)
 {
     sp_desktop_document(object->desk)->root->uflags = TRUE;
     sp_desktop_document(object->desk)->root->mflags = TRUE;
+    object->desk->enableInteraction();
     sp_desktop_document(object->desk)->_updateDocument();
+    object->desk->disableInteraction();
     sp_desktop_document(object->desk)->root->uflags = FALSE;
     sp_desktop_document(object->desk)->root->mflags = FALSE;
     //sp_document_done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions");
@@ -989,12 +1001,23 @@ document_interface_selection_copy (DocumentInterface *object, GError **error)
     //sp_selection_copy ();
     return dbus_call_verb (object, SP_VERB_EDIT_COPY, error);
 }
-
+/*
+gboolean
+document_interface_selection_paste (DocumentInterface *object, GError **error)
+{
+    desktop_ensure_active (object->desk);
+                    if (!object->updates)
+                    document_interface_pause_updates (object, error);
+    sp_selection_paste (object->desk, TRUE);
+                    if (!object->updates)
+                    document_interface_pause_updates (object, error);
+    return TRUE;
+    //return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error);
+}
+*/
 gboolean
 document_interface_selection_paste (DocumentInterface *object, GError **error)
 {
-    //desktop_ensure_active (object->desk);
-    //sp_selection_paste (object->desk, TRUE);
     return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error);
 }