[f-spot: 3/6] Extract FinishTagCompletion from OnActivate



commit 3b1b8754a99cab23369d01f51b600cc4538f0db4
Author: Joachim Breitner <mail joachim-breitner de>
Date:   Thu Jun 11 21:30:35 2009 +0200

    Extract FinishTagCompletion from OnActivate
    
    This patch separates the two actions of confirming a tab completion and
    of actually applying the changes into different methods. It does not
    change the semantics of the code.

 src/Widgets/TagEntry.cs |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/Widgets/TagEntry.cs b/src/Widgets/TagEntry.cs
index 6ff56b3..bb30669 100644
--- a/src/Widgets/TagEntry.cs
+++ b/src/Widgets/TagEntry.cs
@@ -134,9 +134,12 @@ namespace FSpot.Widgets {
 				args.RetVal = false;
 			} else if (args.Event.Key == Gdk.Key.Return) { 
 				if (tag_completion_index != -1) {
-					OnActivated ();
+					// If we are completing a tag, then finish that
+					FinishTagCompletion ();
 					args.RetVal = true;
 				} else
+					// Otherwise, pass the event to Gtk.Entry
+					// which will call OnActivated
 					args.RetVal = false;
 			} else if (args.Event.Key == Gdk.Key.Tab) {
 				DoTagCompletion (true);
@@ -204,22 +207,25 @@ namespace FSpot.Widgets {
 			SelectRegion (tag_completion_typed_position, Text.Length);
 		}
 
-		//Activated means the user pressed 'Enter'
-		protected override void OnActivated ()
+		void FinishTagCompletion ()
 		{
-			string [] tagnames = GetTypedTagNames ();
-	
-			if (tagnames == null)
-				return;
-
 			int sel_start, sel_end;
 			if (GetSelectionBounds (out sel_start, out sel_end) && tag_completion_index != -1) {
 				InsertText (", ", ref sel_end);
 				SelectRegion (-1, -1);
 				Position = sel_end + 2;
 				ClearTagCompletions ();
-				return;
 			}
+			
+		}
+
+		//Activated means the user pressed 'Enter'
+		protected override void OnActivated ()
+		{
+			string [] tagnames = GetTypedTagNames ();
+	
+			if (tagnames == null)
+				return;
 
 			// Add any new tags to the selected photos
 			ArrayList new_tags = new ArrayList ();



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