[ease] [general] Replace dialog construction with Dialog.



commit f8af83949c8f922e409a440d6d1686c42db09503
Author: Nate Stedman <natesm gmail com>
Date:   Sat Aug 7 04:01:34 2010 -0400

    [general] Replace dialog construction with Dialog.

 ease-core/ease-html-exporter.vala |   24 +++------------
 ease/ease-editor-window.vala      |   58 +++++++++----------------------------
 2 files changed, 19 insertions(+), 63 deletions(-)
---
diff --git a/ease-core/ease-html-exporter.vala b/ease-core/ease-html-exporter.vala
index 6bebd64..88f6a37 100644
--- a/ease-core/ease-html-exporter.vala
+++ b/ease-core/ease-html-exporter.vala
@@ -66,21 +66,10 @@ public class Ease.HTMLExporter : GLib.Object
 	 */
 	public bool request_path(Gtk.Window win)
 	{
-		var dialog = new Gtk.FileChooserDialog(_("Export to HTML"),
-		                                       win,
-		                                       Gtk.FileChooserAction.SAVE,
-		                                       "gtk-save",
-		                                       Gtk.ResponseType.ACCEPT,
-		                                       "gtk-cancel",
-		                                       Gtk.ResponseType.CANCEL,
-		                                       null);
+		path = Dialogs.save(_("Export to HTML"), win);
 		
-		if (dialog.run() == Gtk.ResponseType.ACCEPT)
-		{
-			// clean up the file dialog
-			path = dialog.get_filename();
-			dialog.destroy();
-			
+		if (path != null)
+		{	
 			// create the progress dialog
 			window = new Gtk.Dialog();
 			window.width_request = 400;
@@ -91,11 +80,8 @@ public class Ease.HTMLExporter : GLib.Object
 			
 			return true;
 		}
-		else
-		{
-			dialog.destroy();
-			return false;
-		}
+		
+		return false;
 	}
 	
 	/**
diff --git a/ease/ease-editor-window.vala b/ease/ease-editor-window.vala
index 63cabc8..702b6fd 100644
--- a/ease/ease-editor-window.vala
+++ b/ease/ease-editor-window.vala
@@ -415,19 +415,13 @@ internal class Ease.EditorWindow : Gtk.Window
 	[CCode (instance_pos = -1)]
 	internal void insert_image(Gtk.Widget sender)
 	{
-		var dialog = new Gtk.FileChooserDialog(_("Insert Image"),
-		                                       null,
-		                                       Gtk.FileChooserAction.OPEN,
-		                                       "gtk-cancel",
-		                                       Gtk.ResponseType.CANCEL,
-		                                       "gtk-open",
-		                                       Gtk.ResponseType.ACCEPT);
+		var filename = Dialogs.open(_("Insert Image"), this);
 
-		if (dialog.run() == Gtk.ResponseType.ACCEPT)
+		if (filename != null)
 		{
 			try
 			{
-				var img = new Clutter.Texture.from_file(dialog.get_filename());
+				var img = new Clutter.Texture.from_file(filename);
 				var e = new ImageElement();
 				
 				// set the size and position of the element
@@ -441,8 +435,8 @@ internal class Ease.EditorWindow : Gtk.Window
 				
 				e.element_type = Slide.IMAGE_TYPE;
 				e.identifier = Theme.CUSTOM_MEDIA;
-				e.filename = document.add_media_file(dialog.get_filename());
-				e.source_filename = dialog.get_filename();
+				e.filename = document.add_media_file(filename);
+				e.source_filename = filename;
 				
 				// add the element
 				slide.append(e);
@@ -453,21 +447,14 @@ internal class Ease.EditorWindow : Gtk.Window
 				error_dialog(_("Error Inserting Image"), e.message);
 			}
 		}
-		dialog.destroy();
 	}
 	
 	[CCode (instance_pos = -1)]
 	internal void insert_video(Gtk.Widget sender)
 	{
-		var dialog = new Gtk.FileChooserDialog(_("Insert Video"),
-		                                       null,
-		                                       Gtk.FileChooserAction.OPEN,
-		                                       "gtk-cancel",
-		                                       Gtk.ResponseType.CANCEL,
-		                                       "gtk-open",
-		                                       Gtk.ResponseType.ACCEPT);
+		var filename = Dialogs.open(_("Insert Video"), this);
 
-		if (dialog.run() == Gtk.ResponseType.ACCEPT)
+		if (filename != null)
 		{
 			try
 			{
@@ -481,8 +468,8 @@ internal class Ease.EditorWindow : Gtk.Window
 				
 				e.element_type = Slide.VIDEO_TYPE;
 				e.identifier = Theme.CUSTOM_MEDIA;
-				e.filename = document.add_media_file(dialog.get_filename());
-				e.source_filename = dialog.get_filename();
+				e.filename = document.add_media_file(filename);
+				e.source_filename = filename;
 				
 				// add the element
 				slide.append(e);
@@ -493,7 +480,6 @@ internal class Ease.EditorWindow : Gtk.Window
 				error_dialog(_("Error Inserting Video"), e.message);
 			}
 		}
-		dialog.destroy();
 	}
 	
 	[CCode (instance_pos = -1)]
@@ -563,29 +549,13 @@ internal class Ease.EditorWindow : Gtk.Window
 	{
 		if (document.filename == null)
 		{
-			var dialog =
-				new Gtk.FileChooserDialog(_("Save Document"),
-	        	                          null,
-	        	                          Gtk.FileChooserAction.SAVE,
-	        	                          "gtk-cancel",
-	        	                          Gtk.ResponseType.CANCEL,
-	        	                          "gtk-save",
-	        	                          Gtk.ResponseType.ACCEPT, null);
-	        
-	        var filter = new Gtk.FileFilter();
-			filter.add_pattern("*.ease");
-			dialog.filter = filter;
-
-			if (dialog.run() == Gtk.ResponseType.ACCEPT)
-			{
-				document.filename = dialog.get_filename();
-			}
-			else
+			var filename = Dialogs.save(_("Save Document"), this);
+			
+			if (filename != null)
 			{
-				dialog.destroy();
-				return false;
+				document.filename = filename;
 			}
-			dialog.destroy();
+			else return false;
 		}
 	
 		try



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