[ease] [editor] Allow the user to add custom text
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [editor] Allow the user to add custom text
- Date: Sat, 24 Jul 2010 21:53:01 +0000 (UTC)
commit 4c5d683edfb8154b8a7555ded0d53b2f05f460a1
Author: Nate Stedman <natesm gmail com>
Date: Sat Jul 24 17:52:09 2010 -0400
[editor] Allow the user to add custom text
- User can add custom text.
- New elements are automatically selected.
- New text type "custom-text".
data/theme-defaults.json | 5 +++++
data/ui/editor-window.ui | 13 +++++++++++++
src/ease-editor-embed.vala | 36 +++++++++++++++++++++++++++++++++---
src/ease-editor-window.vala | 12 ++++++++++++
src/ease-theme.vala | 14 +++++++++++++-
src/ease-undo-action.vala | 4 ++--
6 files changed, 78 insertions(+), 6 deletions(-)
---
diff --git a/data/theme-defaults.json b/data/theme-defaults.json
index 5b28d38..5ade5d6 100644
--- a/data/theme-defaults.json
+++ b/data/theme-defaults.json
@@ -43,6 +43,11 @@
"content-text" : {
"padding-top" : "20"
+ },
+
+ "custom-text" : {
+ "width" : "400",
+ "height" : "75"
}
},
diff --git a/data/ui/editor-window.ui b/data/ui/editor-window.ui
index a914783..9827465 100644
--- a/data/ui/editor-window.ui
+++ b/data/ui/editor-window.ui
@@ -183,6 +183,19 @@
<property name="use_underline">True</property>
</object>
</child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem3">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="Insert Text">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Text</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="ease_editor_window_insert_text"/>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/ease-editor-embed.vala b/src/ease-editor-embed.vala
index b567050..521563e 100644
--- a/src/ease-editor-embed.vala
+++ b/src/ease-editor-embed.vala
@@ -270,7 +270,8 @@ public class Ease.EditorEmbed : ScrollableEmbed
ActorContext.EDITOR);
// make the elements clickable
- for (unowned List<Clutter.Actor>* itr = slide_actor.contents.get_children();
+ for (unowned List<Clutter.Actor>* itr =
+ slide_actor.contents.get_children();
itr != null;
itr = itr->next)
{
@@ -344,6 +345,25 @@ public class Ease.EditorEmbed : ScrollableEmbed
}
/**
+ * Selects an { link Actor} by { link Element}.
+ *
+ * @param e The element to search for.
+ */
+ public void select_element(Element e)
+ {
+ for (unowned List<Clutter.Actor>* itr =
+ slide_actor.contents.get_children();
+ itr != null;
+ itr = itr->next)
+ {
+ if (((Actor*)(itr->data))->element == e)
+ {
+ select_actor(itr->data as Actor);
+ }
+ }
+ }
+
+ /**
* Signal handler for clicking on { link Actor}s.
*
* This handler is attached to the button_press_event of all
@@ -377,6 +397,18 @@ public class Ease.EditorEmbed : ScrollableEmbed
return true;
}
+ select_actor(sender as Actor);
+
+ return true;
+ }
+
+ /**
+ * Selects an { link Actor}.
+ *
+ * @param sender The Actor to select.
+ */
+ private void select_actor(Actor sender)
+ {
// if editing another Actor, finish that edit
if (selected != null && is_editing)
{
@@ -421,8 +453,6 @@ public class Ease.EditorEmbed : ScrollableEmbed
handles[i].reposition(selection_rectangle);
contents.raise_child(handles[i], selection_rectangle);
}
-
- return true;
}
/**
diff --git a/src/ease-editor-window.vala b/src/ease-editor-window.vala
index 0fd3bd2..ed525f2 100644
--- a/src/ease-editor-window.vala
+++ b/src/ease-editor-window.vala
@@ -317,6 +317,17 @@ public class Ease.EditorWindow : Gtk.Window
}
[CCode (instance_pos = -1)]
+ public void insert_text(Gtk.Widget sender)
+ {
+ var text = document.theme.create_custom_text();
+ text.x = document.width / 2 - text.width / 2;
+ text.y = document.height / 2 - text.height / 2;
+ slide.add_element(0, text);
+ embed.recreate_slide();
+ embed.select_element(text);
+ }
+
+ [CCode (instance_pos = -1)]
public void insert_image(Gtk.Widget sender)
{
var dialog = new Gtk.FileChooserDialog(_("Insert Image"),
@@ -349,6 +360,7 @@ public class Ease.EditorWindow : Gtk.Window
// add the element
slide.add_element(0, e);
embed.recreate_slide();
+ embed.select_element(e);
}
catch (Error e)
{
diff --git a/src/ease-theme.vala b/src/ease-theme.vala
index a051472..43cc6a1 100644
--- a/src/ease-theme.vala
+++ b/src/ease-theme.vala
@@ -72,6 +72,7 @@ public class Ease.Theme : GLib.Object
private const string AUTHOR_TEXT = "author-text";
private const string CONTENT_TEXT = "content-text";
private const string HEADER_TEXT = "header-text";
+ private const string CUSTOM_TEXT = "custom-text";
// text properties
public const string TEXT_FONT = "text-font";
@@ -420,13 +421,24 @@ public class Ease.Theme : GLib.Object
}
/**
+ * Returns a custom { link TextElement} with its x and y positions set to 0.
+ */
+ public TextElement create_custom_text()
+ {
+ return create_text(CUSTOM_TEXT, 0, 0,
+ element_get(CUSTOM_TEXT, WIDTH).to_int(),
+ element_get(CUSTOM_TEXT, HEIGHT).to_int());
+ }
+
+ /**
* Creates a text element, given an element type and dimensions.
*/
private TextElement create_text(string type, int x, int y, int w, int h)
{
// error if an improper element type is used
if (!(type == TITLE_TEXT || type == AUTHOR_TEXT ||
- type == CONTENT_TEXT || type == HEADER_TEXT))
+ type == CUSTOM_TEXT || type == CONTENT_TEXT ||
+ type == HEADER_TEXT))
{
error(_("Not a valid text element type: %s"), type);
}
diff --git a/src/ease-undo-action.vala b/src/ease-undo-action.vala
index 472022a..79f7592 100644
--- a/src/ease-undo-action.vala
+++ b/src/ease-undo-action.vala
@@ -60,7 +60,7 @@ public class Ease.UndoAction : Object
*
* @param action An UndoAction to add properties from.
*/
- public void combine(UndoAction action)
+ public virtual void combine(UndoAction action)
{
foreach (var p in action.pairs) pairs.add(p);
}
@@ -70,7 +70,7 @@ public class Ease.UndoAction : Object
*
* Returns an UndoAction that will redo the undo action.
*/
- public UndoAction apply()
+ public virtual UndoAction apply()
{
foreach (var pair in pairs) pair.apply();
applied(this);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]