[ease] Double-clicking a theme creates a presentation with it.



commit e4ba66c405df9f1b69ff61d438255b5eba0342cf
Author: Stéphane Maniaci <stephane maniaci gmail com>
Date:   Fri Jun 11 03:01:48 2010 +0200

    Double-clicking a theme creates a presentation with it.

 src/WelcomeActor.vala  |    6 ++----
 src/WelcomeWindow.vala |   37 +++++++++++++++++++++++++++++--------
 2 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/src/WelcomeActor.vala b/src/WelcomeActor.vala
index 4ffcc14..408824b 100644
--- a/src/WelcomeActor.vala
+++ b/src/WelcomeActor.vala
@@ -130,15 +130,13 @@ public class Ease.WelcomeActor : Clutter.Group
 	private void fade()
 	{
 		is_selected = false;
-		slide_actor.animate(FADE_EASE, FADE_TIME, "opacity", FADE_VALUE);
-		text.animate(FADE_EASE, FADE_TIME, "opacity", FADE_VALUE);
+		this.animate(FADE_EASE, FADE_TIME, "opacity", FADE_VALUE);
 	}
 	
 	private void unfade()
 	{
 		is_selected = true;
-		slide_actor.animate(FADE_EASE, FADE_TIME, "opacity", 255);
-		text.animate(FADE_EASE, FADE_TIME, "opacity", 255);
+		this.animate(FADE_EASE, FADE_TIME, "opacity", 255);
 	}
 }
 
diff --git a/src/WelcomeWindow.vala b/src/WelcomeWindow.vala
index 65df72a..a7c6585 100644
--- a/src/WelcomeWindow.vala
+++ b/src/WelcomeWindow.vala
@@ -35,7 +35,8 @@ public class Ease.WelcomeWindow : Gtk.Window
 	// themes
 	private Gee.ArrayList<Theme> themes = new Gee.ArrayList<Theme>();
 	private Theme selected_theme;
-	private const string THEME_DIR = "/usr/local/share/ease/themes";
+	// TODO : don't hardcode the theme path.
+	private const string THEME_DIR = "/usr/share/ease/themes";
 
 	// clutter view
 	private ScrollableEmbed embed;
@@ -255,11 +256,32 @@ public class Ease.WelcomeWindow : Gtk.Window
 		// click on previews
 		foreach (var a in previews)
 		{
-			a.button_press_event.connect((act, event) => {
-				((WelcomeActor)(act)).clicked();
-				selected_theme = ((WelcomeActor)(act)).theme;
-				return false;
-			});
+			a.button_press_event.connect((act, event) =>
+                {
+                    if (event.click_count == 2) {
+                        // TODO : copy-pasted from above, let's fix that info a function.
+						try
+						{
+							// create a new Document
+							var document = new Document.from_theme(selected_theme,
+																   (int)x_res.get_value(),
+																   (int)y_res.get_value());
+
+							// create an EditorWindow for the new Document
+							var editor = new EditorWindow(document);
+
+							Main.add_window(editor);
+							Main.remove_welcome();
+						}
+						catch (Error e)
+						{
+							error_dialog(_("Error creating new document"), e.message);
+						}
+					}
+					((WelcomeActor)(act)).clicked();
+					selected_theme = ((WelcomeActor)(act)).theme;
+					return false;
+				});
 		}
 		
 		// change the zoom of the previews when the zoom slider is moved
@@ -411,5 +433,4 @@ public class Ease.WelcomeWindow : Gtk.Window
 			preview_background.height = embed.height;
 		}
 	}
-}
-
+}
\ No newline at end of file



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