[ease] [editor] Added a menu to the "Add Slide" tool item
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [editor] Added a menu to the "Add Slide" tool item
- Date: Sat, 24 Jul 2010 02:33:12 +0000 (UTC)
commit 4312f8f0757ed3f7224b91df88880ff4f20dd54e
Author: Nate Stedman <natesm gmail com>
Date: Fri Jul 23 22:32:31 2010 -0400
[editor] Added a menu to the "Add Slide" tool item
- Users can now add any type of slide that Ease provides.
data/ui/editor-window.ui | 9 ++++--
src/ease-editor-window.vala | 25 +++++++++++++++
src/ease-theme.vala | 69 ++++++++++++++++++++++++++++++++++++++++--
3 files changed, 96 insertions(+), 7 deletions(-)
---
diff --git a/data/ui/editor-window.ui b/data/ui/editor-window.ui
index 532cfd9..a914783 100644
--- a/data/ui/editor-window.ui
+++ b/data/ui/editor-window.ui
@@ -250,16 +250,16 @@
<object class="GtkToolbar" id="Main Toolbar">
<property name="visible">True</property>
<child>
- <object class="GtkToolButton" id="Add Slide">
+ <object class="GtkMenuToolButton" id="Add Slide">
<property name="visible">True</property>
<property name="label" translatable="yes">Add Slide</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-add</property>
+ <property name="menu">add-slide-menu</property>
<signal name="clicked" handler="ease_editor_window_new_slide_handler"/>
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">True</property>
</packing>
</child>
<child>
@@ -366,7 +366,7 @@
<child>
<object class="GtkToolButton" id="Show Inspector">
<property name="visible">True</property>
- <property name="label" translatable="yes">Inspector</property>
+ <property name="label" translatable="yes">Show Inspector</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-info</property>
<signal name="clicked" handler="ease_editor_window_inspector_clicked_handler"/>
@@ -492,4 +492,7 @@
<property name="stock">gtk-copy</property>
</object>
<object class="GtkAccelGroup" id="Menu Accelerators"/>
+ <object class="GtkMenu" id="add-slide-menu">
+ <property name="visible">True</property>
+ </object>
</interface>
diff --git a/src/ease-editor-window.vala b/src/ease-editor-window.vala
index fd5af2e..8d0d9b3 100644
--- a/src/ease-editor-window.vala
+++ b/src/ease-editor-window.vala
@@ -161,6 +161,19 @@ public class Ease.EditorWindow : Gtk.Window
(builder.get_object("Zoom Slider Item") as Gtk.ToolItem).
add(create_zoom_slider());
+ // add slide menu
+ var menu = builder.get_object("add-slide-menu") as Gtk.MenuShell;
+
+ foreach (var master in Theme.MASTER_SLIDES)
+ {
+ var item = new Gtk.MenuItem.with_mnemonic(
+ Theme.master_mnemonic_description(master));
+ menu.append(item);
+
+ item.activate.connect(on_new_slide_menu);
+ }
+ menu.show_all();
+
// final window setup
show_all();
embed.show();
@@ -253,6 +266,18 @@ public class Ease.EditorWindow : Gtk.Window
document.add_slide(index, slide);
}
+ public void on_new_slide_menu(Gtk.Widget? sender)
+ {
+ var item = sender as Gtk.MenuItem;
+ var slide = document.theme.create_slide(
+ Theme.master_from_description(item.get_label()),
+ document.width, document.height);
+
+ var index = document.index_of(slide) + 1;
+
+ document.add_slide(index, slide);
+ }
+
[CCode (instance_pos = -1)]
public void remove_slide(Gtk.Widget? sender)
{
diff --git a/src/ease-theme.vala b/src/ease-theme.vala
index 5c40a2f..61b10b5 100644
--- a/src/ease-theme.vala
+++ b/src/ease-theme.vala
@@ -47,12 +47,12 @@ public class Ease.Theme : GLib.Object
*/
public const string[] MASTER_SLIDES = {
TITLE,
- CONTENT,
CONTENT_HEADER,
- CONTENT_DUAL,
+ CONTENT,
CONTENT_DUAL_HEADER,
- MEDIA,
- MEDIA_HEADER
+ CONTENT_DUAL,
+ MEDIA_HEADER,
+ MEDIA
};
// master slide properties
@@ -489,6 +489,67 @@ public class Ease.Theme : GLib.Object
}
/**
+ * Returns a string description for a specified master identifier.
+ *
+ * @param master The identifier. This should be a constant of this class.
+ */
+ public static string master_description(string master)
+ {
+ return master_mnemonic_description(master).replace("_", "");
+ }
+
+ /**
+ * Returns a string description, with mnemonic, for a specified master
+ * identifier.
+ *
+ * @param master The identifier. This should be a constant of this class.
+ */
+ public static string master_mnemonic_description(string master)
+ {
+ switch (master)
+ {
+ case TITLE:
+ return _("_Title slide");
+ case CONTENT:
+ return _("Content slide _without header");
+ case CONTENT_HEADER:
+ return _("_Content slide");
+ case CONTENT_DUAL:
+ return _("Two column slide without _header");
+ case CONTENT_DUAL_HEADER:
+ return _("T_wo column slide with header");
+ case MEDIA:
+ return _("M_edia slide without header");
+ case MEDIA_HEADER:
+ return _("_Media slide");
+ }
+
+ critical(_("%s is not a valid identifier"), master);
+ return master;
+ }
+
+ /**
+ * Finds the master identifier associated with the provided description.
+ *
+ * The description may be a mnemonic.
+ *
+ * @param desc The description, provided by master_description or
+ * master_mnemonic_description.
+ */
+ public static string master_from_description(string desc)
+ {
+ var replaced = desc.replace("_", "");
+
+ foreach (var master in MASTER_SLIDES)
+ {
+ if (master_description(master) == replaced) return master;
+ }
+
+ critical("Not a valid master description: %s", desc);
+ return desc;
+ }
+
+ /**
* Fills a Gee.Map with style property overrides in the form of more
* Gee.Maps.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]