[gnumeric] clipboard: simplify interface for undo



commit a534d94da65140cfe70b2ac89538aa71db61cb4f
Author: Morten Welinder <terra gnome org>
Date:   Fri May 23 11:38:38 2014 -0400

    clipboard: simplify interface for undo
    
    With this change, a single call to clipboard_copy_ranges_undo will create
    an undo object for the selection.

 ChangeLog       |    5 +++++
 src/clipboard.c |   23 +++++++++++++++++++++++
 src/clipboard.h |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ae7ee8f..e2ff43d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-23  Morten Welinder  <terra gnome org>
+
+       * src/clipboard.c (clipboard_copy_ranges_undo): New function.  We
+       need better building blocks for commands; this is one such.
+
 2014-05-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * src/commands.c (cmd_hyperlink_undo): use posiitons rather than cells
diff --git a/src/clipboard.c b/src/clipboard.c
index a29f113..5f63238 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -755,6 +755,29 @@ clipboard_copy_range_undo (Sheet *sheet, GnmRange const *r)
                                   (GFreeFunc)g_free);
 }
 
+/**
+ * clipboard_copy_ranges_undo:
+ * @sheet: #Sheet
+ * @ranges: (element-type GnmRange) (transfer none): list of ranges
+ *
+ * Returns: (transfer full): A #GOUndo object that will restore the contents
+ * of the given range.
+ **/
+GOUndo *
+clipboard_copy_ranges_undo (Sheet *sheet, GSList *ranges)
+{
+       GSList *l;
+       GOUndo *undo = NULL;
+
+       for (l = ranges; l != NULL; l = l->next) {
+               GnmRange *r = l->data;
+               GOUndo *undo1 = clipboard_copy_range_undo (sheet, r);
+               undo = go_undo_combine (undo, undo1);
+       }
+
+       return undo;
+}
+
 
 /**
  * clipboard_copy_obj:
diff --git a/src/clipboard.h b/src/clipboard.h
index a026a95..e13347c 100644
--- a/src/clipboard.h
+++ b/src/clipboard.h
@@ -85,6 +85,7 @@ GType gnm_paste_target_get_type (void);
 
 GnmCellRegion  *clipboard_copy_range   (Sheet *sheet, GnmRange const *r);
 GOUndo         *clipboard_copy_range_undo (Sheet *sheet, GnmRange const *r);
+GOUndo         *clipboard_copy_ranges_undo (Sheet *sheet, GSList *ranges);
 GnmCellRegion  *clipboard_copy_obj     (Sheet *sheet, GSList *objects);
 gboolean        clipboard_paste_region (GnmCellRegion const *cr,
                                        GnmPasteTarget const *pt,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]