Code

inform user of progress during long-running simplify operations
authorjohncoswell <johncoswell@users.sourceforge.net>
Sun, 13 Aug 2006 18:48:37 +0000 (18:48 +0000)
committerjohncoswell <johncoswell@users.sourceforge.net>
Sun, 13 Aug 2006 18:48:37 +0000 (18:48 +0000)
src/splivarot.cpp

index 87ad24800c95a4b164e7b895d52078a1c28fae0c..2fd01cb69c7cabb104f084b0d1eb33fb49f882c7 100644 (file)
@@ -1482,6 +1482,13 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
   bool simplifyIndividualPaths =
     (bool) prefs_get_int_attribute("options.simplifyindividualpaths", "value", 0);
   
+  gchar *simplificationType;
+  if (simplifyIndividualPaths) {
+    simplificationType = "individual paths";
+  } else {
+    simplificationType = "as a group";
+  }
+
   bool didSomething = false;
 
   NR::Rect selectionBbox = selection->bounds();
@@ -1489,6 +1496,11 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
 
   gdouble simplifySize  = selectionSize;
   
+  int pathsSimplified = 0;
+  int totalPathCount  = g_slist_length(items);
+  
+  desktop->disableInteraction();
+  
   for (; items != NULL; items = items->next) {
       SPItem *item = (SPItem *) items->data;
       
@@ -1500,10 +1512,25 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
           simplifySize      = L2(itemBbox.dimensions());
       }
 
+
+      pathsSimplified++;
+
+      if (pathsSimplified % 20 == 0) {
+        gchar *message = g_strdup_printf(_("Simplifying %s - <b>%d</b> of <b>%d</b> paths simplified..."), simplificationType, pathsSimplified, totalPathCount);
+        desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message);
+        desktop->updateCanvasNow();
+      }
+
       didSomething |= sp_selected_path_simplify_item(desktop, selection, item,
                           threshold, justCoalesce, angleLimit, breakableAngles, simplifySize, modifySelection);
   }
 
+  desktop->enableInteraction();
+  
+  if (pathsSimplified > 20) {
+    desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, g_strdup_printf(_("Done - <b>%d</b> paths simplified."), pathsSimplified));
+  }
+  
   return didSomething;
 }