[ease/themes] [editor] Allow the user to change typefaces.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/themes] [editor] Allow the user to change typefaces.
- Date: Fri, 23 Jul 2010 15:17:43 +0000 (UTC)
commit 56a40d2f34278b8ba70217e225ddfa14d5b8954a
Author: Nate Stedman <natesm gmail com>
Date: Fri Jul 23 11:17:15 2010 -0400
[editor] Allow the user to change typefaces.
data/ui/editor-window.ui | 1 +
src/ease-editor-embed.vala | 7 +++++--
src/ease-editor-window.vala | 28 ++++++++++++++++++++++++++++
src/ease-text-actor.vala | 16 ++++++++++++----
src/ease-text-element.vala | 14 +++++++++++++-
5 files changed, 59 insertions(+), 7 deletions(-)
---
diff --git a/data/ui/editor-window.ui b/data/ui/editor-window.ui
index 12bf8ec..532cfd9 100644
--- a/data/ui/editor-window.ui
+++ b/data/ui/editor-window.ui
@@ -404,6 +404,7 @@
<property name="label" translatable="yes">Fonts</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-select-font</property>
+ <signal name="clicked" handler="ease_editor_window_select_font"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/ease-editor-embed.vala b/src/ease-editor-embed.vala
index eeaae76..3db88f5 100644
--- a/src/ease-editor-embed.vala
+++ b/src/ease-editor-embed.vala
@@ -256,9 +256,12 @@ public class Ease.EditorEmbed : ScrollableEmbed
*/
public void set_slide(Slide slide)
{
- if (slide == null)
+ if (slide == null) return;
+
+ if (is_editing)
{
- return;
+ selected.end_edit(this);
+ is_editing = false;
}
// clean up the previous slide
diff --git a/src/ease-editor-window.vala b/src/ease-editor-window.vala
index f73f200..95bfa28 100644
--- a/src/ease-editor-window.vala
+++ b/src/ease-editor-window.vala
@@ -108,6 +108,9 @@ public class Ease.EditorWindow : Gtk.Window
200, 250, 300, 400};
private const string UI_FILE_PATH = "editor-window.ui";
+
+ private const string FONT_TEXT =
+ _("The quick brown fox jumps over the lazy dog");
/**
* Creates a new EditorWindow.
@@ -497,6 +500,31 @@ public class Ease.EditorWindow : Gtk.Window
Transformations.clutter_color_to_gdk_color(color);
}
+ [CCode (instance_pos = -1)]
+ public void select_font(Gtk.Widget? sender)
+ {
+ var font_selection = new Gtk.FontSelectionDialog(_("Select Font"));
+
+ var text = embed.selected.element as TextElement;
+
+ font_selection.set_preview_text(text.text != "" ?
+ text.text : FONT_TEXT);
+
+ font_selection.set_font_name(text.font_description.to_string());
+
+ switch (font_selection.run())
+ {
+ case Gtk.ResponseType.OK:
+ text.font_description =
+ Pango.FontDescription.from_string(
+ font_selection.get_font_name());
+ text.parent.changed(text.parent);
+ break;
+ }
+
+ font_selection.destroy();
+ }
+
private ZoomSlider create_zoom_slider()
{
// create zoom slider
diff --git a/src/ease-text-actor.vala b/src/ease-text-actor.vala
index 9cc2ab4..07910db 100644
--- a/src/ease-text-actor.vala
+++ b/src/ease-text-actor.vala
@@ -45,17 +45,16 @@ public class Ease.TextActor : Actor
base(e, c);
var text = new Clutter.Text();
+ contents = text;
// set actor properties
text.use_markup = true;
text.line_wrap = true;
text.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
text.color = e.color;
- text.set_markup(e.has_been_edited ? e.get("text") : DEFAULT_TEXT);
- text.font_name = e.font_description.to_string();
text.line_alignment = e.text_align;
-
- contents = text;
+ format(e);
+ text.set_markup(e.has_been_edited ? e.get("text") : DEFAULT_TEXT);
add_actor(contents);
contents.width = e.width;
@@ -67,6 +66,15 @@ public class Ease.TextActor : Actor
e.notify["color"].connect((sender, spec) => {
text.color = (sender as TextElement).color;
});
+
+ e.notify["font-description"].connect((sender, spec) => {
+ format(element as TextElement);
+ });
+ }
+
+ private void format(TextElement e)
+ {
+ (contents as Clutter.Text).font_name = e.font_description.to_string();
}
/**
diff --git a/src/ease-text-element.vala b/src/ease-text-element.vala
index baca0c7..bef1ec9 100644
--- a/src/ease-text-element.vala
+++ b/src/ease-text-element.vala
@@ -20,6 +20,8 @@
*/
public class Ease.TextElement : Element
{
+ private bool freeze = false;
+
/**
* Create a new element, with an empty { link ElementMap}.
*/
@@ -162,7 +164,11 @@ public class Ease.TextElement : Element
public string font_name
{
owned get { return data.get(Theme.TEXT_FONT); }
- set { data.set(Theme.TEXT_FONT, value); }
+ set
+ {
+ data.set(Theme.TEXT_FONT, value);
+ if (!freeze) notify_property("font-description");
+ }
}
/**
@@ -196,6 +202,7 @@ public class Ease.TextElement : Element
data.set(Theme.TEXT_STYLE, "Normal");
break;
}
+ if (!freeze) notify_property("font-description");
}
}
@@ -215,6 +222,7 @@ public class Ease.TextElement : Element
data.set(Theme.TEXT_VARIANT,
value == Pango.Variant.NORMAL ?
"Normal" : "Small Caps");
+ if (!freeze) notify_property("font-description");
}
}
@@ -230,6 +238,7 @@ public class Ease.TextElement : Element
set
{
data.set(Theme.TEXT_WEIGHT, ((int)value).to_string());
+ if (!freeze) notify_property("font-description");
}
}
@@ -254,11 +263,13 @@ public class Ease.TextElement : Element
}
set
{
+ 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;
+ freeze = false;
}
}
@@ -317,6 +328,7 @@ public class Ease.TextElement : Element
set
{
data.set(Theme.TEXT_SIZE, value.to_string());
+ if (!freeze) notify_property("font-description");
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]