[ease/themes] [editor] Added support for undoing colors.



commit 003e8bdfeca5e947dac9009cf2b3211e803ac58f
Author: Nate Stedman <natesm gmail com>
Date:   Thu Jul 22 02:43:42 2010 -0400

    [editor] Added support for undoing colors.
    
    - Also renamed ease-undo-actions to ease-undo-action
      as the file is no longer intended for many
      subclasses.

 Makefile.am                                        |    2 +-
 src/ease-editor-window.vala                        |   14 ++++++++++++++
 ...ase-undo-actions.vala => ease-undo-action.vala} |    5 +++++
 3 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9a92585..e62d567 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,7 +50,7 @@ ease_SOURCES = \
 	src/ease-transformations.vala \
 	src/ease-transition-pane.vala \
 	src/ease-transitions.vala \
-	src/ease-undo-actions.vala \
+	src/ease-undo-action.vala \
 	src/ease-undo-controller.vala \
 	src/ease-utilities.vala \
 	src/ease-welcome-actor.vala \
diff --git a/src/ease-editor-window.vala b/src/ease-editor-window.vala
index a63b931..6368ede 100644
--- a/src/ease-editor-window.vala
+++ b/src/ease-editor-window.vala
@@ -67,6 +67,11 @@ public class Ease.EditorWindow : Gtk.Window
 	private UndoController undo;
 	
 	/**
+	 * Space to temporarily cache an { link UndoAction}.
+	 */
+	private UndoAction undo_action;
+	
+	/**
 	 * The undo button.
 	 */
 	private Gtk.ToolButton undo_button;
@@ -414,6 +419,9 @@ public class Ease.EditorWindow : Gtk.Window
 		// store the original color in case the user cancels	
 		var original_color = embed.selected.element.get_color();
 		
+		// create an UndoAction for potential use
+		undo_action = new UndoAction(embed.selected.element, "color");
+		
 		// create the dialog
 		color_dialog = new Gtk.ColorSelectionDialog(_("Select Color"));
 		color_selection = color_dialog.color_selection as Gtk.ColorSelection;
@@ -435,6 +443,12 @@ public class Ease.EditorWindow : Gtk.Window
 		// hide the dialog when the ok button is clicked
 		(color_dialog.ok_button as Gtk.Button).clicked.connect(() => {
 			color_dialog.hide();
+			
+			// if the color was changed, add the UndoAction
+			if (original_color != embed.selected.element.get_color())
+			{
+				add_undo_action(undo_action);
+			}
 		});
 		
 		// reset the original color and hide the dialog when cancel is clicked
diff --git a/src/ease-undo-actions.vala b/src/ease-undo-action.vala
similarity index 96%
rename from src/ease-undo-actions.vala
rename to src/ease-undo-action.vala
index d91b098..fa39ba7 100644
--- a/src/ease-undo-actions.vala
+++ b/src/ease-undo-action.vala
@@ -73,10 +73,15 @@ public class Ease.UndoAction : Object
 		
 		public UndoPair(GLib.Object obj, string prop)
 		{
+			// basic properties
 			object = obj;
 			property = prop;
+			
+			// find the type and create a value
 			type = obj.get_class().find_property(prop).value_type;
 			val = GLib.Value(type);
+			
+			// fill in the GValue
 			obj.get_property(prop, ref val);
 		}
 		



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