[ease/libraries: 2/138] Build Ease primarily as a library.



commit 689473593da99a3d2175ceac468f412583517651
Author: Nate Stedman <natesm gmail com>
Date:   Fri Jul 2 15:06:57 2010 -0400

    Build Ease primarily as a library.
    
    - All source files moved to "libease"
    - Small "main" is the entirety of ease

 .gitignore                                      |    8 +
 Makefile.am                                     |   81 +-------
 autogen.sh                                      |    2 +-
 configure.ac                                    |    8 +-
 ease-0.1.pc.in                                  |   11 +
 libease/Makefile.am                             |  111 +++++++++++
 {src => libease}/ease-about-dialog.vala         |    0
 {src => libease}/ease-actor.vala                |    0
 {src => libease}/ease-close-confirm-dialog.vala |    0
 {src => libease}/ease-document.vala             |    0
 {src => libease}/ease-editor-embed.vala         |    0
 {src => libease}/ease-editor-window.vala        |    0
 {src => libease}/ease-element-map-value.vala    |    0
 {src => libease}/ease-element-map.vala          |    0
 {src => libease}/ease-element.vala              |    0
 {src => libease}/ease-enums.vala                |    0
 {src => libease}/ease-handle.vala               |    0
 {src => libease}/ease-html-exporter.vala        |    0
 {src => libease}/ease-image-actor.vala          |    0
 {src => libease}/ease-image-element.vala        |    0
 {src => libease}/ease-inspector-pane.vala       |    0
 {src => libease}/ease-inspector-window.vala     |    0
 {src => libease}/ease-inspector.vala            |    0
 {src => libease}/ease-json-parser.vala          |    0
 libease/ease-main.vala                          |  243 +++++++++++++++++++++++
 {src => libease}/ease-media-element.vala        |    0
 {src => libease}/ease-open-dialog.vala          |    0
 {src => libease}/ease-pdf-exporter.vala         |    0
 {src => libease}/ease-player.vala               |    0
 {src => libease}/ease-scrollable-embed.vala     |    0
 {src => libease}/ease-slide-actor.vala          |    0
 {src => libease}/ease-slide-button-panel.vala   |    0
 {src => libease}/ease-slide-button.vala         |    0
 {src => libease}/ease-slide-pane.vala           |    0
 {src => libease}/ease-slide-set.vala            |    0
 {src => libease}/ease-slide.vala                |    0
 {src => libease}/ease-temp.vala                 |    0
 {src => libease}/ease-text-actor.vala           |    0
 {src => libease}/ease-text-element.vala         |    0
 {src => libease}/ease-theme.vala                |    0
 {src => libease}/ease-transformations.vala      |    0
 {src => libease}/ease-transition-pane.vala      |    0
 {src => libease}/ease-transitions.vala          |    0
 {src => libease}/ease-undo-actions.vala         |    0
 {src => libease}/ease-undo-controller.vala      |    0
 {src => libease}/ease-utilities.vala            |    0
 {src => libease}/ease-video-actor.vala          |    0
 {src => libease}/ease-video-element.vala        |    0
 {src => libease}/ease-welcome-actor.vala        |    0
 {src => libease}/ease-welcome-window.vala       |    0
 {src => libease}/ease-zoom-slider.vala          |    0
 src/Makefile.am                                 |   40 ++++
 src/main.vala                                   |  225 +---------------------
 53 files changed, 430 insertions(+), 299 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 6d716aa..9d58789 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,10 @@ ease
 *.h
 *.o
 src/*.c
+libease/*.c
+libease/*.vapi
+*.lo
+.libs
 
 *.ogv
 doc
@@ -52,3 +56,7 @@ intltool-*.in
 aclocal.m4
 # don't version it to get always latest in tarball
 INSTALL
+
+*.pc
+*.la
+*.stamp
diff --git a/Makefile.am b/Makefile.am
index c43ebef..dfa0923 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,85 +1,15 @@
 NULL =
 
-INCLUDES = 
+INCLUDES = \
 	-include config.h \
 	$(EASE_CFLAGS)
 
-bin_PROGRAMS = ease
-
 AM_CPPFLAGS = \
 	$(EASE_CFLAGS) \
 	-include $(CONFIG_HEADER) \
 	$(NULL)
 
-ease_SOURCES = \
-	src/ease-about-dialog.vala \
-	src/ease-actor.vala \
-	src/ease-close-confirm-dialog.vala \
-	src/ease-document.vala \
-	src/ease-editor-embed.vala \
-	src/ease-editor-window.vala \
-	src/ease-element-map.vala \
-	src/ease-element-map-value.vala \
-	src/ease-element.vala \
-	src/ease-enums.vala \
-	src/ease-handle.vala \
-	src/ease-html-exporter.vala \
-	src/ease-image-actor.vala \
-	src/ease-image-element.vala \
-	src/ease-inspector-pane.vala \
-	src/ease-inspector.vala \
-	src/ease-inspector-window.vala \
-	src/ease-json-parser.vala \
-	src/ease-media-element.vala \
-	src/ease-open-dialog.vala \
-	src/ease-pdf-exporter.vala \
-	src/ease-player.vala \
-	src/ease-scrollable-embed.vala \
-	src/ease-slide-actor.vala \
-	src/ease-slide-button-panel.vala \
-	src/ease-slide-button.vala \
-	src/ease-slide-pane.vala \
-	src/ease-slide-set.vala \
-	src/ease-slide.vala \
-	src/ease-temp.vala \
-	src/ease-text-actor.vala \
-	src/ease-text-element.vala \
-	src/ease-theme.vala \
-	src/ease-transformations.vala \
-	src/ease-transition-pane.vala \
-	src/ease-transitions.vala \
-	src/ease-undo-actions.vala \
-	src/ease-undo-controller.vala \
-	src/ease-utilities.vala \
-	src/ease-video-actor.vala \
-	src/ease-video-element.vala \
-	src/ease-welcome-actor.vala \
-	src/ease-welcome-window.vala \
-	src/ease-zoom-slider.vala \
-	src/main.vala \
-	$(NULL)
-
-# ease_VALAFLAGS = $(EASE_PACKAGES)
-VALAFLAGS = --pkg glib-2.0 \
-		--pkg gtk+-2.0 \
-		--pkg clutter-1.0 \
-		--pkg gdk-2.0 \
-		--pkg gee-1.0 \
-		--pkg clutter-gtk-0.10 \
-		--pkg cogl-1.0 \
-		--pkg gio-2.0 \
-		--pkg clutter-gst-1.0\
-		--pkg json-glib-1.0\
-		--pkg libarchive\
-		--pkg gmodule-2.0\
-		-g \
-		$(NULL)
-
-SUBDIRS = po data
-
-ease_LDADD = \
-	$(EASE_LIBS) \
-	$(NULL)
+SUBDIRS = po data libease src
 
 EXTRA_DIST = data/ease.desktop.in  \
 	$(NULL)
@@ -89,12 +19,15 @@ DISTCLEANFILES = data/ease.desktop \
 
 ACLOCAL_AMFLAGS = -I m4
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = ease-0.1.pc
+
 themedir = $(datadir)/ease/themes
 theme_DATA = $(wildcard $(top_srcdir)/themes/*.easetheme)
 
-doc: src/*.vala
+doc: libease/*.vala
 	rm -rf doc
-	valadoc --internal --private --pkg "json-glib-1.0" --pkg "gee-1.0"  --pkg "clutter-gtk-0.10" --pkg "clutter-gst-1.0" --pkg "libarchive" --directory=./doc --basedir=src ./src/*.vala
+	valadoc --internal --private --pkg "json-glib-1.0" --pkg "gee-1.0"  --pkg "clutter-gtk-0.10" --pkg "clutter-gst-1.0" --pkg "libarchive" --directory=./doc --basedir=src ./libease/*.vala
 	gnome-open doc/doc/Ease.html
 
 archive: themes/* examples/*
diff --git a/autogen.sh b/autogen.sh
index 16236b7..0e52d3a 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -7,7 +7,7 @@ test -z "$srcdir" && srcdir=.
 PKG_NAME="ease"
 REQUIRED_AUTOMAKE_VERSION=1.11
 
-(test -f $srcdir/src/main.vala) || {
+(test -f $srcdir/libease/ease-main.vala) || {
     echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
     echo " top-level $PKG_NAME directory"
     exit 1
diff --git a/configure.ac b/configure.ac
index f6cd4a4..5bf62e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,13 @@ AC_INIT([Ease], [0.1], [https://bugzilla.gnome.org/enter_bug.cgi?product=ease],
 
 AC_PREREQ([2.59])
 
-AC_CONFIG_FILES([Makefile po/Makefile.in data/Makefile])
+AC_CONFIG_FILES([Makefile
+                 po/Makefile.in
+                 data/Makefile
+                 libease/Makefile
+                 src/Makefile
+                 ease-0.1.pc])
+
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
 
diff --git a/ease-0.1.pc.in b/ease-0.1.pc.in
new file mode 100644
index 0000000..15582f5
--- /dev/null
+++ b/ease-0.1.pc.in
@@ -0,0 +1,11 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: libease
+Description: Ease backend library
+Requires: gtk+-2.0 clutter-1.0 clutter-gst-1.0 clutter-gtk-0.10 gee-1.0 clutter-gst-1.0 json-glib-1.0 libarchive gmodule-2.0
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lease-0.1
+Cflags: -I${includedir}/ease-0.1 -I${libdir}/ease-0.1/include
diff --git a/libease/Makefile.am b/libease/Makefile.am
new file mode 100644
index 0000000..c9f1834
--- /dev/null
+++ b/libease/Makefile.am
@@ -0,0 +1,111 @@
+lib_LTLIBRARIES = libease-0.1.la
+
+INCLUDES = \
+	-include config.h \
+	$(EASE_CFLAGS)
+
+AM_CPPFLAGS = \
+	$(EASE_CFLAGS) \
+	-include $(CONFIG_HEADER) \
+	$(NULL)
+
+# source files
+libease_0_1_la_SOURCES = \
+	ease-about-dialog.vala \
+	ease-actor.vala \
+	ease-close-confirm-dialog.vala \
+	ease-document.vala \
+	ease-editor-embed.vala \
+	ease-editor-window.vala \
+	ease-element-map.vala \
+	ease-element-map-value.vala \
+	ease-element.vala \
+	ease-enums.vala \
+	ease-handle.vala \
+	ease-html-exporter.vala \
+	ease-image-actor.vala \
+	ease-image-element.vala \
+	ease-inspector-pane.vala \
+	ease-inspector.vala \
+	ease-inspector-window.vala \
+	ease-json-parser.vala \
+	ease-media-element.vala \
+	ease-open-dialog.vala \
+	ease-pdf-exporter.vala \
+	ease-player.vala \
+	ease-scrollable-embed.vala \
+	ease-slide-actor.vala \
+	ease-slide-button-panel.vala \
+	ease-slide-button.vala \
+	ease-slide-pane.vala \
+	ease-slide-set.vala \
+	ease-slide.vala \
+	ease-temp.vala \
+	ease-text-actor.vala \
+	ease-text-element.vala \
+	ease-theme.vala \
+	ease-transformations.vala \
+	ease-transition-pane.vala \
+	ease-transitions.vala \
+	ease-undo-actions.vala \
+	ease-undo-controller.vala \
+	ease-utilities.vala \
+	ease-video-actor.vala \
+	ease-video-element.vala \
+	ease-welcome-actor.vala \
+	ease-welcome-window.vala \
+	ease-zoom-slider.vala \
+	ease-main.vala \
+	$(NULL)
+
+# compiler flags
+libease_0_1_la_VALAFLAGS = \
+	--pkg glib-2.0 \
+	--pkg gtk+-2.0 \
+	--pkg clutter-1.0 \
+	--pkg gdk-2.0 \
+	--pkg gee-1.0 \
+	--pkg clutter-gtk-0.10 \
+	--pkg cogl-1.0 \
+	--pkg gio-2.0 \
+	--pkg clutter-gst-1.0 \
+	--pkg json-glib-1.0 \
+	--pkg libarchive \
+	--pkg gmodule-2.0 \
+	--vapi=ease.vapi \
+	--header=libease.h \
+	--thread \
+	-g \
+	$(NULL)
+
+libease_0_1_la_CFLAGS = `pkg-config --cflags \
+	glib-2.0 \
+	gtk+-2.0 \
+	clutter-1.0 \
+	gdk-2.0 \
+	gee-1.0 \
+	clutter-gtk-0.10 \
+	cogl-1.0 \
+	gio-2.0 \
+	clutter-gst-1.0 \
+	json-glib-1.0 \
+	libarchive \
+	gmodule-2.0 `
+	
+libease_0_1_la_LDFLAGS = `pkgconfig --libs \
+	glib-2.0 \
+	gtk+-2.0 \
+	clutter-1.0 \
+	gdk-2.0 \
+	gee-1.0 \
+	clutter-gtk-0.10 \
+	cogl-1.0 \
+	gio-2.0 \
+	clutter-gst-1.0 \
+	json-glib-1.0 \
+	libarchive \
+	gmodule-2.0 `
+
+# header installation
+libease_includedir=$(includedir)/ease-0.1/
+libease_include_HEADERS = libease.h
diff --git a/src/ease-about-dialog.vala b/libease/ease-about-dialog.vala
similarity index 100%
rename from src/ease-about-dialog.vala
rename to libease/ease-about-dialog.vala
diff --git a/src/ease-actor.vala b/libease/ease-actor.vala
similarity index 100%
rename from src/ease-actor.vala
rename to libease/ease-actor.vala
diff --git a/src/ease-close-confirm-dialog.vala b/libease/ease-close-confirm-dialog.vala
similarity index 100%
rename from src/ease-close-confirm-dialog.vala
rename to libease/ease-close-confirm-dialog.vala
diff --git a/src/ease-document.vala b/libease/ease-document.vala
similarity index 100%
rename from src/ease-document.vala
rename to libease/ease-document.vala
diff --git a/src/ease-editor-embed.vala b/libease/ease-editor-embed.vala
similarity index 100%
rename from src/ease-editor-embed.vala
rename to libease/ease-editor-embed.vala
diff --git a/src/ease-editor-window.vala b/libease/ease-editor-window.vala
similarity index 100%
rename from src/ease-editor-window.vala
rename to libease/ease-editor-window.vala
diff --git a/src/ease-element-map-value.vala b/libease/ease-element-map-value.vala
similarity index 100%
rename from src/ease-element-map-value.vala
rename to libease/ease-element-map-value.vala
diff --git a/src/ease-element-map.vala b/libease/ease-element-map.vala
similarity index 100%
rename from src/ease-element-map.vala
rename to libease/ease-element-map.vala
diff --git a/src/ease-element.vala b/libease/ease-element.vala
similarity index 100%
rename from src/ease-element.vala
rename to libease/ease-element.vala
diff --git a/src/ease-enums.vala b/libease/ease-enums.vala
similarity index 100%
rename from src/ease-enums.vala
rename to libease/ease-enums.vala
diff --git a/src/ease-handle.vala b/libease/ease-handle.vala
similarity index 100%
rename from src/ease-handle.vala
rename to libease/ease-handle.vala
diff --git a/src/ease-html-exporter.vala b/libease/ease-html-exporter.vala
similarity index 100%
rename from src/ease-html-exporter.vala
rename to libease/ease-html-exporter.vala
diff --git a/src/ease-image-actor.vala b/libease/ease-image-actor.vala
similarity index 100%
rename from src/ease-image-actor.vala
rename to libease/ease-image-actor.vala
diff --git a/src/ease-image-element.vala b/libease/ease-image-element.vala
similarity index 100%
rename from src/ease-image-element.vala
rename to libease/ease-image-element.vala
diff --git a/src/ease-inspector-pane.vala b/libease/ease-inspector-pane.vala
similarity index 100%
rename from src/ease-inspector-pane.vala
rename to libease/ease-inspector-pane.vala
diff --git a/src/ease-inspector-window.vala b/libease/ease-inspector-window.vala
similarity index 100%
rename from src/ease-inspector-window.vala
rename to libease/ease-inspector-window.vala
diff --git a/src/ease-inspector.vala b/libease/ease-inspector.vala
similarity index 100%
rename from src/ease-inspector.vala
rename to libease/ease-inspector.vala
diff --git a/src/ease-json-parser.vala b/libease/ease-json-parser.vala
similarity index 100%
rename from src/ease-json-parser.vala
rename to libease/ease-json-parser.vala
diff --git a/libease/ease-main.vala b/libease/ease-main.vala
new file mode 100644
index 0000000..0738b01
--- /dev/null
+++ b/libease/ease-main.vala
@@ -0,0 +1,243 @@
+/*  Ease, a GTK presentation application
+    Copyright (C) 2010 Nate Stedman
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * Handles core actions in Ease
+ *
+ * When Ease starts, the  simple C main function calls a function in this
+ * class. Main then initializes GTK, Clutter, and anything else.
+ * 
+ * Main keeps track of { link EditorWindow}s, as well as the status of the
+ * single { link WelcomeWindow}. Main will end Ease if none of these are
+ * shown on the screen.
+ */
+public static class Ease.Main : GLib.Object
+{
+	private static Gee.ArrayList<EditorWindow> windows;
+	private static WelcomeWindow welcome;
+	
+	// options
+	static string play_filename;
+	static string[] filenames;
+	public static bool presentation_windowed = false;
+	
+	private const OptionEntry[] options = {
+		{ "play", 'p', 0, OptionArg.FILENAME, ref play_filename,
+		   "Play the specified file", "FILE" },
+		{ "window", 'w', 0, OptionArg.NONE, ref presentation_windowed,
+		  "Display presentations in a window", null},
+		{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref filenames, null, "FILE..." },
+		{ null } };
+	
+	private static Player player;
+	
+	/**
+	 * Start Ease to edit files.
+	 * 
+	 * If the user runs Ease with a filename as a parameter, this function
+	 * will open an { link EditorWindow}. Otherwise, a { link WelcomeWindow}
+	 * will be opened.
+	 *
+	 * @param args Program arguments.
+	 */
+	public static int main(string[] args)
+	{	
+		// parse command line options
+		var context = new OptionContext(_(" - a presentation editor"));
+		
+		// TODO: set translation
+		context.add_main_entries(options, null);
+
+		// add library option groups
+		context.add_group(Gtk.get_option_group(true));
+		context.add_group(Clutter.get_option_group());
+		
+		try
+		{
+			if (!context.parse(ref args))
+			{
+				return 1;
+			}
+		}
+		catch (OptionError e)
+		{
+			stdout.printf(_("error parsing options: %s\n"), e.message);
+			return 1;
+		}
+	
+		ClutterGst.init(ref args);
+
+		// initalize static classes
+		Transitions.init();
+		OpenDialog.init();
+		windows = new Gee.ArrayList<EditorWindow>();
+		
+		// Clutter settings
+		var backend = Clutter.get_default_backend();
+		var settings = Gtk.Settings.get_default();
+		backend.set_double_click_time(settings.gtk_double_click_time);
+		backend.set_double_click_distance(settings.gtk_double_click_distance);
+	
+		// open editor windows for each argument specified
+		if (filenames != null)
+		{
+			for (int i = 0; filenames[i] != null; i++)
+			{
+				open_file(filenames[i]);
+			}
+		}
+		
+		// if --play is specified, play the presentation
+		if (play_filename != null)
+		{
+			try
+			{
+				var doc = JSONParser.document(play_filename);
+				player = new Player(doc);
+			
+				// if no editor windows are specified, quit when done
+				if (filenames == null)
+				{
+					player.stage.hide.connect(() => {
+						Gtk.main_quit();
+					});
+				}
+			}
+			catch (Error e)
+			{
+				error_dialog(_("Error Playing Document"), e.message);
+			}
+		}
+		
+		// if no files are given, show the new presentation window
+		if (filenames == null && play_filename == null)
+		{
+			show_welcome();
+		}
+	
+		Gtk.main();
+		
+		Temp.clean();
+	
+		return 0;
+	}
+
+	/**
+	 * Creates a new { link EditorWindow}, or raises an existing one.
+	 *
+	 * If the passed filename does not have a window associated with it,
+	 * a new window will be created to edit that file. Otherwise, the currently
+	 * existing window will be raised.
+	 *
+	 * @param path The filename
+	 */
+	public static void open_file(string path)
+	{
+		foreach (var w in windows)
+		{
+			if (w.document.path == path)
+			{
+				w.present();
+				
+				return;
+			}
+		}
+		
+		try
+		{
+			var doc = JSONParser.document(path);
+			add_window(new EditorWindow(doc));
+		}
+		catch (Error e)
+		{
+			error_dialog(_("Error Opening Document"), e.message);
+			return;
+		}
+	}
+
+	/**
+	 * Removes an { link EditorWindow} from Ease's internal store of windows.
+	 * 
+	 * Ease tracks the current windows in order to properly quit when there
+	 * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
+	 * hidden. This function will quit Ease if the removed window is the final
+	 * window and the { link WelcomeWindow} is hidden.
+	 *
+	 * @param win The { link EditorWindow}.
+	 */
+	public static void remove_window(EditorWindow win)
+	{
+		windows.remove(win);
+		if (windows.size == 0 && welcome == null)
+		{
+			Gtk.main_quit();
+		}
+	}
+
+	/**
+	 * Adds an { link EditorWindow} to Ease's internal store of windows.
+	 * 
+	 * Ease tracks the current windows in order to properly quit when there
+	 * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
+	 * hidden. 
+	 *
+	 * @param win The { link EditorWindow}.
+	 */
+	public static void add_window(EditorWindow win)
+	{
+		windows.add(win);
+	}
+
+	/**
+	 * Shows the { link WelcomeWindow}
+	 * 
+	 * Shows the { link WelcomeWindow}, or raises it to the top if it is not
+	 * already displayed.
+	 *
+	 */
+	public static void show_welcome()
+	{
+		if (welcome == null)
+		{
+			welcome = new WelcomeWindow();
+			welcome.hide.connect(() => remove_welcome());
+		}
+		else
+		{
+			welcome.present();
+		}
+	}
+
+	/**
+	 * Hides the { link WelcomeWindow}.
+	 * 
+	 * It's important to call this function when the { link WelcomeWindow} is
+	 * hidden, so that Ease can properly exit when all windows are closed.
+	 * When the { link WelcomeWindow} is shown via show_welcome, this function
+	 * is automatically added in that window's hide signal handler.
+	 */
+	public static void remove_welcome()
+	{
+		welcome.hide_all();
+		welcome = null;
+		if (windows.size == 0)
+		{
+			Gtk.main_quit();
+		}
+	}
+}
+
diff --git a/src/ease-media-element.vala b/libease/ease-media-element.vala
similarity index 100%
rename from src/ease-media-element.vala
rename to libease/ease-media-element.vala
diff --git a/src/ease-open-dialog.vala b/libease/ease-open-dialog.vala
similarity index 100%
rename from src/ease-open-dialog.vala
rename to libease/ease-open-dialog.vala
diff --git a/src/ease-pdf-exporter.vala b/libease/ease-pdf-exporter.vala
similarity index 100%
rename from src/ease-pdf-exporter.vala
rename to libease/ease-pdf-exporter.vala
diff --git a/src/ease-player.vala b/libease/ease-player.vala
similarity index 100%
rename from src/ease-player.vala
rename to libease/ease-player.vala
diff --git a/src/ease-scrollable-embed.vala b/libease/ease-scrollable-embed.vala
similarity index 100%
rename from src/ease-scrollable-embed.vala
rename to libease/ease-scrollable-embed.vala
diff --git a/src/ease-slide-actor.vala b/libease/ease-slide-actor.vala
similarity index 100%
rename from src/ease-slide-actor.vala
rename to libease/ease-slide-actor.vala
diff --git a/src/ease-slide-button-panel.vala b/libease/ease-slide-button-panel.vala
similarity index 100%
rename from src/ease-slide-button-panel.vala
rename to libease/ease-slide-button-panel.vala
diff --git a/src/ease-slide-button.vala b/libease/ease-slide-button.vala
similarity index 100%
rename from src/ease-slide-button.vala
rename to libease/ease-slide-button.vala
diff --git a/src/ease-slide-pane.vala b/libease/ease-slide-pane.vala
similarity index 100%
rename from src/ease-slide-pane.vala
rename to libease/ease-slide-pane.vala
diff --git a/src/ease-slide-set.vala b/libease/ease-slide-set.vala
similarity index 100%
rename from src/ease-slide-set.vala
rename to libease/ease-slide-set.vala
diff --git a/src/ease-slide.vala b/libease/ease-slide.vala
similarity index 100%
rename from src/ease-slide.vala
rename to libease/ease-slide.vala
diff --git a/src/ease-temp.vala b/libease/ease-temp.vala
similarity index 100%
rename from src/ease-temp.vala
rename to libease/ease-temp.vala
diff --git a/src/ease-text-actor.vala b/libease/ease-text-actor.vala
similarity index 100%
rename from src/ease-text-actor.vala
rename to libease/ease-text-actor.vala
diff --git a/src/ease-text-element.vala b/libease/ease-text-element.vala
similarity index 100%
rename from src/ease-text-element.vala
rename to libease/ease-text-element.vala
diff --git a/src/ease-theme.vala b/libease/ease-theme.vala
similarity index 100%
rename from src/ease-theme.vala
rename to libease/ease-theme.vala
diff --git a/src/ease-transformations.vala b/libease/ease-transformations.vala
similarity index 100%
rename from src/ease-transformations.vala
rename to libease/ease-transformations.vala
diff --git a/src/ease-transition-pane.vala b/libease/ease-transition-pane.vala
similarity index 100%
rename from src/ease-transition-pane.vala
rename to libease/ease-transition-pane.vala
diff --git a/src/ease-transitions.vala b/libease/ease-transitions.vala
similarity index 100%
rename from src/ease-transitions.vala
rename to libease/ease-transitions.vala
diff --git a/src/ease-undo-actions.vala b/libease/ease-undo-actions.vala
similarity index 100%
rename from src/ease-undo-actions.vala
rename to libease/ease-undo-actions.vala
diff --git a/src/ease-undo-controller.vala b/libease/ease-undo-controller.vala
similarity index 100%
rename from src/ease-undo-controller.vala
rename to libease/ease-undo-controller.vala
diff --git a/src/ease-utilities.vala b/libease/ease-utilities.vala
similarity index 100%
rename from src/ease-utilities.vala
rename to libease/ease-utilities.vala
diff --git a/src/ease-video-actor.vala b/libease/ease-video-actor.vala
similarity index 100%
rename from src/ease-video-actor.vala
rename to libease/ease-video-actor.vala
diff --git a/src/ease-video-element.vala b/libease/ease-video-element.vala
similarity index 100%
rename from src/ease-video-element.vala
rename to libease/ease-video-element.vala
diff --git a/src/ease-welcome-actor.vala b/libease/ease-welcome-actor.vala
similarity index 100%
rename from src/ease-welcome-actor.vala
rename to libease/ease-welcome-actor.vala
diff --git a/src/ease-welcome-window.vala b/libease/ease-welcome-window.vala
similarity index 100%
rename from src/ease-welcome-window.vala
rename to libease/ease-welcome-window.vala
diff --git a/src/ease-zoom-slider.vala b/libease/ease-zoom-slider.vala
similarity index 100%
rename from src/ease-zoom-slider.vala
rename to libease/ease-zoom-slider.vala
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..8ecbd88
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,40 @@
+bin_PROGRAMS = ease
+
+# source files
+ease_SOURCES = main.vala
+
+# compiler flags
+ease_VALAFLAGS = --pkg ease --pkg gtk+-2.0 --pkg clutter-1.0 --pkg gee-1.0 --pkg json-glib-1.0 --vapidir ../libease
+
+ease_LDADD = \
+	../libease/libease-0.1.la \
+	$(EASE_LIBS) \
+	$(NULL)
+	
+ease_CFLAGS = `pkg-config --cflags \
+	glib-2.0 \
+	gtk+-2.0 \
+	clutter-1.0 \
+	gdk-2.0 \
+	gee-1.0 \
+	clutter-gtk-0.10 \
+	cogl-1.0 \
+	gio-2.0 \
+	clutter-gst-1.0 \
+	json-glib-1.0 \
+	libarchive \
+	gmodule-2.0 `
+	
+ease_LDFLAGS = `pkgconfig --libs \
+	glib-2.0 \
+	gtk+-2.0 \
+	clutter-1.0 \
+	gdk-2.0 \
+	gee-1.0 \
+	clutter-gtk-0.10 \
+	cogl-1.0 \
+	gio-2.0 \
+	clutter-gst-1.0 \
+	json-glib-1.0 \
+	libarchive \
+	gmodule-2.0 `
diff --git a/src/main.vala b/src/main.vala
index 0738b01..d57d61e 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -15,229 +15,8 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-/**
- * Handles core actions in Ease
- *
- * When Ease starts, the  simple C main function calls a function in this
- * class. Main then initializes GTK, Clutter, and anything else.
- * 
- * Main keeps track of { link EditorWindow}s, as well as the status of the
- * single { link WelcomeWindow}. Main will end Ease if none of these are
- * shown on the screen.
- */
-public static class Ease.Main : GLib.Object
+public static int main(string[] args)
 {
-	private static Gee.ArrayList<EditorWindow> windows;
-	private static WelcomeWindow welcome;
-	
-	// options
-	static string play_filename;
-	static string[] filenames;
-	public static bool presentation_windowed = false;
-	
-	private const OptionEntry[] options = {
-		{ "play", 'p', 0, OptionArg.FILENAME, ref play_filename,
-		   "Play the specified file", "FILE" },
-		{ "window", 'w', 0, OptionArg.NONE, ref presentation_windowed,
-		  "Display presentations in a window", null},
-		{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref filenames, null, "FILE..." },
-		{ null } };
-	
-	private static Player player;
-	
-	/**
-	 * Start Ease to edit files.
-	 * 
-	 * If the user runs Ease with a filename as a parameter, this function
-	 * will open an { link EditorWindow}. Otherwise, a { link WelcomeWindow}
-	 * will be opened.
-	 *
-	 * @param args Program arguments.
-	 */
-	public static int main(string[] args)
-	{	
-		// parse command line options
-		var context = new OptionContext(_(" - a presentation editor"));
-		
-		// TODO: set translation
-		context.add_main_entries(options, null);
-
-		// add library option groups
-		context.add_group(Gtk.get_option_group(true));
-		context.add_group(Clutter.get_option_group());
-		
-		try
-		{
-			if (!context.parse(ref args))
-			{
-				return 1;
-			}
-		}
-		catch (OptionError e)
-		{
-			stdout.printf(_("error parsing options: %s\n"), e.message);
-			return 1;
-		}
-	
-		ClutterGst.init(ref args);
-
-		// initalize static classes
-		Transitions.init();
-		OpenDialog.init();
-		windows = new Gee.ArrayList<EditorWindow>();
-		
-		// Clutter settings
-		var backend = Clutter.get_default_backend();
-		var settings = Gtk.Settings.get_default();
-		backend.set_double_click_time(settings.gtk_double_click_time);
-		backend.set_double_click_distance(settings.gtk_double_click_distance);
-	
-		// open editor windows for each argument specified
-		if (filenames != null)
-		{
-			for (int i = 0; filenames[i] != null; i++)
-			{
-				open_file(filenames[i]);
-			}
-		}
-		
-		// if --play is specified, play the presentation
-		if (play_filename != null)
-		{
-			try
-			{
-				var doc = JSONParser.document(play_filename);
-				player = new Player(doc);
-			
-				// if no editor windows are specified, quit when done
-				if (filenames == null)
-				{
-					player.stage.hide.connect(() => {
-						Gtk.main_quit();
-					});
-				}
-			}
-			catch (Error e)
-			{
-				error_dialog(_("Error Playing Document"), e.message);
-			}
-		}
-		
-		// if no files are given, show the new presentation window
-		if (filenames == null && play_filename == null)
-		{
-			show_welcome();
-		}
-	
-		Gtk.main();
-		
-		Temp.clean();
-	
-		return 0;
-	}
-
-	/**
-	 * Creates a new { link EditorWindow}, or raises an existing one.
-	 *
-	 * If the passed filename does not have a window associated with it,
-	 * a new window will be created to edit that file. Otherwise, the currently
-	 * existing window will be raised.
-	 *
-	 * @param path The filename
-	 */
-	public static void open_file(string path)
-	{
-		foreach (var w in windows)
-		{
-			if (w.document.path == path)
-			{
-				w.present();
-				
-				return;
-			}
-		}
-		
-		try
-		{
-			var doc = JSONParser.document(path);
-			add_window(new EditorWindow(doc));
-		}
-		catch (Error e)
-		{
-			error_dialog(_("Error Opening Document"), e.message);
-			return;
-		}
-	}
-
-	/**
-	 * Removes an { link EditorWindow} from Ease's internal store of windows.
-	 * 
-	 * Ease tracks the current windows in order to properly quit when there
-	 * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
-	 * hidden. This function will quit Ease if the removed window is the final
-	 * window and the { link WelcomeWindow} is hidden.
-	 *
-	 * @param win The { link EditorWindow}.
-	 */
-	public static void remove_window(EditorWindow win)
-	{
-		windows.remove(win);
-		if (windows.size == 0 && welcome == null)
-		{
-			Gtk.main_quit();
-		}
-	}
-
-	/**
-	 * Adds an { link EditorWindow} to Ease's internal store of windows.
-	 * 
-	 * Ease tracks the current windows in order to properly quit when there
-	 * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
-	 * hidden. 
-	 *
-	 * @param win The { link EditorWindow}.
-	 */
-	public static void add_window(EditorWindow win)
-	{
-		windows.add(win);
-	}
-
-	/**
-	 * Shows the { link WelcomeWindow}
-	 * 
-	 * Shows the { link WelcomeWindow}, or raises it to the top if it is not
-	 * already displayed.
-	 *
-	 */
-	public static void show_welcome()
-	{
-		if (welcome == null)
-		{
-			welcome = new WelcomeWindow();
-			welcome.hide.connect(() => remove_welcome());
-		}
-		else
-		{
-			welcome.present();
-		}
-	}
-
-	/**
-	 * Hides the { link WelcomeWindow}.
-	 * 
-	 * It's important to call this function when the { link WelcomeWindow} is
-	 * hidden, so that Ease can properly exit when all windows are closed.
-	 * When the { link WelcomeWindow} is shown via show_welcome, this function
-	 * is automatically added in that window's hide signal handler.
-	 */
-	public static void remove_welcome()
-	{
-		welcome.hide_all();
-		welcome = null;
-		if (windows.size == 0)
-		{
-			Gtk.main_quit();
-		}
-	}
+	return Ease.Main.main(args);
 }
 



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