[ease/themes] [general] Standardize TextElement property names.



commit 83a3de46901b5684b35f641f1c5cf687e5334a5f
Author: Nate Stedman <natesm gmail com>
Date:   Fri Jul 23 16:30:50 2010 -0400

    [general] Standardize TextElement property names.
    
    - TextElement property names now match their
      representation in themes and saved documents.
    - TextElement HTML export uses Theme.CONSTANTs
      to request properties as strings.

 src/ease-document.vala      |    3 ++-
 src/ease-editor-window.vala |    9 +++++++++
 src/ease-text-element.vala  |   38 +++++++++++++++++++-------------------
 src/ease-theme.vala         |    2 +-
 4 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/src/ease-document.vala b/src/ease-document.vala
index b6c70c3..37e3072 100644
--- a/src/ease-document.vala
+++ b/src/ease-document.vala
@@ -78,7 +78,8 @@ public class Ease.Document : SlideSet
 	 * @param w The width of the new Document.
 	 * @param h The height of the new Document.
 	 */
-	public Document.from_theme(Theme doc_theme, int w, int h) throws GLib.Error
+	public Document.from_theme(Theme doc_theme,
+	                           int w, int h) throws GLib.Error
 	{
 		assert(doc_theme != null);
 		
diff --git a/src/ease-editor-window.vala b/src/ease-editor-window.vala
index d47323a..fd5af2e 100644
--- a/src/ease-editor-window.vala
+++ b/src/ease-editor-window.vala
@@ -503,24 +503,33 @@ public class Ease.EditorWindow : Gtk.Window
 	[CCode (instance_pos = -1)]
 	public void select_font(Gtk.Widget? sender)
 	{
+		// create a font selection dialog
 		var font_selection = new Gtk.FontSelectionDialog(_("Select Font"));
 		
+		// grab the selected element, classes as TextElement
 		var text = embed.selected.element as TextElement;
 		
+		// set the preview text to the element's text, if none, use preview text
 		font_selection.set_preview_text(text.text != "" ?
 		                                text.text : FONT_TEXT);
 		
+		// set the dialog's font to the current font
 		font_selection.set_font_name(text.font_description.to_string());
 		
+		// run the dialog
 		switch (font_selection.run())
 		{
 			case Gtk.ResponseType.OK:
+				// allow the user to undo the font change
 				add_undo_action(
 					new UndoAction(embed.selected.element, "font-description"));
 				
+				// set the font description to the new font
 				text.font_description = 
 					Pango.FontDescription.from_string(
 						font_selection.get_font_name());
+						
+				// emit the "changed" signal on the element's slide
 				text.parent.changed(text.parent);
 				break;
 		}
diff --git a/src/ease-text-element.vala b/src/ease-text-element.vala
index bef1ec9..8f101d9 100644
--- a/src/ease-text-element.vala
+++ b/src/ease-text-element.vala
@@ -86,16 +86,16 @@ public class Ease.TextElement : Element
 		html += " color:" + 
 		        @"rgb($(color.red),$(color.green),$(color.blue));";
 		        
-		html += " font-family:'" + data.get("font_name") +
+		html += " font-family:'" + data.get(Theme.TEXT_FONT) +
 		        "', sans-serif;";
 		        
-		html += " font-size:" + data.get("font_size") + "pt;";
+		html += " font-size:" + data.get(Theme.TEXT_SIZE) + "pt;";
 		
-		html += " font-weight:" + data.get("font_weight") + ";";
-		html += " font-style:" + data.get("font_style").down() +
+		html += " font-weight:" + data.get(Theme.TEXT_WEIGHT) + ";";
+		html += " font-style:" + data.get(Theme.TEXT_STYLE).down() +
 		        ";";
 		        
-		html += " text-align:" + data.get("align") + ";\"";
+		html += " text-align:" + data.get(Theme.TEXT_ALIGN) + ";\"";
 		
 		// write the actual content
 		html += ">" + data.get("text").replace("\n", "<br />") +
@@ -161,7 +161,7 @@ public class Ease.TextElement : Element
 	/**
 	 * The name of the text's font family.
 	 */
-	public string font_name
+	public string text_font
 	{
 		owned get { return data.get(Theme.TEXT_FONT); }
 		set
@@ -174,7 +174,7 @@ public class Ease.TextElement : Element
 	/**
 	 * The PangoStyle for this Element.
 	 */
-	public Pango.Style font_style
+	public Pango.Style text_style
 	{
 		get
 		{
@@ -209,7 +209,7 @@ public class Ease.TextElement : Element
 	/**
 	 * The PangoVariant for this Element.
 	 */
-	public Pango.Variant font_variant
+	public Pango.Variant text_variant
 	{
 		get
 		{
@@ -229,7 +229,7 @@ public class Ease.TextElement : Element
 	/**
 	 * The font's weight.
 	 */
-	public Pango.Weight font_weight
+	public Pango.Weight text_weight
 	{
 		get
 		{
@@ -246,7 +246,7 @@ public class Ease.TextElement : Element
 	 * A full PangoFontDescription for this Element.
 	 *
 	 * This property creates a new FontDescription when retrieved, and
-	 * sets all appropriate properties (font_weight, etc.) when set.
+	 * sets all appropriate properties (text_weight, etc.) when set.
 	 */
 	public Pango.FontDescription font_description
 	{
@@ -254,10 +254,10 @@ public class Ease.TextElement : Element
 		{
 			var desc = new Pango.FontDescription();
 			desc.set_family(data.get(Theme.TEXT_FONT));
-			desc.set_style(font_style);
-			desc.set_weight(font_weight);
-			desc.set_variant(font_variant);
-			desc.set_size(font_size * Pango.SCALE);
+			desc.set_style(text_style);
+			desc.set_weight(text_weight);
+			desc.set_variant(text_variant);
+			desc.set_size(text_size * Pango.SCALE);
 			
 			return desc;
 		}
@@ -265,10 +265,10 @@ public class Ease.TextElement : Element
 		{
 			freeze = true;
 			data.set(Theme.TEXT_FONT, value.get_family());
-			font_style = value.get_style();
-			font_weight = value.get_weight();
-			font_variant = value.get_variant();
-			font_size = value.get_size() / Pango.SCALE;
+			text_style = value.get_style();
+			text_weight = value.get_weight();
+			text_variant = value.get_variant();
+			text_size = value.get_size() / Pango.SCALE;
 			freeze = false;
 		}
 	}
@@ -319,7 +319,7 @@ public class Ease.TextElement : Element
 	 * This value should be multiplied by Pango.SCALE for rendering, otherwise
 	 * the text will be far too small to be visible.
 	 */
-	public int font_size
+	public int text_size
 	{
 		get
 		{
diff --git a/src/ease-theme.vala b/src/ease-theme.vala
index ba124f8..6f98d0c 100644
--- a/src/ease-theme.vala
+++ b/src/ease-theme.vala
@@ -93,7 +93,7 @@ public class Ease.Theme : GLib.Object
 	public string title;
 	
 	/**
-mk	 * The path to the theme's extracted files.
+	 * The path to the theme's extracted files.
 	 */
 	public string path { get; set; }
 	



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