Index: configure.in
===================================================================
--- configure.in	(revision 5646)
+++ configure.in	(working copy)
@@ -318,6 +318,18 @@
 AM_CONDITIONAL(HAVE_XVIDMODE, [test x$have_xvidmode = xyes])
 
 dnl ================================================================
+dnl GObject Introspection
+dnl ================================================================
+
+AC_MSG_CHECKING([for gobject-introspection])
+PKG_CHECK_EXISTS(INTROSPECTION, gobject-introspection-1.0, have_introspection=true, have_introspection=false)
+AC_MSG_RESULT($have_introspection)
+if test "x$have_introspection" = "xtrue"; then
+	AC_DEFINE(HAVE_INTROSPECTION, [1], [Define if GObject Introspection is available])
+fi
+AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$have_introspection" = "xtrue")
+
+dnl ================================================================
 dnl Python plugins
 dnl ================================================================
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 5646)
+++ src/Makefile.am	(working copy)
@@ -3,6 +3,7 @@
 bin_PROGRAMS = totem totem-video-thumbnailer totem-video-indexer totem-audio-preview
 libexec_PROGRAMS =
 noinst_LTLIBRARIES =				\
+	libtotem.la				\
 	libbaconmessageconnection.la		\
 	libtotem_player.la
 
@@ -94,7 +95,7 @@
 totemvideolist-marshal.c: totemvideolist-marshal.h Makefile
 	( $(GLIB_GENMARSHAL) --prefix=totemvideolist_marshal $(srcdir)/totemvideolist-marshal.list --header --body > totemvideolist-marshal.c )
 
-totem_SOURCES = 					\
+libtotem_la_SOURCES = \
 	totem.c totem.h					\
 	totem-object.c					\
 	$(TOTEMMARSHALFILES)				\
@@ -119,7 +120,9 @@
 	totem-dvb-setup.c		\
 	totem-dvb-setup.h
 
-totem_CPPFLAGS = \
+totem_SOURCES = main.c
+
+libtotem_la_CPPFLAGS = \
 	-I$(top_srcdir)/		\
 	-I$(srcdir)/backend		\
 	-I$(srcdir)/plugins		\
@@ -127,7 +130,9 @@
 	$(common_defines)		\
 	$(AM_CPPFLAGS)
 
-totem_CFLAGS = \
+totem_CPPFLAGS = $(libtotem_la_CPPFLAGS)
+
+libtotem_la_CFLAGS = \
 	$(WARN_CFLAGS)			\
 	$(EXTRA_GNOME_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
@@ -135,10 +140,13 @@
 	$(MISSING_PLUGINS_CFLAGS) \
 	$(AM_CFLAGS)
 
+totem_CFLAGS = $(libtotem_la_CFLAGS)
+
 totem_LDFLAGS = \
 	$(AM_LDFLAGS)
 
-totem_LDADD =						\
+totem_LDADD=						\
+	libtotem.la					\
 	backend/libbaconvideowidget.la			\
 	plugins/libtotemmodule.la			\
 	libbaconmessageconnection.la			\
@@ -343,4 +351,3 @@
 	totemobject-marshal.list	\
 	totemvideolist-marshal.list	\
 	totemplaylist-marshal.list
-		
Index: src/totem.c
===================================================================
--- src/totem.c	(revision 5646)
+++ src/totem.c	(working copy)
@@ -117,13 +117,6 @@
 void fs_exit1_activate_cb (GtkButton *button, Totem *totem);
 
 static void
-long_action (void)
-{
-	while (gtk_events_pending ())
-		gtk_main_iteration ();
-}
-
-static void
 reset_seek_status (Totem *totem)
 {
 	/* Release the lock and reset everything so that we
@@ -155,9 +148,9 @@
 			GTK_WINDOW (totem->win));
 }
 
-static void
+void
 totem_action_error_and_exit (const char *title,
-		const char *reason, Totem *totem)
+			     const char *reason, Totem *totem)
 {
 	reset_seek_status (totem);
 	totem_interface_error_blocking (title, reason,
@@ -1906,7 +1899,7 @@
 	return FALSE;
 }
 
-static gboolean
+gboolean
 totem_action_open_files (Totem *totem, char **list)
 {
 	GSList *slist = NULL;
@@ -3023,7 +3016,7 @@
 	}
 }
 
-static char *
+char *
 totem_setup_window (Totem *totem)
 {
 	GKeyFile *keyfile;
@@ -3112,7 +3105,7 @@
 	return page_id;
 }
 
-static void
+void
 totem_callback_connect (Totem *totem)
 {
 	GtkWidget *item, *arrow;
@@ -3231,8 +3224,8 @@
 	gtk_action_set_sensitive (action, FALSE);
 }
 
-static void
-playlist_widget_setup (Totem *totem)
+void
+totem_playlist_widget_setup (Totem *totem)
 {
 	totem->playlist = TOTEM_PLAYLIST (totem_playlist_new ());
 
@@ -3265,8 +3258,8 @@
 			  totem);
 }
 
-static void
-video_widget_create (Totem *totem) 
+void
+totem_video_widget_create (Totem *totem) 
 {
 	GError *err = NULL;
 	GtkContainer *container;
@@ -3369,205 +3362,3 @@
 			G_CALLBACK (property_notify_cb_seekable), totem);
 	update_volume_sliders (totem);
 }
-
-static void
-totem_message_connection_receive_cb (const char *msg, Totem *totem)
-{
-	char *command_str, *url;
-	int command;
-
-	if (strlen (msg) < 4)
-		return;
-
-	command_str = g_strndup (msg, 3);
-	sscanf (command_str, "%d", &command);
-	g_free (command_str);
-
-	if (msg[4] != '\0')
-		url = g_strdup (msg + 4);
-	else
-		url = NULL;
-
-	totem_action_remote (totem, command, url);
-
-	g_free (url);
-}
-
-int
-main (int argc, char **argv)
-{
-	Totem *totem;
-	GConfClient *gc;
-#ifndef HAVE_GTK_ONLY
-	GnomeProgram *program;
-#else
-	GError *error = NULL;
-#endif
-	GOptionContext *context;
-	GOptionGroup *baconoptiongroup;
-	char *sidebar_pageid;
-
-	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
-	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-	textdomain (GETTEXT_PACKAGE);
-
-#ifdef GDK_WINDOWING_X11
-	if (XInitThreads () == 0)
-	{
-		gtk_init (&argc, &argv);
-		g_set_application_name (_("Totem Movie Player"));
-		totem_action_error_and_exit (_("Could not initialize the thread-safe libraries."), _("Verify your system installation. Totem will now exit."), NULL);
-	}
-#endif
-
-	g_thread_init (NULL);
-	g_type_init ();
-
-	/* Handle command line arguments */
-	context = g_option_context_new (N_("- Play movies and songs"));
-	baconoptiongroup = bacon_video_widget_get_option_group();
-	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
-	g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
-	g_option_context_add_group (context, baconoptiongroup);
-
-#ifdef HAVE_GTK_ONLY
-	g_option_context_add_group (context, gtk_get_option_group (TRUE));
-	if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
-		g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
-				error->message, argv[0]);
-		g_error_free (error);
-		totem_action_exit (NULL);
-	}
-#else
-	program = gnome_program_init (PACKAGE, VERSION,
-			LIBGNOMEUI_MODULE,
-			argc, argv,
-			GNOME_PARAM_APP_DATADIR, DATADIR,
-			GNOME_PARAM_GOPTION_CONTEXT, context,
-			GNOME_PARAM_NONE);
-#endif /* HAVE_GTK_ONLY */
-
-	g_set_application_name (_("Totem Movie Player"));
-	gtk_window_set_default_icon_name ("totem");
-
-	gc = gconf_client_get_default ();
-	if (gc == NULL)
-	{
-		totem_action_error_and_exit (_("Totem could not initialize the configuration engine."), _("Make sure that GNOME is properly installed."), NULL);
-	}
-
-	totem = g_object_new (TOTEM_TYPE_OBJECT, NULL);
-	totem->gc = gc;
-
-	/* IPC stuff */
-	if (optionstate.notconnectexistingsession == FALSE) {
-		totem->conn = bacon_message_connection_new (GETTEXT_PACKAGE);
-		if (bacon_message_connection_get_is_server (totem->conn) == FALSE) {
-			totem_options_process_for_server (totem->conn, &optionstate);
-			gdk_notify_startup_complete ();
-			totem_action_exit (totem);
-		} else {
-			totem_options_process_early (totem, &optionstate);
-		}
-	} else {
-		totem_options_process_early (totem, &optionstate);
-	}
-
-	/* Main window */
-	totem->xml = totem_interface_load ("totem.ui", TRUE, NULL, totem);
-	if (totem->xml == NULL)
-		totem_action_exit (NULL);
-
-	totem->win = GTK_WIDGET (gtk_builder_get_object (totem->xml, "totem_main_window"));
-
-	/* Menubar */
-	totem_ui_manager_setup (totem);
-
-	/* The sidebar */
-	playlist_widget_setup (totem);
-
-	/* The rest of the widgets */
-	totem->state = STATE_STOPPED;
-	totem->seek = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_seek_hscale"));
-	totem->seekadj = gtk_range_get_adjustment (GTK_RANGE (totem->seek));
-	totem->volume = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_volume_button"));
-	totem->statusbar = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_statusbar"));
-	totem->seek_lock = FALSE;
-	totem->fs = totem_fullscreen_new (GTK_WINDOW (totem->win));
-	gtk_scale_button_set_adjustment (GTK_SCALE_BUTTON (totem->fs->volume),
-					 gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (totem->volume)));
-	gtk_range_set_adjustment (GTK_RANGE (totem->fs->seek), totem->seekadj);
-
-	totem_session_setup (totem, argv);
-	totem_setup_file_monitoring (totem);
-	totem_setup_file_filters ();
-	totem_setup_play_disc (totem);
-	totem_callback_connect (totem);
-	sidebar_pageid = totem_setup_window (totem);
-
-	/* Show ! gtk_main_iteration trickery to show all the widgets
-	 * we have so far */
-	if (optionstate.fullscreen == FALSE) {
-		gtk_widget_show (totem->win);
-		totem_gdk_window_set_waiting_cursor (totem->win->window);
-		long_action ();
-	} else {
-		gtk_widget_realize (totem->win);
-	}
-
-	totem->controls_visibility = TOTEM_CONTROLS_UNDEFINED;
-
-	/* Show ! (again) the video widget this time. */
-	video_widget_create (totem);
-	gtk_widget_grab_focus (GTK_WIDGET (totem->bvw));
-	totem_fullscreen_set_video_widget (totem->fs, totem->bvw);
-
-	if (optionstate.fullscreen != FALSE) {
-		gtk_widget_show (totem->win);
-		gdk_flush ();
-		totem_action_fullscreen (totem, TRUE);
-	}
-
-	/* The prefs after the video widget is connected */
-	totem_setup_preferences (totem);
-
-	totem_setup_recent (totem);
-
-	/* Command-line handling */
-	totem_options_process_late (totem, &optionstate);
-
-	/* Initialise all the plugins, and set the default page, in case
-	 * it comes from a plugin */
-	totem_object_plugins_init (totem);
-	totem_sidebar_set_current_page (totem, sidebar_pageid, FALSE);
-	g_free (sidebar_pageid);
-
-	if (totem->session_restored != FALSE) {
-		totem_session_restore (totem, optionstate.filenames);
-	} else if (optionstate.filenames != NULL && totem_action_open_files (totem, optionstate.filenames)) {
-		totem_action_play_pause (totem);
-	} else {
-		totem_action_set_mrl (totem, NULL, NULL);
-	}
-
-	/* Set the logo at the last minute so we won't try to show it before a video */
-	bacon_video_widget_set_logo (totem->bvw, LOGO_PATH);
-
-	if (optionstate.fullscreen == FALSE)
-		gdk_window_set_cursor (totem->win->window, NULL);
-
-	if (totem->conn != NULL && bacon_message_connection_get_is_server (totem->conn) != FALSE)
-	{
-		bacon_message_connection_set_callback (totem->conn,
-				(BaconMessageReceivedFunc)
-				totem_message_connection_receive_cb, totem);
-	}
-
-	gtk_main ();
-
-#ifndef HAVE_GTK_ONLY
-	/* Will destroy GOption allocated data automatically */
-	g_object_unref (program);
-#endif	
-	return 0;
-}
Index: src/totem.h
===================================================================
--- src/totem.h	(revision 5646)
+++ src/totem.h	(working copy)
@@ -157,6 +157,9 @@
 void    totem_action_error                      (const char *title,
 						 const char *reason,
 						 Totem *totem);
+void    totem_action_error_and_exit             (const char *title,
+						 const char *reason, Totem *totem);
+
 void    totem_action_play_media_device		(Totem *totem,
 						 const char *device);
 
@@ -204,4 +207,5 @@
 gboolean totem_action_remote_get_setting	(Totem *totem,
 						 TotemRemoteSetting setting);
 
+/* Initialization */
 #endif /* __TOTEM_H__ */
